babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852
  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. import { Nullable } from "babylonjs/types";
  431. /**
  432. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  433. */
  434. export class WebRequest implements IWebRequest {
  435. private _xhr;
  436. /**
  437. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  438. * i.e. when loading files, where the server/service expects an Authorization header
  439. */
  440. static CustomRequestHeaders: {
  441. [key: string]: string;
  442. };
  443. /**
  444. * Add callback functions in this array to update all the requests before they get sent to the network
  445. */
  446. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  447. private _injectCustomRequestHeaders;
  448. /**
  449. * Gets or sets a function to be called when loading progress changes
  450. */
  451. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  452. /**
  453. * Returns client's state
  454. */
  455. readonly readyState: number;
  456. /**
  457. * Returns client's status
  458. */
  459. readonly status: number;
  460. /**
  461. * Returns client's status as a text
  462. */
  463. readonly statusText: string;
  464. /**
  465. * Returns client's response
  466. */
  467. readonly response: any;
  468. /**
  469. * Returns client's response url
  470. */
  471. readonly responseURL: string;
  472. /**
  473. * Returns client's response as text
  474. */
  475. readonly responseText: string;
  476. /**
  477. * Gets or sets the expected response type
  478. */
  479. responseType: XMLHttpRequestResponseType;
  480. /** @hidden */
  481. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  482. /** @hidden */
  483. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  484. /**
  485. * Cancels any network activity
  486. */
  487. abort(): void;
  488. /**
  489. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  490. * @param body defines an optional request body
  491. */
  492. send(body?: Document | BodyInit | null): void;
  493. /**
  494. * Sets the request method, request URL
  495. * @param method defines the method to use (GET, POST, etc..)
  496. * @param url defines the url to connect with
  497. */
  498. open(method: string, url: string): void;
  499. /**
  500. * Sets the value of a request header.
  501. * @param name The name of the header whose value is to be set
  502. * @param value The value to set as the body of the header
  503. */
  504. setRequestHeader(name: string, value: string): void;
  505. /**
  506. * Get the string containing the text of a particular header's value.
  507. * @param name The name of the header
  508. * @returns The string containing the text of the given header name
  509. */
  510. getResponseHeader(name: string): Nullable<string>;
  511. }
  512. }
  513. declare module "babylonjs/Misc/fileRequest" {
  514. import { Observable } from "babylonjs/Misc/observable";
  515. /**
  516. * File request interface
  517. */
  518. export interface IFileRequest {
  519. /**
  520. * Raised when the request is complete (success or error).
  521. */
  522. onCompleteObservable: Observable<IFileRequest>;
  523. /**
  524. * Aborts the request for a file.
  525. */
  526. abort: () => void;
  527. }
  528. }
  529. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  530. /**
  531. * Define options used to create a render target texture
  532. */
  533. export class RenderTargetCreationOptions {
  534. /**
  535. * Specifies is mipmaps must be generated
  536. */
  537. generateMipMaps?: boolean;
  538. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  539. generateDepthBuffer?: boolean;
  540. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  541. generateStencilBuffer?: boolean;
  542. /** Defines texture type (int by default) */
  543. type?: number;
  544. /** Defines sampling mode (trilinear by default) */
  545. samplingMode?: number;
  546. /** Defines format (RGBA by default) */
  547. format?: number;
  548. }
  549. }
  550. declare module "babylonjs/Instrumentation/timeToken" {
  551. import { Nullable } from "babylonjs/types";
  552. /**
  553. * @hidden
  554. **/
  555. export class _TimeToken {
  556. _startTimeQuery: Nullable<WebGLQuery>;
  557. _endTimeQuery: Nullable<WebGLQuery>;
  558. _timeElapsedQuery: Nullable<WebGLQuery>;
  559. _timeElapsedQueryEnded: boolean;
  560. }
  561. }
  562. declare module "babylonjs/Engines/constants" {
  563. /** Defines the cross module used constants to avoid circular dependncies */
  564. export class Constants {
  565. /** Defines that alpha blending is disabled */
  566. static readonly ALPHA_DISABLE: number;
  567. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  568. static readonly ALPHA_ADD: number;
  569. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  570. static readonly ALPHA_COMBINE: number;
  571. /** Defines that alpha blending to DEST - SRC * DEST */
  572. static readonly ALPHA_SUBTRACT: number;
  573. /** Defines that alpha blending to SRC * DEST */
  574. static readonly ALPHA_MULTIPLY: number;
  575. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  576. static readonly ALPHA_MAXIMIZED: number;
  577. /** Defines that alpha blending to SRC + DEST */
  578. static readonly ALPHA_ONEONE: number;
  579. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  580. static readonly ALPHA_PREMULTIPLIED: number;
  581. /**
  582. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  583. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  584. */
  585. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  586. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  587. static readonly ALPHA_INTERPOLATE: number;
  588. /**
  589. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  590. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  591. */
  592. static readonly ALPHA_SCREENMODE: number;
  593. /**
  594. * Defines that alpha blending to SRC + DST
  595. * Alpha will be set to SRC ALPHA + DST ALPHA
  596. */
  597. static readonly ALPHA_ONEONE_ONEONE: number;
  598. /**
  599. * Defines that alpha blending to SRC * DST ALPHA + DST
  600. * Alpha will be set to 0
  601. */
  602. static readonly ALPHA_ALPHATOCOLOR: number;
  603. /**
  604. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  605. */
  606. static readonly ALPHA_REVERSEONEMINUS: number;
  607. /**
  608. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  609. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  610. */
  611. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  612. /**
  613. * Defines that alpha blending to SRC + DST
  614. * Alpha will be set to SRC ALPHA
  615. */
  616. static readonly ALPHA_ONEONE_ONEZERO: number;
  617. /** Defines that alpha blending equation a SUM */
  618. static readonly ALPHA_EQUATION_ADD: number;
  619. /** Defines that alpha blending equation a SUBSTRACTION */
  620. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  621. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  622. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  623. /** Defines that alpha blending equation a MAX operation */
  624. static readonly ALPHA_EQUATION_MAX: number;
  625. /** Defines that alpha blending equation a MIN operation */
  626. static readonly ALPHA_EQUATION_MIN: number;
  627. /**
  628. * Defines that alpha blending equation a DARKEN operation:
  629. * It takes the min of the src and sums the alpha channels.
  630. */
  631. static readonly ALPHA_EQUATION_DARKEN: number;
  632. /** Defines that the ressource is not delayed*/
  633. static readonly DELAYLOADSTATE_NONE: number;
  634. /** Defines that the ressource was successfully delay loaded */
  635. static readonly DELAYLOADSTATE_LOADED: number;
  636. /** Defines that the ressource is currently delay loading */
  637. static readonly DELAYLOADSTATE_LOADING: number;
  638. /** Defines that the ressource is delayed and has not started loading */
  639. static readonly DELAYLOADSTATE_NOTLOADED: number;
  640. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  641. static readonly NEVER: number;
  642. /** 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 */
  643. static readonly ALWAYS: number;
  644. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  645. static readonly LESS: number;
  646. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  647. static readonly EQUAL: number;
  648. /** 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 */
  649. static readonly LEQUAL: number;
  650. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  651. static readonly GREATER: number;
  652. /** 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 */
  653. static readonly GEQUAL: number;
  654. /** 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 */
  655. static readonly NOTEQUAL: number;
  656. /** Passed to stencilOperation to specify that stencil value must be kept */
  657. static readonly KEEP: number;
  658. /** Passed to stencilOperation to specify that stencil value must be replaced */
  659. static readonly REPLACE: number;
  660. /** Passed to stencilOperation to specify that stencil value must be incremented */
  661. static readonly INCR: number;
  662. /** Passed to stencilOperation to specify that stencil value must be decremented */
  663. static readonly DECR: number;
  664. /** Passed to stencilOperation to specify that stencil value must be inverted */
  665. static readonly INVERT: number;
  666. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  667. static readonly INCR_WRAP: number;
  668. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  669. static readonly DECR_WRAP: number;
  670. /** Texture is not repeating outside of 0..1 UVs */
  671. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  672. /** Texture is repeating outside of 0..1 UVs */
  673. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  674. /** Texture is repeating and mirrored */
  675. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  676. /** ALPHA */
  677. static readonly TEXTUREFORMAT_ALPHA: number;
  678. /** LUMINANCE */
  679. static readonly TEXTUREFORMAT_LUMINANCE: number;
  680. /** LUMINANCE_ALPHA */
  681. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  682. /** RGB */
  683. static readonly TEXTUREFORMAT_RGB: number;
  684. /** RGBA */
  685. static readonly TEXTUREFORMAT_RGBA: number;
  686. /** RED */
  687. static readonly TEXTUREFORMAT_RED: number;
  688. /** RED (2nd reference) */
  689. static readonly TEXTUREFORMAT_R: number;
  690. /** RG */
  691. static readonly TEXTUREFORMAT_RG: number;
  692. /** RED_INTEGER */
  693. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  694. /** RED_INTEGER (2nd reference) */
  695. static readonly TEXTUREFORMAT_R_INTEGER: number;
  696. /** RG_INTEGER */
  697. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  698. /** RGB_INTEGER */
  699. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  700. /** RGBA_INTEGER */
  701. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  702. /** UNSIGNED_BYTE */
  703. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  704. /** UNSIGNED_BYTE (2nd reference) */
  705. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  706. /** FLOAT */
  707. static readonly TEXTURETYPE_FLOAT: number;
  708. /** HALF_FLOAT */
  709. static readonly TEXTURETYPE_HALF_FLOAT: number;
  710. /** BYTE */
  711. static readonly TEXTURETYPE_BYTE: number;
  712. /** SHORT */
  713. static readonly TEXTURETYPE_SHORT: number;
  714. /** UNSIGNED_SHORT */
  715. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  716. /** INT */
  717. static readonly TEXTURETYPE_INT: number;
  718. /** UNSIGNED_INT */
  719. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  720. /** UNSIGNED_SHORT_4_4_4_4 */
  721. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  722. /** UNSIGNED_SHORT_5_5_5_1 */
  723. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  724. /** UNSIGNED_SHORT_5_6_5 */
  725. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  726. /** UNSIGNED_INT_2_10_10_10_REV */
  727. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  728. /** UNSIGNED_INT_24_8 */
  729. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  730. /** UNSIGNED_INT_10F_11F_11F_REV */
  731. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  732. /** UNSIGNED_INT_5_9_9_9_REV */
  733. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  734. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  735. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  736. /** nearest is mag = nearest and min = nearest and mip = linear */
  737. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  738. /** Bilinear is mag = linear and min = linear and mip = nearest */
  739. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  740. /** Trilinear is mag = linear and min = linear and mip = linear */
  741. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  742. /** nearest is mag = nearest and min = nearest and mip = linear */
  743. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  744. /** Bilinear is mag = linear and min = linear and mip = nearest */
  745. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  746. /** Trilinear is mag = linear and min = linear and mip = linear */
  747. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  748. /** mag = nearest and min = nearest and mip = nearest */
  749. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  750. /** mag = nearest and min = linear and mip = nearest */
  751. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  752. /** mag = nearest and min = linear and mip = linear */
  753. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  754. /** mag = nearest and min = linear and mip = none */
  755. static readonly TEXTURE_NEAREST_LINEAR: number;
  756. /** mag = nearest and min = nearest and mip = none */
  757. static readonly TEXTURE_NEAREST_NEAREST: number;
  758. /** mag = linear and min = nearest and mip = nearest */
  759. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  760. /** mag = linear and min = nearest and mip = linear */
  761. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  762. /** mag = linear and min = linear and mip = none */
  763. static readonly TEXTURE_LINEAR_LINEAR: number;
  764. /** mag = linear and min = nearest and mip = none */
  765. static readonly TEXTURE_LINEAR_NEAREST: number;
  766. /** Explicit coordinates mode */
  767. static readonly TEXTURE_EXPLICIT_MODE: number;
  768. /** Spherical coordinates mode */
  769. static readonly TEXTURE_SPHERICAL_MODE: number;
  770. /** Planar coordinates mode */
  771. static readonly TEXTURE_PLANAR_MODE: number;
  772. /** Cubic coordinates mode */
  773. static readonly TEXTURE_CUBIC_MODE: number;
  774. /** Projection coordinates mode */
  775. static readonly TEXTURE_PROJECTION_MODE: number;
  776. /** Skybox coordinates mode */
  777. static readonly TEXTURE_SKYBOX_MODE: number;
  778. /** Inverse Cubic coordinates mode */
  779. static readonly TEXTURE_INVCUBIC_MODE: number;
  780. /** Equirectangular coordinates mode */
  781. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  782. /** Equirectangular Fixed coordinates mode */
  783. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  784. /** Equirectangular Fixed Mirrored coordinates mode */
  785. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  786. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  787. static readonly SCALEMODE_FLOOR: number;
  788. /** Defines that texture rescaling will look for the nearest power of 2 size */
  789. static readonly SCALEMODE_NEAREST: number;
  790. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  791. static readonly SCALEMODE_CEILING: number;
  792. /**
  793. * The dirty texture flag value
  794. */
  795. static readonly MATERIAL_TextureDirtyFlag: number;
  796. /**
  797. * The dirty light flag value
  798. */
  799. static readonly MATERIAL_LightDirtyFlag: number;
  800. /**
  801. * The dirty fresnel flag value
  802. */
  803. static readonly MATERIAL_FresnelDirtyFlag: number;
  804. /**
  805. * The dirty attribute flag value
  806. */
  807. static readonly MATERIAL_AttributesDirtyFlag: number;
  808. /**
  809. * The dirty misc flag value
  810. */
  811. static readonly MATERIAL_MiscDirtyFlag: number;
  812. /**
  813. * The all dirty flag value
  814. */
  815. static readonly MATERIAL_AllDirtyFlag: number;
  816. /**
  817. * Returns the triangle fill mode
  818. */
  819. static readonly MATERIAL_TriangleFillMode: number;
  820. /**
  821. * Returns the wireframe mode
  822. */
  823. static readonly MATERIAL_WireFrameFillMode: number;
  824. /**
  825. * Returns the point fill mode
  826. */
  827. static readonly MATERIAL_PointFillMode: number;
  828. /**
  829. * Returns the point list draw mode
  830. */
  831. static readonly MATERIAL_PointListDrawMode: number;
  832. /**
  833. * Returns the line list draw mode
  834. */
  835. static readonly MATERIAL_LineListDrawMode: number;
  836. /**
  837. * Returns the line loop draw mode
  838. */
  839. static readonly MATERIAL_LineLoopDrawMode: number;
  840. /**
  841. * Returns the line strip draw mode
  842. */
  843. static readonly MATERIAL_LineStripDrawMode: number;
  844. /**
  845. * Returns the triangle strip draw mode
  846. */
  847. static readonly MATERIAL_TriangleStripDrawMode: number;
  848. /**
  849. * Returns the triangle fan draw mode
  850. */
  851. static readonly MATERIAL_TriangleFanDrawMode: number;
  852. /**
  853. * Stores the clock-wise side orientation
  854. */
  855. static readonly MATERIAL_ClockWiseSideOrientation: number;
  856. /**
  857. * Stores the counter clock-wise side orientation
  858. */
  859. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  860. /**
  861. * Nothing
  862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  863. */
  864. static readonly ACTION_NothingTrigger: number;
  865. /**
  866. * On pick
  867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  868. */
  869. static readonly ACTION_OnPickTrigger: number;
  870. /**
  871. * On left pick
  872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  873. */
  874. static readonly ACTION_OnLeftPickTrigger: number;
  875. /**
  876. * On right pick
  877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  878. */
  879. static readonly ACTION_OnRightPickTrigger: number;
  880. /**
  881. * On center pick
  882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  883. */
  884. static readonly ACTION_OnCenterPickTrigger: number;
  885. /**
  886. * On pick down
  887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  888. */
  889. static readonly ACTION_OnPickDownTrigger: number;
  890. /**
  891. * On double pick
  892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  893. */
  894. static readonly ACTION_OnDoublePickTrigger: number;
  895. /**
  896. * On pick up
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_OnPickUpTrigger: number;
  900. /**
  901. * On pick out.
  902. * This trigger will only be raised if you also declared a OnPickDown
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickOutTrigger: number;
  906. /**
  907. * On long press
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLongPressTrigger: number;
  911. /**
  912. * On pointer over
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnPointerOverTrigger: number;
  916. /**
  917. * On pointer out
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPointerOutTrigger: number;
  921. /**
  922. * On every frame
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnEveryFrameTrigger: number;
  926. /**
  927. * On intersection enter
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnIntersectionEnterTrigger: number;
  931. /**
  932. * On intersection exit
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnIntersectionExitTrigger: number;
  936. /**
  937. * On key down
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnKeyDownTrigger: number;
  941. /**
  942. * On key up
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnKeyUpTrigger: number;
  946. /**
  947. * Billboard mode will only apply to Y axis
  948. */
  949. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  950. /**
  951. * Billboard mode will apply to all axes
  952. */
  953. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  954. /**
  955. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  956. */
  957. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  958. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  959. * Test order :
  960. * Is the bounding sphere outside the frustum ?
  961. * If not, are the bounding box vertices outside the frustum ?
  962. * It not, then the cullable object is in the frustum.
  963. */
  964. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  965. /** Culling strategy : Bounding Sphere Only.
  966. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  967. * It's also less accurate than the standard because some not visible objects can still be selected.
  968. * Test : is the bounding sphere outside the frustum ?
  969. * If not, then the cullable object is in the frustum.
  970. */
  971. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  972. /** Culling strategy : Optimistic Inclusion.
  973. * This in an inclusion test first, then the standard exclusion test.
  974. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  975. * 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.
  976. * Anyway, it's as accurate as the standard strategy.
  977. * Test :
  978. * Is the cullable object bounding sphere center in the frustum ?
  979. * If not, apply the default culling strategy.
  980. */
  981. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  982. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  983. * This in an inclusion test first, then the bounding sphere only exclusion test.
  984. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  985. * 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.
  986. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  987. * Test :
  988. * Is the cullable object bounding sphere center in the frustum ?
  989. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  990. */
  991. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  992. /**
  993. * No logging while loading
  994. */
  995. static readonly SCENELOADER_NO_LOGGING: number;
  996. /**
  997. * Minimal logging while loading
  998. */
  999. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1000. /**
  1001. * Summary logging while loading
  1002. */
  1003. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1004. /**
  1005. * Detailled logging while loading
  1006. */
  1007. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1008. }
  1009. }
  1010. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1011. import { Nullable } from "babylonjs/types";
  1012. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1013. /**
  1014. * This represents the required contract to create a new type of texture loader.
  1015. */
  1016. export interface IInternalTextureLoader {
  1017. /**
  1018. * Defines wether the loader supports cascade loading the different faces.
  1019. */
  1020. supportCascades: boolean;
  1021. /**
  1022. * This returns if the loader support the current file information.
  1023. * @param extension defines the file extension of the file being loaded
  1024. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1025. * @param fallback defines the fallback internal texture if any
  1026. * @param isBase64 defines whether the texture is encoded as a base64
  1027. * @param isBuffer defines whether the texture data are stored as a buffer
  1028. * @returns true if the loader can load the specified file
  1029. */
  1030. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1031. /**
  1032. * Transform the url before loading if required.
  1033. * @param rootUrl the url of the texture
  1034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1035. * @returns the transformed texture
  1036. */
  1037. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1038. /**
  1039. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1040. * @param rootUrl the url of the texture
  1041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1042. * @returns the fallback texture
  1043. */
  1044. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1045. /**
  1046. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1047. * @param data contains the texture data
  1048. * @param texture defines the BabylonJS internal texture
  1049. * @param createPolynomials will be true if polynomials have been requested
  1050. * @param onLoad defines the callback to trigger once the texture is ready
  1051. * @param onError defines the callback to trigger in case of error
  1052. */
  1053. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1054. /**
  1055. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1056. * @param data contains the texture data
  1057. * @param texture defines the BabylonJS internal texture
  1058. * @param callback defines the method to call once ready to upload
  1059. */
  1060. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1061. }
  1062. }
  1063. declare module "babylonjs/Engines/IPipelineContext" {
  1064. /**
  1065. * Class used to store and describe the pipeline context associated with an effect
  1066. */
  1067. export interface IPipelineContext {
  1068. /**
  1069. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1070. */
  1071. isAsync: boolean;
  1072. /**
  1073. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1074. */
  1075. isReady: boolean;
  1076. /** @hidden */
  1077. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Meshes/dataBuffer" {
  1081. /**
  1082. * Class used to store gfx data (like WebGLBuffer)
  1083. */
  1084. export class DataBuffer {
  1085. /**
  1086. * Gets or sets the number of objects referencing this buffer
  1087. */
  1088. references: number;
  1089. /** Gets or sets the size of the underlying buffer */
  1090. capacity: number;
  1091. /**
  1092. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1093. */
  1094. is32Bits: boolean;
  1095. /**
  1096. * Gets the underlying buffer
  1097. */
  1098. readonly underlyingResource: any;
  1099. }
  1100. }
  1101. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1102. /** @hidden */
  1103. export interface IShaderProcessor {
  1104. attributeProcessor?: (attribute: string) => string;
  1105. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1106. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1107. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1108. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1109. lineProcessor?: (line: string, isFragment: boolean) => string;
  1110. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1111. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1112. }
  1113. }
  1114. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1115. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1116. /** @hidden */
  1117. export interface ProcessingOptions {
  1118. defines: string[];
  1119. indexParameters: any;
  1120. isFragment: boolean;
  1121. shouldUseHighPrecisionShader: boolean;
  1122. supportsUniformBuffers: boolean;
  1123. shadersRepository: string;
  1124. includesShadersStore: {
  1125. [key: string]: string;
  1126. };
  1127. processor?: IShaderProcessor;
  1128. version: string;
  1129. platformName: string;
  1130. lookForClosingBracketForUniformBuffer?: boolean;
  1131. }
  1132. }
  1133. declare module "babylonjs/Misc/stringTools" {
  1134. /**
  1135. * Helper to manipulate strings
  1136. */
  1137. export class StringTools {
  1138. /**
  1139. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1140. * @param str Source string
  1141. * @param suffix Suffix to search for in the source string
  1142. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1143. */
  1144. static EndsWith(str: string, suffix: string): boolean;
  1145. /**
  1146. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1147. * @param str Source string
  1148. * @param suffix Suffix to search for in the source string
  1149. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1150. */
  1151. static StartsWith(str: string, suffix: string): boolean;
  1152. /**
  1153. * Decodes a buffer into a string
  1154. * @param buffer The buffer to decode
  1155. * @returns The decoded string
  1156. */
  1157. static Decode(buffer: Uint8Array | Uint16Array): string;
  1158. }
  1159. }
  1160. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1161. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1162. /** @hidden */
  1163. export class ShaderCodeNode {
  1164. line: string;
  1165. children: ShaderCodeNode[];
  1166. additionalDefineKey?: string;
  1167. additionalDefineValue?: string;
  1168. isValid(preprocessors: {
  1169. [key: string]: string;
  1170. }): boolean;
  1171. process(preprocessors: {
  1172. [key: string]: string;
  1173. }, options: ProcessingOptions): string;
  1174. }
  1175. }
  1176. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1177. /** @hidden */
  1178. export class ShaderCodeCursor {
  1179. private _lines;
  1180. lineIndex: number;
  1181. readonly currentLine: string;
  1182. readonly canRead: boolean;
  1183. lines: string[];
  1184. }
  1185. }
  1186. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1187. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1188. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1189. /** @hidden */
  1190. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1191. process(preprocessors: {
  1192. [key: string]: string;
  1193. }, options: ProcessingOptions): string;
  1194. }
  1195. }
  1196. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1197. /** @hidden */
  1198. export class ShaderDefineExpression {
  1199. isTrue(preprocessors: {
  1200. [key: string]: string;
  1201. }): boolean;
  1202. }
  1203. }
  1204. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1205. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1206. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1207. /** @hidden */
  1208. export class ShaderCodeTestNode extends ShaderCodeNode {
  1209. testExpression: ShaderDefineExpression;
  1210. isValid(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1216. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1217. /** @hidden */
  1218. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1219. define: string;
  1220. not: boolean;
  1221. constructor(define: string, not?: boolean);
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1228. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1229. /** @hidden */
  1230. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1231. leftOperand: ShaderDefineExpression;
  1232. rightOperand: ShaderDefineExpression;
  1233. isTrue(preprocessors: {
  1234. [key: string]: string;
  1235. }): boolean;
  1236. }
  1237. }
  1238. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1239. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1240. /** @hidden */
  1241. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1242. leftOperand: ShaderDefineExpression;
  1243. rightOperand: ShaderDefineExpression;
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1250. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1251. /** @hidden */
  1252. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1253. define: string;
  1254. operand: string;
  1255. testValue: string;
  1256. constructor(define: string, operand: string, testValue: string);
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Offline/IOfflineProvider" {
  1263. /**
  1264. * Class used to enable access to offline support
  1265. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1266. */
  1267. export interface IOfflineProvider {
  1268. /**
  1269. * Gets a boolean indicating if scene must be saved in the database
  1270. */
  1271. enableSceneOffline: boolean;
  1272. /**
  1273. * Gets a boolean indicating if textures must be saved in the database
  1274. */
  1275. enableTexturesOffline: boolean;
  1276. /**
  1277. * Open the offline support and make it available
  1278. * @param successCallback defines the callback to call on success
  1279. * @param errorCallback defines the callback to call on error
  1280. */
  1281. open(successCallback: () => void, errorCallback: () => void): void;
  1282. /**
  1283. * Loads an image from the offline support
  1284. * @param url defines the url to load from
  1285. * @param image defines the target DOM image
  1286. */
  1287. loadImage(url: string, image: HTMLImageElement): void;
  1288. /**
  1289. * Loads a file from offline support
  1290. * @param url defines the URL to load from
  1291. * @param sceneLoaded defines a callback to call on success
  1292. * @param progressCallBack defines a callback to call when progress changed
  1293. * @param errorCallback defines a callback to call on error
  1294. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1295. */
  1296. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1297. }
  1298. }
  1299. declare module "babylonjs/Misc/filesInputStore" {
  1300. /**
  1301. * Class used to help managing file picking and drag'n'drop
  1302. * File Storage
  1303. */
  1304. export class FilesInputStore {
  1305. /**
  1306. * List of files ready to be loaded
  1307. */
  1308. static FilesToLoad: {
  1309. [key: string]: File;
  1310. };
  1311. }
  1312. }
  1313. declare module "babylonjs/Misc/retryStrategy" {
  1314. import { WebRequest } from "babylonjs/Misc/webRequest";
  1315. /**
  1316. * Class used to define a retry strategy when error happens while loading assets
  1317. */
  1318. export class RetryStrategy {
  1319. /**
  1320. * Function used to defines an exponential back off strategy
  1321. * @param maxRetries defines the maximum number of retries (3 by default)
  1322. * @param baseInterval defines the interval between retries
  1323. * @returns the strategy function to use
  1324. */
  1325. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1326. }
  1327. }
  1328. declare module "babylonjs/Misc/baseError" {
  1329. /**
  1330. * @ignore
  1331. * Application error to support additional information when loading a file
  1332. */
  1333. export abstract class BaseError extends Error {
  1334. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1335. }
  1336. }
  1337. declare module "babylonjs/Misc/fileTools" {
  1338. import { WebRequest } from "babylonjs/Misc/webRequest";
  1339. import { Nullable } from "babylonjs/types";
  1340. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1341. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1342. import { BaseError } from "babylonjs/Misc/baseError";
  1343. /** @ignore */
  1344. export class LoadFileError extends BaseError {
  1345. request?: WebRequest;
  1346. file?: File;
  1347. /**
  1348. * Creates a new LoadFileError
  1349. * @param message defines the message of the error
  1350. * @param request defines the optional web request
  1351. * @param file defines the optional file
  1352. */
  1353. constructor(message: string, object?: WebRequest | File);
  1354. }
  1355. /** @ignore */
  1356. export class RequestFileError extends BaseError {
  1357. request: WebRequest;
  1358. /**
  1359. * Creates a new LoadFileError
  1360. * @param message defines the message of the error
  1361. * @param request defines the optional web request
  1362. */
  1363. constructor(message: string, request: WebRequest);
  1364. }
  1365. /** @ignore */
  1366. export class ReadFileError extends BaseError {
  1367. file: File;
  1368. /**
  1369. * Creates a new ReadFileError
  1370. * @param message defines the message of the error
  1371. * @param file defines the optional file
  1372. */
  1373. constructor(message: string, file: File);
  1374. }
  1375. /**
  1376. * @hidden
  1377. */
  1378. export class FileTools {
  1379. /**
  1380. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1381. */
  1382. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1383. /**
  1384. * Gets or sets the base URL to use to load assets
  1385. */
  1386. static BaseUrl: string;
  1387. /**
  1388. * Default behaviour for cors in the application.
  1389. * It can be a string if the expected behavior is identical in the entire app.
  1390. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1391. */
  1392. static CorsBehavior: string | ((url: string | string[]) => string);
  1393. /**
  1394. * Gets or sets a function used to pre-process url before using them to load assets
  1395. */
  1396. static PreprocessUrl: (url: string) => string;
  1397. /**
  1398. * Removes unwanted characters from an url
  1399. * @param url defines the url to clean
  1400. * @returns the cleaned url
  1401. */
  1402. private static _CleanUrl;
  1403. /**
  1404. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1405. * @param url define the url we are trying
  1406. * @param element define the dom element where to configure the cors policy
  1407. */
  1408. static SetCorsBehavior(url: string | string[], element: {
  1409. crossOrigin: string | null;
  1410. }): void;
  1411. /**
  1412. * Encode an array buffer into a base64 string
  1413. * @param buffer defines the buffer to encode
  1414. * @returns a string containing the base64 version of the buffer
  1415. */
  1416. static ArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * 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".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Classed used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * 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"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * 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"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Creates a right-handed perspective projection matrix
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * 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.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. /**
  4784. * new Path3D(path, normal, raw)
  4785. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4786. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4787. * @param path an array of Vector3, the curve axis of the Path3D
  4788. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4789. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4790. */
  4791. constructor(
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4796. /**
  4797. * Returns the Path3D array of successive Vector3 designing its curve.
  4798. * @returns the Path3D array of successive Vector3 designing its curve.
  4799. */
  4800. getCurve(): Vector3[];
  4801. /**
  4802. * Returns an array populated with tangent vectors on each Path3D curve point.
  4803. * @returns an array populated with tangent vectors on each Path3D curve point.
  4804. */
  4805. getTangents(): Vector3[];
  4806. /**
  4807. * Returns an array populated with normal vectors on each Path3D curve point.
  4808. * @returns an array populated with normal vectors on each Path3D curve point.
  4809. */
  4810. getNormals(): Vector3[];
  4811. /**
  4812. * Returns an array populated with binormal vectors on each Path3D curve point.
  4813. * @returns an array populated with binormal vectors on each Path3D curve point.
  4814. */
  4815. getBinormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4818. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4819. */
  4820. getDistances(): number[];
  4821. /**
  4822. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4823. * @param path path which all values are copied into the curves points
  4824. * @param firstNormal which should be projected onto the curve
  4825. * @returns the same object updated.
  4826. */
  4827. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4828. private _compute;
  4829. private _getFirstNonNullVector;
  4830. private _getLastNonNullVector;
  4831. private _normalVector;
  4832. }
  4833. /**
  4834. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4835. * A Curve3 is designed from a series of successive Vector3.
  4836. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4837. */
  4838. export class Curve3 {
  4839. private _points;
  4840. private _length;
  4841. /**
  4842. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4843. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4844. * @param v1 (Vector3) the control point
  4845. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4846. * @param nbPoints (integer) the wanted number of points in the curve
  4847. * @returns the created Curve3
  4848. */
  4849. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4850. /**
  4851. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4852. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4853. * @param v1 (Vector3) the first control point
  4854. * @param v2 (Vector3) the second control point
  4855. * @param v3 (Vector3) the end point of the Cubic Bezier
  4856. * @param nbPoints (integer) the wanted number of points in the curve
  4857. * @returns the created Curve3
  4858. */
  4859. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4860. /**
  4861. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4862. * @param p1 (Vector3) the origin point of the Hermite Spline
  4863. * @param t1 (Vector3) the tangent vector at the origin point
  4864. * @param p2 (Vector3) the end point of the Hermite Spline
  4865. * @param t2 (Vector3) the tangent vector at the end point
  4866. * @param nbPoints (integer) the wanted number of points in the curve
  4867. * @returns the created Curve3
  4868. */
  4869. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4870. /**
  4871. * Returns a Curve3 object along a CatmullRom Spline curve :
  4872. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4873. * @param nbPoints (integer) the wanted number of points between each curve control points
  4874. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4875. * @returns the created Curve3
  4876. */
  4877. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4878. /**
  4879. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4880. * A Curve3 is designed from a series of successive Vector3.
  4881. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4882. * @param points points which make up the curve
  4883. */
  4884. constructor(points: Vector3[]);
  4885. /**
  4886. * @returns the Curve3 stored array of successive Vector3
  4887. */
  4888. getPoints(): Vector3[];
  4889. /**
  4890. * @returns the computed length (float) of the curve.
  4891. */
  4892. length(): number;
  4893. /**
  4894. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4895. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4896. * curveA and curveB keep unchanged.
  4897. * @param curve the curve to continue from this curve
  4898. * @returns the newly constructed curve
  4899. */
  4900. continue(curve: DeepImmutable<Curve3>): Curve3;
  4901. private _computeLength;
  4902. }
  4903. }
  4904. declare module "babylonjs/Animations/easing" {
  4905. /**
  4906. * This represents the main contract an easing function should follow.
  4907. * Easing functions are used throughout the animation system.
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export interface IEasingFunction {
  4911. /**
  4912. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4913. * of the easing function.
  4914. * The link below provides some of the most common examples of easing functions.
  4915. * @see https://easings.net/
  4916. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4917. * @returns the corresponding value on the curve defined by the easing function
  4918. */
  4919. ease(gradient: number): number;
  4920. }
  4921. /**
  4922. * Base class used for every default easing function.
  4923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4924. */
  4925. export class EasingFunction implements IEasingFunction {
  4926. /**
  4927. * Interpolation follows the mathematical formula associated with the easing function.
  4928. */
  4929. static readonly EASINGMODE_EASEIN: number;
  4930. /**
  4931. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4932. */
  4933. static readonly EASINGMODE_EASEOUT: number;
  4934. /**
  4935. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4936. */
  4937. static readonly EASINGMODE_EASEINOUT: number;
  4938. private _easingMode;
  4939. /**
  4940. * Sets the easing mode of the current function.
  4941. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4942. */
  4943. setEasingMode(easingMode: number): void;
  4944. /**
  4945. * Gets the current easing mode.
  4946. * @returns the easing mode
  4947. */
  4948. getEasingMode(): number;
  4949. /**
  4950. * @hidden
  4951. */
  4952. easeInCore(gradient: number): number;
  4953. /**
  4954. * Given an input gradient between 0 and 1, this returns the corresponding value
  4955. * of the easing function.
  4956. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4957. * @returns the corresponding value on the curve defined by the easing function
  4958. */
  4959. ease(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a circle shape (see link below).
  4963. * @see https://easings.net/#easeInCirc
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. export class CircleEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a ease back shape (see link below).
  4972. * @see https://easings.net/#easeInBack
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. export class BackEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the amplitude of the function */
  4977. amplitude: number;
  4978. /**
  4979. * Instantiates a back ease easing
  4980. * @see https://easings.net/#easeInBack
  4981. * @param amplitude Defines the amplitude of the function
  4982. */
  4983. constructor(
  4984. /** Defines the amplitude of the function */
  4985. amplitude?: number);
  4986. /** @hidden */
  4987. easeInCore(gradient: number): number;
  4988. }
  4989. /**
  4990. * Easing function with a bouncing shape (see link below).
  4991. * @see https://easings.net/#easeInBounce
  4992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4993. */
  4994. export class BounceEase extends EasingFunction implements IEasingFunction {
  4995. /** Defines the number of bounces */
  4996. bounces: number;
  4997. /** Defines the amplitude of the bounce */
  4998. bounciness: number;
  4999. /**
  5000. * Instantiates a bounce easing
  5001. * @see https://easings.net/#easeInBounce
  5002. * @param bounces Defines the number of bounces
  5003. * @param bounciness Defines the amplitude of the bounce
  5004. */
  5005. constructor(
  5006. /** Defines the number of bounces */
  5007. bounces?: number,
  5008. /** Defines the amplitude of the bounce */
  5009. bounciness?: number);
  5010. /** @hidden */
  5011. easeInCore(gradient: number): number;
  5012. }
  5013. /**
  5014. * Easing function with a power of 3 shape (see link below).
  5015. * @see https://easings.net/#easeInCubic
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export class CubicEase extends EasingFunction implements IEasingFunction {
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. /**
  5023. * Easing function with an elastic shape (see link below).
  5024. * @see https://easings.net/#easeInElastic
  5025. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5026. */
  5027. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5028. /** Defines the number of oscillations*/
  5029. oscillations: number;
  5030. /** Defines the amplitude of the oscillations*/
  5031. springiness: number;
  5032. /**
  5033. * Instantiates an elastic easing function
  5034. * @see https://easings.net/#easeInElastic
  5035. * @param oscillations Defines the number of oscillations
  5036. * @param springiness Defines the amplitude of the oscillations
  5037. */
  5038. constructor(
  5039. /** Defines the number of oscillations*/
  5040. oscillations?: number,
  5041. /** Defines the amplitude of the oscillations*/
  5042. springiness?: number);
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with an exponential shape (see link below).
  5048. * @see https://easings.net/#easeInExpo
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5052. /** Defines the exponent of the function */
  5053. exponent: number;
  5054. /**
  5055. * Instantiates an exponential easing function
  5056. * @see https://easings.net/#easeInExpo
  5057. * @param exponent Defines the exponent of the function
  5058. */
  5059. constructor(
  5060. /** Defines the exponent of the function */
  5061. exponent?: number);
  5062. /** @hidden */
  5063. easeInCore(gradient: number): number;
  5064. }
  5065. /**
  5066. * Easing function with a power shape (see link below).
  5067. * @see https://easings.net/#easeInQuad
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export class PowerEase extends EasingFunction implements IEasingFunction {
  5071. /** Defines the power of the function */
  5072. power: number;
  5073. /**
  5074. * Instantiates an power base easing function
  5075. * @see https://easings.net/#easeInQuad
  5076. * @param power Defines the power of the function
  5077. */
  5078. constructor(
  5079. /** Defines the power of the function */
  5080. power?: number);
  5081. /** @hidden */
  5082. easeInCore(gradient: number): number;
  5083. }
  5084. /**
  5085. * Easing function with a power of 2 shape (see link below).
  5086. * @see https://easings.net/#easeInQuad
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5090. /** @hidden */
  5091. easeInCore(gradient: number): number;
  5092. }
  5093. /**
  5094. * Easing function with a power of 4 shape (see link below).
  5095. * @see https://easings.net/#easeInQuart
  5096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5097. */
  5098. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 5 shape (see link below).
  5104. * @see https://easings.net/#easeInQuint
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with a sin shape (see link below).
  5113. * @see https://easings.net/#easeInSine
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class SineEase extends EasingFunction implements IEasingFunction {
  5117. /** @hidden */
  5118. easeInCore(gradient: number): number;
  5119. }
  5120. /**
  5121. * Easing function with a bezier shape (see link below).
  5122. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5124. */
  5125. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5126. /** Defines the x component of the start tangent in the bezier curve */
  5127. x1: number;
  5128. /** Defines the y component of the start tangent in the bezier curve */
  5129. y1: number;
  5130. /** Defines the x component of the end tangent in the bezier curve */
  5131. x2: number;
  5132. /** Defines the y component of the end tangent in the bezier curve */
  5133. y2: number;
  5134. /**
  5135. * Instantiates a bezier function
  5136. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5137. * @param x1 Defines the x component of the start tangent in the bezier curve
  5138. * @param y1 Defines the y component of the start tangent in the bezier curve
  5139. * @param x2 Defines the x component of the end tangent in the bezier curve
  5140. * @param y2 Defines the y component of the end tangent in the bezier curve
  5141. */
  5142. constructor(
  5143. /** Defines the x component of the start tangent in the bezier curve */
  5144. x1?: number,
  5145. /** Defines the y component of the start tangent in the bezier curve */
  5146. y1?: number,
  5147. /** Defines the x component of the end tangent in the bezier curve */
  5148. x2?: number,
  5149. /** Defines the y component of the end tangent in the bezier curve */
  5150. y2?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. }
  5155. declare module "babylonjs/Maths/math.color" {
  5156. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5157. /**
  5158. * Class used to hold a RBG color
  5159. */
  5160. export class Color3 {
  5161. /**
  5162. * Defines the red component (between 0 and 1, default is 0)
  5163. */
  5164. r: number;
  5165. /**
  5166. * Defines the green component (between 0 and 1, default is 0)
  5167. */
  5168. g: number;
  5169. /**
  5170. * Defines the blue component (between 0 and 1, default is 0)
  5171. */
  5172. b: number;
  5173. /**
  5174. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5175. * @param r defines the red component (between 0 and 1, default is 0)
  5176. * @param g defines the green component (between 0 and 1, default is 0)
  5177. * @param b defines the blue component (between 0 and 1, default is 0)
  5178. */
  5179. constructor(
  5180. /**
  5181. * Defines the red component (between 0 and 1, default is 0)
  5182. */
  5183. r?: number,
  5184. /**
  5185. * Defines the green component (between 0 and 1, default is 0)
  5186. */
  5187. g?: number,
  5188. /**
  5189. * Defines the blue component (between 0 and 1, default is 0)
  5190. */
  5191. b?: number);
  5192. /**
  5193. * Creates a string with the Color3 current values
  5194. * @returns the string representation of the Color3 object
  5195. */
  5196. toString(): string;
  5197. /**
  5198. * Returns the string "Color3"
  5199. * @returns "Color3"
  5200. */
  5201. getClassName(): string;
  5202. /**
  5203. * Compute the Color3 hash code
  5204. * @returns an unique number that can be used to hash Color3 objects
  5205. */
  5206. getHashCode(): number;
  5207. /**
  5208. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5209. * @param array defines the array where to store the r,g,b components
  5210. * @param index defines an optional index in the target array to define where to start storing values
  5211. * @returns the current Color3 object
  5212. */
  5213. toArray(array: FloatArray, index?: number): Color3;
  5214. /**
  5215. * Returns a new Color4 object from the current Color3 and the given alpha
  5216. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5217. * @returns a new Color4 object
  5218. */
  5219. toColor4(alpha?: number): Color4;
  5220. /**
  5221. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5222. * @returns the new array
  5223. */
  5224. asArray(): number[];
  5225. /**
  5226. * Returns the luminance value
  5227. * @returns a float value
  5228. */
  5229. toLuminance(): number;
  5230. /**
  5231. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5232. * @param otherColor defines the second operand
  5233. * @returns the new Color3 object
  5234. */
  5235. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5236. /**
  5237. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5238. * @param otherColor defines the second operand
  5239. * @param result defines the Color3 object where to store the result
  5240. * @returns the current Color3
  5241. */
  5242. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5243. /**
  5244. * Determines equality between Color3 objects
  5245. * @param otherColor defines the second operand
  5246. * @returns true if the rgb values are equal to the given ones
  5247. */
  5248. equals(otherColor: DeepImmutable<Color3>): boolean;
  5249. /**
  5250. * Determines equality between the current Color3 object and a set of r,b,g values
  5251. * @param r defines the red component to check
  5252. * @param g defines the green component to check
  5253. * @param b defines the blue component to check
  5254. * @returns true if the rgb values are equal to the given ones
  5255. */
  5256. equalsFloats(r: number, g: number, b: number): boolean;
  5257. /**
  5258. * Multiplies in place each rgb value by scale
  5259. * @param scale defines the scaling factor
  5260. * @returns the updated Color3
  5261. */
  5262. scale(scale: number): Color3;
  5263. /**
  5264. * Multiplies the rgb values by scale and stores the result into "result"
  5265. * @param scale defines the scaling factor
  5266. * @param result defines the Color3 object where to store the result
  5267. * @returns the unmodified current Color3
  5268. */
  5269. scaleToRef(scale: number, result: Color3): Color3;
  5270. /**
  5271. * Scale the current Color3 values by a factor and add the result to a given Color3
  5272. * @param scale defines the scale factor
  5273. * @param result defines color to store the result into
  5274. * @returns the unmodified current Color3
  5275. */
  5276. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5277. /**
  5278. * Clamps the rgb values by the min and max values and stores the result into "result"
  5279. * @param min defines minimum clamping value (default is 0)
  5280. * @param max defines maximum clamping value (default is 1)
  5281. * @param result defines color to store the result into
  5282. * @returns the original Color3
  5283. */
  5284. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5285. /**
  5286. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5287. * @param otherColor defines the second operand
  5288. * @returns the new Color3
  5289. */
  5290. add(otherColor: DeepImmutable<Color3>): Color3;
  5291. /**
  5292. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5293. * @param otherColor defines the second operand
  5294. * @param result defines Color3 object to store the result into
  5295. * @returns the unmodified current Color3
  5296. */
  5297. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5298. /**
  5299. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5300. * @param otherColor defines the second operand
  5301. * @returns the new Color3
  5302. */
  5303. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5304. /**
  5305. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5306. * @param otherColor defines the second operand
  5307. * @param result defines Color3 object to store the result into
  5308. * @returns the unmodified current Color3
  5309. */
  5310. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5311. /**
  5312. * Copy the current object
  5313. * @returns a new Color3 copied the current one
  5314. */
  5315. clone(): Color3;
  5316. /**
  5317. * Copies the rgb values from the source in the current Color3
  5318. * @param source defines the source Color3 object
  5319. * @returns the updated Color3 object
  5320. */
  5321. copyFrom(source: DeepImmutable<Color3>): Color3;
  5322. /**
  5323. * Updates the Color3 rgb values from the given floats
  5324. * @param r defines the red component to read from
  5325. * @param g defines the green component to read from
  5326. * @param b defines the blue component to read from
  5327. * @returns the current Color3 object
  5328. */
  5329. copyFromFloats(r: number, g: number, b: number): Color3;
  5330. /**
  5331. * Updates the Color3 rgb values from the given floats
  5332. * @param r defines the red component to read from
  5333. * @param g defines the green component to read from
  5334. * @param b defines the blue component to read from
  5335. * @returns the current Color3 object
  5336. */
  5337. set(r: number, g: number, b: number): Color3;
  5338. /**
  5339. * Compute the Color3 hexadecimal code as a string
  5340. * @returns a string containing the hexadecimal representation of the Color3 object
  5341. */
  5342. toHexString(): string;
  5343. /**
  5344. * Computes a new Color3 converted from the current one to linear space
  5345. * @returns a new Color3 object
  5346. */
  5347. toLinearSpace(): Color3;
  5348. /**
  5349. * Converts current color in rgb space to HSV values
  5350. * @returns a new color3 representing the HSV values
  5351. */
  5352. toHSV(): Color3;
  5353. /**
  5354. * Converts current color in rgb space to HSV values
  5355. * @param result defines the Color3 where to store the HSV values
  5356. */
  5357. toHSVToRef(result: Color3): void;
  5358. /**
  5359. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5360. * @param convertedColor defines the Color3 object where to store the linear space version
  5361. * @returns the unmodified Color3
  5362. */
  5363. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5364. /**
  5365. * Computes a new Color3 converted from the current one to gamma space
  5366. * @returns a new Color3 object
  5367. */
  5368. toGammaSpace(): Color3;
  5369. /**
  5370. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5371. * @param convertedColor defines the Color3 object where to store the gamma space version
  5372. * @returns the unmodified Color3
  5373. */
  5374. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5375. private static _BlackReadOnly;
  5376. /**
  5377. * Convert Hue, saturation and value to a Color3 (RGB)
  5378. * @param hue defines the hue
  5379. * @param saturation defines the saturation
  5380. * @param value defines the value
  5381. * @param result defines the Color3 where to store the RGB values
  5382. */
  5383. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5384. /**
  5385. * Creates a new Color3 from the string containing valid hexadecimal values
  5386. * @param hex defines a string containing valid hexadecimal values
  5387. * @returns a new Color3 object
  5388. */
  5389. static FromHexString(hex: string): Color3;
  5390. /**
  5391. * Creates a new Color3 from the starting index of the given array
  5392. * @param array defines the source array
  5393. * @param offset defines an offset in the source array
  5394. * @returns a new Color3 object
  5395. */
  5396. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5397. /**
  5398. * Creates a new Color3 from integer values (< 256)
  5399. * @param r defines the red component to read from (value between 0 and 255)
  5400. * @param g defines the green component to read from (value between 0 and 255)
  5401. * @param b defines the blue component to read from (value between 0 and 255)
  5402. * @returns a new Color3 object
  5403. */
  5404. static FromInts(r: number, g: number, b: number): Color3;
  5405. /**
  5406. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5407. * @param start defines the start Color3 value
  5408. * @param end defines the end Color3 value
  5409. * @param amount defines the gradient value between start and end
  5410. * @returns a new Color3 object
  5411. */
  5412. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5413. /**
  5414. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5415. * @param left defines the start value
  5416. * @param right defines the end value
  5417. * @param amount defines the gradient factor
  5418. * @param result defines the Color3 object where to store the result
  5419. */
  5420. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5421. /**
  5422. * Returns a Color3 value containing a red color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Red(): Color3;
  5426. /**
  5427. * Returns a Color3 value containing a green color
  5428. * @returns a new Color3 object
  5429. */
  5430. static Green(): Color3;
  5431. /**
  5432. * Returns a Color3 value containing a blue color
  5433. * @returns a new Color3 object
  5434. */
  5435. static Blue(): Color3;
  5436. /**
  5437. * Returns a Color3 value containing a black color
  5438. * @returns a new Color3 object
  5439. */
  5440. static Black(): Color3;
  5441. /**
  5442. * Gets a Color3 value containing a black color that must not be updated
  5443. */
  5444. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5445. /**
  5446. * Returns a Color3 value containing a white color
  5447. * @returns a new Color3 object
  5448. */
  5449. static White(): Color3;
  5450. /**
  5451. * Returns a Color3 value containing a purple color
  5452. * @returns a new Color3 object
  5453. */
  5454. static Purple(): Color3;
  5455. /**
  5456. * Returns a Color3 value containing a magenta color
  5457. * @returns a new Color3 object
  5458. */
  5459. static Magenta(): Color3;
  5460. /**
  5461. * Returns a Color3 value containing a yellow color
  5462. * @returns a new Color3 object
  5463. */
  5464. static Yellow(): Color3;
  5465. /**
  5466. * Returns a Color3 value containing a gray color
  5467. * @returns a new Color3 object
  5468. */
  5469. static Gray(): Color3;
  5470. /**
  5471. * Returns a Color3 value containing a teal color
  5472. * @returns a new Color3 object
  5473. */
  5474. static Teal(): Color3;
  5475. /**
  5476. * Returns a Color3 value containing a random color
  5477. * @returns a new Color3 object
  5478. */
  5479. static Random(): Color3;
  5480. }
  5481. /**
  5482. * Class used to hold a RBGA color
  5483. */
  5484. export class Color4 {
  5485. /**
  5486. * Defines the red component (between 0 and 1, default is 0)
  5487. */
  5488. r: number;
  5489. /**
  5490. * Defines the green component (between 0 and 1, default is 0)
  5491. */
  5492. g: number;
  5493. /**
  5494. * Defines the blue component (between 0 and 1, default is 0)
  5495. */
  5496. b: number;
  5497. /**
  5498. * Defines the alpha component (between 0 and 1, default is 1)
  5499. */
  5500. a: number;
  5501. /**
  5502. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5503. * @param r defines the red component (between 0 and 1, default is 0)
  5504. * @param g defines the green component (between 0 and 1, default is 0)
  5505. * @param b defines the blue component (between 0 and 1, default is 0)
  5506. * @param a defines the alpha component (between 0 and 1, default is 1)
  5507. */
  5508. constructor(
  5509. /**
  5510. * Defines the red component (between 0 and 1, default is 0)
  5511. */
  5512. r?: number,
  5513. /**
  5514. * Defines the green component (between 0 and 1, default is 0)
  5515. */
  5516. g?: number,
  5517. /**
  5518. * Defines the blue component (between 0 and 1, default is 0)
  5519. */
  5520. b?: number,
  5521. /**
  5522. * Defines the alpha component (between 0 and 1, default is 1)
  5523. */
  5524. a?: number);
  5525. /**
  5526. * Adds in place the given Color4 values to the current Color4 object
  5527. * @param right defines the second operand
  5528. * @returns the current updated Color4 object
  5529. */
  5530. addInPlace(right: DeepImmutable<Color4>): Color4;
  5531. /**
  5532. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5533. * @returns the new array
  5534. */
  5535. asArray(): number[];
  5536. /**
  5537. * Stores from the starting index in the given array the Color4 successive values
  5538. * @param array defines the array where to store the r,g,b components
  5539. * @param index defines an optional index in the target array to define where to start storing values
  5540. * @returns the current Color4 object
  5541. */
  5542. toArray(array: number[], index?: number): Color4;
  5543. /**
  5544. * Determines equality between Color4 objects
  5545. * @param otherColor defines the second operand
  5546. * @returns true if the rgba values are equal to the given ones
  5547. */
  5548. equals(otherColor: DeepImmutable<Color4>): boolean;
  5549. /**
  5550. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5551. * @param right defines the second operand
  5552. * @returns a new Color4 object
  5553. */
  5554. add(right: DeepImmutable<Color4>): Color4;
  5555. /**
  5556. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5557. * @param right defines the second operand
  5558. * @returns a new Color4 object
  5559. */
  5560. subtract(right: DeepImmutable<Color4>): Color4;
  5561. /**
  5562. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5563. * @param right defines the second operand
  5564. * @param result defines the Color4 object where to store the result
  5565. * @returns the current Color4 object
  5566. */
  5567. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5568. /**
  5569. * Creates a new Color4 with the current Color4 values multiplied by scale
  5570. * @param scale defines the scaling factor to apply
  5571. * @returns a new Color4 object
  5572. */
  5573. scale(scale: number): Color4;
  5574. /**
  5575. * Multiplies the current Color4 values by scale and stores the result in "result"
  5576. * @param scale defines the scaling factor to apply
  5577. * @param result defines the Color4 object where to store the result
  5578. * @returns the current unmodified Color4
  5579. */
  5580. scaleToRef(scale: number, result: Color4): Color4;
  5581. /**
  5582. * Scale the current Color4 values by a factor and add the result to a given Color4
  5583. * @param scale defines the scale factor
  5584. * @param result defines the Color4 object where to store the result
  5585. * @returns the unmodified current Color4
  5586. */
  5587. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5588. /**
  5589. * Clamps the rgb values by the min and max values and stores the result into "result"
  5590. * @param min defines minimum clamping value (default is 0)
  5591. * @param max defines maximum clamping value (default is 1)
  5592. * @param result defines color to store the result into.
  5593. * @returns the cuurent Color4
  5594. */
  5595. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5596. /**
  5597. * Multipy an Color4 value by another and return a new Color4 object
  5598. * @param color defines the Color4 value to multiply by
  5599. * @returns a new Color4 object
  5600. */
  5601. multiply(color: Color4): Color4;
  5602. /**
  5603. * Multipy a Color4 value by another and push the result in a reference value
  5604. * @param color defines the Color4 value to multiply by
  5605. * @param result defines the Color4 to fill the result in
  5606. * @returns the result Color4
  5607. */
  5608. multiplyToRef(color: Color4, result: Color4): Color4;
  5609. /**
  5610. * Creates a string with the Color4 current values
  5611. * @returns the string representation of the Color4 object
  5612. */
  5613. toString(): string;
  5614. /**
  5615. * Returns the string "Color4"
  5616. * @returns "Color4"
  5617. */
  5618. getClassName(): string;
  5619. /**
  5620. * Compute the Color4 hash code
  5621. * @returns an unique number that can be used to hash Color4 objects
  5622. */
  5623. getHashCode(): number;
  5624. /**
  5625. * Creates a new Color4 copied from the current one
  5626. * @returns a new Color4 object
  5627. */
  5628. clone(): Color4;
  5629. /**
  5630. * Copies the given Color4 values into the current one
  5631. * @param source defines the source Color4 object
  5632. * @returns the current updated Color4 object
  5633. */
  5634. copyFrom(source: Color4): Color4;
  5635. /**
  5636. * Copies the given float values into the current one
  5637. * @param r defines the red component to read from
  5638. * @param g defines the green component to read from
  5639. * @param b defines the blue component to read from
  5640. * @param a defines the alpha component to read from
  5641. * @returns the current updated Color4 object
  5642. */
  5643. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5644. /**
  5645. * Copies the given float values into the current one
  5646. * @param r defines the red component to read from
  5647. * @param g defines the green component to read from
  5648. * @param b defines the blue component to read from
  5649. * @param a defines the alpha component to read from
  5650. * @returns the current updated Color4 object
  5651. */
  5652. set(r: number, g: number, b: number, a: number): Color4;
  5653. /**
  5654. * Compute the Color4 hexadecimal code as a string
  5655. * @returns a string containing the hexadecimal representation of the Color4 object
  5656. */
  5657. toHexString(): string;
  5658. /**
  5659. * Computes a new Color4 converted from the current one to linear space
  5660. * @returns a new Color4 object
  5661. */
  5662. toLinearSpace(): Color4;
  5663. /**
  5664. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5665. * @param convertedColor defines the Color4 object where to store the linear space version
  5666. * @returns the unmodified Color4
  5667. */
  5668. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5669. /**
  5670. * Computes a new Color4 converted from the current one to gamma space
  5671. * @returns a new Color4 object
  5672. */
  5673. toGammaSpace(): Color4;
  5674. /**
  5675. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5676. * @param convertedColor defines the Color4 object where to store the gamma space version
  5677. * @returns the unmodified Color4
  5678. */
  5679. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5680. /**
  5681. * Creates a new Color4 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color4 object
  5684. */
  5685. static FromHexString(hex: string): Color4;
  5686. /**
  5687. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5688. * @param left defines the start value
  5689. * @param right defines the end value
  5690. * @param amount defines the gradient factor
  5691. * @returns a new Color4 object
  5692. */
  5693. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5694. /**
  5695. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5696. * @param left defines the start value
  5697. * @param right defines the end value
  5698. * @param amount defines the gradient factor
  5699. * @param result defines the Color4 object where to store data
  5700. */
  5701. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5702. /**
  5703. * Creates a new Color4 from a Color3 and an alpha value
  5704. * @param color3 defines the source Color3 to read from
  5705. * @param alpha defines the alpha component (1.0 by default)
  5706. * @returns a new Color4 object
  5707. */
  5708. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5709. /**
  5710. * Creates a new Color4 from the starting index element of the given array
  5711. * @param array defines the source array to read from
  5712. * @param offset defines the offset in the source array
  5713. * @returns a new Color4 object
  5714. */
  5715. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5716. /**
  5717. * Creates a new Color3 from integer values (< 256)
  5718. * @param r defines the red component to read from (value between 0 and 255)
  5719. * @param g defines the green component to read from (value between 0 and 255)
  5720. * @param b defines the blue component to read from (value between 0 and 255)
  5721. * @param a defines the alpha component to read from (value between 0 and 255)
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5725. /**
  5726. * Check the content of a given array and convert it to an array containing RGBA data
  5727. * If the original array was already containing count * 4 values then it is returned directly
  5728. * @param colors defines the array to check
  5729. * @param count defines the number of RGBA data to expect
  5730. * @returns an array containing count * 4 values (RGBA)
  5731. */
  5732. static CheckColors4(colors: number[], count: number): number[];
  5733. }
  5734. /**
  5735. * @hidden
  5736. */
  5737. export class TmpColors {
  5738. static Color3: Color3[];
  5739. static Color4: Color4[];
  5740. }
  5741. }
  5742. declare module "babylonjs/Animations/animationKey" {
  5743. /**
  5744. * Defines an interface which represents an animation key frame
  5745. */
  5746. export interface IAnimationKey {
  5747. /**
  5748. * Frame of the key frame
  5749. */
  5750. frame: number;
  5751. /**
  5752. * Value at the specifies key frame
  5753. */
  5754. value: any;
  5755. /**
  5756. * The input tangent for the cubic hermite spline
  5757. */
  5758. inTangent?: any;
  5759. /**
  5760. * The output tangent for the cubic hermite spline
  5761. */
  5762. outTangent?: any;
  5763. /**
  5764. * The animation interpolation type
  5765. */
  5766. interpolation?: AnimationKeyInterpolation;
  5767. }
  5768. /**
  5769. * Enum for the animation key frame interpolation type
  5770. */
  5771. export enum AnimationKeyInterpolation {
  5772. /**
  5773. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5774. */
  5775. STEP = 1
  5776. }
  5777. }
  5778. declare module "babylonjs/Animations/animationRange" {
  5779. /**
  5780. * Represents the range of an animation
  5781. */
  5782. export class AnimationRange {
  5783. /**The name of the animation range**/
  5784. name: string;
  5785. /**The starting frame of the animation */
  5786. from: number;
  5787. /**The ending frame of the animation*/
  5788. to: number;
  5789. /**
  5790. * Initializes the range of an animation
  5791. * @param name The name of the animation range
  5792. * @param from The starting frame of the animation
  5793. * @param to The ending frame of the animation
  5794. */
  5795. constructor(
  5796. /**The name of the animation range**/
  5797. name: string,
  5798. /**The starting frame of the animation */
  5799. from: number,
  5800. /**The ending frame of the animation*/
  5801. to: number);
  5802. /**
  5803. * Makes a copy of the animation range
  5804. * @returns A copy of the animation range
  5805. */
  5806. clone(): AnimationRange;
  5807. }
  5808. }
  5809. declare module "babylonjs/Animations/animationEvent" {
  5810. /**
  5811. * Composed of a frame, and an action function
  5812. */
  5813. export class AnimationEvent {
  5814. /** The frame for which the event is triggered **/
  5815. frame: number;
  5816. /** The event to perform when triggered **/
  5817. action: (currentFrame: number) => void;
  5818. /** Specifies if the event should be triggered only once**/
  5819. onlyOnce?: boolean | undefined;
  5820. /**
  5821. * Specifies if the animation event is done
  5822. */
  5823. isDone: boolean;
  5824. /**
  5825. * Initializes the animation event
  5826. * @param frame The frame for which the event is triggered
  5827. * @param action The event to perform when triggered
  5828. * @param onlyOnce Specifies if the event should be triggered only once
  5829. */
  5830. constructor(
  5831. /** The frame for which the event is triggered **/
  5832. frame: number,
  5833. /** The event to perform when triggered **/
  5834. action: (currentFrame: number) => void,
  5835. /** Specifies if the event should be triggered only once**/
  5836. onlyOnce?: boolean | undefined);
  5837. /** @hidden */
  5838. _clone(): AnimationEvent;
  5839. }
  5840. }
  5841. declare module "babylonjs/Behaviors/behavior" {
  5842. import { Nullable } from "babylonjs/types";
  5843. /**
  5844. * Interface used to define a behavior
  5845. */
  5846. export interface Behavior<T> {
  5847. /** gets or sets behavior's name */
  5848. name: string;
  5849. /**
  5850. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5851. */
  5852. init(): void;
  5853. /**
  5854. * Called when the behavior is attached to a target
  5855. * @param target defines the target where the behavior is attached to
  5856. */
  5857. attach(target: T): void;
  5858. /**
  5859. * Called when the behavior is detached from its target
  5860. */
  5861. detach(): void;
  5862. }
  5863. /**
  5864. * Interface implemented by classes supporting behaviors
  5865. */
  5866. export interface IBehaviorAware<T> {
  5867. /**
  5868. * Attach a behavior
  5869. * @param behavior defines the behavior to attach
  5870. * @returns the current host
  5871. */
  5872. addBehavior(behavior: Behavior<T>): T;
  5873. /**
  5874. * Remove a behavior from the current object
  5875. * @param behavior defines the behavior to detach
  5876. * @returns the current host
  5877. */
  5878. removeBehavior(behavior: Behavior<T>): T;
  5879. /**
  5880. * Gets a behavior using its name to search
  5881. * @param name defines the name to search
  5882. * @returns the behavior or null if not found
  5883. */
  5884. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5885. }
  5886. }
  5887. declare module "babylonjs/Misc/smartArray" {
  5888. /**
  5889. * Defines an array and its length.
  5890. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5891. */
  5892. export interface ISmartArrayLike<T> {
  5893. /**
  5894. * The data of the array.
  5895. */
  5896. data: Array<T>;
  5897. /**
  5898. * The active length of the array.
  5899. */
  5900. length: number;
  5901. }
  5902. /**
  5903. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5904. */
  5905. export class SmartArray<T> implements ISmartArrayLike<T> {
  5906. /**
  5907. * The full set of data from the array.
  5908. */
  5909. data: Array<T>;
  5910. /**
  5911. * The active length of the array.
  5912. */
  5913. length: number;
  5914. protected _id: number;
  5915. /**
  5916. * Instantiates a Smart Array.
  5917. * @param capacity defines the default capacity of the array.
  5918. */
  5919. constructor(capacity: number);
  5920. /**
  5921. * Pushes a value at the end of the active data.
  5922. * @param value defines the object to push in the array.
  5923. */
  5924. push(value: T): void;
  5925. /**
  5926. * Iterates over the active data and apply the lambda to them.
  5927. * @param func defines the action to apply on each value.
  5928. */
  5929. forEach(func: (content: T) => void): void;
  5930. /**
  5931. * Sorts the full sets of data.
  5932. * @param compareFn defines the comparison function to apply.
  5933. */
  5934. sort(compareFn: (a: T, b: T) => number): void;
  5935. /**
  5936. * Resets the active data to an empty array.
  5937. */
  5938. reset(): void;
  5939. /**
  5940. * Releases all the data from the array as well as the array.
  5941. */
  5942. dispose(): void;
  5943. /**
  5944. * Concats the active data with a given array.
  5945. * @param array defines the data to concatenate with.
  5946. */
  5947. concat(array: any): void;
  5948. /**
  5949. * Returns the position of a value in the active data.
  5950. * @param value defines the value to find the index for
  5951. * @returns the index if found in the active data otherwise -1
  5952. */
  5953. indexOf(value: T): number;
  5954. /**
  5955. * Returns whether an element is part of the active data.
  5956. * @param value defines the value to look for
  5957. * @returns true if found in the active data otherwise false
  5958. */
  5959. contains(value: T): boolean;
  5960. private static _GlobalId;
  5961. }
  5962. /**
  5963. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5964. * The data in this array can only be present once
  5965. */
  5966. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5967. private _duplicateId;
  5968. /**
  5969. * Pushes a value at the end of the active data.
  5970. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5971. * @param value defines the object to push in the array.
  5972. */
  5973. push(value: T): void;
  5974. /**
  5975. * Pushes a value at the end of the active data.
  5976. * If the data is already present, it won t be added again
  5977. * @param value defines the object to push in the array.
  5978. * @returns true if added false if it was already present
  5979. */
  5980. pushNoDuplicate(value: T): boolean;
  5981. /**
  5982. * Resets the active data to an empty array.
  5983. */
  5984. reset(): void;
  5985. /**
  5986. * Concats the active data with a given array.
  5987. * This ensures no dupplicate will be present in the result.
  5988. * @param array defines the data to concatenate with.
  5989. */
  5990. concatWithNoDuplicate(array: any): void;
  5991. }
  5992. }
  5993. declare module "babylonjs/Cameras/cameraInputsManager" {
  5994. import { Nullable } from "babylonjs/types";
  5995. import { Camera } from "babylonjs/Cameras/camera";
  5996. /**
  5997. * @ignore
  5998. * This is a list of all the different input types that are available in the application.
  5999. * Fo instance: ArcRotateCameraGamepadInput...
  6000. */
  6001. export var CameraInputTypes: {};
  6002. /**
  6003. * This is the contract to implement in order to create a new input class.
  6004. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6005. */
  6006. export interface ICameraInput<TCamera extends Camera> {
  6007. /**
  6008. * Defines the camera the input is attached to.
  6009. */
  6010. camera: Nullable<TCamera>;
  6011. /**
  6012. * Gets the class name of the current intput.
  6013. * @returns the class name
  6014. */
  6015. getClassName(): string;
  6016. /**
  6017. * Get the friendly name associated with the input class.
  6018. * @returns the input friendly name
  6019. */
  6020. getSimpleName(): string;
  6021. /**
  6022. * Attach the input controls to a specific dom element to get the input from.
  6023. * @param element Defines the element the controls should be listened from
  6024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6025. */
  6026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6027. /**
  6028. * Detach the current controls from the specified dom element.
  6029. * @param element Defines the element to stop listening the inputs from
  6030. */
  6031. detachControl(element: Nullable<HTMLElement>): void;
  6032. /**
  6033. * Update the current camera state depending on the inputs that have been used this frame.
  6034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6035. */
  6036. checkInputs?: () => void;
  6037. }
  6038. /**
  6039. * Represents a map of input types to input instance or input index to input instance.
  6040. */
  6041. export interface CameraInputsMap<TCamera extends Camera> {
  6042. /**
  6043. * Accessor to the input by input type.
  6044. */
  6045. [name: string]: ICameraInput<TCamera>;
  6046. /**
  6047. * Accessor to the input by input index.
  6048. */
  6049. [idx: number]: ICameraInput<TCamera>;
  6050. }
  6051. /**
  6052. * This represents the input manager used within a camera.
  6053. * It helps dealing with all the different kind of input attached to a camera.
  6054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6055. */
  6056. export class CameraInputsManager<TCamera extends Camera> {
  6057. /**
  6058. * Defines the list of inputs attahed to the camera.
  6059. */
  6060. attached: CameraInputsMap<TCamera>;
  6061. /**
  6062. * Defines the dom element the camera is collecting inputs from.
  6063. * This is null if the controls have not been attached.
  6064. */
  6065. attachedElement: Nullable<HTMLElement>;
  6066. /**
  6067. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6068. */
  6069. noPreventDefault: boolean;
  6070. /**
  6071. * Defined the camera the input manager belongs to.
  6072. */
  6073. camera: TCamera;
  6074. /**
  6075. * Update the current camera state depending on the inputs that have been used this frame.
  6076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6077. */
  6078. checkInputs: () => void;
  6079. /**
  6080. * Instantiate a new Camera Input Manager.
  6081. * @param camera Defines the camera the input manager blongs to
  6082. */
  6083. constructor(camera: TCamera);
  6084. /**
  6085. * Add an input method to a camera
  6086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6087. * @param input camera input method
  6088. */
  6089. add(input: ICameraInput<TCamera>): void;
  6090. /**
  6091. * Remove a specific input method from a camera
  6092. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6093. * @param inputToRemove camera input method
  6094. */
  6095. remove(inputToRemove: ICameraInput<TCamera>): void;
  6096. /**
  6097. * Remove a specific input type from a camera
  6098. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6099. * @param inputType the type of the input to remove
  6100. */
  6101. removeByType(inputType: string): void;
  6102. private _addCheckInputs;
  6103. /**
  6104. * Attach the input controls to the currently attached dom element to listen the events from.
  6105. * @param input Defines the input to attach
  6106. */
  6107. attachInput(input: ICameraInput<TCamera>): void;
  6108. /**
  6109. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6110. * @param element Defines the dom element to collect the events from
  6111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6112. */
  6113. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6114. /**
  6115. * Detach the current manager inputs controls from a specific dom element.
  6116. * @param element Defines the dom element to collect the events from
  6117. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6118. */
  6119. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6120. /**
  6121. * Rebuild the dynamic inputCheck function from the current list of
  6122. * defined inputs in the manager.
  6123. */
  6124. rebuildInputCheck(): void;
  6125. /**
  6126. * Remove all attached input methods from a camera
  6127. */
  6128. clear(): void;
  6129. /**
  6130. * Serialize the current input manager attached to a camera.
  6131. * This ensures than once parsed,
  6132. * the input associated to the camera will be identical to the current ones
  6133. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6134. */
  6135. serialize(serializedCamera: any): void;
  6136. /**
  6137. * Parses an input manager serialized JSON to restore the previous list of inputs
  6138. * and states associated to a camera.
  6139. * @param parsedCamera Defines the JSON to parse
  6140. */
  6141. parse(parsedCamera: any): void;
  6142. }
  6143. }
  6144. declare module "babylonjs/Meshes/buffer" {
  6145. import { Nullable, DataArray } from "babylonjs/types";
  6146. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6147. /**
  6148. * Class used to store data that will be store in GPU memory
  6149. */
  6150. export class Buffer {
  6151. private _engine;
  6152. private _buffer;
  6153. /** @hidden */
  6154. _data: Nullable<DataArray>;
  6155. private _updatable;
  6156. private _instanced;
  6157. private _divisor;
  6158. /**
  6159. * Gets the byte stride.
  6160. */
  6161. readonly byteStride: number;
  6162. /**
  6163. * Constructor
  6164. * @param engine the engine
  6165. * @param data the data to use for this buffer
  6166. * @param updatable whether the data is updatable
  6167. * @param stride the stride (optional)
  6168. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6169. * @param instanced whether the buffer is instanced (optional)
  6170. * @param useBytes set to true if the stride in in bytes (optional)
  6171. * @param divisor sets an optional divisor for instances (1 by default)
  6172. */
  6173. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6174. /**
  6175. * Create a new VertexBuffer based on the current buffer
  6176. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6177. * @param offset defines offset in the buffer (0 by default)
  6178. * @param size defines the size in floats of attributes (position is 3 for instance)
  6179. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6180. * @param instanced defines if the vertex buffer contains indexed data
  6181. * @param useBytes defines if the offset and stride are in bytes *
  6182. * @param divisor sets an optional divisor for instances (1 by default)
  6183. * @returns the new vertex buffer
  6184. */
  6185. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6186. /**
  6187. * Gets a boolean indicating if the Buffer is updatable?
  6188. * @returns true if the buffer is updatable
  6189. */
  6190. isUpdatable(): boolean;
  6191. /**
  6192. * Gets current buffer's data
  6193. * @returns a DataArray or null
  6194. */
  6195. getData(): Nullable<DataArray>;
  6196. /**
  6197. * Gets underlying native buffer
  6198. * @returns underlying native buffer
  6199. */
  6200. getBuffer(): Nullable<DataBuffer>;
  6201. /**
  6202. * Gets the stride in float32 units (i.e. byte stride / 4).
  6203. * May not be an integer if the byte stride is not divisible by 4.
  6204. * DEPRECATED. Use byteStride instead.
  6205. * @returns the stride in float32 units
  6206. */
  6207. getStrideSize(): number;
  6208. /**
  6209. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6210. * @param data defines the data to store
  6211. */
  6212. create(data?: Nullable<DataArray>): void;
  6213. /** @hidden */
  6214. _rebuild(): void;
  6215. /**
  6216. * Update current buffer data
  6217. * @param data defines the data to store
  6218. */
  6219. update(data: DataArray): void;
  6220. /**
  6221. * Updates the data directly.
  6222. * @param data the new data
  6223. * @param offset the new offset
  6224. * @param vertexCount the vertex count (optional)
  6225. * @param useBytes set to true if the offset is in bytes
  6226. */
  6227. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6228. /**
  6229. * Release all resources
  6230. */
  6231. dispose(): void;
  6232. }
  6233. /**
  6234. * Specialized buffer used to store vertex data
  6235. */
  6236. export class VertexBuffer {
  6237. /** @hidden */
  6238. _buffer: Buffer;
  6239. private _kind;
  6240. private _size;
  6241. private _ownsBuffer;
  6242. private _instanced;
  6243. private _instanceDivisor;
  6244. /**
  6245. * The byte type.
  6246. */
  6247. static readonly BYTE: number;
  6248. /**
  6249. * The unsigned byte type.
  6250. */
  6251. static readonly UNSIGNED_BYTE: number;
  6252. /**
  6253. * The short type.
  6254. */
  6255. static readonly SHORT: number;
  6256. /**
  6257. * The unsigned short type.
  6258. */
  6259. static readonly UNSIGNED_SHORT: number;
  6260. /**
  6261. * The integer type.
  6262. */
  6263. static readonly INT: number;
  6264. /**
  6265. * The unsigned integer type.
  6266. */
  6267. static readonly UNSIGNED_INT: number;
  6268. /**
  6269. * The float type.
  6270. */
  6271. static readonly FLOAT: number;
  6272. /**
  6273. * Gets or sets the instance divisor when in instanced mode
  6274. */
  6275. instanceDivisor: number;
  6276. /**
  6277. * Gets the byte stride.
  6278. */
  6279. readonly byteStride: number;
  6280. /**
  6281. * Gets the byte offset.
  6282. */
  6283. readonly byteOffset: number;
  6284. /**
  6285. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6286. */
  6287. readonly normalized: boolean;
  6288. /**
  6289. * Gets the data type of each component in the array.
  6290. */
  6291. readonly type: number;
  6292. /**
  6293. * Constructor
  6294. * @param engine the engine
  6295. * @param data the data to use for this vertex buffer
  6296. * @param kind the vertex buffer kind
  6297. * @param updatable whether the data is updatable
  6298. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6299. * @param stride the stride (optional)
  6300. * @param instanced whether the buffer is instanced (optional)
  6301. * @param offset the offset of the data (optional)
  6302. * @param size the number of components (optional)
  6303. * @param type the type of the component (optional)
  6304. * @param normalized whether the data contains normalized data (optional)
  6305. * @param useBytes set to true if stride and offset are in bytes (optional)
  6306. * @param divisor defines the instance divisor to use (1 by default)
  6307. */
  6308. 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, divisor?: number);
  6309. /** @hidden */
  6310. _rebuild(): void;
  6311. /**
  6312. * Returns the kind of the VertexBuffer (string)
  6313. * @returns a string
  6314. */
  6315. getKind(): string;
  6316. /**
  6317. * Gets a boolean indicating if the VertexBuffer is updatable?
  6318. * @returns true if the buffer is updatable
  6319. */
  6320. isUpdatable(): boolean;
  6321. /**
  6322. * Gets current buffer's data
  6323. * @returns a DataArray or null
  6324. */
  6325. getData(): Nullable<DataArray>;
  6326. /**
  6327. * Gets underlying native buffer
  6328. * @returns underlying native buffer
  6329. */
  6330. getBuffer(): Nullable<DataBuffer>;
  6331. /**
  6332. * Gets the stride in float32 units (i.e. byte stride / 4).
  6333. * May not be an integer if the byte stride is not divisible by 4.
  6334. * DEPRECATED. Use byteStride instead.
  6335. * @returns the stride in float32 units
  6336. */
  6337. getStrideSize(): number;
  6338. /**
  6339. * Returns the offset as a multiple of the type byte length.
  6340. * DEPRECATED. Use byteOffset instead.
  6341. * @returns the offset in bytes
  6342. */
  6343. getOffset(): number;
  6344. /**
  6345. * Returns the number of components per vertex attribute (integer)
  6346. * @returns the size in float
  6347. */
  6348. getSize(): number;
  6349. /**
  6350. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6351. * @returns true if this buffer is instanced
  6352. */
  6353. getIsInstanced(): boolean;
  6354. /**
  6355. * Returns the instancing divisor, zero for non-instanced (integer).
  6356. * @returns a number
  6357. */
  6358. getInstanceDivisor(): number;
  6359. /**
  6360. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6361. * @param data defines the data to store
  6362. */
  6363. create(data?: DataArray): void;
  6364. /**
  6365. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6366. * This function will create a new buffer if the current one is not updatable
  6367. * @param data defines the data to store
  6368. */
  6369. update(data: DataArray): void;
  6370. /**
  6371. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6372. * Returns the directly updated WebGLBuffer.
  6373. * @param data the new data
  6374. * @param offset the new offset
  6375. * @param useBytes set to true if the offset is in bytes
  6376. */
  6377. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6378. /**
  6379. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6380. */
  6381. dispose(): void;
  6382. /**
  6383. * Enumerates each value of this vertex buffer as numbers.
  6384. * @param count the number of values to enumerate
  6385. * @param callback the callback function called for each value
  6386. */
  6387. forEach(count: number, callback: (value: number, index: number) => void): void;
  6388. /**
  6389. * Positions
  6390. */
  6391. static readonly PositionKind: string;
  6392. /**
  6393. * Normals
  6394. */
  6395. static readonly NormalKind: string;
  6396. /**
  6397. * Tangents
  6398. */
  6399. static readonly TangentKind: string;
  6400. /**
  6401. * Texture coordinates
  6402. */
  6403. static readonly UVKind: string;
  6404. /**
  6405. * Texture coordinates 2
  6406. */
  6407. static readonly UV2Kind: string;
  6408. /**
  6409. * Texture coordinates 3
  6410. */
  6411. static readonly UV3Kind: string;
  6412. /**
  6413. * Texture coordinates 4
  6414. */
  6415. static readonly UV4Kind: string;
  6416. /**
  6417. * Texture coordinates 5
  6418. */
  6419. static readonly UV5Kind: string;
  6420. /**
  6421. * Texture coordinates 6
  6422. */
  6423. static readonly UV6Kind: string;
  6424. /**
  6425. * Colors
  6426. */
  6427. static readonly ColorKind: string;
  6428. /**
  6429. * Matrix indices (for bones)
  6430. */
  6431. static readonly MatricesIndicesKind: string;
  6432. /**
  6433. * Matrix weights (for bones)
  6434. */
  6435. static readonly MatricesWeightsKind: string;
  6436. /**
  6437. * Additional matrix indices (for bones)
  6438. */
  6439. static readonly MatricesIndicesExtraKind: string;
  6440. /**
  6441. * Additional matrix weights (for bones)
  6442. */
  6443. static readonly MatricesWeightsExtraKind: string;
  6444. /**
  6445. * Deduces the stride given a kind.
  6446. * @param kind The kind string to deduce
  6447. * @returns The deduced stride
  6448. */
  6449. static DeduceStride(kind: string): number;
  6450. /**
  6451. * Gets the byte length of the given type.
  6452. * @param type the type
  6453. * @returns the number of bytes
  6454. */
  6455. static GetTypeByteLength(type: number): number;
  6456. /**
  6457. * Enumerates each value of the given parameters as numbers.
  6458. * @param data the data to enumerate
  6459. * @param byteOffset the byte offset of the data
  6460. * @param byteStride the byte stride of the data
  6461. * @param componentCount the number of components per element
  6462. * @param componentType the type of the component
  6463. * @param count the number of values to enumerate
  6464. * @param normalized whether the data is normalized
  6465. * @param callback the callback function called for each value
  6466. */
  6467. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6468. private static _GetFloatValue;
  6469. }
  6470. }
  6471. declare module "babylonjs/Collisions/intersectionInfo" {
  6472. import { Nullable } from "babylonjs/types";
  6473. /**
  6474. * @hidden
  6475. */
  6476. export class IntersectionInfo {
  6477. bu: Nullable<number>;
  6478. bv: Nullable<number>;
  6479. distance: number;
  6480. faceId: number;
  6481. subMeshId: number;
  6482. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6483. }
  6484. }
  6485. declare module "babylonjs/Maths/math.plane" {
  6486. import { DeepImmutable } from "babylonjs/types";
  6487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6488. /**
  6489. * Represens a plane by the equation ax + by + cz + d = 0
  6490. */
  6491. export class Plane {
  6492. private static _TmpMatrix;
  6493. /**
  6494. * Normal of the plane (a,b,c)
  6495. */
  6496. normal: Vector3;
  6497. /**
  6498. * d component of the plane
  6499. */
  6500. d: number;
  6501. /**
  6502. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6503. * @param a a component of the plane
  6504. * @param b b component of the plane
  6505. * @param c c component of the plane
  6506. * @param d d component of the plane
  6507. */
  6508. constructor(a: number, b: number, c: number, d: number);
  6509. /**
  6510. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6511. */
  6512. asArray(): number[];
  6513. /**
  6514. * @returns a new plane copied from the current Plane.
  6515. */
  6516. clone(): Plane;
  6517. /**
  6518. * @returns the string "Plane".
  6519. */
  6520. getClassName(): string;
  6521. /**
  6522. * @returns the Plane hash code.
  6523. */
  6524. getHashCode(): number;
  6525. /**
  6526. * Normalize the current Plane in place.
  6527. * @returns the updated Plane.
  6528. */
  6529. normalize(): Plane;
  6530. /**
  6531. * Applies a transformation the plane and returns the result
  6532. * @param transformation the transformation matrix to be applied to the plane
  6533. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6534. */
  6535. transform(transformation: DeepImmutable<Matrix>): Plane;
  6536. /**
  6537. * Calcualtte the dot product between the point and the plane normal
  6538. * @param point point to calculate the dot product with
  6539. * @returns the dot product (float) of the point coordinates and the plane normal.
  6540. */
  6541. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6542. /**
  6543. * Updates the current Plane from the plane defined by the three given points.
  6544. * @param point1 one of the points used to contruct the plane
  6545. * @param point2 one of the points used to contruct the plane
  6546. * @param point3 one of the points used to contruct the plane
  6547. * @returns the updated Plane.
  6548. */
  6549. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6550. /**
  6551. * Checks if the plane is facing a given direction
  6552. * @param direction the direction to check if the plane is facing
  6553. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6554. * @returns True is the vector "direction" is the same side than the plane normal.
  6555. */
  6556. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6557. /**
  6558. * Calculates the distance to a point
  6559. * @param point point to calculate distance to
  6560. * @returns the signed distance (float) from the given point to the Plane.
  6561. */
  6562. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6563. /**
  6564. * Creates a plane from an array
  6565. * @param array the array to create a plane from
  6566. * @returns a new Plane from the given array.
  6567. */
  6568. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6569. /**
  6570. * Creates a plane from three points
  6571. * @param point1 point used to create the plane
  6572. * @param point2 point used to create the plane
  6573. * @param point3 point used to create the plane
  6574. * @returns a new Plane defined by the three given points.
  6575. */
  6576. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6577. /**
  6578. * Creates a plane from an origin point and a normal
  6579. * @param origin origin of the plane to be constructed
  6580. * @param normal normal of the plane to be constructed
  6581. * @returns a new Plane the normal vector to this plane at the given origin point.
  6582. * Note : the vector "normal" is updated because normalized.
  6583. */
  6584. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6585. /**
  6586. * Calculates the distance from a plane and a point
  6587. * @param origin origin of the plane to be constructed
  6588. * @param normal normal of the plane to be constructed
  6589. * @param point point to calculate distance to
  6590. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6591. */
  6592. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6593. }
  6594. }
  6595. declare module "babylonjs/Culling/boundingSphere" {
  6596. import { DeepImmutable } from "babylonjs/types";
  6597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6598. import { Plane } from "babylonjs/Maths/math.plane";
  6599. /**
  6600. * Class used to store bounding sphere information
  6601. */
  6602. export class BoundingSphere {
  6603. /**
  6604. * Gets the center of the bounding sphere in local space
  6605. */
  6606. readonly center: Vector3;
  6607. /**
  6608. * Radius of the bounding sphere in local space
  6609. */
  6610. radius: number;
  6611. /**
  6612. * Gets the center of the bounding sphere in world space
  6613. */
  6614. readonly centerWorld: Vector3;
  6615. /**
  6616. * Radius of the bounding sphere in world space
  6617. */
  6618. radiusWorld: number;
  6619. /**
  6620. * Gets the minimum vector in local space
  6621. */
  6622. readonly minimum: Vector3;
  6623. /**
  6624. * Gets the maximum vector in local space
  6625. */
  6626. readonly maximum: Vector3;
  6627. private _worldMatrix;
  6628. private static readonly TmpVector3;
  6629. /**
  6630. * Creates a new bounding sphere
  6631. * @param min defines the minimum vector (in local space)
  6632. * @param max defines the maximum vector (in local space)
  6633. * @param worldMatrix defines the new world matrix
  6634. */
  6635. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6636. /**
  6637. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6638. * @param min defines the new minimum vector (in local space)
  6639. * @param max defines the new maximum vector (in local space)
  6640. * @param worldMatrix defines the new world matrix
  6641. */
  6642. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6643. /**
  6644. * Scale the current bounding sphere by applying a scale factor
  6645. * @param factor defines the scale factor to apply
  6646. * @returns the current bounding box
  6647. */
  6648. scale(factor: number): BoundingSphere;
  6649. /**
  6650. * Gets the world matrix of the bounding box
  6651. * @returns a matrix
  6652. */
  6653. getWorldMatrix(): DeepImmutable<Matrix>;
  6654. /** @hidden */
  6655. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6656. /**
  6657. * Tests if the bounding sphere is intersecting the frustum planes
  6658. * @param frustumPlanes defines the frustum planes to test
  6659. * @returns true if there is an intersection
  6660. */
  6661. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6662. /**
  6663. * Tests if the bounding sphere center is in between the frustum planes.
  6664. * Used for optimistic fast inclusion.
  6665. * @param frustumPlanes defines the frustum planes to test
  6666. * @returns true if the sphere center is in between the frustum planes
  6667. */
  6668. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6669. /**
  6670. * Tests if a point is inside the bounding sphere
  6671. * @param point defines the point to test
  6672. * @returns true if the point is inside the bounding sphere
  6673. */
  6674. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6675. /**
  6676. * Checks if two sphere intersct
  6677. * @param sphere0 sphere 0
  6678. * @param sphere1 sphere 1
  6679. * @returns true if the speres intersect
  6680. */
  6681. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingBox" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6688. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding box information
  6692. */
  6693. export class BoundingBox implements ICullable {
  6694. /**
  6695. * Gets the 8 vectors representing the bounding box in local space
  6696. */
  6697. readonly vectors: Vector3[];
  6698. /**
  6699. * Gets the center of the bounding box in local space
  6700. */
  6701. readonly center: Vector3;
  6702. /**
  6703. * Gets the center of the bounding box in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Gets the extend size in local space
  6708. */
  6709. readonly extendSize: Vector3;
  6710. /**
  6711. * Gets the extend size in world space
  6712. */
  6713. readonly extendSizeWorld: Vector3;
  6714. /**
  6715. * Gets the OBB (object bounding box) directions
  6716. */
  6717. readonly directions: Vector3[];
  6718. /**
  6719. * Gets the 8 vectors representing the bounding box in world space
  6720. */
  6721. readonly vectorsWorld: Vector3[];
  6722. /**
  6723. * Gets the minimum vector in world space
  6724. */
  6725. readonly minimumWorld: Vector3;
  6726. /**
  6727. * Gets the maximum vector in world space
  6728. */
  6729. readonly maximumWorld: Vector3;
  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. * @hidden
  6742. */
  6743. _tag: number;
  6744. /**
  6745. * Creates a new bounding box
  6746. * @param min defines the minimum vector (in local space)
  6747. * @param max defines the maximum vector (in local space)
  6748. * @param worldMatrix defines the new world matrix
  6749. */
  6750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6751. /**
  6752. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6753. * @param min defines the new minimum vector (in local space)
  6754. * @param max defines the new maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6758. /**
  6759. * Scale the current bounding box by applying a scale factor
  6760. * @param factor defines the scale factor to apply
  6761. * @returns the current bounding box
  6762. */
  6763. scale(factor: number): BoundingBox;
  6764. /**
  6765. * Gets the world matrix of the bounding box
  6766. * @returns a matrix
  6767. */
  6768. getWorldMatrix(): DeepImmutable<Matrix>;
  6769. /** @hidden */
  6770. _update(world: DeepImmutable<Matrix>): void;
  6771. /**
  6772. * Tests if the bounding box is intersecting the frustum planes
  6773. * @param frustumPlanes defines the frustum planes to test
  6774. * @returns true if there is an intersection
  6775. */
  6776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6777. /**
  6778. * Tests if the bounding box is entirely inside the frustum planes
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if there is an inclusion
  6781. */
  6782. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding box
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding box
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Tests if the bounding box intersects with a bounding sphere
  6791. * @param sphere defines the sphere to test
  6792. * @returns true if there is an intersection
  6793. */
  6794. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6795. /**
  6796. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6797. * @param min defines the min vector to use
  6798. * @param max defines the max vector to use
  6799. * @returns true if there is an intersection
  6800. */
  6801. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6802. /**
  6803. * Tests if two bounding boxes are intersections
  6804. * @param box0 defines the first box to test
  6805. * @param box1 defines the second box to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6809. /**
  6810. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6811. * @param minPoint defines the minimum vector of the bounding box
  6812. * @param maxPoint defines the maximum vector of the bounding box
  6813. * @param sphereCenter defines the sphere center
  6814. * @param sphereRadius defines the sphere radius
  6815. * @returns true if there is an intersection
  6816. */
  6817. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6818. /**
  6819. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6820. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6821. * @param frustumPlanes defines the frustum planes to test
  6822. * @return true if there is an inclusion
  6823. */
  6824. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6825. /**
  6826. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6827. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6828. * @param frustumPlanes defines the frustum planes to test
  6829. * @return true if there is an intersection
  6830. */
  6831. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6832. }
  6833. }
  6834. declare module "babylonjs/Collisions/collider" {
  6835. import { Nullable, IndicesArray } from "babylonjs/types";
  6836. import { Vector3 } from "babylonjs/Maths/math.vector";
  6837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6838. import { Plane } from "babylonjs/Maths/math.plane";
  6839. /** @hidden */
  6840. export class Collider {
  6841. /** Define if a collision was found */
  6842. collisionFound: boolean;
  6843. /**
  6844. * Define last intersection point in local space
  6845. */
  6846. intersectionPoint: Vector3;
  6847. /**
  6848. * Define last collided mesh
  6849. */
  6850. collidedMesh: Nullable<AbstractMesh>;
  6851. private _collisionPoint;
  6852. private _planeIntersectionPoint;
  6853. private _tempVector;
  6854. private _tempVector2;
  6855. private _tempVector3;
  6856. private _tempVector4;
  6857. private _edge;
  6858. private _baseToVertex;
  6859. private _destinationPoint;
  6860. private _slidePlaneNormal;
  6861. private _displacementVector;
  6862. /** @hidden */
  6863. _radius: Vector3;
  6864. /** @hidden */
  6865. _retry: number;
  6866. private _velocity;
  6867. private _basePoint;
  6868. private _epsilon;
  6869. /** @hidden */
  6870. _velocityWorldLength: number;
  6871. /** @hidden */
  6872. _basePointWorld: Vector3;
  6873. private _velocityWorld;
  6874. private _normalizedVelocity;
  6875. /** @hidden */
  6876. _initialVelocity: Vector3;
  6877. /** @hidden */
  6878. _initialPosition: Vector3;
  6879. private _nearestDistance;
  6880. private _collisionMask;
  6881. collisionMask: number;
  6882. /**
  6883. * Gets the plane normal used to compute the sliding response (in local space)
  6884. */
  6885. readonly slidePlaneNormal: Vector3;
  6886. /** @hidden */
  6887. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6888. /** @hidden */
  6889. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6890. /** @hidden */
  6891. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6892. /** @hidden */
  6893. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6894. /** @hidden */
  6895. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6896. /** @hidden */
  6897. _getResponse(pos: Vector3, vel: Vector3): void;
  6898. }
  6899. }
  6900. declare module "babylonjs/Culling/boundingInfo" {
  6901. import { DeepImmutable } from "babylonjs/types";
  6902. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6904. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6905. import { Plane } from "babylonjs/Maths/math.plane";
  6906. import { Collider } from "babylonjs/Collisions/collider";
  6907. /**
  6908. * Interface for cullable objects
  6909. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6910. */
  6911. export interface ICullable {
  6912. /**
  6913. * Checks if the object or part of the object is in the frustum
  6914. * @param frustumPlanes Camera near/planes
  6915. * @returns true if the object is in frustum otherwise false
  6916. */
  6917. isInFrustum(frustumPlanes: Plane[]): boolean;
  6918. /**
  6919. * Checks if a cullable object (mesh...) is in the camera frustum
  6920. * Unlike isInFrustum this cheks the full bounding box
  6921. * @param frustumPlanes Camera near/planes
  6922. * @returns true if the object is in frustum otherwise false
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6925. }
  6926. /**
  6927. * Info for a bounding data of a mesh
  6928. */
  6929. export class BoundingInfo implements ICullable {
  6930. /**
  6931. * Bounding box for the mesh
  6932. */
  6933. readonly boundingBox: BoundingBox;
  6934. /**
  6935. * Bounding sphere for the mesh
  6936. */
  6937. readonly boundingSphere: BoundingSphere;
  6938. private _isLocked;
  6939. private static readonly TmpVector3;
  6940. /**
  6941. * Constructs bounding info
  6942. * @param minimum min vector of the bounding box/sphere
  6943. * @param maximum max vector of the bounding box/sphere
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * min vector of the bounding box/sphere
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * max vector of the bounding box/sphere
  6960. */
  6961. readonly maximum: Vector3;
  6962. /**
  6963. * If the info is locked and won't be updated to avoid perf overhead
  6964. */
  6965. isLocked: boolean;
  6966. /**
  6967. * Updates the bounding sphere and box
  6968. * @param world world matrix to be used to update
  6969. */
  6970. update(world: DeepImmutable<Matrix>): void;
  6971. /**
  6972. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6973. * @param center New center of the bounding info
  6974. * @param extend New extend of the bounding info
  6975. * @returns the current bounding info
  6976. */
  6977. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6978. /**
  6979. * Scale the current bounding info by applying a scale factor
  6980. * @param factor defines the scale factor to apply
  6981. * @returns the current bounding info
  6982. */
  6983. scale(factor: number): BoundingInfo;
  6984. /**
  6985. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6986. * @param frustumPlanes defines the frustum to test
  6987. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6988. * @returns true if the bounding info is in the frustum planes
  6989. */
  6990. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6991. /**
  6992. * Gets the world distance between the min and max points of the bounding box
  6993. */
  6994. readonly diagonalLength: number;
  6995. /**
  6996. * Checks if a cullable object (mesh...) is in the camera frustum
  6997. * Unlike isInFrustum this cheks the full bounding box
  6998. * @param frustumPlanes Camera near/planes
  6999. * @returns true if the object is in frustum otherwise false
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /** @hidden */
  7003. _checkCollision(collider: Collider): boolean;
  7004. /**
  7005. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7006. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7007. * @param point the point to check intersection with
  7008. * @returns if the point intersects
  7009. */
  7010. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7011. /**
  7012. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7013. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7014. * @param boundingInfo the bounding info to check intersection with
  7015. * @param precise if the intersection should be done using OBB
  7016. * @returns if the bounding info intersects
  7017. */
  7018. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7019. }
  7020. }
  7021. declare module "babylonjs/Maths/math.functions" {
  7022. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7023. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7024. /**
  7025. * Extracts minimum and maximum values from a list of indexed positions
  7026. * @param positions defines the positions to use
  7027. * @param indices defines the indices to the positions
  7028. * @param indexStart defines the start index
  7029. * @param indexCount defines the end index
  7030. * @param bias defines bias value to add to the result
  7031. * @return minimum and maximum values
  7032. */
  7033. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7034. minimum: Vector3;
  7035. maximum: Vector3;
  7036. };
  7037. /**
  7038. * Extracts minimum and maximum values from a list of positions
  7039. * @param positions defines the positions to use
  7040. * @param start defines the start index in the positions array
  7041. * @param count defines the number of positions to handle
  7042. * @param bias defines bias value to add to the result
  7043. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7044. * @return minimum and maximum values
  7045. */
  7046. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7047. minimum: Vector3;
  7048. maximum: Vector3;
  7049. };
  7050. }
  7051. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7052. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7053. /** @hidden */
  7054. export class WebGLDataBuffer extends DataBuffer {
  7055. private _buffer;
  7056. constructor(resource: WebGLBuffer);
  7057. readonly underlyingResource: any;
  7058. }
  7059. }
  7060. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7061. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7062. import { Nullable } from "babylonjs/types";
  7063. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7064. /** @hidden */
  7065. export class WebGLPipelineContext implements IPipelineContext {
  7066. engine: ThinEngine;
  7067. program: Nullable<WebGLProgram>;
  7068. context?: WebGLRenderingContext;
  7069. vertexShader?: WebGLShader;
  7070. fragmentShader?: WebGLShader;
  7071. isParallelCompiled: boolean;
  7072. onCompiled?: () => void;
  7073. transformFeedback?: WebGLTransformFeedback | null;
  7074. readonly isAsync: boolean;
  7075. readonly isReady: boolean;
  7076. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7077. }
  7078. }
  7079. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7080. import { FloatArray, Nullable } from "babylonjs/types";
  7081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7082. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7083. module "babylonjs/Engines/thinEngine" {
  7084. interface ThinEngine {
  7085. /**
  7086. * Create an uniform buffer
  7087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7088. * @param elements defines the content of the uniform buffer
  7089. * @returns the webGL uniform buffer
  7090. */
  7091. createUniformBuffer(elements: FloatArray): DataBuffer;
  7092. /**
  7093. * Create a dynamic uniform buffer
  7094. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7095. * @param elements defines the content of the uniform buffer
  7096. * @returns the webGL uniform buffer
  7097. */
  7098. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7099. /**
  7100. * Update an existing uniform buffer
  7101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7102. * @param uniformBuffer defines the target uniform buffer
  7103. * @param elements defines the content to update
  7104. * @param offset defines the offset in the uniform buffer where update should start
  7105. * @param count defines the size of the data to update
  7106. */
  7107. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7108. /**
  7109. * Bind an uniform buffer to the current webGL context
  7110. * @param buffer defines the buffer to bind
  7111. */
  7112. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7113. /**
  7114. * Bind a buffer to the current webGL context at a given location
  7115. * @param buffer defines the buffer to bind
  7116. * @param location defines the index where to bind the buffer
  7117. */
  7118. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7119. /**
  7120. * Bind a specific block at a given index in a specific shader program
  7121. * @param pipelineContext defines the pipeline context to use
  7122. * @param blockName defines the block name
  7123. * @param index defines the index where to bind the block
  7124. */
  7125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7126. }
  7127. }
  7128. }
  7129. declare module "babylonjs/Materials/uniformBuffer" {
  7130. import { Nullable, FloatArray } from "babylonjs/types";
  7131. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7132. import { Engine } from "babylonjs/Engines/engine";
  7133. import { Effect } from "babylonjs/Materials/effect";
  7134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7135. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7136. import { Color3 } from "babylonjs/Maths/math.color";
  7137. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7138. /**
  7139. * Uniform buffer objects.
  7140. *
  7141. * Handles blocks of uniform on the GPU.
  7142. *
  7143. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7144. *
  7145. * For more information, please refer to :
  7146. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7147. */
  7148. export class UniformBuffer {
  7149. private _engine;
  7150. private _buffer;
  7151. private _data;
  7152. private _bufferData;
  7153. private _dynamic?;
  7154. private _uniformLocations;
  7155. private _uniformSizes;
  7156. private _uniformLocationPointer;
  7157. private _needSync;
  7158. private _noUBO;
  7159. private _currentEffect;
  7160. /** @hidden */
  7161. _alreadyBound: boolean;
  7162. private static _MAX_UNIFORM_SIZE;
  7163. private static _tempBuffer;
  7164. /**
  7165. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7166. * This is dynamic to allow compat with webgl 1 and 2.
  7167. * You will need to pass the name of the uniform as well as the value.
  7168. */
  7169. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7170. /**
  7171. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7172. * This is dynamic to allow compat with webgl 1 and 2.
  7173. * You will need to pass the name of the uniform as well as the value.
  7174. */
  7175. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7176. /**
  7177. * Lambda to Update a single float in a uniform buffer.
  7178. * This is dynamic to allow compat with webgl 1 and 2.
  7179. * You will need to pass the name of the uniform as well as the value.
  7180. */
  7181. updateFloat: (name: string, x: number) => void;
  7182. /**
  7183. * Lambda to Update a vec2 of float in a uniform buffer.
  7184. * This is dynamic to allow compat with webgl 1 and 2.
  7185. * You will need to pass the name of the uniform as well as the value.
  7186. */
  7187. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7188. /**
  7189. * Lambda to Update a vec3 of float in a uniform buffer.
  7190. * This is dynamic to allow compat with webgl 1 and 2.
  7191. * You will need to pass the name of the uniform as well as the value.
  7192. */
  7193. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7194. /**
  7195. * Lambda to Update a vec4 of float in a uniform buffer.
  7196. * This is dynamic to allow compat with webgl 1 and 2.
  7197. * You will need to pass the name of the uniform as well as the value.
  7198. */
  7199. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7200. /**
  7201. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix: (name: string, mat: Matrix) => void;
  7206. /**
  7207. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateVector3: (name: string, vector: Vector3) => void;
  7212. /**
  7213. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateVector4: (name: string, vector: Vector4) => void;
  7218. /**
  7219. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7230. /**
  7231. * Instantiates a new Uniform buffer objects.
  7232. *
  7233. * Handles blocks of uniform on the GPU.
  7234. *
  7235. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7236. *
  7237. * For more information, please refer to :
  7238. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7239. * @param engine Define the engine the buffer is associated with
  7240. * @param data Define the data contained in the buffer
  7241. * @param dynamic Define if the buffer is updatable
  7242. */
  7243. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7244. /**
  7245. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7246. * or just falling back on setUniformXXX calls.
  7247. */
  7248. readonly useUbo: boolean;
  7249. /**
  7250. * Indicates if the WebGL underlying uniform buffer is in sync
  7251. * with the javascript cache data.
  7252. */
  7253. readonly isSync: boolean;
  7254. /**
  7255. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7256. * Also, a dynamic UniformBuffer will disable cache verification and always
  7257. * update the underlying WebGL uniform buffer to the GPU.
  7258. * @returns if Dynamic, otherwise false
  7259. */
  7260. isDynamic(): boolean;
  7261. /**
  7262. * The data cache on JS side.
  7263. * @returns the underlying data as a float array
  7264. */
  7265. getData(): Float32Array;
  7266. /**
  7267. * The underlying WebGL Uniform buffer.
  7268. * @returns the webgl buffer
  7269. */
  7270. getBuffer(): Nullable<DataBuffer>;
  7271. /**
  7272. * std140 layout specifies how to align data within an UBO structure.
  7273. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7274. * for specs.
  7275. */
  7276. private _fillAlignment;
  7277. /**
  7278. * Adds an uniform in the buffer.
  7279. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7280. * for the layout to be correct !
  7281. * @param name Name of the uniform, as used in the uniform block in the shader.
  7282. * @param size Data size, or data directly.
  7283. */
  7284. addUniform(name: string, size: number | number[]): void;
  7285. /**
  7286. * Adds a Matrix 4x4 to the uniform buffer.
  7287. * @param name Name of the uniform, as used in the uniform block in the shader.
  7288. * @param mat A 4x4 matrix.
  7289. */
  7290. addMatrix(name: string, mat: Matrix): void;
  7291. /**
  7292. * Adds a vec2 to the uniform buffer.
  7293. * @param name Name of the uniform, as used in the uniform block in the shader.
  7294. * @param x Define the x component value of the vec2
  7295. * @param y Define the y component value of the vec2
  7296. */
  7297. addFloat2(name: string, x: number, y: number): void;
  7298. /**
  7299. * Adds a vec3 to the uniform buffer.
  7300. * @param name Name of the uniform, as used in the uniform block in the shader.
  7301. * @param x Define the x component value of the vec3
  7302. * @param y Define the y component value of the vec3
  7303. * @param z Define the z component value of the vec3
  7304. */
  7305. addFloat3(name: string, x: number, y: number, z: number): void;
  7306. /**
  7307. * Adds a vec3 to the uniform buffer.
  7308. * @param name Name of the uniform, as used in the uniform block in the shader.
  7309. * @param color Define the vec3 from a Color
  7310. */
  7311. addColor3(name: string, color: Color3): void;
  7312. /**
  7313. * Adds a vec4 to the uniform buffer.
  7314. * @param name Name of the uniform, as used in the uniform block in the shader.
  7315. * @param color Define the rgb components from a Color
  7316. * @param alpha Define the a component of the vec4
  7317. */
  7318. addColor4(name: string, color: Color3, alpha: number): void;
  7319. /**
  7320. * Adds a vec3 to the uniform buffer.
  7321. * @param name Name of the uniform, as used in the uniform block in the shader.
  7322. * @param vector Define the vec3 components from a Vector
  7323. */
  7324. addVector3(name: string, vector: Vector3): void;
  7325. /**
  7326. * Adds a Matrix 3x3 to the uniform buffer.
  7327. * @param name Name of the uniform, as used in the uniform block in the shader.
  7328. */
  7329. addMatrix3x3(name: string): void;
  7330. /**
  7331. * Adds a Matrix 2x2 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. */
  7334. addMatrix2x2(name: string): void;
  7335. /**
  7336. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7337. */
  7338. create(): void;
  7339. /** @hidden */
  7340. _rebuild(): void;
  7341. /**
  7342. * Updates the WebGL Uniform Buffer on the GPU.
  7343. * If the `dynamic` flag is set to true, no cache comparison is done.
  7344. * Otherwise, the buffer will be updated only if the cache differs.
  7345. */
  7346. update(): void;
  7347. /**
  7348. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7349. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7350. * @param data Define the flattened data
  7351. * @param size Define the size of the data.
  7352. */
  7353. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7354. private _valueCache;
  7355. private _cacheMatrix;
  7356. private _updateMatrix3x3ForUniform;
  7357. private _updateMatrix3x3ForEffect;
  7358. private _updateMatrix2x2ForEffect;
  7359. private _updateMatrix2x2ForUniform;
  7360. private _updateFloatForEffect;
  7361. private _updateFloatForUniform;
  7362. private _updateFloat2ForEffect;
  7363. private _updateFloat2ForUniform;
  7364. private _updateFloat3ForEffect;
  7365. private _updateFloat3ForUniform;
  7366. private _updateFloat4ForEffect;
  7367. private _updateFloat4ForUniform;
  7368. private _updateMatrixForEffect;
  7369. private _updateMatrixForUniform;
  7370. private _updateVector3ForEffect;
  7371. private _updateVector3ForUniform;
  7372. private _updateVector4ForEffect;
  7373. private _updateVector4ForUniform;
  7374. private _updateColor3ForEffect;
  7375. private _updateColor3ForUniform;
  7376. private _updateColor4ForEffect;
  7377. private _updateColor4ForUniform;
  7378. /**
  7379. * Sets a sampler uniform on the effect.
  7380. * @param name Define the name of the sampler.
  7381. * @param texture Define the texture to set in the sampler
  7382. */
  7383. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7384. /**
  7385. * Directly updates the value of the uniform in the cache AND on the GPU.
  7386. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7387. * @param data Define the flattened data
  7388. */
  7389. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7390. /**
  7391. * Binds this uniform buffer to an effect.
  7392. * @param effect Define the effect to bind the buffer to
  7393. * @param name Name of the uniform block in the shader.
  7394. */
  7395. bindToEffect(effect: Effect, name: string): void;
  7396. /**
  7397. * Disposes the uniform buffer.
  7398. */
  7399. dispose(): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/iInspectable" {
  7403. /**
  7404. * Enum that determines the text-wrapping mode to use.
  7405. */
  7406. export enum InspectableType {
  7407. /**
  7408. * Checkbox for booleans
  7409. */
  7410. Checkbox = 0,
  7411. /**
  7412. * Sliders for numbers
  7413. */
  7414. Slider = 1,
  7415. /**
  7416. * Vector3
  7417. */
  7418. Vector3 = 2,
  7419. /**
  7420. * Quaternions
  7421. */
  7422. Quaternion = 3,
  7423. /**
  7424. * Color3
  7425. */
  7426. Color3 = 4,
  7427. /**
  7428. * String
  7429. */
  7430. String = 5
  7431. }
  7432. /**
  7433. * Interface used to define custom inspectable properties.
  7434. * This interface is used by the inspector to display custom property grids
  7435. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7436. */
  7437. export interface IInspectable {
  7438. /**
  7439. * Gets the label to display
  7440. */
  7441. label: string;
  7442. /**
  7443. * Gets the name of the property to edit
  7444. */
  7445. propertyName: string;
  7446. /**
  7447. * Gets the type of the editor to use
  7448. */
  7449. type: InspectableType;
  7450. /**
  7451. * Gets the minimum value of the property when using in "slider" mode
  7452. */
  7453. min?: number;
  7454. /**
  7455. * Gets the maximum value of the property when using in "slider" mode
  7456. */
  7457. max?: number;
  7458. /**
  7459. * Gets the setp to use when using in "slider" mode
  7460. */
  7461. step?: number;
  7462. }
  7463. }
  7464. declare module "babylonjs/Misc/timingTools" {
  7465. /**
  7466. * Class used to provide helper for timing
  7467. */
  7468. export class TimingTools {
  7469. /**
  7470. * Polyfill for setImmediate
  7471. * @param action defines the action to execute after the current execution block
  7472. */
  7473. static SetImmediate(action: () => void): void;
  7474. }
  7475. }
  7476. declare module "babylonjs/Misc/instantiationTools" {
  7477. /**
  7478. * Class used to enable instatition of objects by class name
  7479. */
  7480. export class InstantiationTools {
  7481. /**
  7482. * Use this object to register external classes like custom textures or material
  7483. * to allow the laoders to instantiate them
  7484. */
  7485. static RegisteredExternalClasses: {
  7486. [key: string]: Object;
  7487. };
  7488. /**
  7489. * Tries to instantiate a new object from a given class name
  7490. * @param className defines the class name to instantiate
  7491. * @returns the new object or null if the system was not able to do the instantiation
  7492. */
  7493. static Instantiate(className: string): any;
  7494. }
  7495. }
  7496. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7497. /**
  7498. * Define options used to create a depth texture
  7499. */
  7500. export class DepthTextureCreationOptions {
  7501. /** Specifies whether or not a stencil should be allocated in the texture */
  7502. generateStencil?: boolean;
  7503. /** Specifies whether or not bilinear filtering is enable on the texture */
  7504. bilinearFiltering?: boolean;
  7505. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7506. comparisonFunction?: number;
  7507. /** Specifies if the created texture is a cube texture */
  7508. isCube?: boolean;
  7509. }
  7510. }
  7511. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7513. import { Nullable } from "babylonjs/types";
  7514. import { Scene } from "babylonjs/scene";
  7515. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7516. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7517. module "babylonjs/Engines/thinEngine" {
  7518. interface ThinEngine {
  7519. /**
  7520. * Creates a depth stencil cube texture.
  7521. * This is only available in WebGL 2.
  7522. * @param size The size of face edge in the cube texture.
  7523. * @param options The options defining the cube texture.
  7524. * @returns The cube texture
  7525. */
  7526. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7527. /**
  7528. * Creates a cube texture
  7529. * @param rootUrl defines the url where the files to load is located
  7530. * @param scene defines the current scene
  7531. * @param files defines the list of files to load (1 per face)
  7532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7533. * @param onLoad defines an optional callback raised when the texture is loaded
  7534. * @param onError defines an optional callback raised if there is an issue to load the texture
  7535. * @param format defines the format of the data
  7536. * @param forcedExtension defines the extension to use to pick the right loader
  7537. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7540. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7541. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7542. * @returns the cube texture as an InternalTexture
  7543. */
  7544. 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;
  7545. /**
  7546. * Creates a cube texture
  7547. * @param rootUrl defines the url where the files to load is located
  7548. * @param scene defines the current scene
  7549. * @param files defines the list of files to load (1 per face)
  7550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7551. * @param onLoad defines an optional callback raised when the texture is loaded
  7552. * @param onError defines an optional callback raised if there is an issue to load the texture
  7553. * @param format defines the format of the data
  7554. * @param forcedExtension defines the extension to use to pick the right loader
  7555. * @returns the cube texture as an InternalTexture
  7556. */
  7557. 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;
  7558. /**
  7559. * Creates a cube texture
  7560. * @param rootUrl defines the url where the files to load is located
  7561. * @param scene defines the current scene
  7562. * @param files defines the list of files to load (1 per face)
  7563. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7564. * @param onLoad defines an optional callback raised when the texture is loaded
  7565. * @param onError defines an optional callback raised if there is an issue to load the texture
  7566. * @param format defines the format of the data
  7567. * @param forcedExtension defines the extension to use to pick the right loader
  7568. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7571. * @returns the cube texture as an InternalTexture
  7572. */
  7573. 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;
  7574. /** @hidden */
  7575. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7576. /** @hidden */
  7577. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7578. /** @hidden */
  7579. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7580. /** @hidden */
  7581. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7582. }
  7583. }
  7584. }
  7585. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7586. import { Nullable } from "babylonjs/types";
  7587. import { Scene } from "babylonjs/scene";
  7588. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7590. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7591. /**
  7592. * Class for creating a cube texture
  7593. */
  7594. export class CubeTexture extends BaseTexture {
  7595. private _delayedOnLoad;
  7596. /**
  7597. * The url of the texture
  7598. */
  7599. url: string;
  7600. /**
  7601. * Gets or sets the center of the bounding box associated with the cube texture.
  7602. * It must define where the camera used to render the texture was set
  7603. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7604. */
  7605. boundingBoxPosition: Vector3;
  7606. private _boundingBoxSize;
  7607. /**
  7608. * Gets or sets the size of the bounding box associated with the cube texture
  7609. * When defined, the cubemap will switch to local mode
  7610. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7611. * @example https://www.babylonjs-playground.com/#RNASML
  7612. */
  7613. /**
  7614. * Returns the bounding box size
  7615. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7616. */
  7617. boundingBoxSize: Vector3;
  7618. protected _rotationY: number;
  7619. /**
  7620. * Sets texture matrix rotation angle around Y axis in radians.
  7621. */
  7622. /**
  7623. * Gets texture matrix rotation angle around Y axis radians.
  7624. */
  7625. rotationY: number;
  7626. /**
  7627. * Are mip maps generated for this texture or not.
  7628. */
  7629. readonly noMipmap: boolean;
  7630. private _noMipmap;
  7631. private _files;
  7632. protected _forcedExtension: Nullable<string>;
  7633. private _extensions;
  7634. private _textureMatrix;
  7635. private _format;
  7636. private _createPolynomials;
  7637. /** @hidden */
  7638. _prefiltered: boolean;
  7639. /**
  7640. * Creates a cube texture from an array of image urls
  7641. * @param files defines an array of image urls
  7642. * @param scene defines the hosting scene
  7643. * @param noMipmap specifies if mip maps are not used
  7644. * @returns a cube texture
  7645. */
  7646. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7647. /**
  7648. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7649. * @param url defines the url of the prefiltered texture
  7650. * @param scene defines the scene the texture is attached to
  7651. * @param forcedExtension defines the extension of the file if different from the url
  7652. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7653. * @return the prefiltered texture
  7654. */
  7655. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7656. /**
  7657. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7658. * as prefiltered data.
  7659. * @param rootUrl defines the url of the texture or the root name of the six images
  7660. * @param scene defines the scene the texture is attached to
  7661. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7662. * @param noMipmap defines if mipmaps should be created or not
  7663. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7664. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7665. * @param onError defines a callback triggered in case of error during load
  7666. * @param format defines the internal format to use for the texture once loaded
  7667. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7668. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7669. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7670. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7671. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7672. * @return the cube texture
  7673. */
  7674. 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);
  7675. /**
  7676. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7677. */
  7678. readonly isPrefiltered: boolean;
  7679. /**
  7680. * Get the current class name of the texture useful for serialization or dynamic coding.
  7681. * @returns "CubeTexture"
  7682. */
  7683. getClassName(): string;
  7684. /**
  7685. * Update the url (and optional buffer) of this texture if url was null during construction.
  7686. * @param url the url of the texture
  7687. * @param forcedExtension defines the extension to use
  7688. * @param onLoad callback called when the texture is loaded (defaults to null)
  7689. */
  7690. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7691. /**
  7692. * Delays loading of the cube texture
  7693. * @param forcedExtension defines the extension to use
  7694. */
  7695. delayLoad(forcedExtension?: string): void;
  7696. /**
  7697. * Returns the reflection texture matrix
  7698. * @returns the reflection texture matrix
  7699. */
  7700. getReflectionTextureMatrix(): Matrix;
  7701. /**
  7702. * Sets the reflection texture matrix
  7703. * @param value Reflection texture matrix
  7704. */
  7705. setReflectionTextureMatrix(value: Matrix): void;
  7706. /**
  7707. * Parses text to create a cube texture
  7708. * @param parsedTexture define the serialized text to read from
  7709. * @param scene defines the hosting scene
  7710. * @param rootUrl defines the root url of the cube texture
  7711. * @returns a cube texture
  7712. */
  7713. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7714. /**
  7715. * Makes a clone, or deep copy, of the cube texture
  7716. * @returns a new cube texture
  7717. */
  7718. clone(): CubeTexture;
  7719. }
  7720. }
  7721. declare module "babylonjs/Materials/materialDefines" {
  7722. /**
  7723. * Manages the defines for the Material
  7724. */
  7725. export class MaterialDefines {
  7726. /** @hidden */
  7727. protected _keys: string[];
  7728. private _isDirty;
  7729. /** @hidden */
  7730. _renderId: number;
  7731. /** @hidden */
  7732. _areLightsDirty: boolean;
  7733. /** @hidden */
  7734. _areLightsDisposed: boolean;
  7735. /** @hidden */
  7736. _areAttributesDirty: boolean;
  7737. /** @hidden */
  7738. _areTexturesDirty: boolean;
  7739. /** @hidden */
  7740. _areFresnelDirty: boolean;
  7741. /** @hidden */
  7742. _areMiscDirty: boolean;
  7743. /** @hidden */
  7744. _areImageProcessingDirty: boolean;
  7745. /** @hidden */
  7746. _normals: boolean;
  7747. /** @hidden */
  7748. _uvs: boolean;
  7749. /** @hidden */
  7750. _needNormals: boolean;
  7751. /** @hidden */
  7752. _needUVs: boolean;
  7753. [id: string]: any;
  7754. /**
  7755. * Specifies if the material needs to be re-calculated
  7756. */
  7757. readonly isDirty: boolean;
  7758. /**
  7759. * Marks the material to indicate that it has been re-calculated
  7760. */
  7761. markAsProcessed(): void;
  7762. /**
  7763. * Marks the material to indicate that it needs to be re-calculated
  7764. */
  7765. markAsUnprocessed(): void;
  7766. /**
  7767. * Marks the material to indicate all of its defines need to be re-calculated
  7768. */
  7769. markAllAsDirty(): void;
  7770. /**
  7771. * Marks the material to indicate that image processing needs to be re-calculated
  7772. */
  7773. markAsImageProcessingDirty(): void;
  7774. /**
  7775. * Marks the material to indicate the lights need to be re-calculated
  7776. * @param disposed Defines whether the light is dirty due to dispose or not
  7777. */
  7778. markAsLightDirty(disposed?: boolean): void;
  7779. /**
  7780. * Marks the attribute state as changed
  7781. */
  7782. markAsAttributesDirty(): void;
  7783. /**
  7784. * Marks the texture state as changed
  7785. */
  7786. markAsTexturesDirty(): void;
  7787. /**
  7788. * Marks the fresnel state as changed
  7789. */
  7790. markAsFresnelDirty(): void;
  7791. /**
  7792. * Marks the misc state as changed
  7793. */
  7794. markAsMiscDirty(): void;
  7795. /**
  7796. * Rebuilds the material defines
  7797. */
  7798. rebuild(): void;
  7799. /**
  7800. * Specifies if two material defines are equal
  7801. * @param other - A material define instance to compare to
  7802. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7803. */
  7804. isEqual(other: MaterialDefines): boolean;
  7805. /**
  7806. * Clones this instance's defines to another instance
  7807. * @param other - material defines to clone values to
  7808. */
  7809. cloneTo(other: MaterialDefines): void;
  7810. /**
  7811. * Resets the material define values
  7812. */
  7813. reset(): void;
  7814. /**
  7815. * Converts the material define values to a string
  7816. * @returns - String of material define information
  7817. */
  7818. toString(): string;
  7819. }
  7820. }
  7821. declare module "babylonjs/Materials/colorCurves" {
  7822. import { Effect } from "babylonjs/Materials/effect";
  7823. /**
  7824. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7825. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7826. * 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;
  7827. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7828. */
  7829. export class ColorCurves {
  7830. private _dirty;
  7831. private _tempColor;
  7832. private _globalCurve;
  7833. private _highlightsCurve;
  7834. private _midtonesCurve;
  7835. private _shadowsCurve;
  7836. private _positiveCurve;
  7837. private _negativeCurve;
  7838. private _globalHue;
  7839. private _globalDensity;
  7840. private _globalSaturation;
  7841. private _globalExposure;
  7842. /**
  7843. * Gets the global Hue value.
  7844. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7845. */
  7846. /**
  7847. * Sets the global Hue value.
  7848. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7849. */
  7850. globalHue: number;
  7851. /**
  7852. * Gets the global Density value.
  7853. * 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.
  7854. * Values less than zero provide a filter of opposite hue.
  7855. */
  7856. /**
  7857. * Sets the global Density value.
  7858. * 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.
  7859. * Values less than zero provide a filter of opposite hue.
  7860. */
  7861. globalDensity: number;
  7862. /**
  7863. * Gets the global Saturation value.
  7864. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7865. */
  7866. /**
  7867. * Sets the global Saturation value.
  7868. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7869. */
  7870. globalSaturation: number;
  7871. /**
  7872. * Gets the global Exposure value.
  7873. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7874. */
  7875. /**
  7876. * Sets the global Exposure value.
  7877. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7878. */
  7879. globalExposure: number;
  7880. private _highlightsHue;
  7881. private _highlightsDensity;
  7882. private _highlightsSaturation;
  7883. private _highlightsExposure;
  7884. /**
  7885. * Gets the highlights Hue value.
  7886. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7887. */
  7888. /**
  7889. * Sets the highlights Hue value.
  7890. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7891. */
  7892. highlightsHue: number;
  7893. /**
  7894. * Gets the highlights Density value.
  7895. * 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.
  7896. * Values less than zero provide a filter of opposite hue.
  7897. */
  7898. /**
  7899. * Sets the highlights Density value.
  7900. * 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.
  7901. * Values less than zero provide a filter of opposite hue.
  7902. */
  7903. highlightsDensity: number;
  7904. /**
  7905. * Gets the highlights Saturation value.
  7906. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7907. */
  7908. /**
  7909. * Sets the highlights Saturation value.
  7910. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7911. */
  7912. highlightsSaturation: number;
  7913. /**
  7914. * Gets the highlights Exposure value.
  7915. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7916. */
  7917. /**
  7918. * Sets the highlights Exposure value.
  7919. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7920. */
  7921. highlightsExposure: number;
  7922. private _midtonesHue;
  7923. private _midtonesDensity;
  7924. private _midtonesSaturation;
  7925. private _midtonesExposure;
  7926. /**
  7927. * Gets the midtones Hue value.
  7928. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7929. */
  7930. /**
  7931. * Sets the midtones Hue value.
  7932. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7933. */
  7934. midtonesHue: number;
  7935. /**
  7936. * Gets the midtones Density value.
  7937. * 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.
  7938. * Values less than zero provide a filter of opposite hue.
  7939. */
  7940. /**
  7941. * Sets the midtones Density value.
  7942. * 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.
  7943. * Values less than zero provide a filter of opposite hue.
  7944. */
  7945. midtonesDensity: number;
  7946. /**
  7947. * Gets the midtones Saturation value.
  7948. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7949. */
  7950. /**
  7951. * Sets the midtones Saturation value.
  7952. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7953. */
  7954. midtonesSaturation: number;
  7955. /**
  7956. * Gets the midtones Exposure value.
  7957. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7958. */
  7959. /**
  7960. * Sets the midtones Exposure value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7962. */
  7963. midtonesExposure: number;
  7964. private _shadowsHue;
  7965. private _shadowsDensity;
  7966. private _shadowsSaturation;
  7967. private _shadowsExposure;
  7968. /**
  7969. * Gets the shadows Hue value.
  7970. * 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).
  7971. */
  7972. /**
  7973. * Sets the shadows Hue value.
  7974. * 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).
  7975. */
  7976. shadowsHue: number;
  7977. /**
  7978. * Gets the shadows Density value.
  7979. * 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.
  7980. * Values less than zero provide a filter of opposite hue.
  7981. */
  7982. /**
  7983. * Sets the shadows Density value.
  7984. * 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.
  7985. * Values less than zero provide a filter of opposite hue.
  7986. */
  7987. shadowsDensity: number;
  7988. /**
  7989. * Gets the shadows Saturation value.
  7990. * 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.
  7991. */
  7992. /**
  7993. * Sets the shadows Saturation value.
  7994. * 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.
  7995. */
  7996. shadowsSaturation: number;
  7997. /**
  7998. * Gets the shadows Exposure value.
  7999. * 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.
  8000. */
  8001. /**
  8002. * Sets the shadows Exposure value.
  8003. * 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.
  8004. */
  8005. shadowsExposure: number;
  8006. /**
  8007. * Returns the class name
  8008. * @returns The class name
  8009. */
  8010. getClassName(): string;
  8011. /**
  8012. * Binds the color curves to the shader.
  8013. * @param colorCurves The color curve to bind
  8014. * @param effect The effect to bind to
  8015. * @param positiveUniform The positive uniform shader parameter
  8016. * @param neutralUniform The neutral uniform shader parameter
  8017. * @param negativeUniform The negative uniform shader parameter
  8018. */
  8019. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8020. /**
  8021. * Prepare the list of uniforms associated with the ColorCurves effects.
  8022. * @param uniformsList The list of uniforms used in the effect
  8023. */
  8024. static PrepareUniforms(uniformsList: string[]): void;
  8025. /**
  8026. * Returns color grading data based on a hue, density, saturation and exposure value.
  8027. * @param filterHue The hue of the color filter.
  8028. * @param filterDensity The density of the color filter.
  8029. * @param saturation The saturation.
  8030. * @param exposure The exposure.
  8031. * @param result The result data container.
  8032. */
  8033. private getColorGradingDataToRef;
  8034. /**
  8035. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8036. * @param value The input slider value in range [-100,100].
  8037. * @returns Adjusted value.
  8038. */
  8039. private static applyColorGradingSliderNonlinear;
  8040. /**
  8041. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8042. * @param hue The hue (H) input.
  8043. * @param saturation The saturation (S) input.
  8044. * @param brightness The brightness (B) input.
  8045. * @result An RGBA color represented as Vector4.
  8046. */
  8047. private static fromHSBToRef;
  8048. /**
  8049. * Returns a value clamped between min and max
  8050. * @param value The value to clamp
  8051. * @param min The minimum of value
  8052. * @param max The maximum of value
  8053. * @returns The clamped value.
  8054. */
  8055. private static clamp;
  8056. /**
  8057. * Clones the current color curve instance.
  8058. * @return The cloned curves
  8059. */
  8060. clone(): ColorCurves;
  8061. /**
  8062. * Serializes the current color curve instance to a json representation.
  8063. * @return a JSON representation
  8064. */
  8065. serialize(): any;
  8066. /**
  8067. * Parses the color curve from a json representation.
  8068. * @param source the JSON source to parse
  8069. * @return The parsed curves
  8070. */
  8071. static Parse(source: any): ColorCurves;
  8072. }
  8073. }
  8074. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8075. import { Observable } from "babylonjs/Misc/observable";
  8076. import { Nullable } from "babylonjs/types";
  8077. import { Color4 } from "babylonjs/Maths/math.color";
  8078. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8079. import { Effect } from "babylonjs/Materials/effect";
  8080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8081. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8082. /**
  8083. * Interface to follow in your material defines to integrate easily the
  8084. * Image proccessing functions.
  8085. * @hidden
  8086. */
  8087. export interface IImageProcessingConfigurationDefines {
  8088. IMAGEPROCESSING: boolean;
  8089. VIGNETTE: boolean;
  8090. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8091. VIGNETTEBLENDMODEOPAQUE: boolean;
  8092. TONEMAPPING: boolean;
  8093. TONEMAPPING_ACES: boolean;
  8094. CONTRAST: boolean;
  8095. EXPOSURE: boolean;
  8096. COLORCURVES: boolean;
  8097. COLORGRADING: boolean;
  8098. COLORGRADING3D: boolean;
  8099. SAMPLER3DGREENDEPTH: boolean;
  8100. SAMPLER3DBGRMAP: boolean;
  8101. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8102. }
  8103. /**
  8104. * @hidden
  8105. */
  8106. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8107. IMAGEPROCESSING: boolean;
  8108. VIGNETTE: boolean;
  8109. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8110. VIGNETTEBLENDMODEOPAQUE: boolean;
  8111. TONEMAPPING: boolean;
  8112. TONEMAPPING_ACES: boolean;
  8113. CONTRAST: boolean;
  8114. COLORCURVES: boolean;
  8115. COLORGRADING: boolean;
  8116. COLORGRADING3D: boolean;
  8117. SAMPLER3DGREENDEPTH: boolean;
  8118. SAMPLER3DBGRMAP: boolean;
  8119. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8120. EXPOSURE: boolean;
  8121. constructor();
  8122. }
  8123. /**
  8124. * This groups together the common properties used for image processing either in direct forward pass
  8125. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8126. * or not.
  8127. */
  8128. export class ImageProcessingConfiguration {
  8129. /**
  8130. * Default tone mapping applied in BabylonJS.
  8131. */
  8132. static readonly TONEMAPPING_STANDARD: number;
  8133. /**
  8134. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8135. * to other engines rendering to increase portability.
  8136. */
  8137. static readonly TONEMAPPING_ACES: number;
  8138. /**
  8139. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8140. */
  8141. colorCurves: Nullable<ColorCurves>;
  8142. private _colorCurvesEnabled;
  8143. /**
  8144. * Gets wether the color curves effect is enabled.
  8145. */
  8146. /**
  8147. * Sets wether the color curves effect is enabled.
  8148. */
  8149. colorCurvesEnabled: boolean;
  8150. private _colorGradingTexture;
  8151. /**
  8152. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8153. */
  8154. /**
  8155. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8156. */
  8157. colorGradingTexture: Nullable<BaseTexture>;
  8158. private _colorGradingEnabled;
  8159. /**
  8160. * Gets wether the color grading effect is enabled.
  8161. */
  8162. /**
  8163. * Sets wether the color grading effect is enabled.
  8164. */
  8165. colorGradingEnabled: boolean;
  8166. private _colorGradingWithGreenDepth;
  8167. /**
  8168. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8169. */
  8170. /**
  8171. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8172. */
  8173. colorGradingWithGreenDepth: boolean;
  8174. private _colorGradingBGR;
  8175. /**
  8176. * Gets wether the color grading texture contains BGR values.
  8177. */
  8178. /**
  8179. * Sets wether the color grading texture contains BGR values.
  8180. */
  8181. colorGradingBGR: boolean;
  8182. /** @hidden */
  8183. _exposure: number;
  8184. /**
  8185. * Gets the Exposure used in the effect.
  8186. */
  8187. /**
  8188. * Sets the Exposure used in the effect.
  8189. */
  8190. exposure: number;
  8191. private _toneMappingEnabled;
  8192. /**
  8193. * Gets wether the tone mapping effect is enabled.
  8194. */
  8195. /**
  8196. * Sets wether the tone mapping effect is enabled.
  8197. */
  8198. toneMappingEnabled: boolean;
  8199. private _toneMappingType;
  8200. /**
  8201. * Gets the type of tone mapping effect.
  8202. */
  8203. /**
  8204. * Sets the type of tone mapping effect used in BabylonJS.
  8205. */
  8206. toneMappingType: number;
  8207. protected _contrast: number;
  8208. /**
  8209. * Gets the contrast used in the effect.
  8210. */
  8211. /**
  8212. * Sets the contrast used in the effect.
  8213. */
  8214. contrast: number;
  8215. /**
  8216. * Vignette stretch size.
  8217. */
  8218. vignetteStretch: number;
  8219. /**
  8220. * Vignette centre X Offset.
  8221. */
  8222. vignetteCentreX: number;
  8223. /**
  8224. * Vignette centre Y Offset.
  8225. */
  8226. vignetteCentreY: number;
  8227. /**
  8228. * Vignette weight or intensity of the vignette effect.
  8229. */
  8230. vignetteWeight: number;
  8231. /**
  8232. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8233. * if vignetteEnabled is set to true.
  8234. */
  8235. vignetteColor: Color4;
  8236. /**
  8237. * Camera field of view used by the Vignette effect.
  8238. */
  8239. vignetteCameraFov: number;
  8240. private _vignetteBlendMode;
  8241. /**
  8242. * Gets the vignette blend mode allowing different kind of effect.
  8243. */
  8244. /**
  8245. * Sets the vignette blend mode allowing different kind of effect.
  8246. */
  8247. vignetteBlendMode: number;
  8248. private _vignetteEnabled;
  8249. /**
  8250. * Gets wether the vignette effect is enabled.
  8251. */
  8252. /**
  8253. * Sets wether the vignette effect is enabled.
  8254. */
  8255. vignetteEnabled: boolean;
  8256. private _applyByPostProcess;
  8257. /**
  8258. * Gets wether the image processing is applied through a post process or not.
  8259. */
  8260. /**
  8261. * Sets wether the image processing is applied through a post process or not.
  8262. */
  8263. applyByPostProcess: boolean;
  8264. private _isEnabled;
  8265. /**
  8266. * Gets wether the image processing is enabled or not.
  8267. */
  8268. /**
  8269. * Sets wether the image processing is enabled or not.
  8270. */
  8271. isEnabled: boolean;
  8272. /**
  8273. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8274. */
  8275. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8276. /**
  8277. * Method called each time the image processing information changes requires to recompile the effect.
  8278. */
  8279. protected _updateParameters(): void;
  8280. /**
  8281. * Gets the current class name.
  8282. * @return "ImageProcessingConfiguration"
  8283. */
  8284. getClassName(): string;
  8285. /**
  8286. * Prepare the list of uniforms associated with the Image Processing effects.
  8287. * @param uniforms The list of uniforms used in the effect
  8288. * @param defines the list of defines currently in use
  8289. */
  8290. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8291. /**
  8292. * Prepare the list of samplers associated with the Image Processing effects.
  8293. * @param samplersList The list of uniforms used in the effect
  8294. * @param defines the list of defines currently in use
  8295. */
  8296. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8297. /**
  8298. * Prepare the list of defines associated to the shader.
  8299. * @param defines the list of defines to complete
  8300. * @param forPostProcess Define if we are currently in post process mode or not
  8301. */
  8302. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8303. /**
  8304. * Returns true if all the image processing information are ready.
  8305. * @returns True if ready, otherwise, false
  8306. */
  8307. isReady(): boolean;
  8308. /**
  8309. * Binds the image processing to the shader.
  8310. * @param effect The effect to bind to
  8311. * @param aspectRatio Define the current aspect ratio of the effect
  8312. */
  8313. bind(effect: Effect, aspectRatio?: number): void;
  8314. /**
  8315. * Clones the current image processing instance.
  8316. * @return The cloned image processing
  8317. */
  8318. clone(): ImageProcessingConfiguration;
  8319. /**
  8320. * Serializes the current image processing instance to a json representation.
  8321. * @return a JSON representation
  8322. */
  8323. serialize(): any;
  8324. /**
  8325. * Parses the image processing from a json representation.
  8326. * @param source the JSON source to parse
  8327. * @return The parsed image processing
  8328. */
  8329. static Parse(source: any): ImageProcessingConfiguration;
  8330. private static _VIGNETTEMODE_MULTIPLY;
  8331. private static _VIGNETTEMODE_OPAQUE;
  8332. /**
  8333. * Used to apply the vignette as a mix with the pixel color.
  8334. */
  8335. static readonly VIGNETTEMODE_MULTIPLY: number;
  8336. /**
  8337. * Used to apply the vignette as a replacement of the pixel color.
  8338. */
  8339. static readonly VIGNETTEMODE_OPAQUE: number;
  8340. }
  8341. }
  8342. declare module "babylonjs/Shaders/postprocess.vertex" {
  8343. /** @hidden */
  8344. export var postprocessVertexShader: {
  8345. name: string;
  8346. shader: string;
  8347. };
  8348. }
  8349. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8350. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8351. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8352. module "babylonjs/Engines/thinEngine" {
  8353. interface ThinEngine {
  8354. /**
  8355. * Creates a new render target texture
  8356. * @param size defines the size of the texture
  8357. * @param options defines the options used to create the texture
  8358. * @returns a new render target texture stored in an InternalTexture
  8359. */
  8360. createRenderTargetTexture(size: number | {
  8361. width: number;
  8362. height: number;
  8363. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8364. }
  8365. }
  8366. }
  8367. declare module "babylonjs/Maths/math.axis" {
  8368. import { Vector3 } from "babylonjs/Maths/math.vector";
  8369. /** Defines supported spaces */
  8370. export enum Space {
  8371. /** Local (object) space */
  8372. LOCAL = 0,
  8373. /** World space */
  8374. WORLD = 1,
  8375. /** Bone space */
  8376. BONE = 2
  8377. }
  8378. /** Defines the 3 main axes */
  8379. export class Axis {
  8380. /** X axis */
  8381. static X: Vector3;
  8382. /** Y axis */
  8383. static Y: Vector3;
  8384. /** Z axis */
  8385. static Z: Vector3;
  8386. }
  8387. }
  8388. declare module "babylonjs/Cameras/targetCamera" {
  8389. import { Nullable } from "babylonjs/types";
  8390. import { Camera } from "babylonjs/Cameras/camera";
  8391. import { Scene } from "babylonjs/scene";
  8392. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8393. /**
  8394. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. */
  8398. export class TargetCamera extends Camera {
  8399. private static _RigCamTransformMatrix;
  8400. private static _TargetTransformMatrix;
  8401. private static _TargetFocalPoint;
  8402. /**
  8403. * Define the current direction the camera is moving to
  8404. */
  8405. cameraDirection: Vector3;
  8406. /**
  8407. * Define the current rotation the camera is rotating to
  8408. */
  8409. cameraRotation: Vector2;
  8410. /**
  8411. * When set, the up vector of the camera will be updated by the rotation of the camera
  8412. */
  8413. updateUpVectorFromRotation: boolean;
  8414. private _tmpQuaternion;
  8415. /**
  8416. * Define the current rotation of the camera
  8417. */
  8418. rotation: Vector3;
  8419. /**
  8420. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8421. */
  8422. rotationQuaternion: Quaternion;
  8423. /**
  8424. * Define the current speed of the camera
  8425. */
  8426. speed: number;
  8427. /**
  8428. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8429. * around all axis.
  8430. */
  8431. noRotationConstraint: boolean;
  8432. /**
  8433. * Define the current target of the camera as an object or a position.
  8434. */
  8435. lockedTarget: any;
  8436. /** @hidden */
  8437. _currentTarget: Vector3;
  8438. /** @hidden */
  8439. _initialFocalDistance: number;
  8440. /** @hidden */
  8441. _viewMatrix: Matrix;
  8442. /** @hidden */
  8443. _camMatrix: Matrix;
  8444. /** @hidden */
  8445. _cameraTransformMatrix: Matrix;
  8446. /** @hidden */
  8447. _cameraRotationMatrix: Matrix;
  8448. /** @hidden */
  8449. _referencePoint: Vector3;
  8450. /** @hidden */
  8451. _transformedReferencePoint: Vector3;
  8452. protected _globalCurrentTarget: Vector3;
  8453. protected _globalCurrentUpVector: Vector3;
  8454. /** @hidden */
  8455. _reset: () => void;
  8456. private _defaultUp;
  8457. /**
  8458. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8459. * This is the base of the follow, arc rotate cameras and Free camera
  8460. * @see http://doc.babylonjs.com/features/cameras
  8461. * @param name Defines the name of the camera in the scene
  8462. * @param position Defines the start position of the camera in the scene
  8463. * @param scene Defines the scene the camera belongs to
  8464. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8465. */
  8466. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8467. /**
  8468. * Gets the position in front of the camera at a given distance.
  8469. * @param distance The distance from the camera we want the position to be
  8470. * @returns the position
  8471. */
  8472. getFrontPosition(distance: number): Vector3;
  8473. /** @hidden */
  8474. _getLockedTargetPosition(): Nullable<Vector3>;
  8475. private _storedPosition;
  8476. private _storedRotation;
  8477. private _storedRotationQuaternion;
  8478. /**
  8479. * Store current camera state of the camera (fov, position, rotation, etc..)
  8480. * @returns the camera
  8481. */
  8482. storeState(): Camera;
  8483. /**
  8484. * Restored camera state. You must call storeState() first
  8485. * @returns whether it was successful or not
  8486. * @hidden
  8487. */
  8488. _restoreStateValues(): boolean;
  8489. /** @hidden */
  8490. _initCache(): void;
  8491. /** @hidden */
  8492. _updateCache(ignoreParentClass?: boolean): void;
  8493. /** @hidden */
  8494. _isSynchronizedViewMatrix(): boolean;
  8495. /** @hidden */
  8496. _computeLocalCameraSpeed(): number;
  8497. /**
  8498. * Defines the target the camera should look at.
  8499. * @param target Defines the new target as a Vector or a mesh
  8500. */
  8501. setTarget(target: Vector3): void;
  8502. /**
  8503. * Return the current target position of the camera. This value is expressed in local space.
  8504. * @returns the target position
  8505. */
  8506. getTarget(): Vector3;
  8507. /** @hidden */
  8508. _decideIfNeedsToMove(): boolean;
  8509. /** @hidden */
  8510. _updatePosition(): void;
  8511. /** @hidden */
  8512. _checkInputs(): void;
  8513. protected _updateCameraRotationMatrix(): void;
  8514. /**
  8515. * 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)
  8516. * @returns the current camera
  8517. */
  8518. private _rotateUpVectorWithCameraRotationMatrix;
  8519. private _cachedRotationZ;
  8520. private _cachedQuaternionRotationZ;
  8521. /** @hidden */
  8522. _getViewMatrix(): Matrix;
  8523. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8524. /**
  8525. * @hidden
  8526. */
  8527. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8528. /**
  8529. * @hidden
  8530. */
  8531. _updateRigCameras(): void;
  8532. private _getRigCamPositionAndTarget;
  8533. /**
  8534. * Gets the current object class name.
  8535. * @return the class name
  8536. */
  8537. getClassName(): string;
  8538. }
  8539. }
  8540. declare module "babylonjs/Events/keyboardEvents" {
  8541. /**
  8542. * Gather the list of keyboard event types as constants.
  8543. */
  8544. export class KeyboardEventTypes {
  8545. /**
  8546. * The keydown event is fired when a key becomes active (pressed).
  8547. */
  8548. static readonly KEYDOWN: number;
  8549. /**
  8550. * The keyup event is fired when a key has been released.
  8551. */
  8552. static readonly KEYUP: number;
  8553. }
  8554. /**
  8555. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8556. */
  8557. export class KeyboardInfo {
  8558. /**
  8559. * Defines the type of event (KeyboardEventTypes)
  8560. */
  8561. type: number;
  8562. /**
  8563. * Defines the related dom event
  8564. */
  8565. event: KeyboardEvent;
  8566. /**
  8567. * Instantiates a new keyboard info.
  8568. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8569. * @param type Defines the type of event (KeyboardEventTypes)
  8570. * @param event Defines the related dom event
  8571. */
  8572. constructor(
  8573. /**
  8574. * Defines the type of event (KeyboardEventTypes)
  8575. */
  8576. type: number,
  8577. /**
  8578. * Defines the related dom event
  8579. */
  8580. event: KeyboardEvent);
  8581. }
  8582. /**
  8583. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8584. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8585. */
  8586. export class KeyboardInfoPre extends KeyboardInfo {
  8587. /**
  8588. * Defines the type of event (KeyboardEventTypes)
  8589. */
  8590. type: number;
  8591. /**
  8592. * Defines the related dom event
  8593. */
  8594. event: KeyboardEvent;
  8595. /**
  8596. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8597. */
  8598. skipOnPointerObservable: boolean;
  8599. /**
  8600. * Instantiates a new keyboard pre info.
  8601. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8602. * @param type Defines the type of event (KeyboardEventTypes)
  8603. * @param event Defines the related dom event
  8604. */
  8605. constructor(
  8606. /**
  8607. * Defines the type of event (KeyboardEventTypes)
  8608. */
  8609. type: number,
  8610. /**
  8611. * Defines the related dom event
  8612. */
  8613. event: KeyboardEvent);
  8614. }
  8615. }
  8616. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8617. import { Nullable } from "babylonjs/types";
  8618. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8619. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8620. /**
  8621. * Manage the keyboard inputs to control the movement of a free camera.
  8622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8623. */
  8624. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8625. /**
  8626. * Defines the camera the input is attached to.
  8627. */
  8628. camera: FreeCamera;
  8629. /**
  8630. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8631. */
  8632. keysUp: number[];
  8633. /**
  8634. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8635. */
  8636. keysDown: number[];
  8637. /**
  8638. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8639. */
  8640. keysLeft: number[];
  8641. /**
  8642. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8643. */
  8644. keysRight: number[];
  8645. private _keys;
  8646. private _onCanvasBlurObserver;
  8647. private _onKeyboardObserver;
  8648. private _engine;
  8649. private _scene;
  8650. /**
  8651. * Attach the input controls to a specific dom element to get the input from.
  8652. * @param element Defines the element the controls should be listened from
  8653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8654. */
  8655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8656. /**
  8657. * Detach the current controls from the specified dom element.
  8658. * @param element Defines the element to stop listening the inputs from
  8659. */
  8660. detachControl(element: Nullable<HTMLElement>): void;
  8661. /**
  8662. * Update the current camera state depending on the inputs that have been used this frame.
  8663. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8664. */
  8665. checkInputs(): void;
  8666. /**
  8667. * Gets the class name of the current intput.
  8668. * @returns the class name
  8669. */
  8670. getClassName(): string;
  8671. /** @hidden */
  8672. _onLostFocus(): void;
  8673. /**
  8674. * Get the friendly name associated with the input class.
  8675. * @returns the input friendly name
  8676. */
  8677. getSimpleName(): string;
  8678. }
  8679. }
  8680. declare module "babylonjs/Lights/shadowLight" {
  8681. import { Camera } from "babylonjs/Cameras/camera";
  8682. import { Scene } from "babylonjs/scene";
  8683. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8685. import { Light } from "babylonjs/Lights/light";
  8686. /**
  8687. * Interface describing all the common properties and methods a shadow light needs to implement.
  8688. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8689. * as well as binding the different shadow properties to the effects.
  8690. */
  8691. export interface IShadowLight extends Light {
  8692. /**
  8693. * The light id in the scene (used in scene.findLighById for instance)
  8694. */
  8695. id: string;
  8696. /**
  8697. * The position the shdow will be casted from.
  8698. */
  8699. position: Vector3;
  8700. /**
  8701. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8702. */
  8703. direction: Vector3;
  8704. /**
  8705. * The transformed position. Position of the light in world space taking parenting in account.
  8706. */
  8707. transformedPosition: Vector3;
  8708. /**
  8709. * The transformed direction. Direction of the light in world space taking parenting in account.
  8710. */
  8711. transformedDirection: Vector3;
  8712. /**
  8713. * The friendly name of the light in the scene.
  8714. */
  8715. name: string;
  8716. /**
  8717. * Defines the shadow projection clipping minimum z value.
  8718. */
  8719. shadowMinZ: number;
  8720. /**
  8721. * Defines the shadow projection clipping maximum z value.
  8722. */
  8723. shadowMaxZ: number;
  8724. /**
  8725. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8726. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8727. */
  8728. computeTransformedInformation(): boolean;
  8729. /**
  8730. * Gets the scene the light belongs to.
  8731. * @returns The scene
  8732. */
  8733. getScene(): Scene;
  8734. /**
  8735. * Callback defining a custom Projection Matrix Builder.
  8736. * This can be used to override the default projection matrix computation.
  8737. */
  8738. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8739. /**
  8740. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8741. * @param matrix The materix to updated with the projection information
  8742. * @param viewMatrix The transform matrix of the light
  8743. * @param renderList The list of mesh to render in the map
  8744. * @returns The current light
  8745. */
  8746. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8747. /**
  8748. * Gets the current depth scale used in ESM.
  8749. * @returns The scale
  8750. */
  8751. getDepthScale(): number;
  8752. /**
  8753. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8754. * @returns true if a cube texture needs to be use
  8755. */
  8756. needCube(): boolean;
  8757. /**
  8758. * Detects if the projection matrix requires to be recomputed this frame.
  8759. * @returns true if it requires to be recomputed otherwise, false.
  8760. */
  8761. needProjectionMatrixCompute(): boolean;
  8762. /**
  8763. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8764. */
  8765. forceProjectionMatrixCompute(): void;
  8766. /**
  8767. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8768. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8769. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8770. */
  8771. getShadowDirection(faceIndex?: number): Vector3;
  8772. /**
  8773. * Gets the minZ used for shadow according to both the scene and the light.
  8774. * @param activeCamera The camera we are returning the min for
  8775. * @returns the depth min z
  8776. */
  8777. getDepthMinZ(activeCamera: Camera): number;
  8778. /**
  8779. * Gets the maxZ used for shadow according to both the scene and the light.
  8780. * @param activeCamera The camera we are returning the max for
  8781. * @returns the depth max z
  8782. */
  8783. getDepthMaxZ(activeCamera: Camera): number;
  8784. }
  8785. /**
  8786. * Base implementation IShadowLight
  8787. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8788. */
  8789. export abstract class ShadowLight extends Light implements IShadowLight {
  8790. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8791. protected _position: Vector3;
  8792. protected _setPosition(value: Vector3): void;
  8793. /**
  8794. * Sets the position the shadow will be casted from. Also use as the light position for both
  8795. * point and spot lights.
  8796. */
  8797. /**
  8798. * Sets the position the shadow will be casted from. Also use as the light position for both
  8799. * point and spot lights.
  8800. */
  8801. position: Vector3;
  8802. protected _direction: Vector3;
  8803. protected _setDirection(value: Vector3): void;
  8804. /**
  8805. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8806. * Also use as the light direction on spot and directional lights.
  8807. */
  8808. /**
  8809. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8810. * Also use as the light direction on spot and directional lights.
  8811. */
  8812. direction: Vector3;
  8813. private _shadowMinZ;
  8814. /**
  8815. * Gets the shadow projection clipping minimum z value.
  8816. */
  8817. /**
  8818. * Sets the shadow projection clipping minimum z value.
  8819. */
  8820. shadowMinZ: number;
  8821. private _shadowMaxZ;
  8822. /**
  8823. * Sets the shadow projection clipping maximum z value.
  8824. */
  8825. /**
  8826. * Gets the shadow projection clipping maximum z value.
  8827. */
  8828. shadowMaxZ: number;
  8829. /**
  8830. * Callback defining a custom Projection Matrix Builder.
  8831. * This can be used to override the default projection matrix computation.
  8832. */
  8833. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. private _needProjectionMatrixCompute;
  8843. /**
  8844. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8845. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8846. */
  8847. computeTransformedInformation(): boolean;
  8848. /**
  8849. * Return the depth scale used for the shadow map.
  8850. * @returns the depth scale.
  8851. */
  8852. getDepthScale(): number;
  8853. /**
  8854. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8855. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8856. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8857. */
  8858. getShadowDirection(faceIndex?: number): Vector3;
  8859. /**
  8860. * Returns the ShadowLight absolute position in the World.
  8861. * @returns the position vector in world space
  8862. */
  8863. getAbsolutePosition(): Vector3;
  8864. /**
  8865. * Sets the ShadowLight direction toward the passed target.
  8866. * @param target The point to target in local space
  8867. * @returns the updated ShadowLight direction
  8868. */
  8869. setDirectionToTarget(target: Vector3): Vector3;
  8870. /**
  8871. * Returns the light rotation in euler definition.
  8872. * @returns the x y z rotation in local space.
  8873. */
  8874. getRotation(): Vector3;
  8875. /**
  8876. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8877. * @returns true if a cube texture needs to be use
  8878. */
  8879. needCube(): boolean;
  8880. /**
  8881. * Detects if the projection matrix requires to be recomputed this frame.
  8882. * @returns true if it requires to be recomputed otherwise, false.
  8883. */
  8884. needProjectionMatrixCompute(): boolean;
  8885. /**
  8886. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8887. */
  8888. forceProjectionMatrixCompute(): void;
  8889. /** @hidden */
  8890. _initCache(): void;
  8891. /** @hidden */
  8892. _isSynchronized(): boolean;
  8893. /**
  8894. * Computes the world matrix of the node
  8895. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8896. * @returns the world matrix
  8897. */
  8898. computeWorldMatrix(force?: boolean): Matrix;
  8899. /**
  8900. * Gets the minZ used for shadow according to both the scene and the light.
  8901. * @param activeCamera The camera we are returning the min for
  8902. * @returns the depth min z
  8903. */
  8904. getDepthMinZ(activeCamera: Camera): number;
  8905. /**
  8906. * Gets the maxZ used for shadow according to both the scene and the light.
  8907. * @param activeCamera The camera we are returning the max for
  8908. * @returns the depth max z
  8909. */
  8910. getDepthMaxZ(activeCamera: Camera): number;
  8911. /**
  8912. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8913. * @param matrix The materix to updated with the projection information
  8914. * @param viewMatrix The transform matrix of the light
  8915. * @param renderList The list of mesh to render in the map
  8916. * @returns The current light
  8917. */
  8918. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8919. }
  8920. }
  8921. declare module "babylonjs/Materials/effectFallbacks" {
  8922. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8923. import { Effect } from "babylonjs/Materials/effect";
  8924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8925. /**
  8926. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8927. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8928. */
  8929. export class EffectFallbacks implements IEffectFallbacks {
  8930. private _defines;
  8931. private _currentRank;
  8932. private _maxRank;
  8933. private _mesh;
  8934. /**
  8935. * Removes the fallback from the bound mesh.
  8936. */
  8937. unBindMesh(): void;
  8938. /**
  8939. * Adds a fallback on the specified property.
  8940. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8941. * @param define The name of the define in the shader
  8942. */
  8943. addFallback(rank: number, define: string): void;
  8944. /**
  8945. * Sets the mesh to use CPU skinning when needing to fallback.
  8946. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8947. * @param mesh The mesh to use the fallbacks.
  8948. */
  8949. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8950. /**
  8951. * Checks to see if more fallbacks are still availible.
  8952. */
  8953. readonly hasMoreFallbacks: boolean;
  8954. /**
  8955. * Removes the defines that should be removed when falling back.
  8956. * @param currentDefines defines the current define statements for the shader.
  8957. * @param effect defines the current effect we try to compile
  8958. * @returns The resulting defines with defines of the current rank removed.
  8959. */
  8960. reduce(currentDefines: string, effect: Effect): string;
  8961. }
  8962. }
  8963. declare module "babylonjs/Materials/materialHelper" {
  8964. import { Nullable } from "babylonjs/types";
  8965. import { Scene } from "babylonjs/scene";
  8966. import { Engine } from "babylonjs/Engines/engine";
  8967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8968. import { Light } from "babylonjs/Lights/light";
  8969. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8970. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8972. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8973. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8974. /**
  8975. * "Static Class" containing the most commonly used helper while dealing with material for
  8976. * rendering purpose.
  8977. *
  8978. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8979. *
  8980. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8981. */
  8982. export class MaterialHelper {
  8983. /**
  8984. * Bind the current view position to an effect.
  8985. * @param effect The effect to be bound
  8986. * @param scene The scene the eyes position is used from
  8987. */
  8988. static BindEyePosition(effect: Effect, scene: Scene): void;
  8989. /**
  8990. * Helps preparing the defines values about the UVs in used in the effect.
  8991. * UVs are shared as much as we can accross channels in the shaders.
  8992. * @param texture The texture we are preparing the UVs for
  8993. * @param defines The defines to update
  8994. * @param key The channel key "diffuse", "specular"... used in the shader
  8995. */
  8996. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8997. /**
  8998. * Binds a texture matrix value to its corrsponding uniform
  8999. * @param texture The texture to bind the matrix for
  9000. * @param uniformBuffer The uniform buffer receivin the data
  9001. * @param key The channel key "diffuse", "specular"... used in the shader
  9002. */
  9003. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9004. /**
  9005. * Gets the current status of the fog (should it be enabled?)
  9006. * @param mesh defines the mesh to evaluate for fog support
  9007. * @param scene defines the hosting scene
  9008. * @returns true if fog must be enabled
  9009. */
  9010. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9011. /**
  9012. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9013. * @param mesh defines the current mesh
  9014. * @param scene defines the current scene
  9015. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9016. * @param pointsCloud defines if point cloud rendering has to be turned on
  9017. * @param fogEnabled defines if fog has to be turned on
  9018. * @param alphaTest defines if alpha testing has to be turned on
  9019. * @param defines defines the current list of defines
  9020. */
  9021. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9022. /**
  9023. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9024. * @param scene defines the current scene
  9025. * @param engine defines the current engine
  9026. * @param defines specifies the list of active defines
  9027. * @param useInstances defines if instances have to be turned on
  9028. * @param useClipPlane defines if clip plane have to be turned on
  9029. */
  9030. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9031. /**
  9032. * Prepares the defines for bones
  9033. * @param mesh The mesh containing the geometry data we will draw
  9034. * @param defines The defines to update
  9035. */
  9036. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9037. /**
  9038. * Prepares the defines for morph targets
  9039. * @param mesh The mesh containing the geometry data we will draw
  9040. * @param defines The defines to update
  9041. */
  9042. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9043. /**
  9044. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9045. * @param mesh The mesh containing the geometry data we will draw
  9046. * @param defines The defines to update
  9047. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9048. * @param useBones Precise whether bones should be used or not (override mesh info)
  9049. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9050. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9051. * @returns false if defines are considered not dirty and have not been checked
  9052. */
  9053. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9054. /**
  9055. * Prepares the defines related to multiview
  9056. * @param scene The scene we are intending to draw
  9057. * @param defines The defines to update
  9058. */
  9059. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9060. /**
  9061. * Prepares the defines related to the light information passed in parameter
  9062. * @param scene The scene we are intending to draw
  9063. * @param mesh The mesh the effect is compiling for
  9064. * @param light The light the effect is compiling for
  9065. * @param lightIndex The index of the light
  9066. * @param defines The defines to update
  9067. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9068. * @param state Defines the current state regarding what is needed (normals, etc...)
  9069. */
  9070. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9071. needNormals: boolean;
  9072. needRebuild: boolean;
  9073. shadowEnabled: boolean;
  9074. specularEnabled: boolean;
  9075. lightmapMode: boolean;
  9076. }): void;
  9077. /**
  9078. * Prepares the defines related to the light information passed in parameter
  9079. * @param scene The scene we are intending to draw
  9080. * @param mesh The mesh the effect is compiling for
  9081. * @param defines The defines to update
  9082. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9083. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9084. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9085. * @returns true if normals will be required for the rest of the effect
  9086. */
  9087. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9088. /**
  9089. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9090. * @param lightIndex defines the light index
  9091. * @param uniformsList The uniform list
  9092. * @param samplersList The sampler list
  9093. * @param projectedLightTexture defines if projected texture must be used
  9094. * @param uniformBuffersList defines an optional list of uniform buffers
  9095. */
  9096. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9097. /**
  9098. * Prepares the uniforms and samplers list to be used in the effect
  9099. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9100. * @param samplersList The sampler list
  9101. * @param defines The defines helping in the list generation
  9102. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9103. */
  9104. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9105. /**
  9106. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9107. * @param defines The defines to update while falling back
  9108. * @param fallbacks The authorized effect fallbacks
  9109. * @param maxSimultaneousLights The maximum number of lights allowed
  9110. * @param rank the current rank of the Effect
  9111. * @returns The newly affected rank
  9112. */
  9113. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9114. private static _TmpMorphInfluencers;
  9115. /**
  9116. * Prepares the list of attributes required for morph targets according to the effect defines.
  9117. * @param attribs The current list of supported attribs
  9118. * @param mesh The mesh to prepare the morph targets attributes for
  9119. * @param influencers The number of influencers
  9120. */
  9121. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9122. /**
  9123. * Prepares the list of attributes required for morph targets according to the effect defines.
  9124. * @param attribs The current list of supported attribs
  9125. * @param mesh The mesh to prepare the morph targets attributes for
  9126. * @param defines The current Defines of the effect
  9127. */
  9128. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9129. /**
  9130. * Prepares the list of attributes required for bones according to the effect defines.
  9131. * @param attribs The current list of supported attribs
  9132. * @param mesh The mesh to prepare the bones attributes for
  9133. * @param defines The current Defines of the effect
  9134. * @param fallbacks The current efffect fallback strategy
  9135. */
  9136. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9137. /**
  9138. * Check and prepare the list of attributes required for instances according to the effect defines.
  9139. * @param attribs The current list of supported attribs
  9140. * @param defines The current MaterialDefines of the effect
  9141. */
  9142. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9143. /**
  9144. * Add the list of attributes required for instances to the attribs array.
  9145. * @param attribs The current list of supported attribs
  9146. */
  9147. static PushAttributesForInstances(attribs: string[]): void;
  9148. /**
  9149. * Binds the light information to the effect.
  9150. * @param light The light containing the generator
  9151. * @param effect The effect we are binding the data to
  9152. * @param lightIndex The light index in the effect used to render
  9153. */
  9154. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9155. /**
  9156. * Binds the lights information from the scene to the effect for the given mesh.
  9157. * @param light Light to bind
  9158. * @param lightIndex Light index
  9159. * @param scene The scene where the light belongs to
  9160. * @param effect The effect we are binding the data to
  9161. * @param useSpecular Defines if specular is supported
  9162. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9163. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9164. */
  9165. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9166. /**
  9167. * Binds the lights information from the scene to the effect for the given mesh.
  9168. * @param scene The scene the lights belongs to
  9169. * @param mesh The mesh we are binding the information to render
  9170. * @param effect The effect we are binding the data to
  9171. * @param defines The generated defines for the effect
  9172. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9173. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9174. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9175. */
  9176. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9177. private static _tempFogColor;
  9178. /**
  9179. * Binds the fog information from the scene to the effect for the given mesh.
  9180. * @param scene The scene the lights belongs to
  9181. * @param mesh The mesh we are binding the information to render
  9182. * @param effect The effect we are binding the data to
  9183. * @param linearSpace Defines if the fog effect is applied in linear space
  9184. */
  9185. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9186. /**
  9187. * Binds the bones information from the mesh to the effect.
  9188. * @param mesh The mesh we are binding the information to render
  9189. * @param effect The effect we are binding the data to
  9190. */
  9191. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9192. /**
  9193. * Binds the morph targets information from the mesh to the effect.
  9194. * @param abstractMesh The mesh we are binding the information to render
  9195. * @param effect The effect we are binding the data to
  9196. */
  9197. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9198. /**
  9199. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9200. * @param defines The generated defines used in the effect
  9201. * @param effect The effect we are binding the data to
  9202. * @param scene The scene we are willing to render with logarithmic scale for
  9203. */
  9204. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9205. /**
  9206. * Binds the clip plane information from the scene to the effect.
  9207. * @param scene The scene the clip plane information are extracted from
  9208. * @param effect The effect we are binding the data to
  9209. */
  9210. static BindClipPlane(effect: Effect, scene: Scene): void;
  9211. }
  9212. }
  9213. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9214. /** @hidden */
  9215. export var packingFunctions: {
  9216. name: string;
  9217. shader: string;
  9218. };
  9219. }
  9220. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9221. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9222. /** @hidden */
  9223. export var shadowMapPixelShader: {
  9224. name: string;
  9225. shader: string;
  9226. };
  9227. }
  9228. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9229. /** @hidden */
  9230. export var bonesDeclaration: {
  9231. name: string;
  9232. shader: string;
  9233. };
  9234. }
  9235. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9236. /** @hidden */
  9237. export var morphTargetsVertexGlobalDeclaration: {
  9238. name: string;
  9239. shader: string;
  9240. };
  9241. }
  9242. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9243. /** @hidden */
  9244. export var morphTargetsVertexDeclaration: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9250. /** @hidden */
  9251. export var instancesDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9257. /** @hidden */
  9258. export var helperFunctions: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9264. /** @hidden */
  9265. export var morphTargetsVertex: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9271. /** @hidden */
  9272. export var instancesVertex: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9278. /** @hidden */
  9279. export var bonesVertex: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9285. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9286. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9287. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9288. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9289. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9290. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9291. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9292. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9293. /** @hidden */
  9294. export var shadowMapVertexShader: {
  9295. name: string;
  9296. shader: string;
  9297. };
  9298. }
  9299. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9300. /** @hidden */
  9301. export var depthBoxBlurPixelShader: {
  9302. name: string;
  9303. shader: string;
  9304. };
  9305. }
  9306. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9307. import { Nullable } from "babylonjs/types";
  9308. import { Scene } from "babylonjs/scene";
  9309. import { Matrix } from "babylonjs/Maths/math.vector";
  9310. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9312. import { Mesh } from "babylonjs/Meshes/mesh";
  9313. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9314. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9315. import { Effect } from "babylonjs/Materials/effect";
  9316. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9317. import "babylonjs/Shaders/shadowMap.fragment";
  9318. import "babylonjs/Shaders/shadowMap.vertex";
  9319. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9320. import { Observable } from "babylonjs/Misc/observable";
  9321. /**
  9322. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9323. */
  9324. export interface ICustomShaderOptions {
  9325. /**
  9326. * Gets or sets the custom shader name to use
  9327. */
  9328. shaderName: string;
  9329. /**
  9330. * The list of attribute names used in the shader
  9331. */
  9332. attributes?: string[];
  9333. /**
  9334. * The list of unifrom names used in the shader
  9335. */
  9336. uniforms?: string[];
  9337. /**
  9338. * The list of sampler names used in the shader
  9339. */
  9340. samplers?: string[];
  9341. /**
  9342. * The list of defines used in the shader
  9343. */
  9344. defines?: string[];
  9345. }
  9346. /**
  9347. * Interface to implement to create a shadow generator compatible with BJS.
  9348. */
  9349. export interface IShadowGenerator {
  9350. /**
  9351. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9352. * @returns The render target texture if present otherwise, null
  9353. */
  9354. getShadowMap(): Nullable<RenderTargetTexture>;
  9355. /**
  9356. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9357. * @returns The render target texture if the shadow map is present otherwise, null
  9358. */
  9359. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9360. /**
  9361. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9362. * @param subMesh The submesh we want to render in the shadow map
  9363. * @param useInstances Defines wether will draw in the map using instances
  9364. * @returns true if ready otherwise, false
  9365. */
  9366. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9367. /**
  9368. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9369. * @param defines Defines of the material we want to update
  9370. * @param lightIndex Index of the light in the enabled light list of the material
  9371. */
  9372. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9373. /**
  9374. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9375. * defined in the generator but impacting the effect).
  9376. * It implies the unifroms available on the materials are the standard BJS ones.
  9377. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9378. * @param effect The effect we are binfing the information for
  9379. */
  9380. bindShadowLight(lightIndex: string, effect: Effect): void;
  9381. /**
  9382. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9383. * (eq to shadow prjection matrix * light transform matrix)
  9384. * @returns The transform matrix used to create the shadow map
  9385. */
  9386. getTransformMatrix(): Matrix;
  9387. /**
  9388. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9389. * Cube and 2D textures for instance.
  9390. */
  9391. recreateShadowMap(): void;
  9392. /**
  9393. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9394. * @param onCompiled Callback triggered at the and of the effects compilation
  9395. * @param options Sets of optional options forcing the compilation with different modes
  9396. */
  9397. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9398. useInstances: boolean;
  9399. }>): void;
  9400. /**
  9401. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9402. * @param options Sets of optional options forcing the compilation with different modes
  9403. * @returns A promise that resolves when the compilation completes
  9404. */
  9405. forceCompilationAsync(options?: Partial<{
  9406. useInstances: boolean;
  9407. }>): Promise<void>;
  9408. /**
  9409. * Serializes the shadow generator setup to a json object.
  9410. * @returns The serialized JSON object
  9411. */
  9412. serialize(): any;
  9413. /**
  9414. * Disposes the Shadow map and related Textures and effects.
  9415. */
  9416. dispose(): void;
  9417. }
  9418. /**
  9419. * Default implementation IShadowGenerator.
  9420. * This is the main object responsible of generating shadows in the framework.
  9421. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9422. */
  9423. export class ShadowGenerator implements IShadowGenerator {
  9424. /**
  9425. * Shadow generator mode None: no filtering applied.
  9426. */
  9427. static readonly FILTER_NONE: number;
  9428. /**
  9429. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9430. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9431. */
  9432. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9433. /**
  9434. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9435. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9436. */
  9437. static readonly FILTER_POISSONSAMPLING: number;
  9438. /**
  9439. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9440. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9441. */
  9442. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9443. /**
  9444. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9445. * edge artifacts on steep falloff.
  9446. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9447. */
  9448. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9449. /**
  9450. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9451. * edge artifacts on steep falloff.
  9452. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9453. */
  9454. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9455. /**
  9456. * Shadow generator mode PCF: Percentage Closer Filtering
  9457. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9458. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9459. */
  9460. static readonly FILTER_PCF: number;
  9461. /**
  9462. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9463. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9464. * Contact Hardening
  9465. */
  9466. static readonly FILTER_PCSS: number;
  9467. /**
  9468. * Reserved for PCF and PCSS
  9469. * Highest Quality.
  9470. *
  9471. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9472. *
  9473. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9474. */
  9475. static readonly QUALITY_HIGH: number;
  9476. /**
  9477. * Reserved for PCF and PCSS
  9478. * Good tradeoff for quality/perf cross devices
  9479. *
  9480. * Execute PCF on a 3*3 kernel.
  9481. *
  9482. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9483. */
  9484. static readonly QUALITY_MEDIUM: number;
  9485. /**
  9486. * Reserved for PCF and PCSS
  9487. * The lowest quality but the fastest.
  9488. *
  9489. * Execute PCF on a 1*1 kernel.
  9490. *
  9491. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9492. */
  9493. static readonly QUALITY_LOW: number;
  9494. /** Gets or sets the custom shader name to use */
  9495. customShaderOptions: ICustomShaderOptions;
  9496. /**
  9497. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9498. */
  9499. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9500. /**
  9501. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9502. */
  9503. onAfterShadowMapRenderObservable: Observable<Effect>;
  9504. /**
  9505. * Observable triggered before a mesh is rendered in the shadow map.
  9506. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9507. */
  9508. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9509. /**
  9510. * Observable triggered after a mesh is rendered in the shadow map.
  9511. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9512. */
  9513. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9514. private _bias;
  9515. /**
  9516. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9517. */
  9518. /**
  9519. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9520. */
  9521. bias: number;
  9522. private _normalBias;
  9523. /**
  9524. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9525. */
  9526. /**
  9527. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9528. */
  9529. normalBias: number;
  9530. private _blurBoxOffset;
  9531. /**
  9532. * Gets the blur box offset: offset applied during the blur pass.
  9533. * Only useful if useKernelBlur = false
  9534. */
  9535. /**
  9536. * Sets the blur box offset: offset applied during the blur pass.
  9537. * Only useful if useKernelBlur = false
  9538. */
  9539. blurBoxOffset: number;
  9540. private _blurScale;
  9541. /**
  9542. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9543. * 2 means half of the size.
  9544. */
  9545. /**
  9546. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9547. * 2 means half of the size.
  9548. */
  9549. blurScale: number;
  9550. private _blurKernel;
  9551. /**
  9552. * Gets the blur kernel: kernel size of the blur pass.
  9553. * Only useful if useKernelBlur = true
  9554. */
  9555. /**
  9556. * Sets the blur kernel: kernel size of the blur pass.
  9557. * Only useful if useKernelBlur = true
  9558. */
  9559. blurKernel: number;
  9560. private _useKernelBlur;
  9561. /**
  9562. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9563. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9564. */
  9565. /**
  9566. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9567. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9568. */
  9569. useKernelBlur: boolean;
  9570. private _depthScale;
  9571. /**
  9572. * Gets the depth scale used in ESM mode.
  9573. */
  9574. /**
  9575. * Sets the depth scale used in ESM mode.
  9576. * This can override the scale stored on the light.
  9577. */
  9578. depthScale: number;
  9579. private _filter;
  9580. /**
  9581. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9582. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9583. */
  9584. /**
  9585. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9586. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9587. */
  9588. filter: number;
  9589. /**
  9590. * Gets if the current filter is set to Poisson Sampling.
  9591. */
  9592. /**
  9593. * Sets the current filter to Poisson Sampling.
  9594. */
  9595. usePoissonSampling: boolean;
  9596. /**
  9597. * Gets if the current filter is set to ESM.
  9598. */
  9599. /**
  9600. * Sets the current filter is to ESM.
  9601. */
  9602. useExponentialShadowMap: boolean;
  9603. /**
  9604. * Gets if the current filter is set to filtered ESM.
  9605. */
  9606. /**
  9607. * Gets if the current filter is set to filtered ESM.
  9608. */
  9609. useBlurExponentialShadowMap: boolean;
  9610. /**
  9611. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9612. * exponential to prevent steep falloff artifacts).
  9613. */
  9614. /**
  9615. * Sets the current filter to "close ESM" (using the inverse of the
  9616. * exponential to prevent steep falloff artifacts).
  9617. */
  9618. useCloseExponentialShadowMap: boolean;
  9619. /**
  9620. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9621. * exponential to prevent steep falloff artifacts).
  9622. */
  9623. /**
  9624. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9625. * exponential to prevent steep falloff artifacts).
  9626. */
  9627. useBlurCloseExponentialShadowMap: boolean;
  9628. /**
  9629. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9630. */
  9631. /**
  9632. * Sets the current filter to "PCF" (percentage closer filtering).
  9633. */
  9634. usePercentageCloserFiltering: boolean;
  9635. private _filteringQuality;
  9636. /**
  9637. * Gets the PCF or PCSS Quality.
  9638. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9639. */
  9640. /**
  9641. * Sets the PCF or PCSS Quality.
  9642. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9643. */
  9644. filteringQuality: number;
  9645. /**
  9646. * Gets if the current filter is set to "PCSS" (contact hardening).
  9647. */
  9648. /**
  9649. * Sets the current filter to "PCSS" (contact hardening).
  9650. */
  9651. useContactHardeningShadow: boolean;
  9652. private _contactHardeningLightSizeUVRatio;
  9653. /**
  9654. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9655. * Using a ratio helps keeping shape stability independently of the map size.
  9656. *
  9657. * It does not account for the light projection as it was having too much
  9658. * instability during the light setup or during light position changes.
  9659. *
  9660. * Only valid if useContactHardeningShadow is true.
  9661. */
  9662. /**
  9663. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9664. * Using a ratio helps keeping shape stability independently of the map size.
  9665. *
  9666. * It does not account for the light projection as it was having too much
  9667. * instability during the light setup or during light position changes.
  9668. *
  9669. * Only valid if useContactHardeningShadow is true.
  9670. */
  9671. contactHardeningLightSizeUVRatio: number;
  9672. private _darkness;
  9673. /** Gets or sets the actual darkness of a shadow */
  9674. darkness: number;
  9675. /**
  9676. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9677. * 0 means strongest and 1 would means no shadow.
  9678. * @returns the darkness.
  9679. */
  9680. getDarkness(): number;
  9681. /**
  9682. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9683. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9684. * @returns the shadow generator allowing fluent coding.
  9685. */
  9686. setDarkness(darkness: number): ShadowGenerator;
  9687. private _transparencyShadow;
  9688. /** Gets or sets the ability to have transparent shadow */
  9689. transparencyShadow: boolean;
  9690. /**
  9691. * Sets the ability to have transparent shadow (boolean).
  9692. * @param transparent True if transparent else False
  9693. * @returns the shadow generator allowing fluent coding
  9694. */
  9695. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9696. private _shadowMap;
  9697. private _shadowMap2;
  9698. /**
  9699. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9700. * @returns The render target texture if present otherwise, null
  9701. */
  9702. getShadowMap(): Nullable<RenderTargetTexture>;
  9703. /**
  9704. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9705. * @returns The render target texture if the shadow map is present otherwise, null
  9706. */
  9707. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9708. /**
  9709. * Gets the class name of that object
  9710. * @returns "ShadowGenerator"
  9711. */
  9712. getClassName(): string;
  9713. /**
  9714. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9715. * @param mesh Mesh to add
  9716. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9717. * @returns the Shadow Generator itself
  9718. */
  9719. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9720. /**
  9721. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9722. * @param mesh Mesh to remove
  9723. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9724. * @returns the Shadow Generator itself
  9725. */
  9726. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9727. /**
  9728. * Controls the extent to which the shadows fade out at the edge of the frustum
  9729. * Used only by directionals and spots
  9730. */
  9731. frustumEdgeFalloff: number;
  9732. private _light;
  9733. /**
  9734. * Returns the associated light object.
  9735. * @returns the light generating the shadow
  9736. */
  9737. getLight(): IShadowLight;
  9738. /**
  9739. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9740. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9741. * It might on the other hand introduce peter panning.
  9742. */
  9743. forceBackFacesOnly: boolean;
  9744. private _scene;
  9745. private _lightDirection;
  9746. private _effect;
  9747. private _viewMatrix;
  9748. private _projectionMatrix;
  9749. private _transformMatrix;
  9750. private _cachedPosition;
  9751. private _cachedDirection;
  9752. private _cachedDefines;
  9753. private _currentRenderID;
  9754. private _boxBlurPostprocess;
  9755. private _kernelBlurXPostprocess;
  9756. private _kernelBlurYPostprocess;
  9757. private _blurPostProcesses;
  9758. private _mapSize;
  9759. private _currentFaceIndex;
  9760. private _currentFaceIndexCache;
  9761. private _textureType;
  9762. private _defaultTextureMatrix;
  9763. private _storedUniqueId;
  9764. /** @hidden */
  9765. static _SceneComponentInitialization: (scene: Scene) => void;
  9766. /**
  9767. * Creates a ShadowGenerator object.
  9768. * A ShadowGenerator is the required tool to use the shadows.
  9769. * Each light casting shadows needs to use its own ShadowGenerator.
  9770. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9771. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9772. * @param light The light object generating the shadows.
  9773. * @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.
  9774. */
  9775. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9776. private _initializeGenerator;
  9777. private _initializeShadowMap;
  9778. private _initializeBlurRTTAndPostProcesses;
  9779. private _renderForShadowMap;
  9780. private _renderSubMeshForShadowMap;
  9781. private _applyFilterValues;
  9782. /**
  9783. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9784. * @param onCompiled Callback triggered at the and of the effects compilation
  9785. * @param options Sets of optional options forcing the compilation with different modes
  9786. */
  9787. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9788. useInstances: boolean;
  9789. }>): void;
  9790. /**
  9791. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9792. * @param options Sets of optional options forcing the compilation with different modes
  9793. * @returns A promise that resolves when the compilation completes
  9794. */
  9795. forceCompilationAsync(options?: Partial<{
  9796. useInstances: boolean;
  9797. }>): Promise<void>;
  9798. /**
  9799. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9800. * @param subMesh The submesh we want to render in the shadow map
  9801. * @param useInstances Defines wether will draw in the map using instances
  9802. * @returns true if ready otherwise, false
  9803. */
  9804. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9805. /**
  9806. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9807. * @param defines Defines of the material we want to update
  9808. * @param lightIndex Index of the light in the enabled light list of the material
  9809. */
  9810. prepareDefines(defines: any, lightIndex: number): void;
  9811. /**
  9812. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9813. * defined in the generator but impacting the effect).
  9814. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9815. * @param effect The effect we are binfing the information for
  9816. */
  9817. bindShadowLight(lightIndex: string, effect: Effect): void;
  9818. /**
  9819. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9820. * (eq to shadow prjection matrix * light transform matrix)
  9821. * @returns The transform matrix used to create the shadow map
  9822. */
  9823. getTransformMatrix(): Matrix;
  9824. /**
  9825. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9826. * Cube and 2D textures for instance.
  9827. */
  9828. recreateShadowMap(): void;
  9829. private _disposeBlurPostProcesses;
  9830. private _disposeRTTandPostProcesses;
  9831. /**
  9832. * Disposes the ShadowGenerator.
  9833. * Returns nothing.
  9834. */
  9835. dispose(): void;
  9836. /**
  9837. * Serializes the shadow generator setup to a json object.
  9838. * @returns The serialized JSON object
  9839. */
  9840. serialize(): any;
  9841. /**
  9842. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9843. * @param parsedShadowGenerator The JSON object to parse
  9844. * @param scene The scene to create the shadow map for
  9845. * @returns The parsed shadow generator
  9846. */
  9847. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9848. }
  9849. }
  9850. declare module "babylonjs/Lights/light" {
  9851. import { Nullable } from "babylonjs/types";
  9852. import { Scene } from "babylonjs/scene";
  9853. import { Vector3 } from "babylonjs/Maths/math.vector";
  9854. import { Color3 } from "babylonjs/Maths/math.color";
  9855. import { Node } from "babylonjs/node";
  9856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9857. import { Effect } from "babylonjs/Materials/effect";
  9858. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9859. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9860. /**
  9861. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9862. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9863. * 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.
  9864. */
  9865. export abstract class Light extends Node {
  9866. /**
  9867. * Falloff Default: light is falling off following the material specification:
  9868. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9869. */
  9870. static readonly FALLOFF_DEFAULT: number;
  9871. /**
  9872. * Falloff Physical: light is falling off following the inverse squared distance law.
  9873. */
  9874. static readonly FALLOFF_PHYSICAL: number;
  9875. /**
  9876. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9877. * to enhance interoperability with other engines.
  9878. */
  9879. static readonly FALLOFF_GLTF: number;
  9880. /**
  9881. * Falloff Standard: light is falling off like in the standard material
  9882. * to enhance interoperability with other materials.
  9883. */
  9884. static readonly FALLOFF_STANDARD: number;
  9885. /**
  9886. * If every light affecting the material is in this lightmapMode,
  9887. * material.lightmapTexture adds or multiplies
  9888. * (depends on material.useLightmapAsShadowmap)
  9889. * after every other light calculations.
  9890. */
  9891. static readonly LIGHTMAP_DEFAULT: number;
  9892. /**
  9893. * material.lightmapTexture as only diffuse lighting from this light
  9894. * adds only specular lighting from this light
  9895. * adds dynamic shadows
  9896. */
  9897. static readonly LIGHTMAP_SPECULAR: number;
  9898. /**
  9899. * material.lightmapTexture as only lighting
  9900. * no light calculation from this light
  9901. * only adds dynamic shadows from this light
  9902. */
  9903. static readonly LIGHTMAP_SHADOWSONLY: number;
  9904. /**
  9905. * Each light type uses the default quantity according to its type:
  9906. * point/spot lights use luminous intensity
  9907. * directional lights use illuminance
  9908. */
  9909. static readonly INTENSITYMODE_AUTOMATIC: number;
  9910. /**
  9911. * lumen (lm)
  9912. */
  9913. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9914. /**
  9915. * candela (lm/sr)
  9916. */
  9917. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9918. /**
  9919. * lux (lm/m^2)
  9920. */
  9921. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9922. /**
  9923. * nit (cd/m^2)
  9924. */
  9925. static readonly INTENSITYMODE_LUMINANCE: number;
  9926. /**
  9927. * Light type const id of the point light.
  9928. */
  9929. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9930. /**
  9931. * Light type const id of the directional light.
  9932. */
  9933. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9934. /**
  9935. * Light type const id of the spot light.
  9936. */
  9937. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9938. /**
  9939. * Light type const id of the hemispheric light.
  9940. */
  9941. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9942. /**
  9943. * Diffuse gives the basic color to an object.
  9944. */
  9945. diffuse: Color3;
  9946. /**
  9947. * Specular produces a highlight color on an object.
  9948. * Note: This is note affecting PBR materials.
  9949. */
  9950. specular: Color3;
  9951. /**
  9952. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9953. * falling off base on range or angle.
  9954. * This can be set to any values in Light.FALLOFF_x.
  9955. *
  9956. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9957. * other types of materials.
  9958. */
  9959. falloffType: number;
  9960. /**
  9961. * Strength of the light.
  9962. * Note: By default it is define in the framework own unit.
  9963. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9964. */
  9965. intensity: number;
  9966. private _range;
  9967. protected _inverseSquaredRange: number;
  9968. /**
  9969. * Defines how far from the source the light is impacting in scene units.
  9970. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9971. */
  9972. /**
  9973. * Defines how far from the source the light is impacting in scene units.
  9974. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9975. */
  9976. range: number;
  9977. /**
  9978. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9979. * of light.
  9980. */
  9981. private _photometricScale;
  9982. private _intensityMode;
  9983. /**
  9984. * Gets the photometric scale used to interpret the intensity.
  9985. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9986. */
  9987. /**
  9988. * Sets the photometric scale used to interpret the intensity.
  9989. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9990. */
  9991. intensityMode: number;
  9992. private _radius;
  9993. /**
  9994. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9995. */
  9996. /**
  9997. * sets the light radius used by PBR Materials to simulate soft area lights.
  9998. */
  9999. radius: number;
  10000. private _renderPriority;
  10001. /**
  10002. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10003. * exceeding the number allowed of the materials.
  10004. */
  10005. renderPriority: number;
  10006. private _shadowEnabled;
  10007. /**
  10008. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10009. * the current shadow generator.
  10010. */
  10011. /**
  10012. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10013. * the current shadow generator.
  10014. */
  10015. shadowEnabled: boolean;
  10016. private _includedOnlyMeshes;
  10017. /**
  10018. * Gets the only meshes impacted by this light.
  10019. */
  10020. /**
  10021. * Sets the only meshes impacted by this light.
  10022. */
  10023. includedOnlyMeshes: AbstractMesh[];
  10024. private _excludedMeshes;
  10025. /**
  10026. * Gets the meshes not impacted by this light.
  10027. */
  10028. /**
  10029. * Sets the meshes not impacted by this light.
  10030. */
  10031. excludedMeshes: AbstractMesh[];
  10032. private _excludeWithLayerMask;
  10033. /**
  10034. * Gets the layer id use to find what meshes are not impacted by the light.
  10035. * Inactive if 0
  10036. */
  10037. /**
  10038. * Sets the layer id use to find what meshes are not impacted by the light.
  10039. * Inactive if 0
  10040. */
  10041. excludeWithLayerMask: number;
  10042. private _includeOnlyWithLayerMask;
  10043. /**
  10044. * Gets the layer id use to find what meshes are impacted by the light.
  10045. * Inactive if 0
  10046. */
  10047. /**
  10048. * Sets the layer id use to find what meshes are impacted by the light.
  10049. * Inactive if 0
  10050. */
  10051. includeOnlyWithLayerMask: number;
  10052. private _lightmapMode;
  10053. /**
  10054. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10055. */
  10056. /**
  10057. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10058. */
  10059. lightmapMode: number;
  10060. /**
  10061. * Shadow generator associted to the light.
  10062. * @hidden Internal use only.
  10063. */
  10064. _shadowGenerator: Nullable<IShadowGenerator>;
  10065. /**
  10066. * @hidden Internal use only.
  10067. */
  10068. _excludedMeshesIds: string[];
  10069. /**
  10070. * @hidden Internal use only.
  10071. */
  10072. _includedOnlyMeshesIds: string[];
  10073. /**
  10074. * The current light unifom buffer.
  10075. * @hidden Internal use only.
  10076. */
  10077. _uniformBuffer: UniformBuffer;
  10078. /** @hidden */
  10079. _renderId: number;
  10080. /**
  10081. * Creates a Light object in the scene.
  10082. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10083. * @param name The firendly name of the light
  10084. * @param scene The scene the light belongs too
  10085. */
  10086. constructor(name: string, scene: Scene);
  10087. protected abstract _buildUniformLayout(): void;
  10088. /**
  10089. * Sets the passed Effect "effect" with the Light information.
  10090. * @param effect The effect to update
  10091. * @param lightIndex The index of the light in the effect to update
  10092. * @returns The light
  10093. */
  10094. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10095. /**
  10096. * Sets the passed Effect "effect" with the Light information.
  10097. * @param effect The effect to update
  10098. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10099. * @returns The light
  10100. */
  10101. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10102. /**
  10103. * Returns the string "Light".
  10104. * @returns the class name
  10105. */
  10106. getClassName(): string;
  10107. /** @hidden */
  10108. readonly _isLight: boolean;
  10109. /**
  10110. * Converts the light information to a readable string for debug purpose.
  10111. * @param fullDetails Supports for multiple levels of logging within scene loading
  10112. * @returns the human readable light info
  10113. */
  10114. toString(fullDetails?: boolean): string;
  10115. /** @hidden */
  10116. protected _syncParentEnabledState(): void;
  10117. /**
  10118. * Set the enabled state of this node.
  10119. * @param value - the new enabled state
  10120. */
  10121. setEnabled(value: boolean): void;
  10122. /**
  10123. * Returns the Light associated shadow generator if any.
  10124. * @return the associated shadow generator.
  10125. */
  10126. getShadowGenerator(): Nullable<IShadowGenerator>;
  10127. /**
  10128. * Returns a Vector3, the absolute light position in the World.
  10129. * @returns the world space position of the light
  10130. */
  10131. getAbsolutePosition(): Vector3;
  10132. /**
  10133. * Specifies if the light will affect the passed mesh.
  10134. * @param mesh The mesh to test against the light
  10135. * @return true the mesh is affected otherwise, false.
  10136. */
  10137. canAffectMesh(mesh: AbstractMesh): boolean;
  10138. /**
  10139. * Sort function to order lights for rendering.
  10140. * @param a First Light object to compare to second.
  10141. * @param b Second Light object to compare first.
  10142. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10143. */
  10144. static CompareLightsPriority(a: Light, b: Light): number;
  10145. /**
  10146. * Releases resources associated with this node.
  10147. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10148. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10149. */
  10150. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10151. /**
  10152. * Returns the light type ID (integer).
  10153. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10154. */
  10155. getTypeID(): number;
  10156. /**
  10157. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10158. * @returns the scaled intensity in intensity mode unit
  10159. */
  10160. getScaledIntensity(): number;
  10161. /**
  10162. * Returns a new Light object, named "name", from the current one.
  10163. * @param name The name of the cloned light
  10164. * @returns the new created light
  10165. */
  10166. clone(name: string): Nullable<Light>;
  10167. /**
  10168. * Serializes the current light into a Serialization object.
  10169. * @returns the serialized object.
  10170. */
  10171. serialize(): any;
  10172. /**
  10173. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10174. * This new light is named "name" and added to the passed scene.
  10175. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10176. * @param name The friendly name of the light
  10177. * @param scene The scene the new light will belong to
  10178. * @returns the constructor function
  10179. */
  10180. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10181. /**
  10182. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10183. * @param parsedLight The JSON representation of the light
  10184. * @param scene The scene to create the parsed light in
  10185. * @returns the created light after parsing
  10186. */
  10187. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10188. private _hookArrayForExcluded;
  10189. private _hookArrayForIncludedOnly;
  10190. private _resyncMeshes;
  10191. /**
  10192. * Forces the meshes to update their light related information in their rendering used effects
  10193. * @hidden Internal Use Only
  10194. */
  10195. _markMeshesAsLightDirty(): void;
  10196. /**
  10197. * Recomputes the cached photometric scale if needed.
  10198. */
  10199. private _computePhotometricScale;
  10200. /**
  10201. * Returns the Photometric Scale according to the light type and intensity mode.
  10202. */
  10203. private _getPhotometricScale;
  10204. /**
  10205. * Reorder the light in the scene according to their defined priority.
  10206. * @hidden Internal Use Only
  10207. */
  10208. _reorderLightsInScene(): void;
  10209. /**
  10210. * Prepares the list of defines specific to the light type.
  10211. * @param defines the list of defines
  10212. * @param lightIndex defines the index of the light for the effect
  10213. */
  10214. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10215. }
  10216. }
  10217. declare module "babylonjs/Actions/action" {
  10218. import { Observable } from "babylonjs/Misc/observable";
  10219. import { Condition } from "babylonjs/Actions/condition";
  10220. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10221. import { ActionManager } from "babylonjs/Actions/actionManager";
  10222. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10223. /**
  10224. * Interface used to define Action
  10225. */
  10226. export interface IAction {
  10227. /**
  10228. * Trigger for the action
  10229. */
  10230. trigger: number;
  10231. /** Options of the trigger */
  10232. triggerOptions: any;
  10233. /**
  10234. * Gets the trigger parameters
  10235. * @returns the trigger parameters
  10236. */
  10237. getTriggerParameter(): any;
  10238. /**
  10239. * Internal only - executes current action event
  10240. * @hidden
  10241. */
  10242. _executeCurrent(evt?: ActionEvent): void;
  10243. /**
  10244. * Serialize placeholder for child classes
  10245. * @param parent of child
  10246. * @returns the serialized object
  10247. */
  10248. serialize(parent: any): any;
  10249. /**
  10250. * Internal only
  10251. * @hidden
  10252. */
  10253. _prepare(): void;
  10254. /**
  10255. * Internal only - manager for action
  10256. * @hidden
  10257. */
  10258. _actionManager: AbstractActionManager;
  10259. /**
  10260. * Adds action to chain of actions, may be a DoNothingAction
  10261. * @param action defines the next action to execute
  10262. * @returns The action passed in
  10263. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10264. */
  10265. then(action: IAction): IAction;
  10266. }
  10267. /**
  10268. * The action to be carried out following a trigger
  10269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10270. */
  10271. export class Action implements IAction {
  10272. /** the trigger, with or without parameters, for the action */
  10273. triggerOptions: any;
  10274. /**
  10275. * Trigger for the action
  10276. */
  10277. trigger: number;
  10278. /**
  10279. * Internal only - manager for action
  10280. * @hidden
  10281. */
  10282. _actionManager: ActionManager;
  10283. private _nextActiveAction;
  10284. private _child;
  10285. private _condition?;
  10286. private _triggerParameter;
  10287. /**
  10288. * An event triggered prior to action being executed.
  10289. */
  10290. onBeforeExecuteObservable: Observable<Action>;
  10291. /**
  10292. * Creates a new Action
  10293. * @param triggerOptions the trigger, with or without parameters, for the action
  10294. * @param condition an optional determinant of action
  10295. */
  10296. constructor(
  10297. /** the trigger, with or without parameters, for the action */
  10298. triggerOptions: any, condition?: Condition);
  10299. /**
  10300. * Internal only
  10301. * @hidden
  10302. */
  10303. _prepare(): void;
  10304. /**
  10305. * Gets the trigger parameters
  10306. * @returns the trigger parameters
  10307. */
  10308. getTriggerParameter(): any;
  10309. /**
  10310. * Internal only - executes current action event
  10311. * @hidden
  10312. */
  10313. _executeCurrent(evt?: ActionEvent): void;
  10314. /**
  10315. * Execute placeholder for child classes
  10316. * @param evt optional action event
  10317. */
  10318. execute(evt?: ActionEvent): void;
  10319. /**
  10320. * Skips to next active action
  10321. */
  10322. skipToNextActiveAction(): void;
  10323. /**
  10324. * Adds action to chain of actions, may be a DoNothingAction
  10325. * @param action defines the next action to execute
  10326. * @returns The action passed in
  10327. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10328. */
  10329. then(action: Action): Action;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. _getProperty(propertyPath: string): string;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. _getEffectiveTarget(target: any, propertyPath: string): any;
  10340. /**
  10341. * Serialize placeholder for child classes
  10342. * @param parent of child
  10343. * @returns the serialized object
  10344. */
  10345. serialize(parent: any): any;
  10346. /**
  10347. * Internal only called by serialize
  10348. * @hidden
  10349. */
  10350. protected _serialize(serializedAction: any, parent?: any): any;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. static _SerializeValueAsString: (value: any) => string;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10361. name: string;
  10362. targetType: string;
  10363. value: string;
  10364. };
  10365. }
  10366. }
  10367. declare module "babylonjs/Actions/condition" {
  10368. import { ActionManager } from "babylonjs/Actions/actionManager";
  10369. /**
  10370. * A Condition applied to an Action
  10371. */
  10372. export class Condition {
  10373. /**
  10374. * Internal only - manager for action
  10375. * @hidden
  10376. */
  10377. _actionManager: ActionManager;
  10378. /**
  10379. * Internal only
  10380. * @hidden
  10381. */
  10382. _evaluationId: number;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. _currentResult: boolean;
  10388. /**
  10389. * Creates a new Condition
  10390. * @param actionManager the manager of the action the condition is applied to
  10391. */
  10392. constructor(actionManager: ActionManager);
  10393. /**
  10394. * Check if the current condition is valid
  10395. * @returns a boolean
  10396. */
  10397. isValid(): boolean;
  10398. /**
  10399. * Internal only
  10400. * @hidden
  10401. */
  10402. _getProperty(propertyPath: string): string;
  10403. /**
  10404. * Internal only
  10405. * @hidden
  10406. */
  10407. _getEffectiveTarget(target: any, propertyPath: string): any;
  10408. /**
  10409. * Serialize placeholder for child classes
  10410. * @returns the serialized object
  10411. */
  10412. serialize(): any;
  10413. /**
  10414. * Internal only
  10415. * @hidden
  10416. */
  10417. protected _serialize(serializedCondition: any): any;
  10418. }
  10419. /**
  10420. * Defines specific conditional operators as extensions of Condition
  10421. */
  10422. export class ValueCondition extends Condition {
  10423. /** path to specify the property of the target the conditional operator uses */
  10424. propertyPath: string;
  10425. /** the value compared by the conditional operator against the current value of the property */
  10426. value: any;
  10427. /** the conditional operator, default ValueCondition.IsEqual */
  10428. operator: number;
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. private static _IsEqual;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. private static _IsDifferent;
  10439. /**
  10440. * Internal only
  10441. * @hidden
  10442. */
  10443. private static _IsGreater;
  10444. /**
  10445. * Internal only
  10446. * @hidden
  10447. */
  10448. private static _IsLesser;
  10449. /**
  10450. * returns the number for IsEqual
  10451. */
  10452. static readonly IsEqual: number;
  10453. /**
  10454. * Returns the number for IsDifferent
  10455. */
  10456. static readonly IsDifferent: number;
  10457. /**
  10458. * Returns the number for IsGreater
  10459. */
  10460. static readonly IsGreater: number;
  10461. /**
  10462. * Returns the number for IsLesser
  10463. */
  10464. static readonly IsLesser: number;
  10465. /**
  10466. * Internal only The action manager for the condition
  10467. * @hidden
  10468. */
  10469. _actionManager: ActionManager;
  10470. /**
  10471. * Internal only
  10472. * @hidden
  10473. */
  10474. private _target;
  10475. /**
  10476. * Internal only
  10477. * @hidden
  10478. */
  10479. private _effectiveTarget;
  10480. /**
  10481. * Internal only
  10482. * @hidden
  10483. */
  10484. private _property;
  10485. /**
  10486. * Creates a new ValueCondition
  10487. * @param actionManager manager for the action the condition applies to
  10488. * @param target for the action
  10489. * @param propertyPath path to specify the property of the target the conditional operator uses
  10490. * @param value the value compared by the conditional operator against the current value of the property
  10491. * @param operator the conditional operator, default ValueCondition.IsEqual
  10492. */
  10493. constructor(actionManager: ActionManager, target: any,
  10494. /** path to specify the property of the target the conditional operator uses */
  10495. propertyPath: string,
  10496. /** the value compared by the conditional operator against the current value of the property */
  10497. value: any,
  10498. /** the conditional operator, default ValueCondition.IsEqual */
  10499. operator?: number);
  10500. /**
  10501. * Compares the given value with the property value for the specified conditional operator
  10502. * @returns the result of the comparison
  10503. */
  10504. isValid(): boolean;
  10505. /**
  10506. * Serialize the ValueCondition into a JSON compatible object
  10507. * @returns serialization object
  10508. */
  10509. serialize(): any;
  10510. /**
  10511. * Gets the name of the conditional operator for the ValueCondition
  10512. * @param operator the conditional operator
  10513. * @returns the name
  10514. */
  10515. static GetOperatorName(operator: number): string;
  10516. }
  10517. /**
  10518. * Defines a predicate condition as an extension of Condition
  10519. */
  10520. export class PredicateCondition extends Condition {
  10521. /** defines the predicate function used to validate the condition */
  10522. predicate: () => boolean;
  10523. /**
  10524. * Internal only - manager for action
  10525. * @hidden
  10526. */
  10527. _actionManager: ActionManager;
  10528. /**
  10529. * Creates a new PredicateCondition
  10530. * @param actionManager manager for the action the condition applies to
  10531. * @param predicate defines the predicate function used to validate the condition
  10532. */
  10533. constructor(actionManager: ActionManager,
  10534. /** defines the predicate function used to validate the condition */
  10535. predicate: () => boolean);
  10536. /**
  10537. * @returns the validity of the predicate condition
  10538. */
  10539. isValid(): boolean;
  10540. }
  10541. /**
  10542. * Defines a state condition as an extension of Condition
  10543. */
  10544. export class StateCondition extends Condition {
  10545. /** Value to compare with target state */
  10546. value: string;
  10547. /**
  10548. * Internal only - manager for action
  10549. * @hidden
  10550. */
  10551. _actionManager: ActionManager;
  10552. /**
  10553. * Internal only
  10554. * @hidden
  10555. */
  10556. private _target;
  10557. /**
  10558. * Creates a new StateCondition
  10559. * @param actionManager manager for the action the condition applies to
  10560. * @param target of the condition
  10561. * @param value to compare with target state
  10562. */
  10563. constructor(actionManager: ActionManager, target: any,
  10564. /** Value to compare with target state */
  10565. value: string);
  10566. /**
  10567. * Gets a boolean indicating if the current condition is met
  10568. * @returns the validity of the state
  10569. */
  10570. isValid(): boolean;
  10571. /**
  10572. * Serialize the StateCondition into a JSON compatible object
  10573. * @returns serialization object
  10574. */
  10575. serialize(): any;
  10576. }
  10577. }
  10578. declare module "babylonjs/Actions/directActions" {
  10579. import { Action } from "babylonjs/Actions/action";
  10580. import { Condition } from "babylonjs/Actions/condition";
  10581. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10582. /**
  10583. * This defines an action responsible to toggle a boolean once triggered.
  10584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10585. */
  10586. export class SwitchBooleanAction extends Action {
  10587. /**
  10588. * The path to the boolean property in the target object
  10589. */
  10590. propertyPath: string;
  10591. private _target;
  10592. private _effectiveTarget;
  10593. private _property;
  10594. /**
  10595. * Instantiate the action
  10596. * @param triggerOptions defines the trigger options
  10597. * @param target defines the object containing the boolean
  10598. * @param propertyPath defines the path to the boolean property in the target object
  10599. * @param condition defines the trigger related conditions
  10600. */
  10601. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10602. /** @hidden */
  10603. _prepare(): void;
  10604. /**
  10605. * Execute the action toggle the boolean value.
  10606. */
  10607. execute(): void;
  10608. /**
  10609. * Serializes the actions and its related information.
  10610. * @param parent defines the object to serialize in
  10611. * @returns the serialized object
  10612. */
  10613. serialize(parent: any): any;
  10614. }
  10615. /**
  10616. * This defines an action responsible to set a the state field of the target
  10617. * to a desired value once triggered.
  10618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10619. */
  10620. export class SetStateAction extends Action {
  10621. /**
  10622. * The value to store in the state field.
  10623. */
  10624. value: string;
  10625. private _target;
  10626. /**
  10627. * Instantiate the action
  10628. * @param triggerOptions defines the trigger options
  10629. * @param target defines the object containing the state property
  10630. * @param value defines the value to store in the state field
  10631. * @param condition defines the trigger related conditions
  10632. */
  10633. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10634. /**
  10635. * Execute the action and store the value on the target state property.
  10636. */
  10637. execute(): void;
  10638. /**
  10639. * Serializes the actions and its related information.
  10640. * @param parent defines the object to serialize in
  10641. * @returns the serialized object
  10642. */
  10643. serialize(parent: any): any;
  10644. }
  10645. /**
  10646. * This defines an action responsible to set a property of the target
  10647. * to a desired value once triggered.
  10648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10649. */
  10650. export class SetValueAction extends Action {
  10651. /**
  10652. * The path of the property to set in the target.
  10653. */
  10654. propertyPath: string;
  10655. /**
  10656. * The value to set in the property
  10657. */
  10658. value: any;
  10659. private _target;
  10660. private _effectiveTarget;
  10661. private _property;
  10662. /**
  10663. * Instantiate the action
  10664. * @param triggerOptions defines the trigger options
  10665. * @param target defines the object containing the property
  10666. * @param propertyPath defines the path of the property to set in the target
  10667. * @param value defines the value to set in the property
  10668. * @param condition defines the trigger related conditions
  10669. */
  10670. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10671. /** @hidden */
  10672. _prepare(): void;
  10673. /**
  10674. * Execute the action and set the targetted property to the desired value.
  10675. */
  10676. execute(): void;
  10677. /**
  10678. * Serializes the actions and its related information.
  10679. * @param parent defines the object to serialize in
  10680. * @returns the serialized object
  10681. */
  10682. serialize(parent: any): any;
  10683. }
  10684. /**
  10685. * This defines an action responsible to increment the target value
  10686. * to a desired value once triggered.
  10687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10688. */
  10689. export class IncrementValueAction extends Action {
  10690. /**
  10691. * The path of the property to increment in the target.
  10692. */
  10693. propertyPath: string;
  10694. /**
  10695. * The value we should increment the property by.
  10696. */
  10697. value: any;
  10698. private _target;
  10699. private _effectiveTarget;
  10700. private _property;
  10701. /**
  10702. * Instantiate the action
  10703. * @param triggerOptions defines the trigger options
  10704. * @param target defines the object containing the property
  10705. * @param propertyPath defines the path of the property to increment in the target
  10706. * @param value defines the value value we should increment the property by
  10707. * @param condition defines the trigger related conditions
  10708. */
  10709. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10710. /** @hidden */
  10711. _prepare(): void;
  10712. /**
  10713. * Execute the action and increment the target of the value amount.
  10714. */
  10715. execute(): void;
  10716. /**
  10717. * Serializes the actions and its related information.
  10718. * @param parent defines the object to serialize in
  10719. * @returns the serialized object
  10720. */
  10721. serialize(parent: any): any;
  10722. }
  10723. /**
  10724. * This defines an action responsible to start an animation once triggered.
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10726. */
  10727. export class PlayAnimationAction extends Action {
  10728. /**
  10729. * Where the animation should start (animation frame)
  10730. */
  10731. from: number;
  10732. /**
  10733. * Where the animation should stop (animation frame)
  10734. */
  10735. to: number;
  10736. /**
  10737. * Define if the animation should loop or stop after the first play.
  10738. */
  10739. loop?: boolean;
  10740. private _target;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param target defines the target animation or animation name
  10745. * @param from defines from where the animation should start (animation frame)
  10746. * @param end defines where the animation should stop (animation frame)
  10747. * @param loop defines if the animation should loop or stop after the first play
  10748. * @param condition defines the trigger related conditions
  10749. */
  10750. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10751. /** @hidden */
  10752. _prepare(): void;
  10753. /**
  10754. * Execute the action and play the animation.
  10755. */
  10756. execute(): void;
  10757. /**
  10758. * Serializes the actions and its related information.
  10759. * @param parent defines the object to serialize in
  10760. * @returns the serialized object
  10761. */
  10762. serialize(parent: any): any;
  10763. }
  10764. /**
  10765. * This defines an action responsible to stop an animation once triggered.
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10767. */
  10768. export class StopAnimationAction extends Action {
  10769. private _target;
  10770. /**
  10771. * Instantiate the action
  10772. * @param triggerOptions defines the trigger options
  10773. * @param target defines the target animation or animation name
  10774. * @param condition defines the trigger related conditions
  10775. */
  10776. constructor(triggerOptions: any, target: any, condition?: Condition);
  10777. /** @hidden */
  10778. _prepare(): void;
  10779. /**
  10780. * Execute the action and stop the animation.
  10781. */
  10782. execute(): void;
  10783. /**
  10784. * Serializes the actions and its related information.
  10785. * @param parent defines the object to serialize in
  10786. * @returns the serialized object
  10787. */
  10788. serialize(parent: any): any;
  10789. }
  10790. /**
  10791. * This defines an action responsible that does nothing once triggered.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class DoNothingAction extends Action {
  10795. /**
  10796. * Instantiate the action
  10797. * @param triggerOptions defines the trigger options
  10798. * @param condition defines the trigger related conditions
  10799. */
  10800. constructor(triggerOptions?: any, condition?: Condition);
  10801. /**
  10802. * Execute the action and do nothing.
  10803. */
  10804. execute(): void;
  10805. /**
  10806. * Serializes the actions and its related information.
  10807. * @param parent defines the object to serialize in
  10808. * @returns the serialized object
  10809. */
  10810. serialize(parent: any): any;
  10811. }
  10812. /**
  10813. * This defines an action responsible to trigger several actions once triggered.
  10814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10815. */
  10816. export class CombineAction extends Action {
  10817. /**
  10818. * The list of aggregated animations to run.
  10819. */
  10820. children: Action[];
  10821. /**
  10822. * Instantiate the action
  10823. * @param triggerOptions defines the trigger options
  10824. * @param children defines the list of aggregated animations to run
  10825. * @param condition defines the trigger related conditions
  10826. */
  10827. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10828. /** @hidden */
  10829. _prepare(): void;
  10830. /**
  10831. * Execute the action and executes all the aggregated actions.
  10832. */
  10833. execute(evt: ActionEvent): void;
  10834. /**
  10835. * Serializes the actions and its related information.
  10836. * @param parent defines the object to serialize in
  10837. * @returns the serialized object
  10838. */
  10839. serialize(parent: any): any;
  10840. }
  10841. /**
  10842. * This defines an action responsible to run code (external event) once triggered.
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10844. */
  10845. export class ExecuteCodeAction extends Action {
  10846. /**
  10847. * The callback function to run.
  10848. */
  10849. func: (evt: ActionEvent) => void;
  10850. /**
  10851. * Instantiate the action
  10852. * @param triggerOptions defines the trigger options
  10853. * @param func defines the callback function to run
  10854. * @param condition defines the trigger related conditions
  10855. */
  10856. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10857. /**
  10858. * Execute the action and run the attached code.
  10859. */
  10860. execute(evt: ActionEvent): void;
  10861. }
  10862. /**
  10863. * This defines an action responsible to set the parent property of the target once triggered.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export class SetParentAction extends Action {
  10867. private _parent;
  10868. private _target;
  10869. /**
  10870. * Instantiate the action
  10871. * @param triggerOptions defines the trigger options
  10872. * @param target defines the target containing the parent property
  10873. * @param parent defines from where the animation should start (animation frame)
  10874. * @param condition defines the trigger related conditions
  10875. */
  10876. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10877. /** @hidden */
  10878. _prepare(): void;
  10879. /**
  10880. * Execute the action and set the parent property.
  10881. */
  10882. execute(): void;
  10883. /**
  10884. * Serializes the actions and its related information.
  10885. * @param parent defines the object to serialize in
  10886. * @returns the serialized object
  10887. */
  10888. serialize(parent: any): any;
  10889. }
  10890. }
  10891. declare module "babylonjs/Actions/actionManager" {
  10892. import { Nullable } from "babylonjs/types";
  10893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10894. import { Scene } from "babylonjs/scene";
  10895. import { IAction } from "babylonjs/Actions/action";
  10896. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10897. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10898. /**
  10899. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10900. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10902. */
  10903. export class ActionManager extends AbstractActionManager {
  10904. /**
  10905. * Nothing
  10906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10907. */
  10908. static readonly NothingTrigger: number;
  10909. /**
  10910. * On pick
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10912. */
  10913. static readonly OnPickTrigger: number;
  10914. /**
  10915. * On left pick
  10916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10917. */
  10918. static readonly OnLeftPickTrigger: number;
  10919. /**
  10920. * On right pick
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10922. */
  10923. static readonly OnRightPickTrigger: number;
  10924. /**
  10925. * On center pick
  10926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10927. */
  10928. static readonly OnCenterPickTrigger: number;
  10929. /**
  10930. * On pick down
  10931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10932. */
  10933. static readonly OnPickDownTrigger: number;
  10934. /**
  10935. * On double pick
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10937. */
  10938. static readonly OnDoublePickTrigger: number;
  10939. /**
  10940. * On pick up
  10941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10942. */
  10943. static readonly OnPickUpTrigger: number;
  10944. /**
  10945. * On pick out.
  10946. * This trigger will only be raised if you also declared a OnPickDown
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10948. */
  10949. static readonly OnPickOutTrigger: number;
  10950. /**
  10951. * On long press
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10953. */
  10954. static readonly OnLongPressTrigger: number;
  10955. /**
  10956. * On pointer over
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10958. */
  10959. static readonly OnPointerOverTrigger: number;
  10960. /**
  10961. * On pointer out
  10962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10963. */
  10964. static readonly OnPointerOutTrigger: number;
  10965. /**
  10966. * On every frame
  10967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10968. */
  10969. static readonly OnEveryFrameTrigger: number;
  10970. /**
  10971. * On intersection enter
  10972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10973. */
  10974. static readonly OnIntersectionEnterTrigger: number;
  10975. /**
  10976. * On intersection exit
  10977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10978. */
  10979. static readonly OnIntersectionExitTrigger: number;
  10980. /**
  10981. * On key down
  10982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10983. */
  10984. static readonly OnKeyDownTrigger: number;
  10985. /**
  10986. * On key up
  10987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10988. */
  10989. static readonly OnKeyUpTrigger: number;
  10990. private _scene;
  10991. /**
  10992. * Creates a new action manager
  10993. * @param scene defines the hosting scene
  10994. */
  10995. constructor(scene: Scene);
  10996. /**
  10997. * Releases all associated resources
  10998. */
  10999. dispose(): void;
  11000. /**
  11001. * Gets hosting scene
  11002. * @returns the hosting scene
  11003. */
  11004. getScene(): Scene;
  11005. /**
  11006. * Does this action manager handles actions of any of the given triggers
  11007. * @param triggers defines the triggers to be tested
  11008. * @return a boolean indicating whether one (or more) of the triggers is handled
  11009. */
  11010. hasSpecificTriggers(triggers: number[]): boolean;
  11011. /**
  11012. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11013. * speed.
  11014. * @param triggerA defines the trigger to be tested
  11015. * @param triggerB defines the trigger to be tested
  11016. * @return a boolean indicating whether one (or more) of the triggers is handled
  11017. */
  11018. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11019. /**
  11020. * Does this action manager handles actions of a given trigger
  11021. * @param trigger defines the trigger to be tested
  11022. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11023. * @return whether the trigger is handled
  11024. */
  11025. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11026. /**
  11027. * Does this action manager has pointer triggers
  11028. */
  11029. readonly hasPointerTriggers: boolean;
  11030. /**
  11031. * Does this action manager has pick triggers
  11032. */
  11033. readonly hasPickTriggers: boolean;
  11034. /**
  11035. * Registers an action to this action manager
  11036. * @param action defines the action to be registered
  11037. * @return the action amended (prepared) after registration
  11038. */
  11039. registerAction(action: IAction): Nullable<IAction>;
  11040. /**
  11041. * Unregisters an action to this action manager
  11042. * @param action defines the action to be unregistered
  11043. * @return a boolean indicating whether the action has been unregistered
  11044. */
  11045. unregisterAction(action: IAction): Boolean;
  11046. /**
  11047. * Process a specific trigger
  11048. * @param trigger defines the trigger to process
  11049. * @param evt defines the event details to be processed
  11050. */
  11051. processTrigger(trigger: number, evt?: IActionEvent): void;
  11052. /** @hidden */
  11053. _getEffectiveTarget(target: any, propertyPath: string): any;
  11054. /** @hidden */
  11055. _getProperty(propertyPath: string): string;
  11056. /**
  11057. * Serialize this manager to a JSON object
  11058. * @param name defines the property name to store this manager
  11059. * @returns a JSON representation of this manager
  11060. */
  11061. serialize(name: string): any;
  11062. /**
  11063. * Creates a new ActionManager from a JSON data
  11064. * @param parsedActions defines the JSON data to read from
  11065. * @param object defines the hosting mesh
  11066. * @param scene defines the hosting scene
  11067. */
  11068. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11069. /**
  11070. * Get a trigger name by index
  11071. * @param trigger defines the trigger index
  11072. * @returns a trigger name
  11073. */
  11074. static GetTriggerName(trigger: number): string;
  11075. }
  11076. }
  11077. declare module "babylonjs/Culling/ray" {
  11078. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11079. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11081. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11082. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11083. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11084. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11085. import { Plane } from "babylonjs/Maths/math.plane";
  11086. /**
  11087. * Class representing a ray with position and direction
  11088. */
  11089. export class Ray {
  11090. /** origin point */
  11091. origin: Vector3;
  11092. /** direction */
  11093. direction: Vector3;
  11094. /** length of the ray */
  11095. length: number;
  11096. private static readonly TmpVector3;
  11097. private _tmpRay;
  11098. /**
  11099. * Creates a new ray
  11100. * @param origin origin point
  11101. * @param direction direction
  11102. * @param length length of the ray
  11103. */
  11104. constructor(
  11105. /** origin point */
  11106. origin: Vector3,
  11107. /** direction */
  11108. direction: Vector3,
  11109. /** length of the ray */
  11110. length?: number);
  11111. /**
  11112. * Checks if the ray intersects a box
  11113. * @param minimum bound of the box
  11114. * @param maximum bound of the box
  11115. * @param intersectionTreshold extra extend to be added to the box in all direction
  11116. * @returns if the box was hit
  11117. */
  11118. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11119. /**
  11120. * Checks if the ray intersects a box
  11121. * @param box the bounding box to check
  11122. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11123. * @returns if the box was hit
  11124. */
  11125. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11126. /**
  11127. * If the ray hits a sphere
  11128. * @param sphere the bounding sphere to check
  11129. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11130. * @returns true if it hits the sphere
  11131. */
  11132. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11133. /**
  11134. * If the ray hits a triange
  11135. * @param vertex0 triangle vertex
  11136. * @param vertex1 triangle vertex
  11137. * @param vertex2 triangle vertex
  11138. * @returns intersection information if hit
  11139. */
  11140. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11141. /**
  11142. * Checks if ray intersects a plane
  11143. * @param plane the plane to check
  11144. * @returns the distance away it was hit
  11145. */
  11146. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11147. /**
  11148. * Calculate the intercept of a ray on a given axis
  11149. * @param axis to check 'x' | 'y' | 'z'
  11150. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11151. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11152. */
  11153. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11154. /**
  11155. * Checks if ray intersects a mesh
  11156. * @param mesh the mesh to check
  11157. * @param fastCheck if only the bounding box should checked
  11158. * @returns picking info of the intersecton
  11159. */
  11160. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11161. /**
  11162. * Checks if ray intersects a mesh
  11163. * @param meshes the meshes to check
  11164. * @param fastCheck if only the bounding box should checked
  11165. * @param results array to store result in
  11166. * @returns Array of picking infos
  11167. */
  11168. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11169. private _comparePickingInfo;
  11170. private static smallnum;
  11171. private static rayl;
  11172. /**
  11173. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11174. * @param sega the first point of the segment to test the intersection against
  11175. * @param segb the second point of the segment to test the intersection against
  11176. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11177. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11178. */
  11179. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11180. /**
  11181. * Update the ray from viewport position
  11182. * @param x position
  11183. * @param y y position
  11184. * @param viewportWidth viewport width
  11185. * @param viewportHeight viewport height
  11186. * @param world world matrix
  11187. * @param view view matrix
  11188. * @param projection projection matrix
  11189. * @returns this ray updated
  11190. */
  11191. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11192. /**
  11193. * Creates a ray with origin and direction of 0,0,0
  11194. * @returns the new ray
  11195. */
  11196. static Zero(): Ray;
  11197. /**
  11198. * Creates a new ray from screen space and viewport
  11199. * @param x position
  11200. * @param y y position
  11201. * @param viewportWidth viewport width
  11202. * @param viewportHeight viewport height
  11203. * @param world world matrix
  11204. * @param view view matrix
  11205. * @param projection projection matrix
  11206. * @returns new ray
  11207. */
  11208. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11209. /**
  11210. * 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
  11211. * transformed to the given world matrix.
  11212. * @param origin The origin point
  11213. * @param end The end point
  11214. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11215. * @returns the new ray
  11216. */
  11217. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11218. /**
  11219. * Transforms a ray by a matrix
  11220. * @param ray ray to transform
  11221. * @param matrix matrix to apply
  11222. * @returns the resulting new ray
  11223. */
  11224. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11225. /**
  11226. * Transforms a ray by a matrix
  11227. * @param ray ray to transform
  11228. * @param matrix matrix to apply
  11229. * @param result ray to store result in
  11230. */
  11231. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11232. /**
  11233. * Unproject a ray from screen space to object space
  11234. * @param sourceX defines the screen space x coordinate to use
  11235. * @param sourceY defines the screen space y coordinate to use
  11236. * @param viewportWidth defines the current width of the viewport
  11237. * @param viewportHeight defines the current height of the viewport
  11238. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11239. * @param view defines the view matrix to use
  11240. * @param projection defines the projection matrix to use
  11241. */
  11242. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11243. }
  11244. /**
  11245. * Type used to define predicate used to select faces when a mesh intersection is detected
  11246. */
  11247. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11248. module "babylonjs/scene" {
  11249. interface Scene {
  11250. /** @hidden */
  11251. _tempPickingRay: Nullable<Ray>;
  11252. /** @hidden */
  11253. _cachedRayForTransform: Ray;
  11254. /** @hidden */
  11255. _pickWithRayInverseMatrix: Matrix;
  11256. /** @hidden */
  11257. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11258. /** @hidden */
  11259. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11260. }
  11261. }
  11262. }
  11263. declare module "babylonjs/sceneComponent" {
  11264. import { Scene } from "babylonjs/scene";
  11265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11266. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11267. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11268. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11269. import { Nullable } from "babylonjs/types";
  11270. import { Camera } from "babylonjs/Cameras/camera";
  11271. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11272. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11273. import { AbstractScene } from "babylonjs/abstractScene";
  11274. /**
  11275. * Groups all the scene component constants in one place to ease maintenance.
  11276. * @hidden
  11277. */
  11278. export class SceneComponentConstants {
  11279. static readonly NAME_EFFECTLAYER: string;
  11280. static readonly NAME_LAYER: string;
  11281. static readonly NAME_LENSFLARESYSTEM: string;
  11282. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11283. static readonly NAME_PARTICLESYSTEM: string;
  11284. static readonly NAME_GAMEPAD: string;
  11285. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11286. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11287. static readonly NAME_DEPTHRENDERER: string;
  11288. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11289. static readonly NAME_SPRITE: string;
  11290. static readonly NAME_OUTLINERENDERER: string;
  11291. static readonly NAME_PROCEDURALTEXTURE: string;
  11292. static readonly NAME_SHADOWGENERATOR: string;
  11293. static readonly NAME_OCTREE: string;
  11294. static readonly NAME_PHYSICSENGINE: string;
  11295. static readonly NAME_AUDIO: string;
  11296. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11297. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11298. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11299. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11300. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11301. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11302. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11303. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11304. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11305. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11306. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11307. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11308. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11309. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11310. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11311. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11312. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11313. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11314. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11315. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11316. static readonly STEP_AFTERRENDER_AUDIO: number;
  11317. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11318. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11319. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11320. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11321. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11322. static readonly STEP_POINTERMOVE_SPRITE: number;
  11323. static readonly STEP_POINTERDOWN_SPRITE: number;
  11324. static readonly STEP_POINTERUP_SPRITE: number;
  11325. }
  11326. /**
  11327. * This represents a scene component.
  11328. *
  11329. * This is used to decouple the dependency the scene is having on the different workloads like
  11330. * layers, post processes...
  11331. */
  11332. export interface ISceneComponent {
  11333. /**
  11334. * The name of the component. Each component must have a unique name.
  11335. */
  11336. name: string;
  11337. /**
  11338. * The scene the component belongs to.
  11339. */
  11340. scene: Scene;
  11341. /**
  11342. * Register the component to one instance of a scene.
  11343. */
  11344. register(): void;
  11345. /**
  11346. * Rebuilds the elements related to this component in case of
  11347. * context lost for instance.
  11348. */
  11349. rebuild(): void;
  11350. /**
  11351. * Disposes the component and the associated ressources.
  11352. */
  11353. dispose(): void;
  11354. }
  11355. /**
  11356. * This represents a SERIALIZABLE scene component.
  11357. *
  11358. * This extends Scene Component to add Serialization methods on top.
  11359. */
  11360. export interface ISceneSerializableComponent extends ISceneComponent {
  11361. /**
  11362. * Adds all the elements from the container to the scene
  11363. * @param container the container holding the elements
  11364. */
  11365. addFromContainer(container: AbstractScene): void;
  11366. /**
  11367. * Removes all the elements in the container from the scene
  11368. * @param container contains the elements to remove
  11369. * @param dispose if the removed element should be disposed (default: false)
  11370. */
  11371. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11372. /**
  11373. * Serializes the component data to the specified json object
  11374. * @param serializationObject The object to serialize to
  11375. */
  11376. serialize(serializationObject: any): void;
  11377. }
  11378. /**
  11379. * Strong typing of a Mesh related stage step action
  11380. */
  11381. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11382. /**
  11383. * Strong typing of a Evaluate Sub Mesh related stage step action
  11384. */
  11385. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11386. /**
  11387. * Strong typing of a Active Mesh related stage step action
  11388. */
  11389. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11390. /**
  11391. * Strong typing of a Camera related stage step action
  11392. */
  11393. export type CameraStageAction = (camera: Camera) => void;
  11394. /**
  11395. * Strong typing of a Camera Frame buffer related stage step action
  11396. */
  11397. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11398. /**
  11399. * Strong typing of a Render Target related stage step action
  11400. */
  11401. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11402. /**
  11403. * Strong typing of a RenderingGroup related stage step action
  11404. */
  11405. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11406. /**
  11407. * Strong typing of a Mesh Render related stage step action
  11408. */
  11409. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11410. /**
  11411. * Strong typing of a simple stage step action
  11412. */
  11413. export type SimpleStageAction = () => void;
  11414. /**
  11415. * Strong typing of a render target action.
  11416. */
  11417. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11418. /**
  11419. * Strong typing of a pointer move action.
  11420. */
  11421. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11422. /**
  11423. * Strong typing of a pointer up/down action.
  11424. */
  11425. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11426. /**
  11427. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11428. * @hidden
  11429. */
  11430. export class Stage<T extends Function> extends Array<{
  11431. index: number;
  11432. component: ISceneComponent;
  11433. action: T;
  11434. }> {
  11435. /**
  11436. * Hide ctor from the rest of the world.
  11437. * @param items The items to add.
  11438. */
  11439. private constructor();
  11440. /**
  11441. * Creates a new Stage.
  11442. * @returns A new instance of a Stage
  11443. */
  11444. static Create<T extends Function>(): Stage<T>;
  11445. /**
  11446. * Registers a step in an ordered way in the targeted stage.
  11447. * @param index Defines the position to register the step in
  11448. * @param component Defines the component attached to the step
  11449. * @param action Defines the action to launch during the step
  11450. */
  11451. registerStep(index: number, component: ISceneComponent, action: T): void;
  11452. /**
  11453. * Clears all the steps from the stage.
  11454. */
  11455. clear(): void;
  11456. }
  11457. }
  11458. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11459. import { Nullable } from "babylonjs/types";
  11460. import { Observable } from "babylonjs/Misc/observable";
  11461. import { Scene } from "babylonjs/scene";
  11462. import { Sprite } from "babylonjs/Sprites/sprite";
  11463. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11464. import { Ray } from "babylonjs/Culling/ray";
  11465. import { Camera } from "babylonjs/Cameras/camera";
  11466. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11467. import { ISceneComponent } from "babylonjs/sceneComponent";
  11468. module "babylonjs/scene" {
  11469. interface Scene {
  11470. /** @hidden */
  11471. _pointerOverSprite: Nullable<Sprite>;
  11472. /** @hidden */
  11473. _pickedDownSprite: Nullable<Sprite>;
  11474. /** @hidden */
  11475. _tempSpritePickingRay: Nullable<Ray>;
  11476. /**
  11477. * All of the sprite managers added to this scene
  11478. * @see http://doc.babylonjs.com/babylon101/sprites
  11479. */
  11480. spriteManagers: Array<ISpriteManager>;
  11481. /**
  11482. * An event triggered when sprites rendering is about to start
  11483. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11484. */
  11485. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11486. /**
  11487. * An event triggered when sprites rendering is done
  11488. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11489. */
  11490. onAfterSpritesRenderingObservable: Observable<Scene>;
  11491. /** @hidden */
  11492. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11493. /** Launch a ray to try to pick a sprite in the scene
  11494. * @param x position on screen
  11495. * @param y position on screen
  11496. * @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
  11497. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11498. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11499. * @returns a PickingInfo
  11500. */
  11501. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11502. /** Use the given ray to pick a sprite in the scene
  11503. * @param ray The ray (in world space) to use to pick meshes
  11504. * @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
  11505. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11506. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11507. * @returns a PickingInfo
  11508. */
  11509. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11510. /** @hidden */
  11511. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11512. /** Launch a ray to try to pick sprites in the scene
  11513. * @param x position on screen
  11514. * @param y position on screen
  11515. * @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
  11516. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11517. * @returns a PickingInfo array
  11518. */
  11519. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11520. /** Use the given ray to pick sprites in the scene
  11521. * @param ray The ray (in world space) to use to pick meshes
  11522. * @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
  11523. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11524. * @returns a PickingInfo array
  11525. */
  11526. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11527. /**
  11528. * Force the sprite under the pointer
  11529. * @param sprite defines the sprite to use
  11530. */
  11531. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11532. /**
  11533. * Gets the sprite under the pointer
  11534. * @returns a Sprite or null if no sprite is under the pointer
  11535. */
  11536. getPointerOverSprite(): Nullable<Sprite>;
  11537. }
  11538. }
  11539. /**
  11540. * Defines the sprite scene component responsible to manage sprites
  11541. * in a given scene.
  11542. */
  11543. export class SpriteSceneComponent implements ISceneComponent {
  11544. /**
  11545. * The component name helpfull to identify the component in the list of scene components.
  11546. */
  11547. readonly name: string;
  11548. /**
  11549. * The scene the component belongs to.
  11550. */
  11551. scene: Scene;
  11552. /** @hidden */
  11553. private _spritePredicate;
  11554. /**
  11555. * Creates a new instance of the component for the given scene
  11556. * @param scene Defines the scene to register the component in
  11557. */
  11558. constructor(scene: Scene);
  11559. /**
  11560. * Registers the component in a given scene
  11561. */
  11562. register(): void;
  11563. /**
  11564. * Rebuilds the elements related to this component in case of
  11565. * context lost for instance.
  11566. */
  11567. rebuild(): void;
  11568. /**
  11569. * Disposes the component and the associated ressources.
  11570. */
  11571. dispose(): void;
  11572. private _pickSpriteButKeepRay;
  11573. private _pointerMove;
  11574. private _pointerDown;
  11575. private _pointerUp;
  11576. }
  11577. }
  11578. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11579. /** @hidden */
  11580. export var fogFragmentDeclaration: {
  11581. name: string;
  11582. shader: string;
  11583. };
  11584. }
  11585. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11586. /** @hidden */
  11587. export var fogFragment: {
  11588. name: string;
  11589. shader: string;
  11590. };
  11591. }
  11592. declare module "babylonjs/Shaders/sprites.fragment" {
  11593. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11594. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11595. /** @hidden */
  11596. export var spritesPixelShader: {
  11597. name: string;
  11598. shader: string;
  11599. };
  11600. }
  11601. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11602. /** @hidden */
  11603. export var fogVertexDeclaration: {
  11604. name: string;
  11605. shader: string;
  11606. };
  11607. }
  11608. declare module "babylonjs/Shaders/sprites.vertex" {
  11609. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11610. /** @hidden */
  11611. export var spritesVertexShader: {
  11612. name: string;
  11613. shader: string;
  11614. };
  11615. }
  11616. declare module "babylonjs/Sprites/spriteManager" {
  11617. import { IDisposable, Scene } from "babylonjs/scene";
  11618. import { Nullable } from "babylonjs/types";
  11619. import { Observable } from "babylonjs/Misc/observable";
  11620. import { Sprite } from "babylonjs/Sprites/sprite";
  11621. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11622. import { Camera } from "babylonjs/Cameras/camera";
  11623. import { Texture } from "babylonjs/Materials/Textures/texture";
  11624. import "babylonjs/Shaders/sprites.fragment";
  11625. import "babylonjs/Shaders/sprites.vertex";
  11626. import { Ray } from "babylonjs/Culling/ray";
  11627. /**
  11628. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11629. */
  11630. export interface ISpriteManager extends IDisposable {
  11631. /**
  11632. * Restricts the camera to viewing objects with the same layerMask.
  11633. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11634. */
  11635. layerMask: number;
  11636. /**
  11637. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11638. */
  11639. isPickable: boolean;
  11640. /**
  11641. * Specifies the rendering group id for this mesh (0 by default)
  11642. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11643. */
  11644. renderingGroupId: number;
  11645. /**
  11646. * Defines the list of sprites managed by the manager.
  11647. */
  11648. sprites: Array<Sprite>;
  11649. /**
  11650. * Tests the intersection of a sprite with a specific ray.
  11651. * @param ray The ray we are sending to test the collision
  11652. * @param camera The camera space we are sending rays in
  11653. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11654. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11655. * @returns picking info or null.
  11656. */
  11657. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11658. /**
  11659. * Intersects the sprites with a ray
  11660. * @param ray defines the ray to intersect with
  11661. * @param camera defines the current active camera
  11662. * @param predicate defines a predicate used to select candidate sprites
  11663. * @returns null if no hit or a PickingInfo array
  11664. */
  11665. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11666. /**
  11667. * Renders the list of sprites on screen.
  11668. */
  11669. render(): void;
  11670. }
  11671. /**
  11672. * Class used to manage multiple sprites on the same spritesheet
  11673. * @see http://doc.babylonjs.com/babylon101/sprites
  11674. */
  11675. export class SpriteManager implements ISpriteManager {
  11676. /** defines the manager's name */
  11677. name: string;
  11678. /** Gets the list of sprites */
  11679. sprites: Sprite[];
  11680. /** Gets or sets the rendering group id (0 by default) */
  11681. renderingGroupId: number;
  11682. /** Gets or sets camera layer mask */
  11683. layerMask: number;
  11684. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11685. fogEnabled: boolean;
  11686. /** Gets or sets a boolean indicating if the sprites are pickable */
  11687. isPickable: boolean;
  11688. /** Defines the default width of a cell in the spritesheet */
  11689. cellWidth: number;
  11690. /** Defines the default height of a cell in the spritesheet */
  11691. cellHeight: number;
  11692. /** Associative array from JSON sprite data file */
  11693. private _cellData;
  11694. /** Array of sprite names from JSON sprite data file */
  11695. private _spriteMap;
  11696. /** True when packed cell data from JSON file is ready*/
  11697. private _packedAndReady;
  11698. /**
  11699. * An event triggered when the manager is disposed.
  11700. */
  11701. onDisposeObservable: Observable<SpriteManager>;
  11702. private _onDisposeObserver;
  11703. /**
  11704. * Callback called when the manager is disposed
  11705. */
  11706. onDispose: () => void;
  11707. private _capacity;
  11708. private _fromPacked;
  11709. private _spriteTexture;
  11710. private _epsilon;
  11711. private _scene;
  11712. private _vertexData;
  11713. private _buffer;
  11714. private _vertexBuffers;
  11715. private _indexBuffer;
  11716. private _effectBase;
  11717. private _effectFog;
  11718. /**
  11719. * Gets or sets the spritesheet texture
  11720. */
  11721. texture: Texture;
  11722. /**
  11723. * Creates a new sprite manager
  11724. * @param name defines the manager's name
  11725. * @param imgUrl defines the sprite sheet url
  11726. * @param capacity defines the maximum allowed number of sprites
  11727. * @param cellSize defines the size of a sprite cell
  11728. * @param scene defines the hosting scene
  11729. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11730. * @param samplingMode defines the smapling mode to use with spritesheet
  11731. * @param fromPacked set to false; do not alter
  11732. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11733. */
  11734. constructor(
  11735. /** defines the manager's name */
  11736. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11737. private _makePacked;
  11738. private _appendSpriteVertex;
  11739. /**
  11740. * Intersects the sprites with a ray
  11741. * @param ray defines the ray to intersect with
  11742. * @param camera defines the current active camera
  11743. * @param predicate defines a predicate used to select candidate sprites
  11744. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11745. * @returns null if no hit or a PickingInfo
  11746. */
  11747. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11748. /**
  11749. * Intersects the sprites with a ray
  11750. * @param ray defines the ray to intersect with
  11751. * @param camera defines the current active camera
  11752. * @param predicate defines a predicate used to select candidate sprites
  11753. * @returns null if no hit or a PickingInfo array
  11754. */
  11755. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11756. /**
  11757. * Render all child sprites
  11758. */
  11759. render(): void;
  11760. /**
  11761. * Release associated resources
  11762. */
  11763. dispose(): void;
  11764. }
  11765. }
  11766. declare module "babylonjs/Sprites/sprite" {
  11767. import { Vector3 } from "babylonjs/Maths/math.vector";
  11768. import { Nullable } from "babylonjs/types";
  11769. import { ActionManager } from "babylonjs/Actions/actionManager";
  11770. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11771. import { Color4 } from "babylonjs/Maths/math.color";
  11772. /**
  11773. * Class used to represent a sprite
  11774. * @see http://doc.babylonjs.com/babylon101/sprites
  11775. */
  11776. export class Sprite {
  11777. /** defines the name */
  11778. name: string;
  11779. /** Gets or sets the current world position */
  11780. position: Vector3;
  11781. /** Gets or sets the main color */
  11782. color: Color4;
  11783. /** Gets or sets the width */
  11784. width: number;
  11785. /** Gets or sets the height */
  11786. height: number;
  11787. /** Gets or sets rotation angle */
  11788. angle: number;
  11789. /** Gets or sets the cell index in the sprite sheet */
  11790. cellIndex: number;
  11791. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11792. cellRef: string;
  11793. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11794. invertU: number;
  11795. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11796. invertV: number;
  11797. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11798. disposeWhenFinishedAnimating: boolean;
  11799. /** Gets the list of attached animations */
  11800. animations: Animation[];
  11801. /** Gets or sets a boolean indicating if the sprite can be picked */
  11802. isPickable: boolean;
  11803. /**
  11804. * Gets or sets the associated action manager
  11805. */
  11806. actionManager: Nullable<ActionManager>;
  11807. private _animationStarted;
  11808. private _loopAnimation;
  11809. private _fromIndex;
  11810. private _toIndex;
  11811. private _delay;
  11812. private _direction;
  11813. private _manager;
  11814. private _time;
  11815. private _onAnimationEnd;
  11816. /**
  11817. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11818. */
  11819. isVisible: boolean;
  11820. /**
  11821. * Gets or sets the sprite size
  11822. */
  11823. size: number;
  11824. /**
  11825. * Creates a new Sprite
  11826. * @param name defines the name
  11827. * @param manager defines the manager
  11828. */
  11829. constructor(
  11830. /** defines the name */
  11831. name: string, manager: ISpriteManager);
  11832. /**
  11833. * Starts an animation
  11834. * @param from defines the initial key
  11835. * @param to defines the end key
  11836. * @param loop defines if the animation must loop
  11837. * @param delay defines the start delay (in ms)
  11838. * @param onAnimationEnd defines a callback to call when animation ends
  11839. */
  11840. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11841. /** Stops current animation (if any) */
  11842. stopAnimation(): void;
  11843. /** @hidden */
  11844. _animate(deltaTime: number): void;
  11845. /** Release associated resources */
  11846. dispose(): void;
  11847. }
  11848. }
  11849. declare module "babylonjs/Collisions/pickingInfo" {
  11850. import { Nullable } from "babylonjs/types";
  11851. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11853. import { Sprite } from "babylonjs/Sprites/sprite";
  11854. import { Ray } from "babylonjs/Culling/ray";
  11855. /**
  11856. * Information about the result of picking within a scene
  11857. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11858. */
  11859. export class PickingInfo {
  11860. /** @hidden */
  11861. _pickingUnavailable: boolean;
  11862. /**
  11863. * If the pick collided with an object
  11864. */
  11865. hit: boolean;
  11866. /**
  11867. * Distance away where the pick collided
  11868. */
  11869. distance: number;
  11870. /**
  11871. * The location of pick collision
  11872. */
  11873. pickedPoint: Nullable<Vector3>;
  11874. /**
  11875. * The mesh corresponding the the pick collision
  11876. */
  11877. pickedMesh: Nullable<AbstractMesh>;
  11878. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11879. bu: number;
  11880. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11881. bv: number;
  11882. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11883. faceId: number;
  11884. /** Id of the the submesh that was picked */
  11885. subMeshId: number;
  11886. /** If a sprite was picked, this will be the sprite the pick collided with */
  11887. pickedSprite: Nullable<Sprite>;
  11888. /**
  11889. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11890. */
  11891. originMesh: Nullable<AbstractMesh>;
  11892. /**
  11893. * The ray that was used to perform the picking.
  11894. */
  11895. ray: Nullable<Ray>;
  11896. /**
  11897. * Gets the normal correspodning to the face the pick collided with
  11898. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11899. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11900. * @returns The normal correspodning to the face the pick collided with
  11901. */
  11902. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11903. /**
  11904. * Gets the texture coordinates of where the pick occured
  11905. * @returns the vector containing the coordnates of the texture
  11906. */
  11907. getTextureCoordinates(): Nullable<Vector2>;
  11908. }
  11909. }
  11910. declare module "babylonjs/Events/pointerEvents" {
  11911. import { Nullable } from "babylonjs/types";
  11912. import { Vector2 } from "babylonjs/Maths/math.vector";
  11913. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11914. import { Ray } from "babylonjs/Culling/ray";
  11915. /**
  11916. * Gather the list of pointer event types as constants.
  11917. */
  11918. export class PointerEventTypes {
  11919. /**
  11920. * 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.
  11921. */
  11922. static readonly POINTERDOWN: number;
  11923. /**
  11924. * The pointerup event is fired when a pointer is no longer active.
  11925. */
  11926. static readonly POINTERUP: number;
  11927. /**
  11928. * The pointermove event is fired when a pointer changes coordinates.
  11929. */
  11930. static readonly POINTERMOVE: number;
  11931. /**
  11932. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11933. */
  11934. static readonly POINTERWHEEL: number;
  11935. /**
  11936. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11937. */
  11938. static readonly POINTERPICK: number;
  11939. /**
  11940. * The pointertap event is fired when a the object has been touched and released without drag.
  11941. */
  11942. static readonly POINTERTAP: number;
  11943. /**
  11944. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11945. */
  11946. static readonly POINTERDOUBLETAP: number;
  11947. }
  11948. /**
  11949. * Base class of pointer info types.
  11950. */
  11951. export class PointerInfoBase {
  11952. /**
  11953. * Defines the type of event (PointerEventTypes)
  11954. */
  11955. type: number;
  11956. /**
  11957. * Defines the related dom event
  11958. */
  11959. event: PointerEvent | MouseWheelEvent;
  11960. /**
  11961. * Instantiates the base class of pointers info.
  11962. * @param type Defines the type of event (PointerEventTypes)
  11963. * @param event Defines the related dom event
  11964. */
  11965. constructor(
  11966. /**
  11967. * Defines the type of event (PointerEventTypes)
  11968. */
  11969. type: number,
  11970. /**
  11971. * Defines the related dom event
  11972. */
  11973. event: PointerEvent | MouseWheelEvent);
  11974. }
  11975. /**
  11976. * This class is used to store pointer related info for the onPrePointerObservable event.
  11977. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11978. */
  11979. export class PointerInfoPre extends PointerInfoBase {
  11980. /**
  11981. * Ray from a pointer if availible (eg. 6dof controller)
  11982. */
  11983. ray: Nullable<Ray>;
  11984. /**
  11985. * Defines the local position of the pointer on the canvas.
  11986. */
  11987. localPosition: Vector2;
  11988. /**
  11989. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11990. */
  11991. skipOnPointerObservable: boolean;
  11992. /**
  11993. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11994. * @param type Defines the type of event (PointerEventTypes)
  11995. * @param event Defines the related dom event
  11996. * @param localX Defines the local x coordinates of the pointer when the event occured
  11997. * @param localY Defines the local y coordinates of the pointer when the event occured
  11998. */
  11999. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12000. }
  12001. /**
  12002. * This type contains all the data related to a pointer event in Babylon.js.
  12003. * 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.
  12004. */
  12005. export class PointerInfo extends PointerInfoBase {
  12006. /**
  12007. * Defines the picking info associated to the info (if any)\
  12008. */
  12009. pickInfo: Nullable<PickingInfo>;
  12010. /**
  12011. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12012. * @param type Defines the type of event (PointerEventTypes)
  12013. * @param event Defines the related dom event
  12014. * @param pickInfo Defines the picking info associated to the info (if any)\
  12015. */
  12016. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12017. /**
  12018. * Defines the picking info associated to the info (if any)\
  12019. */
  12020. pickInfo: Nullable<PickingInfo>);
  12021. }
  12022. /**
  12023. * Data relating to a touch event on the screen.
  12024. */
  12025. export interface PointerTouch {
  12026. /**
  12027. * X coordinate of touch.
  12028. */
  12029. x: number;
  12030. /**
  12031. * Y coordinate of touch.
  12032. */
  12033. y: number;
  12034. /**
  12035. * Id of touch. Unique for each finger.
  12036. */
  12037. pointerId: number;
  12038. /**
  12039. * Event type passed from DOM.
  12040. */
  12041. type: any;
  12042. }
  12043. }
  12044. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12045. import { Observable } from "babylonjs/Misc/observable";
  12046. import { Nullable } from "babylonjs/types";
  12047. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12048. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12049. /**
  12050. * Manage the mouse inputs to control the movement of a free camera.
  12051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12052. */
  12053. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12054. /**
  12055. * Define if touch is enabled in the mouse input
  12056. */
  12057. touchEnabled: boolean;
  12058. /**
  12059. * Defines the camera the input is attached to.
  12060. */
  12061. camera: FreeCamera;
  12062. /**
  12063. * Defines the buttons associated with the input to handle camera move.
  12064. */
  12065. buttons: number[];
  12066. /**
  12067. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12068. */
  12069. angularSensibility: number;
  12070. private _pointerInput;
  12071. private _onMouseMove;
  12072. private _observer;
  12073. private previousPosition;
  12074. /**
  12075. * Observable for when a pointer move event occurs containing the move offset
  12076. */
  12077. onPointerMovedObservable: Observable<{
  12078. offsetX: number;
  12079. offsetY: number;
  12080. }>;
  12081. /**
  12082. * @hidden
  12083. * If the camera should be rotated automatically based on pointer movement
  12084. */
  12085. _allowCameraRotation: boolean;
  12086. /**
  12087. * Manage the mouse inputs to control the movement of a free camera.
  12088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12089. * @param touchEnabled Defines if touch is enabled or not
  12090. */
  12091. constructor(
  12092. /**
  12093. * Define if touch is enabled in the mouse input
  12094. */
  12095. touchEnabled?: boolean);
  12096. /**
  12097. * Attach the input controls to a specific dom element to get the input from.
  12098. * @param element Defines the element the controls should be listened from
  12099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12100. */
  12101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12102. /**
  12103. * Called on JS contextmenu event.
  12104. * Override this method to provide functionality.
  12105. */
  12106. protected onContextMenu(evt: PointerEvent): void;
  12107. /**
  12108. * Detach the current controls from the specified dom element.
  12109. * @param element Defines the element to stop listening the inputs from
  12110. */
  12111. detachControl(element: Nullable<HTMLElement>): void;
  12112. /**
  12113. * Gets the class name of the current intput.
  12114. * @returns the class name
  12115. */
  12116. getClassName(): string;
  12117. /**
  12118. * Get the friendly name associated with the input class.
  12119. * @returns the input friendly name
  12120. */
  12121. getSimpleName(): string;
  12122. }
  12123. }
  12124. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12125. import { Nullable } from "babylonjs/types";
  12126. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12127. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12128. /**
  12129. * Manage the touch inputs to control the movement of a free camera.
  12130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12131. */
  12132. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12133. /**
  12134. * Defines the camera the input is attached to.
  12135. */
  12136. camera: FreeCamera;
  12137. /**
  12138. * Defines the touch sensibility for rotation.
  12139. * The higher the faster.
  12140. */
  12141. touchAngularSensibility: number;
  12142. /**
  12143. * Defines the touch sensibility for move.
  12144. * The higher the faster.
  12145. */
  12146. touchMoveSensibility: number;
  12147. private _offsetX;
  12148. private _offsetY;
  12149. private _pointerPressed;
  12150. private _pointerInput;
  12151. private _observer;
  12152. private _onLostFocus;
  12153. /**
  12154. * Attach the input controls to a specific dom element to get the input from.
  12155. * @param element Defines the element the controls should be listened from
  12156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12157. */
  12158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12159. /**
  12160. * Detach the current controls from the specified dom element.
  12161. * @param element Defines the element to stop listening the inputs from
  12162. */
  12163. detachControl(element: Nullable<HTMLElement>): void;
  12164. /**
  12165. * Update the current camera state depending on the inputs that have been used this frame.
  12166. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12167. */
  12168. checkInputs(): void;
  12169. /**
  12170. * Gets the class name of the current intput.
  12171. * @returns the class name
  12172. */
  12173. getClassName(): string;
  12174. /**
  12175. * Get the friendly name associated with the input class.
  12176. * @returns the input friendly name
  12177. */
  12178. getSimpleName(): string;
  12179. }
  12180. }
  12181. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12182. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12183. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12184. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12185. import { Nullable } from "babylonjs/types";
  12186. /**
  12187. * Default Inputs manager for the FreeCamera.
  12188. * It groups all the default supported inputs for ease of use.
  12189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12190. */
  12191. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12192. /**
  12193. * @hidden
  12194. */
  12195. _mouseInput: Nullable<FreeCameraMouseInput>;
  12196. /**
  12197. * Instantiates a new FreeCameraInputsManager.
  12198. * @param camera Defines the camera the inputs belong to
  12199. */
  12200. constructor(camera: FreeCamera);
  12201. /**
  12202. * Add keyboard input support to the input manager.
  12203. * @returns the current input manager
  12204. */
  12205. addKeyboard(): FreeCameraInputsManager;
  12206. /**
  12207. * Add mouse input support to the input manager.
  12208. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12209. * @returns the current input manager
  12210. */
  12211. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12212. /**
  12213. * Removes the mouse input support from the manager
  12214. * @returns the current input manager
  12215. */
  12216. removeMouse(): FreeCameraInputsManager;
  12217. /**
  12218. * Add touch input support to the input manager.
  12219. * @returns the current input manager
  12220. */
  12221. addTouch(): FreeCameraInputsManager;
  12222. /**
  12223. * Remove all attached input methods from a camera
  12224. */
  12225. clear(): void;
  12226. }
  12227. }
  12228. declare module "babylonjs/Cameras/freeCamera" {
  12229. import { Vector3 } from "babylonjs/Maths/math.vector";
  12230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12231. import { Scene } from "babylonjs/scene";
  12232. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12233. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12234. /**
  12235. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12236. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12237. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12238. */
  12239. export class FreeCamera extends TargetCamera {
  12240. /**
  12241. * Define the collision ellipsoid of the camera.
  12242. * This is helpful to simulate a camera body like the player body around the camera
  12243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12244. */
  12245. ellipsoid: Vector3;
  12246. /**
  12247. * Define an offset for the position of the ellipsoid around the camera.
  12248. * This can be helpful to determine the center of the body near the gravity center of the body
  12249. * instead of its head.
  12250. */
  12251. ellipsoidOffset: Vector3;
  12252. /**
  12253. * Enable or disable collisions of the camera with the rest of the scene objects.
  12254. */
  12255. checkCollisions: boolean;
  12256. /**
  12257. * Enable or disable gravity on the camera.
  12258. */
  12259. applyGravity: boolean;
  12260. /**
  12261. * Define the input manager associated to the camera.
  12262. */
  12263. inputs: FreeCameraInputsManager;
  12264. /**
  12265. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12266. * Higher values reduce sensitivity.
  12267. */
  12268. /**
  12269. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12270. * Higher values reduce sensitivity.
  12271. */
  12272. angularSensibility: number;
  12273. /**
  12274. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12275. */
  12276. keysUp: number[];
  12277. /**
  12278. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12279. */
  12280. keysDown: number[];
  12281. /**
  12282. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12283. */
  12284. keysLeft: number[];
  12285. /**
  12286. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12287. */
  12288. keysRight: number[];
  12289. /**
  12290. * Event raised when the camera collide with a mesh in the scene.
  12291. */
  12292. onCollide: (collidedMesh: AbstractMesh) => void;
  12293. private _collider;
  12294. private _needMoveForGravity;
  12295. private _oldPosition;
  12296. private _diffPosition;
  12297. private _newPosition;
  12298. /** @hidden */
  12299. _localDirection: Vector3;
  12300. /** @hidden */
  12301. _transformedDirection: Vector3;
  12302. /**
  12303. * Instantiates a Free Camera.
  12304. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12305. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12306. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12307. * @param name Define the name of the camera in the scene
  12308. * @param position Define the start position of the camera in the scene
  12309. * @param scene Define the scene the camera belongs to
  12310. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12311. */
  12312. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12313. /**
  12314. * Attached controls to the current camera.
  12315. * @param element Defines the element the controls should be listened from
  12316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12317. */
  12318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12319. /**
  12320. * Detach the current controls from the camera.
  12321. * The camera will stop reacting to inputs.
  12322. * @param element Defines the element to stop listening the inputs from
  12323. */
  12324. detachControl(element: HTMLElement): void;
  12325. private _collisionMask;
  12326. /**
  12327. * Define a collision mask to limit the list of object the camera can collide with
  12328. */
  12329. collisionMask: number;
  12330. /** @hidden */
  12331. _collideWithWorld(displacement: Vector3): void;
  12332. private _onCollisionPositionChange;
  12333. /** @hidden */
  12334. _checkInputs(): void;
  12335. /** @hidden */
  12336. _decideIfNeedsToMove(): boolean;
  12337. /** @hidden */
  12338. _updatePosition(): void;
  12339. /**
  12340. * Destroy the camera and release the current resources hold by it.
  12341. */
  12342. dispose(): void;
  12343. /**
  12344. * Gets the current object class name.
  12345. * @return the class name
  12346. */
  12347. getClassName(): string;
  12348. }
  12349. }
  12350. declare module "babylonjs/Gamepads/gamepad" {
  12351. import { Observable } from "babylonjs/Misc/observable";
  12352. /**
  12353. * Represents a gamepad control stick position
  12354. */
  12355. export class StickValues {
  12356. /**
  12357. * The x component of the control stick
  12358. */
  12359. x: number;
  12360. /**
  12361. * The y component of the control stick
  12362. */
  12363. y: number;
  12364. /**
  12365. * Initializes the gamepad x and y control stick values
  12366. * @param x The x component of the gamepad control stick value
  12367. * @param y The y component of the gamepad control stick value
  12368. */
  12369. constructor(
  12370. /**
  12371. * The x component of the control stick
  12372. */
  12373. x: number,
  12374. /**
  12375. * The y component of the control stick
  12376. */
  12377. y: number);
  12378. }
  12379. /**
  12380. * An interface which manages callbacks for gamepad button changes
  12381. */
  12382. export interface GamepadButtonChanges {
  12383. /**
  12384. * Called when a gamepad has been changed
  12385. */
  12386. changed: boolean;
  12387. /**
  12388. * Called when a gamepad press event has been triggered
  12389. */
  12390. pressChanged: boolean;
  12391. /**
  12392. * Called when a touch event has been triggered
  12393. */
  12394. touchChanged: boolean;
  12395. /**
  12396. * Called when a value has changed
  12397. */
  12398. valueChanged: boolean;
  12399. }
  12400. /**
  12401. * Represents a gamepad
  12402. */
  12403. export class Gamepad {
  12404. /**
  12405. * The id of the gamepad
  12406. */
  12407. id: string;
  12408. /**
  12409. * The index of the gamepad
  12410. */
  12411. index: number;
  12412. /**
  12413. * The browser gamepad
  12414. */
  12415. browserGamepad: any;
  12416. /**
  12417. * Specifies what type of gamepad this represents
  12418. */
  12419. type: number;
  12420. private _leftStick;
  12421. private _rightStick;
  12422. /** @hidden */
  12423. _isConnected: boolean;
  12424. private _leftStickAxisX;
  12425. private _leftStickAxisY;
  12426. private _rightStickAxisX;
  12427. private _rightStickAxisY;
  12428. /**
  12429. * Triggered when the left control stick has been changed
  12430. */
  12431. private _onleftstickchanged;
  12432. /**
  12433. * Triggered when the right control stick has been changed
  12434. */
  12435. private _onrightstickchanged;
  12436. /**
  12437. * Represents a gamepad controller
  12438. */
  12439. static GAMEPAD: number;
  12440. /**
  12441. * Represents a generic controller
  12442. */
  12443. static GENERIC: number;
  12444. /**
  12445. * Represents an XBox controller
  12446. */
  12447. static XBOX: number;
  12448. /**
  12449. * Represents a pose-enabled controller
  12450. */
  12451. static POSE_ENABLED: number;
  12452. /**
  12453. * Represents an Dual Shock controller
  12454. */
  12455. static DUALSHOCK: number;
  12456. /**
  12457. * Specifies whether the left control stick should be Y-inverted
  12458. */
  12459. protected _invertLeftStickY: boolean;
  12460. /**
  12461. * Specifies if the gamepad has been connected
  12462. */
  12463. readonly isConnected: boolean;
  12464. /**
  12465. * Initializes the gamepad
  12466. * @param id The id of the gamepad
  12467. * @param index The index of the gamepad
  12468. * @param browserGamepad The browser gamepad
  12469. * @param leftStickX The x component of the left joystick
  12470. * @param leftStickY The y component of the left joystick
  12471. * @param rightStickX The x component of the right joystick
  12472. * @param rightStickY The y component of the right joystick
  12473. */
  12474. constructor(
  12475. /**
  12476. * The id of the gamepad
  12477. */
  12478. id: string,
  12479. /**
  12480. * The index of the gamepad
  12481. */
  12482. index: number,
  12483. /**
  12484. * The browser gamepad
  12485. */
  12486. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12487. /**
  12488. * Callback triggered when the left joystick has changed
  12489. * @param callback
  12490. */
  12491. onleftstickchanged(callback: (values: StickValues) => void): void;
  12492. /**
  12493. * Callback triggered when the right joystick has changed
  12494. * @param callback
  12495. */
  12496. onrightstickchanged(callback: (values: StickValues) => void): void;
  12497. /**
  12498. * Gets the left joystick
  12499. */
  12500. /**
  12501. * Sets the left joystick values
  12502. */
  12503. leftStick: StickValues;
  12504. /**
  12505. * Gets the right joystick
  12506. */
  12507. /**
  12508. * Sets the right joystick value
  12509. */
  12510. rightStick: StickValues;
  12511. /**
  12512. * Updates the gamepad joystick positions
  12513. */
  12514. update(): void;
  12515. /**
  12516. * Disposes the gamepad
  12517. */
  12518. dispose(): void;
  12519. }
  12520. /**
  12521. * Represents a generic gamepad
  12522. */
  12523. export class GenericPad extends Gamepad {
  12524. private _buttons;
  12525. private _onbuttondown;
  12526. private _onbuttonup;
  12527. /**
  12528. * Observable triggered when a button has been pressed
  12529. */
  12530. onButtonDownObservable: Observable<number>;
  12531. /**
  12532. * Observable triggered when a button has been released
  12533. */
  12534. onButtonUpObservable: Observable<number>;
  12535. /**
  12536. * Callback triggered when a button has been pressed
  12537. * @param callback Called when a button has been pressed
  12538. */
  12539. onbuttondown(callback: (buttonPressed: number) => void): void;
  12540. /**
  12541. * Callback triggered when a button has been released
  12542. * @param callback Called when a button has been released
  12543. */
  12544. onbuttonup(callback: (buttonReleased: number) => void): void;
  12545. /**
  12546. * Initializes the generic gamepad
  12547. * @param id The id of the generic gamepad
  12548. * @param index The index of the generic gamepad
  12549. * @param browserGamepad The browser gamepad
  12550. */
  12551. constructor(id: string, index: number, browserGamepad: any);
  12552. private _setButtonValue;
  12553. /**
  12554. * Updates the generic gamepad
  12555. */
  12556. update(): void;
  12557. /**
  12558. * Disposes the generic gamepad
  12559. */
  12560. dispose(): void;
  12561. }
  12562. }
  12563. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12564. import { Nullable } from "babylonjs/types";
  12565. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12566. import { Scene } from "babylonjs/scene";
  12567. module "babylonjs/Engines/engine" {
  12568. interface Engine {
  12569. /**
  12570. * Creates a raw texture
  12571. * @param data defines the data to store in the texture
  12572. * @param width defines the width of the texture
  12573. * @param height defines the height of the texture
  12574. * @param format defines the format of the data
  12575. * @param generateMipMaps defines if the engine should generate the mip levels
  12576. * @param invertY defines if data must be stored with Y axis inverted
  12577. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12578. * @param compression defines the compression used (null by default)
  12579. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12580. * @returns the raw texture inside an InternalTexture
  12581. */
  12582. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12583. /**
  12584. * Update a raw texture
  12585. * @param texture defines the texture to update
  12586. * @param data defines the data to store in the texture
  12587. * @param format defines the format of the data
  12588. * @param invertY defines if data must be stored with Y axis inverted
  12589. */
  12590. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12591. /**
  12592. * Update a raw texture
  12593. * @param texture defines the texture to update
  12594. * @param data defines the data to store in the texture
  12595. * @param format defines the format of the data
  12596. * @param invertY defines if data must be stored with Y axis inverted
  12597. * @param compression defines the compression used (null by default)
  12598. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12599. */
  12600. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12601. /**
  12602. * Creates a new raw cube texture
  12603. * @param data defines the array of data to use to create each face
  12604. * @param size defines the size of the textures
  12605. * @param format defines the format of the data
  12606. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12607. * @param generateMipMaps defines if the engine should generate the mip levels
  12608. * @param invertY defines if data must be stored with Y axis inverted
  12609. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12610. * @param compression defines the compression used (null by default)
  12611. * @returns the cube texture as an InternalTexture
  12612. */
  12613. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12614. /**
  12615. * Update a raw cube texture
  12616. * @param texture defines the texture to udpdate
  12617. * @param data defines the data to store
  12618. * @param format defines the data format
  12619. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12620. * @param invertY defines if data must be stored with Y axis inverted
  12621. */
  12622. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12623. /**
  12624. * Update a raw cube texture
  12625. * @param texture defines the texture to udpdate
  12626. * @param data defines the data to store
  12627. * @param format defines the data format
  12628. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12629. * @param invertY defines if data must be stored with Y axis inverted
  12630. * @param compression defines the compression used (null by default)
  12631. */
  12632. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12633. /**
  12634. * Update a raw cube texture
  12635. * @param texture defines the texture to udpdate
  12636. * @param data defines the data to store
  12637. * @param format defines the data format
  12638. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12639. * @param invertY defines if data must be stored with Y axis inverted
  12640. * @param compression defines the compression used (null by default)
  12641. * @param level defines which level of the texture to update
  12642. */
  12643. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12644. /**
  12645. * Creates a new raw cube texture from a specified url
  12646. * @param url defines the url where the data is located
  12647. * @param scene defines the current scene
  12648. * @param size defines the size of the textures
  12649. * @param format defines the format of the data
  12650. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12651. * @param noMipmap defines if the engine should avoid generating the mip levels
  12652. * @param callback defines a callback used to extract texture data from loaded data
  12653. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12654. * @param onLoad defines a callback called when texture is loaded
  12655. * @param onError defines a callback called if there is an error
  12656. * @returns the cube texture as an InternalTexture
  12657. */
  12658. 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;
  12659. /**
  12660. * Creates a new raw cube texture from a specified url
  12661. * @param url defines the url where the data is located
  12662. * @param scene defines the current scene
  12663. * @param size defines the size of the textures
  12664. * @param format defines the format of the data
  12665. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12666. * @param noMipmap defines if the engine should avoid generating the mip levels
  12667. * @param callback defines a callback used to extract texture data from loaded data
  12668. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12669. * @param onLoad defines a callback called when texture is loaded
  12670. * @param onError defines a callback called if there is an error
  12671. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12672. * @param invertY defines if data must be stored with Y axis inverted
  12673. * @returns the cube texture as an InternalTexture
  12674. */
  12675. 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;
  12676. /**
  12677. * Creates a new raw 3D texture
  12678. * @param data defines the data used to create the texture
  12679. * @param width defines the width of the texture
  12680. * @param height defines the height of the texture
  12681. * @param depth defines the depth of the texture
  12682. * @param format defines the format of the texture
  12683. * @param generateMipMaps defines if the engine must generate mip levels
  12684. * @param invertY defines if data must be stored with Y axis inverted
  12685. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12686. * @param compression defines the compressed used (can be null)
  12687. * @param textureType defines the compressed used (can be null)
  12688. * @returns a new raw 3D texture (stored in an InternalTexture)
  12689. */
  12690. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12691. /**
  12692. * Update a raw 3D texture
  12693. * @param texture defines the texture to update
  12694. * @param data defines the data to store
  12695. * @param format defines the data format
  12696. * @param invertY defines if data must be stored with Y axis inverted
  12697. */
  12698. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12699. /**
  12700. * Update a raw 3D texture
  12701. * @param texture defines the texture to update
  12702. * @param data defines the data to store
  12703. * @param format defines the data format
  12704. * @param invertY defines if data must be stored with Y axis inverted
  12705. * @param compression defines the used compression (can be null)
  12706. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12707. */
  12708. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12709. }
  12710. }
  12711. }
  12712. declare module "babylonjs/Materials/Textures/rawTexture" {
  12713. import { Scene } from "babylonjs/scene";
  12714. import { Texture } from "babylonjs/Materials/Textures/texture";
  12715. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12716. /**
  12717. * Raw texture can help creating a texture directly from an array of data.
  12718. * This can be super useful if you either get the data from an uncompressed source or
  12719. * if you wish to create your texture pixel by pixel.
  12720. */
  12721. export class RawTexture extends Texture {
  12722. /**
  12723. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12724. */
  12725. format: number;
  12726. private _engine;
  12727. /**
  12728. * Instantiates a new RawTexture.
  12729. * Raw texture can help creating a texture directly from an array of data.
  12730. * This can be super useful if you either get the data from an uncompressed source or
  12731. * if you wish to create your texture pixel by pixel.
  12732. * @param data define the array of data to use to create the texture
  12733. * @param width define the width of the texture
  12734. * @param height define the height of the texture
  12735. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12736. * @param scene define the scene the texture belongs to
  12737. * @param generateMipMaps define whether mip maps should be generated or not
  12738. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12739. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12740. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12741. */
  12742. constructor(data: ArrayBufferView, width: number, height: number,
  12743. /**
  12744. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12745. */
  12746. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12747. /**
  12748. * Updates the texture underlying data.
  12749. * @param data Define the new data of the texture
  12750. */
  12751. update(data: ArrayBufferView): void;
  12752. /**
  12753. * Creates a luminance texture from some data.
  12754. * @param data Define the texture data
  12755. * @param width Define the width of the texture
  12756. * @param height Define the height of the texture
  12757. * @param scene Define the scene the texture belongs to
  12758. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12759. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12760. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12761. * @returns the luminance texture
  12762. */
  12763. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12764. /**
  12765. * Creates a luminance alpha texture from some data.
  12766. * @param data Define the texture data
  12767. * @param width Define the width of the texture
  12768. * @param height Define the height of the texture
  12769. * @param scene Define the scene the texture belongs to
  12770. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12771. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12772. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12773. * @returns the luminance alpha texture
  12774. */
  12775. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12776. /**
  12777. * Creates an alpha texture from some data.
  12778. * @param data Define the texture data
  12779. * @param width Define the width of the texture
  12780. * @param height Define the height of the texture
  12781. * @param scene Define the scene the texture belongs to
  12782. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12783. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12784. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12785. * @returns the alpha texture
  12786. */
  12787. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12788. /**
  12789. * Creates a RGB texture from some data.
  12790. * @param data Define the texture data
  12791. * @param width Define the width of the texture
  12792. * @param height Define the height of the texture
  12793. * @param scene Define the scene the texture belongs to
  12794. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12795. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12796. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12797. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12798. * @returns the RGB alpha texture
  12799. */
  12800. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12801. /**
  12802. * Creates a RGBA texture from some data.
  12803. * @param data Define the texture data
  12804. * @param width Define the width of the texture
  12805. * @param height Define the height of the texture
  12806. * @param scene Define the scene the texture belongs to
  12807. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12808. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12809. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12810. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12811. * @returns the RGBA texture
  12812. */
  12813. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12814. /**
  12815. * Creates a R texture from some data.
  12816. * @param data Define the texture data
  12817. * @param width Define the width of the texture
  12818. * @param height Define the height of the texture
  12819. * @param scene Define the scene the texture belongs to
  12820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12823. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12824. * @returns the R texture
  12825. */
  12826. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12827. }
  12828. }
  12829. declare module "babylonjs/Maths/math.size" {
  12830. /**
  12831. * Interface for the size containing width and height
  12832. */
  12833. export interface ISize {
  12834. /**
  12835. * Width
  12836. */
  12837. width: number;
  12838. /**
  12839. * Heighht
  12840. */
  12841. height: number;
  12842. }
  12843. /**
  12844. * Size containing widht and height
  12845. */
  12846. export class Size implements ISize {
  12847. /**
  12848. * Width
  12849. */
  12850. width: number;
  12851. /**
  12852. * Height
  12853. */
  12854. height: number;
  12855. /**
  12856. * Creates a Size object from the given width and height (floats).
  12857. * @param width width of the new size
  12858. * @param height height of the new size
  12859. */
  12860. constructor(width: number, height: number);
  12861. /**
  12862. * Returns a string with the Size width and height
  12863. * @returns a string with the Size width and height
  12864. */
  12865. toString(): string;
  12866. /**
  12867. * "Size"
  12868. * @returns the string "Size"
  12869. */
  12870. getClassName(): string;
  12871. /**
  12872. * Returns the Size hash code.
  12873. * @returns a hash code for a unique width and height
  12874. */
  12875. getHashCode(): number;
  12876. /**
  12877. * Updates the current size from the given one.
  12878. * @param src the given size
  12879. */
  12880. copyFrom(src: Size): void;
  12881. /**
  12882. * Updates in place the current Size from the given floats.
  12883. * @param width width of the new size
  12884. * @param height height of the new size
  12885. * @returns the updated Size.
  12886. */
  12887. copyFromFloats(width: number, height: number): Size;
  12888. /**
  12889. * Updates in place the current Size from the given floats.
  12890. * @param width width to set
  12891. * @param height height to set
  12892. * @returns the updated Size.
  12893. */
  12894. set(width: number, height: number): Size;
  12895. /**
  12896. * Multiplies the width and height by numbers
  12897. * @param w factor to multiple the width by
  12898. * @param h factor to multiple the height by
  12899. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12900. */
  12901. multiplyByFloats(w: number, h: number): Size;
  12902. /**
  12903. * Clones the size
  12904. * @returns a new Size copied from the given one.
  12905. */
  12906. clone(): Size;
  12907. /**
  12908. * True if the current Size and the given one width and height are strictly equal.
  12909. * @param other the other size to compare against
  12910. * @returns True if the current Size and the given one width and height are strictly equal.
  12911. */
  12912. equals(other: Size): boolean;
  12913. /**
  12914. * The surface of the Size : width * height (float).
  12915. */
  12916. readonly surface: number;
  12917. /**
  12918. * Create a new size of zero
  12919. * @returns a new Size set to (0.0, 0.0)
  12920. */
  12921. static Zero(): Size;
  12922. /**
  12923. * Sums the width and height of two sizes
  12924. * @param otherSize size to add to this size
  12925. * @returns a new Size set as the addition result of the current Size and the given one.
  12926. */
  12927. add(otherSize: Size): Size;
  12928. /**
  12929. * Subtracts the width and height of two
  12930. * @param otherSize size to subtract to this size
  12931. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12932. */
  12933. subtract(otherSize: Size): Size;
  12934. /**
  12935. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12936. * @param start starting size to lerp between
  12937. * @param end end size to lerp between
  12938. * @param amount amount to lerp between the start and end values
  12939. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12940. */
  12941. static Lerp(start: Size, end: Size, amount: number): Size;
  12942. }
  12943. }
  12944. declare module "babylonjs/Animations/runtimeAnimation" {
  12945. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12946. import { Animatable } from "babylonjs/Animations/animatable";
  12947. import { Scene } from "babylonjs/scene";
  12948. /**
  12949. * Defines a runtime animation
  12950. */
  12951. export class RuntimeAnimation {
  12952. private _events;
  12953. /**
  12954. * The current frame of the runtime animation
  12955. */
  12956. private _currentFrame;
  12957. /**
  12958. * The animation used by the runtime animation
  12959. */
  12960. private _animation;
  12961. /**
  12962. * The target of the runtime animation
  12963. */
  12964. private _target;
  12965. /**
  12966. * The initiating animatable
  12967. */
  12968. private _host;
  12969. /**
  12970. * The original value of the runtime animation
  12971. */
  12972. private _originalValue;
  12973. /**
  12974. * The original blend value of the runtime animation
  12975. */
  12976. private _originalBlendValue;
  12977. /**
  12978. * The offsets cache of the runtime animation
  12979. */
  12980. private _offsetsCache;
  12981. /**
  12982. * The high limits cache of the runtime animation
  12983. */
  12984. private _highLimitsCache;
  12985. /**
  12986. * Specifies if the runtime animation has been stopped
  12987. */
  12988. private _stopped;
  12989. /**
  12990. * The blending factor of the runtime animation
  12991. */
  12992. private _blendingFactor;
  12993. /**
  12994. * The BabylonJS scene
  12995. */
  12996. private _scene;
  12997. /**
  12998. * The current value of the runtime animation
  12999. */
  13000. private _currentValue;
  13001. /** @hidden */
  13002. _animationState: _IAnimationState;
  13003. /**
  13004. * The active target of the runtime animation
  13005. */
  13006. private _activeTargets;
  13007. private _currentActiveTarget;
  13008. private _directTarget;
  13009. /**
  13010. * The target path of the runtime animation
  13011. */
  13012. private _targetPath;
  13013. /**
  13014. * The weight of the runtime animation
  13015. */
  13016. private _weight;
  13017. /**
  13018. * The ratio offset of the runtime animation
  13019. */
  13020. private _ratioOffset;
  13021. /**
  13022. * The previous delay of the runtime animation
  13023. */
  13024. private _previousDelay;
  13025. /**
  13026. * The previous ratio of the runtime animation
  13027. */
  13028. private _previousRatio;
  13029. private _enableBlending;
  13030. private _keys;
  13031. private _minFrame;
  13032. private _maxFrame;
  13033. private _minValue;
  13034. private _maxValue;
  13035. private _targetIsArray;
  13036. /**
  13037. * Gets the current frame of the runtime animation
  13038. */
  13039. readonly currentFrame: number;
  13040. /**
  13041. * Gets the weight of the runtime animation
  13042. */
  13043. readonly weight: number;
  13044. /**
  13045. * Gets the current value of the runtime animation
  13046. */
  13047. readonly currentValue: any;
  13048. /**
  13049. * Gets the target path of the runtime animation
  13050. */
  13051. readonly targetPath: string;
  13052. /**
  13053. * Gets the actual target of the runtime animation
  13054. */
  13055. readonly target: any;
  13056. /** @hidden */
  13057. _onLoop: () => void;
  13058. /**
  13059. * Create a new RuntimeAnimation object
  13060. * @param target defines the target of the animation
  13061. * @param animation defines the source animation object
  13062. * @param scene defines the hosting scene
  13063. * @param host defines the initiating Animatable
  13064. */
  13065. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13066. private _preparePath;
  13067. /**
  13068. * Gets the animation from the runtime animation
  13069. */
  13070. readonly animation: Animation;
  13071. /**
  13072. * Resets the runtime animation to the beginning
  13073. * @param restoreOriginal defines whether to restore the target property to the original value
  13074. */
  13075. reset(restoreOriginal?: boolean): void;
  13076. /**
  13077. * Specifies if the runtime animation is stopped
  13078. * @returns Boolean specifying if the runtime animation is stopped
  13079. */
  13080. isStopped(): boolean;
  13081. /**
  13082. * Disposes of the runtime animation
  13083. */
  13084. dispose(): void;
  13085. /**
  13086. * Apply the interpolated value to the target
  13087. * @param currentValue defines the value computed by the animation
  13088. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13089. */
  13090. setValue(currentValue: any, weight: number): void;
  13091. private _getOriginalValues;
  13092. private _setValue;
  13093. /**
  13094. * Gets the loop pmode of the runtime animation
  13095. * @returns Loop Mode
  13096. */
  13097. private _getCorrectLoopMode;
  13098. /**
  13099. * Move the current animation to a given frame
  13100. * @param frame defines the frame to move to
  13101. */
  13102. goToFrame(frame: number): void;
  13103. /**
  13104. * @hidden Internal use only
  13105. */
  13106. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13107. /**
  13108. * Execute the current animation
  13109. * @param delay defines the delay to add to the current frame
  13110. * @param from defines the lower bound of the animation range
  13111. * @param to defines the upper bound of the animation range
  13112. * @param loop defines if the current animation must loop
  13113. * @param speedRatio defines the current speed ratio
  13114. * @param weight defines the weight of the animation (default is -1 so no weight)
  13115. * @param onLoop optional callback called when animation loops
  13116. * @returns a boolean indicating if the animation is running
  13117. */
  13118. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13119. }
  13120. }
  13121. declare module "babylonjs/Animations/animatable" {
  13122. import { Animation } from "babylonjs/Animations/animation";
  13123. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13124. import { Nullable } from "babylonjs/types";
  13125. import { Observable } from "babylonjs/Misc/observable";
  13126. import { Scene } from "babylonjs/scene";
  13127. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13128. import { Node } from "babylonjs/node";
  13129. /**
  13130. * Class used to store an actual running animation
  13131. */
  13132. export class Animatable {
  13133. /** defines the target object */
  13134. target: any;
  13135. /** defines the starting frame number (default is 0) */
  13136. fromFrame: number;
  13137. /** defines the ending frame number (default is 100) */
  13138. toFrame: number;
  13139. /** defines if the animation must loop (default is false) */
  13140. loopAnimation: boolean;
  13141. /** defines a callback to call when animation ends if it is not looping */
  13142. onAnimationEnd?: (() => void) | null | undefined;
  13143. /** defines a callback to call when animation loops */
  13144. onAnimationLoop?: (() => void) | null | undefined;
  13145. private _localDelayOffset;
  13146. private _pausedDelay;
  13147. private _runtimeAnimations;
  13148. private _paused;
  13149. private _scene;
  13150. private _speedRatio;
  13151. private _weight;
  13152. private _syncRoot;
  13153. /**
  13154. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13155. * This will only apply for non looping animation (default is true)
  13156. */
  13157. disposeOnEnd: boolean;
  13158. /**
  13159. * Gets a boolean indicating if the animation has started
  13160. */
  13161. animationStarted: boolean;
  13162. /**
  13163. * Observer raised when the animation ends
  13164. */
  13165. onAnimationEndObservable: Observable<Animatable>;
  13166. /**
  13167. * Observer raised when the animation loops
  13168. */
  13169. onAnimationLoopObservable: Observable<Animatable>;
  13170. /**
  13171. * Gets the root Animatable used to synchronize and normalize animations
  13172. */
  13173. readonly syncRoot: Nullable<Animatable>;
  13174. /**
  13175. * Gets the current frame of the first RuntimeAnimation
  13176. * Used to synchronize Animatables
  13177. */
  13178. readonly masterFrame: number;
  13179. /**
  13180. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13181. */
  13182. weight: number;
  13183. /**
  13184. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13185. */
  13186. speedRatio: number;
  13187. /**
  13188. * Creates a new Animatable
  13189. * @param scene defines the hosting scene
  13190. * @param target defines the target object
  13191. * @param fromFrame defines the starting frame number (default is 0)
  13192. * @param toFrame defines the ending frame number (default is 100)
  13193. * @param loopAnimation defines if the animation must loop (default is false)
  13194. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13195. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13196. * @param animations defines a group of animation to add to the new Animatable
  13197. * @param onAnimationLoop defines a callback to call when animation loops
  13198. */
  13199. constructor(scene: Scene,
  13200. /** defines the target object */
  13201. target: any,
  13202. /** defines the starting frame number (default is 0) */
  13203. fromFrame?: number,
  13204. /** defines the ending frame number (default is 100) */
  13205. toFrame?: number,
  13206. /** defines if the animation must loop (default is false) */
  13207. loopAnimation?: boolean, speedRatio?: number,
  13208. /** defines a callback to call when animation ends if it is not looping */
  13209. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13210. /** defines a callback to call when animation loops */
  13211. onAnimationLoop?: (() => void) | null | undefined);
  13212. /**
  13213. * Synchronize and normalize current Animatable with a source Animatable
  13214. * This is useful when using animation weights and when animations are not of the same length
  13215. * @param root defines the root Animatable to synchronize with
  13216. * @returns the current Animatable
  13217. */
  13218. syncWith(root: Animatable): Animatable;
  13219. /**
  13220. * Gets the list of runtime animations
  13221. * @returns an array of RuntimeAnimation
  13222. */
  13223. getAnimations(): RuntimeAnimation[];
  13224. /**
  13225. * Adds more animations to the current animatable
  13226. * @param target defines the target of the animations
  13227. * @param animations defines the new animations to add
  13228. */
  13229. appendAnimations(target: any, animations: Animation[]): void;
  13230. /**
  13231. * Gets the source animation for a specific property
  13232. * @param property defines the propertyu to look for
  13233. * @returns null or the source animation for the given property
  13234. */
  13235. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13236. /**
  13237. * Gets the runtime animation for a specific property
  13238. * @param property defines the propertyu to look for
  13239. * @returns null or the runtime animation for the given property
  13240. */
  13241. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13242. /**
  13243. * Resets the animatable to its original state
  13244. */
  13245. reset(): void;
  13246. /**
  13247. * Allows the animatable to blend with current running animations
  13248. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13249. * @param blendingSpeed defines the blending speed to use
  13250. */
  13251. enableBlending(blendingSpeed: number): void;
  13252. /**
  13253. * Disable animation blending
  13254. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13255. */
  13256. disableBlending(): void;
  13257. /**
  13258. * Jump directly to a given frame
  13259. * @param frame defines the frame to jump to
  13260. */
  13261. goToFrame(frame: number): void;
  13262. /**
  13263. * Pause the animation
  13264. */
  13265. pause(): void;
  13266. /**
  13267. * Restart the animation
  13268. */
  13269. restart(): void;
  13270. private _raiseOnAnimationEnd;
  13271. /**
  13272. * Stop and delete the current animation
  13273. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13274. * @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)
  13275. */
  13276. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13277. /**
  13278. * Wait asynchronously for the animation to end
  13279. * @returns a promise which will be fullfilled when the animation ends
  13280. */
  13281. waitAsync(): Promise<Animatable>;
  13282. /** @hidden */
  13283. _animate(delay: number): boolean;
  13284. }
  13285. module "babylonjs/scene" {
  13286. interface Scene {
  13287. /** @hidden */
  13288. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13289. /** @hidden */
  13290. _processLateAnimationBindingsForMatrices(holder: {
  13291. totalWeight: number;
  13292. animations: RuntimeAnimation[];
  13293. originalValue: Matrix;
  13294. }): any;
  13295. /** @hidden */
  13296. _processLateAnimationBindingsForQuaternions(holder: {
  13297. totalWeight: number;
  13298. animations: RuntimeAnimation[];
  13299. originalValue: Quaternion;
  13300. }, refQuaternion: Quaternion): Quaternion;
  13301. /** @hidden */
  13302. _processLateAnimationBindings(): void;
  13303. /**
  13304. * Will start the animation sequence of a given target
  13305. * @param target defines the target
  13306. * @param from defines from which frame should animation start
  13307. * @param to defines until which frame should animation run.
  13308. * @param weight defines the weight to apply to the animation (1.0 by default)
  13309. * @param loop defines if the animation loops
  13310. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13311. * @param onAnimationEnd defines the function to be executed when the animation ends
  13312. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13313. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13314. * @param onAnimationLoop defines the callback to call when an animation loops
  13315. * @returns the animatable object created for this animation
  13316. */
  13317. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13318. /**
  13319. * Will start the animation sequence of a given target
  13320. * @param target defines the target
  13321. * @param from defines from which frame should animation start
  13322. * @param to defines until which frame should animation run.
  13323. * @param loop defines if the animation loops
  13324. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13325. * @param onAnimationEnd defines the function to be executed when the animation ends
  13326. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13327. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13328. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13329. * @param onAnimationLoop defines the callback to call when an animation loops
  13330. * @returns the animatable object created for this animation
  13331. */
  13332. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13333. /**
  13334. * Will start the animation sequence of a given target and its hierarchy
  13335. * @param target defines the target
  13336. * @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.
  13337. * @param from defines from which frame should animation start
  13338. * @param to defines until which frame should animation run.
  13339. * @param loop defines if the animation loops
  13340. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13341. * @param onAnimationEnd defines the function to be executed when the animation ends
  13342. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13343. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13344. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13345. * @param onAnimationLoop defines the callback to call when an animation loops
  13346. * @returns the list of created animatables
  13347. */
  13348. 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[];
  13349. /**
  13350. * Begin a new animation on a given node
  13351. * @param target defines the target where the animation will take place
  13352. * @param animations defines the list of animations to start
  13353. * @param from defines the initial value
  13354. * @param to defines the final value
  13355. * @param loop defines if you want animation to loop (off by default)
  13356. * @param speedRatio defines the speed ratio to apply to all animations
  13357. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13358. * @param onAnimationLoop defines the callback to call when an animation loops
  13359. * @returns the list of created animatables
  13360. */
  13361. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13362. /**
  13363. * Begin a new animation on a given node and its hierarchy
  13364. * @param target defines the root node where the animation will take place
  13365. * @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.
  13366. * @param animations defines the list of animations to start
  13367. * @param from defines the initial value
  13368. * @param to defines the final value
  13369. * @param loop defines if you want animation to loop (off by default)
  13370. * @param speedRatio defines the speed ratio to apply to all animations
  13371. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13372. * @param onAnimationLoop defines the callback to call when an animation loops
  13373. * @returns the list of animatables created for all nodes
  13374. */
  13375. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13376. /**
  13377. * Gets the animatable associated with a specific target
  13378. * @param target defines the target of the animatable
  13379. * @returns the required animatable if found
  13380. */
  13381. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13382. /**
  13383. * Gets all animatables associated with a given target
  13384. * @param target defines the target to look animatables for
  13385. * @returns an array of Animatables
  13386. */
  13387. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13388. /**
  13389. * Stops and removes all animations that have been applied to the scene
  13390. */
  13391. stopAllAnimations(): void;
  13392. /**
  13393. * Gets the current delta time used by animation engine
  13394. */
  13395. deltaTime: number;
  13396. }
  13397. }
  13398. module "babylonjs/Bones/bone" {
  13399. interface Bone {
  13400. /**
  13401. * Copy an animation range from another bone
  13402. * @param source defines the source bone
  13403. * @param rangeName defines the range name to copy
  13404. * @param frameOffset defines the frame offset
  13405. * @param rescaleAsRequired defines if rescaling must be applied if required
  13406. * @param skelDimensionsRatio defines the scaling ratio
  13407. * @returns true if operation was successful
  13408. */
  13409. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13410. }
  13411. }
  13412. }
  13413. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13414. /**
  13415. * Class used to override all child animations of a given target
  13416. */
  13417. export class AnimationPropertiesOverride {
  13418. /**
  13419. * Gets or sets a value indicating if animation blending must be used
  13420. */
  13421. enableBlending: boolean;
  13422. /**
  13423. * Gets or sets the blending speed to use when enableBlending is true
  13424. */
  13425. blendingSpeed: number;
  13426. /**
  13427. * Gets or sets the default loop mode to use
  13428. */
  13429. loopMode: number;
  13430. }
  13431. }
  13432. declare module "babylonjs/Bones/skeleton" {
  13433. import { Bone } from "babylonjs/Bones/bone";
  13434. import { Observable } from "babylonjs/Misc/observable";
  13435. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13436. import { Scene } from "babylonjs/scene";
  13437. import { Nullable } from "babylonjs/types";
  13438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13439. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13440. import { Animatable } from "babylonjs/Animations/animatable";
  13441. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13442. import { Animation } from "babylonjs/Animations/animation";
  13443. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13444. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13445. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13446. /**
  13447. * Class used to handle skinning animations
  13448. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13449. */
  13450. export class Skeleton implements IAnimatable {
  13451. /** defines the skeleton name */
  13452. name: string;
  13453. /** defines the skeleton Id */
  13454. id: string;
  13455. /**
  13456. * Defines the list of child bones
  13457. */
  13458. bones: Bone[];
  13459. /**
  13460. * Defines an estimate of the dimension of the skeleton at rest
  13461. */
  13462. dimensionsAtRest: Vector3;
  13463. /**
  13464. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13465. */
  13466. needInitialSkinMatrix: boolean;
  13467. /**
  13468. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13469. */
  13470. overrideMesh: Nullable<AbstractMesh>;
  13471. /**
  13472. * Gets the list of animations attached to this skeleton
  13473. */
  13474. animations: Array<Animation>;
  13475. private _scene;
  13476. private _isDirty;
  13477. private _transformMatrices;
  13478. private _transformMatrixTexture;
  13479. private _meshesWithPoseMatrix;
  13480. private _animatables;
  13481. private _identity;
  13482. private _synchronizedWithMesh;
  13483. private _ranges;
  13484. private _lastAbsoluteTransformsUpdateId;
  13485. private _canUseTextureForBones;
  13486. private _uniqueId;
  13487. /** @hidden */
  13488. _numBonesWithLinkedTransformNode: number;
  13489. /** @hidden */
  13490. _hasWaitingData: Nullable<boolean>;
  13491. /**
  13492. * Specifies if the skeleton should be serialized
  13493. */
  13494. doNotSerialize: boolean;
  13495. private _useTextureToStoreBoneMatrices;
  13496. /**
  13497. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13498. * Please note that this option is not available if the hardware does not support it
  13499. */
  13500. useTextureToStoreBoneMatrices: boolean;
  13501. private _animationPropertiesOverride;
  13502. /**
  13503. * Gets or sets the animation properties override
  13504. */
  13505. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13506. /**
  13507. * List of inspectable custom properties (used by the Inspector)
  13508. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13509. */
  13510. inspectableCustomProperties: IInspectable[];
  13511. /**
  13512. * An observable triggered before computing the skeleton's matrices
  13513. */
  13514. onBeforeComputeObservable: Observable<Skeleton>;
  13515. /**
  13516. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13517. */
  13518. readonly isUsingTextureForMatrices: boolean;
  13519. /**
  13520. * Gets the unique ID of this skeleton
  13521. */
  13522. readonly uniqueId: number;
  13523. /**
  13524. * Creates a new skeleton
  13525. * @param name defines the skeleton name
  13526. * @param id defines the skeleton Id
  13527. * @param scene defines the hosting scene
  13528. */
  13529. constructor(
  13530. /** defines the skeleton name */
  13531. name: string,
  13532. /** defines the skeleton Id */
  13533. id: string, scene: Scene);
  13534. /**
  13535. * Gets the current object class name.
  13536. * @return the class name
  13537. */
  13538. getClassName(): string;
  13539. /**
  13540. * Returns an array containing the root bones
  13541. * @returns an array containing the root bones
  13542. */
  13543. getChildren(): Array<Bone>;
  13544. /**
  13545. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13546. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13547. * @returns a Float32Array containing matrices data
  13548. */
  13549. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13550. /**
  13551. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13552. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13553. * @returns a raw texture containing the data
  13554. */
  13555. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13556. /**
  13557. * Gets the current hosting scene
  13558. * @returns a scene object
  13559. */
  13560. getScene(): Scene;
  13561. /**
  13562. * Gets a string representing the current skeleton data
  13563. * @param fullDetails defines a boolean indicating if we want a verbose version
  13564. * @returns a string representing the current skeleton data
  13565. */
  13566. toString(fullDetails?: boolean): string;
  13567. /**
  13568. * Get bone's index searching by name
  13569. * @param name defines bone's name to search for
  13570. * @return the indice of the bone. Returns -1 if not found
  13571. */
  13572. getBoneIndexByName(name: string): number;
  13573. /**
  13574. * Creater a new animation range
  13575. * @param name defines the name of the range
  13576. * @param from defines the start key
  13577. * @param to defines the end key
  13578. */
  13579. createAnimationRange(name: string, from: number, to: number): void;
  13580. /**
  13581. * Delete a specific animation range
  13582. * @param name defines the name of the range
  13583. * @param deleteFrames defines if frames must be removed as well
  13584. */
  13585. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13586. /**
  13587. * Gets a specific animation range
  13588. * @param name defines the name of the range to look for
  13589. * @returns the requested animation range or null if not found
  13590. */
  13591. getAnimationRange(name: string): Nullable<AnimationRange>;
  13592. /**
  13593. * Gets the list of all animation ranges defined on this skeleton
  13594. * @returns an array
  13595. */
  13596. getAnimationRanges(): Nullable<AnimationRange>[];
  13597. /**
  13598. * Copy animation range from a source skeleton.
  13599. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13600. * @param source defines the source skeleton
  13601. * @param name defines the name of the range to copy
  13602. * @param rescaleAsRequired defines if rescaling must be applied if required
  13603. * @returns true if operation was successful
  13604. */
  13605. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13606. /**
  13607. * Forces the skeleton to go to rest pose
  13608. */
  13609. returnToRest(): void;
  13610. private _getHighestAnimationFrame;
  13611. /**
  13612. * Begin a specific animation range
  13613. * @param name defines the name of the range to start
  13614. * @param loop defines if looping must be turned on (false by default)
  13615. * @param speedRatio defines the speed ratio to apply (1 by default)
  13616. * @param onAnimationEnd defines a callback which will be called when animation will end
  13617. * @returns a new animatable
  13618. */
  13619. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13620. /** @hidden */
  13621. _markAsDirty(): void;
  13622. /** @hidden */
  13623. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13624. /** @hidden */
  13625. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13626. private _computeTransformMatrices;
  13627. /**
  13628. * Build all resources required to render a skeleton
  13629. */
  13630. prepare(): void;
  13631. /**
  13632. * Gets the list of animatables currently running for this skeleton
  13633. * @returns an array of animatables
  13634. */
  13635. getAnimatables(): IAnimatable[];
  13636. /**
  13637. * Clone the current skeleton
  13638. * @param name defines the name of the new skeleton
  13639. * @param id defines the id of the new skeleton
  13640. * @returns the new skeleton
  13641. */
  13642. clone(name: string, id: string): Skeleton;
  13643. /**
  13644. * Enable animation blending for this skeleton
  13645. * @param blendingSpeed defines the blending speed to apply
  13646. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13647. */
  13648. enableBlending(blendingSpeed?: number): void;
  13649. /**
  13650. * Releases all resources associated with the current skeleton
  13651. */
  13652. dispose(): void;
  13653. /**
  13654. * Serialize the skeleton in a JSON object
  13655. * @returns a JSON object
  13656. */
  13657. serialize(): any;
  13658. /**
  13659. * Creates a new skeleton from serialized data
  13660. * @param parsedSkeleton defines the serialized data
  13661. * @param scene defines the hosting scene
  13662. * @returns a new skeleton
  13663. */
  13664. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13665. /**
  13666. * Compute all node absolute transforms
  13667. * @param forceUpdate defines if computation must be done even if cache is up to date
  13668. */
  13669. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13670. /**
  13671. * Gets the root pose matrix
  13672. * @returns a matrix
  13673. */
  13674. getPoseMatrix(): Nullable<Matrix>;
  13675. /**
  13676. * Sorts bones per internal index
  13677. */
  13678. sortBones(): void;
  13679. private _sortBones;
  13680. }
  13681. }
  13682. declare module "babylonjs/Bones/bone" {
  13683. import { Skeleton } from "babylonjs/Bones/skeleton";
  13684. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13685. import { Nullable } from "babylonjs/types";
  13686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13687. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13688. import { Node } from "babylonjs/node";
  13689. import { Space } from "babylonjs/Maths/math.axis";
  13690. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13691. /**
  13692. * Class used to store bone information
  13693. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13694. */
  13695. export class Bone extends Node {
  13696. /**
  13697. * defines the bone name
  13698. */
  13699. name: string;
  13700. private static _tmpVecs;
  13701. private static _tmpQuat;
  13702. private static _tmpMats;
  13703. /**
  13704. * Gets the list of child bones
  13705. */
  13706. children: Bone[];
  13707. /** Gets the animations associated with this bone */
  13708. animations: import("babylonjs/Animations/animation").Animation[];
  13709. /**
  13710. * Gets or sets bone length
  13711. */
  13712. length: number;
  13713. /**
  13714. * @hidden Internal only
  13715. * Set this value to map this bone to a different index in the transform matrices
  13716. * Set this value to -1 to exclude the bone from the transform matrices
  13717. */
  13718. _index: Nullable<number>;
  13719. private _skeleton;
  13720. private _localMatrix;
  13721. private _restPose;
  13722. private _baseMatrix;
  13723. private _absoluteTransform;
  13724. private _invertedAbsoluteTransform;
  13725. private _parent;
  13726. private _scalingDeterminant;
  13727. private _worldTransform;
  13728. private _localScaling;
  13729. private _localRotation;
  13730. private _localPosition;
  13731. private _needToDecompose;
  13732. private _needToCompose;
  13733. /** @hidden */
  13734. _linkedTransformNode: Nullable<TransformNode>;
  13735. /** @hidden */
  13736. _waitingTransformNodeId: Nullable<string>;
  13737. /** @hidden */
  13738. /** @hidden */
  13739. _matrix: Matrix;
  13740. /**
  13741. * Create a new bone
  13742. * @param name defines the bone name
  13743. * @param skeleton defines the parent skeleton
  13744. * @param parentBone defines the parent (can be null if the bone is the root)
  13745. * @param localMatrix defines the local matrix
  13746. * @param restPose defines the rest pose matrix
  13747. * @param baseMatrix defines the base matrix
  13748. * @param index defines index of the bone in the hiearchy
  13749. */
  13750. constructor(
  13751. /**
  13752. * defines the bone name
  13753. */
  13754. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13755. /**
  13756. * Gets the current object class name.
  13757. * @return the class name
  13758. */
  13759. getClassName(): string;
  13760. /**
  13761. * Gets the parent skeleton
  13762. * @returns a skeleton
  13763. */
  13764. getSkeleton(): Skeleton;
  13765. /**
  13766. * Gets parent bone
  13767. * @returns a bone or null if the bone is the root of the bone hierarchy
  13768. */
  13769. getParent(): Nullable<Bone>;
  13770. /**
  13771. * Returns an array containing the root bones
  13772. * @returns an array containing the root bones
  13773. */
  13774. getChildren(): Array<Bone>;
  13775. /**
  13776. * Sets the parent bone
  13777. * @param parent defines the parent (can be null if the bone is the root)
  13778. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13779. */
  13780. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13781. /**
  13782. * Gets the local matrix
  13783. * @returns a matrix
  13784. */
  13785. getLocalMatrix(): Matrix;
  13786. /**
  13787. * Gets the base matrix (initial matrix which remains unchanged)
  13788. * @returns a matrix
  13789. */
  13790. getBaseMatrix(): Matrix;
  13791. /**
  13792. * Gets the rest pose matrix
  13793. * @returns a matrix
  13794. */
  13795. getRestPose(): Matrix;
  13796. /**
  13797. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13798. */
  13799. getWorldMatrix(): Matrix;
  13800. /**
  13801. * Sets the local matrix to rest pose matrix
  13802. */
  13803. returnToRest(): void;
  13804. /**
  13805. * Gets the inverse of the absolute transform matrix.
  13806. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13807. * @returns a matrix
  13808. */
  13809. getInvertedAbsoluteTransform(): Matrix;
  13810. /**
  13811. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13812. * @returns a matrix
  13813. */
  13814. getAbsoluteTransform(): Matrix;
  13815. /**
  13816. * Links with the given transform node.
  13817. * The local matrix of this bone is copied from the transform node every frame.
  13818. * @param transformNode defines the transform node to link to
  13819. */
  13820. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13821. /**
  13822. * Gets the node used to drive the bone's transformation
  13823. * @returns a transform node or null
  13824. */
  13825. getTransformNode(): Nullable<TransformNode>;
  13826. /** Gets or sets current position (in local space) */
  13827. position: Vector3;
  13828. /** Gets or sets current rotation (in local space) */
  13829. rotation: Vector3;
  13830. /** Gets or sets current rotation quaternion (in local space) */
  13831. rotationQuaternion: Quaternion;
  13832. /** Gets or sets current scaling (in local space) */
  13833. scaling: Vector3;
  13834. /**
  13835. * Gets the animation properties override
  13836. */
  13837. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13838. private _decompose;
  13839. private _compose;
  13840. /**
  13841. * Update the base and local matrices
  13842. * @param matrix defines the new base or local matrix
  13843. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13844. * @param updateLocalMatrix defines if the local matrix should be updated
  13845. */
  13846. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13847. /** @hidden */
  13848. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13849. /**
  13850. * Flag the bone as dirty (Forcing it to update everything)
  13851. */
  13852. markAsDirty(): void;
  13853. /** @hidden */
  13854. _markAsDirtyAndCompose(): void;
  13855. private _markAsDirtyAndDecompose;
  13856. /**
  13857. * Translate the bone in local or world space
  13858. * @param vec The amount to translate the bone
  13859. * @param space The space that the translation is in
  13860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13861. */
  13862. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13863. /**
  13864. * Set the postion of the bone in local or world space
  13865. * @param position The position to set the bone
  13866. * @param space The space that the position is in
  13867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13868. */
  13869. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13870. /**
  13871. * Set the absolute position of the bone (world space)
  13872. * @param position The position to set the bone
  13873. * @param mesh The mesh that this bone is attached to
  13874. */
  13875. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13876. /**
  13877. * Scale the bone on the x, y and z axes (in local space)
  13878. * @param x The amount to scale the bone on the x axis
  13879. * @param y The amount to scale the bone on the y axis
  13880. * @param z The amount to scale the bone on the z axis
  13881. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13882. */
  13883. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13884. /**
  13885. * Set the bone scaling in local space
  13886. * @param scale defines the scaling vector
  13887. */
  13888. setScale(scale: Vector3): void;
  13889. /**
  13890. * Gets the current scaling in local space
  13891. * @returns the current scaling vector
  13892. */
  13893. getScale(): Vector3;
  13894. /**
  13895. * Gets the current scaling in local space and stores it in a target vector
  13896. * @param result defines the target vector
  13897. */
  13898. getScaleToRef(result: Vector3): void;
  13899. /**
  13900. * Set the yaw, pitch, and roll of the bone in local or world space
  13901. * @param yaw The rotation of the bone on the y axis
  13902. * @param pitch The rotation of the bone on the x axis
  13903. * @param roll The rotation of the bone on the z axis
  13904. * @param space The space that the axes of rotation are in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. */
  13907. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13908. /**
  13909. * Add a rotation to the bone on an axis in local or world space
  13910. * @param axis The axis to rotate the bone on
  13911. * @param amount The amount to rotate the bone
  13912. * @param space The space that the axis is in
  13913. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13914. */
  13915. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13916. /**
  13917. * Set the rotation of the bone to a particular axis angle in local or world space
  13918. * @param axis The axis to rotate the bone on
  13919. * @param angle The angle that the bone should be rotated to
  13920. * @param space The space that the axis is in
  13921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13922. */
  13923. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13924. /**
  13925. * Set the euler rotation of the bone in local of world space
  13926. * @param rotation The euler rotation that the bone should be set to
  13927. * @param space The space that the rotation is in
  13928. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13929. */
  13930. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13931. /**
  13932. * Set the quaternion rotation of the bone in local of world space
  13933. * @param quat The quaternion rotation that the bone should be set to
  13934. * @param space The space that the rotation is in
  13935. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13936. */
  13937. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13938. /**
  13939. * Set the rotation matrix of the bone in local of world space
  13940. * @param rotMat The rotation matrix that the bone should be set to
  13941. * @param space The space that the rotation is in
  13942. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13943. */
  13944. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13945. private _rotateWithMatrix;
  13946. private _getNegativeRotationToRef;
  13947. /**
  13948. * Get the position of the bone in local or world space
  13949. * @param space The space that the returned position is in
  13950. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13951. * @returns The position of the bone
  13952. */
  13953. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13954. /**
  13955. * Copy the position of the bone to a vector3 in local or world space
  13956. * @param space The space that the returned position is in
  13957. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13958. * @param result The vector3 to copy the position to
  13959. */
  13960. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13961. /**
  13962. * Get the absolute position of the bone (world space)
  13963. * @param mesh The mesh that this bone is attached to
  13964. * @returns The absolute position of the bone
  13965. */
  13966. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13967. /**
  13968. * Copy the absolute position of the bone (world space) to the result param
  13969. * @param mesh The mesh that this bone is attached to
  13970. * @param result The vector3 to copy the absolute position to
  13971. */
  13972. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13973. /**
  13974. * Compute the absolute transforms of this bone and its children
  13975. */
  13976. computeAbsoluteTransforms(): void;
  13977. /**
  13978. * Get the world direction from an axis that is in the local space of the bone
  13979. * @param localAxis The local direction that is used to compute the world direction
  13980. * @param mesh The mesh that this bone is attached to
  13981. * @returns The world direction
  13982. */
  13983. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13984. /**
  13985. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13986. * @param localAxis The local direction that is used to compute the world direction
  13987. * @param mesh The mesh that this bone is attached to
  13988. * @param result The vector3 that the world direction will be copied to
  13989. */
  13990. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13991. /**
  13992. * Get the euler rotation of the bone in local or world space
  13993. * @param space The space that the rotation should be in
  13994. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13995. * @returns The euler rotation
  13996. */
  13997. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13998. /**
  13999. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14000. * @param space The space that the rotation should be in
  14001. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14002. * @param result The vector3 that the rotation should be copied to
  14003. */
  14004. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14005. /**
  14006. * Get the quaternion rotation of the bone in either local or world space
  14007. * @param space The space that the rotation should be in
  14008. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14009. * @returns The quaternion rotation
  14010. */
  14011. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14012. /**
  14013. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14014. * @param space The space that the rotation should be in
  14015. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14016. * @param result The quaternion that the rotation should be copied to
  14017. */
  14018. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14019. /**
  14020. * Get the rotation matrix of the bone in local or world space
  14021. * @param space The space that the rotation should be in
  14022. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14023. * @returns The rotation matrix
  14024. */
  14025. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14026. /**
  14027. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14028. * @param space The space that the rotation should be in
  14029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14030. * @param result The quaternion that the rotation should be copied to
  14031. */
  14032. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14033. /**
  14034. * Get the world position of a point that is in the local space of the bone
  14035. * @param position The local position
  14036. * @param mesh The mesh that this bone is attached to
  14037. * @returns The world position
  14038. */
  14039. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14040. /**
  14041. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14042. * @param position The local position
  14043. * @param mesh The mesh that this bone is attached to
  14044. * @param result The vector3 that the world position should be copied to
  14045. */
  14046. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14047. /**
  14048. * Get the local position of a point that is in world space
  14049. * @param position The world position
  14050. * @param mesh The mesh that this bone is attached to
  14051. * @returns The local position
  14052. */
  14053. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14054. /**
  14055. * Get the local position of a point that is in world space and copy it to the result param
  14056. * @param position The world position
  14057. * @param mesh The mesh that this bone is attached to
  14058. * @param result The vector3 that the local position should be copied to
  14059. */
  14060. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14061. }
  14062. }
  14063. declare module "babylonjs/Meshes/transformNode" {
  14064. import { DeepImmutable } from "babylonjs/types";
  14065. import { Observable } from "babylonjs/Misc/observable";
  14066. import { Nullable } from "babylonjs/types";
  14067. import { Camera } from "babylonjs/Cameras/camera";
  14068. import { Scene } from "babylonjs/scene";
  14069. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14070. import { Node } from "babylonjs/node";
  14071. import { Bone } from "babylonjs/Bones/bone";
  14072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14073. import { Space } from "babylonjs/Maths/math.axis";
  14074. /**
  14075. * 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.
  14076. * @see https://doc.babylonjs.com/how_to/transformnode
  14077. */
  14078. export class TransformNode extends Node {
  14079. /**
  14080. * Object will not rotate to face the camera
  14081. */
  14082. static BILLBOARDMODE_NONE: number;
  14083. /**
  14084. * Object will rotate to face the camera but only on the x axis
  14085. */
  14086. static BILLBOARDMODE_X: number;
  14087. /**
  14088. * Object will rotate to face the camera but only on the y axis
  14089. */
  14090. static BILLBOARDMODE_Y: number;
  14091. /**
  14092. * Object will rotate to face the camera but only on the z axis
  14093. */
  14094. static BILLBOARDMODE_Z: number;
  14095. /**
  14096. * Object will rotate to face the camera
  14097. */
  14098. static BILLBOARDMODE_ALL: number;
  14099. /**
  14100. * Object will rotate to face the camera's position instead of orientation
  14101. */
  14102. static BILLBOARDMODE_USE_POSITION: number;
  14103. private _forward;
  14104. private _forwardInverted;
  14105. private _up;
  14106. private _right;
  14107. private _rightInverted;
  14108. private _position;
  14109. private _rotation;
  14110. private _rotationQuaternion;
  14111. protected _scaling: Vector3;
  14112. protected _isDirty: boolean;
  14113. private _transformToBoneReferal;
  14114. private _isAbsoluteSynced;
  14115. private _billboardMode;
  14116. /**
  14117. * Gets or sets the billboard mode. Default is 0.
  14118. *
  14119. * | Value | Type | Description |
  14120. * | --- | --- | --- |
  14121. * | 0 | BILLBOARDMODE_NONE | |
  14122. * | 1 | BILLBOARDMODE_X | |
  14123. * | 2 | BILLBOARDMODE_Y | |
  14124. * | 4 | BILLBOARDMODE_Z | |
  14125. * | 7 | BILLBOARDMODE_ALL | |
  14126. *
  14127. */
  14128. billboardMode: number;
  14129. private _preserveParentRotationForBillboard;
  14130. /**
  14131. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14132. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14133. */
  14134. preserveParentRotationForBillboard: boolean;
  14135. /**
  14136. * 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
  14137. */
  14138. scalingDeterminant: number;
  14139. private _infiniteDistance;
  14140. /**
  14141. * Gets or sets the distance of the object to max, often used by skybox
  14142. */
  14143. infiniteDistance: boolean;
  14144. /**
  14145. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14146. * By default the system will update normals to compensate
  14147. */
  14148. ignoreNonUniformScaling: boolean;
  14149. /**
  14150. * 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
  14151. */
  14152. reIntegrateRotationIntoRotationQuaternion: boolean;
  14153. /** @hidden */
  14154. _poseMatrix: Nullable<Matrix>;
  14155. /** @hidden */
  14156. _localMatrix: Matrix;
  14157. private _usePivotMatrix;
  14158. private _absolutePosition;
  14159. private _absoluteScaling;
  14160. private _absoluteRotationQuaternion;
  14161. private _pivotMatrix;
  14162. private _pivotMatrixInverse;
  14163. protected _postMultiplyPivotMatrix: boolean;
  14164. protected _isWorldMatrixFrozen: boolean;
  14165. /** @hidden */
  14166. _indexInSceneTransformNodesArray: number;
  14167. /**
  14168. * An event triggered after the world matrix is updated
  14169. */
  14170. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14171. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14172. /**
  14173. * Gets a string identifying the name of the class
  14174. * @returns "TransformNode" string
  14175. */
  14176. getClassName(): string;
  14177. /**
  14178. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14179. */
  14180. position: Vector3;
  14181. /**
  14182. * 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)).
  14183. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14184. */
  14185. rotation: Vector3;
  14186. /**
  14187. * 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)).
  14188. */
  14189. scaling: Vector3;
  14190. /**
  14191. * 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).
  14192. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14193. */
  14194. rotationQuaternion: Nullable<Quaternion>;
  14195. /**
  14196. * The forward direction of that transform in world space.
  14197. */
  14198. readonly forward: Vector3;
  14199. /**
  14200. * The up direction of that transform in world space.
  14201. */
  14202. readonly up: Vector3;
  14203. /**
  14204. * The right direction of that transform in world space.
  14205. */
  14206. readonly right: Vector3;
  14207. /**
  14208. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14209. * @param matrix the matrix to copy the pose from
  14210. * @returns this TransformNode.
  14211. */
  14212. updatePoseMatrix(matrix: Matrix): TransformNode;
  14213. /**
  14214. * Returns the mesh Pose matrix.
  14215. * @returns the pose matrix
  14216. */
  14217. getPoseMatrix(): Matrix;
  14218. /** @hidden */
  14219. _isSynchronized(): boolean;
  14220. /** @hidden */
  14221. _initCache(): void;
  14222. /**
  14223. * Flag the transform node as dirty (Forcing it to update everything)
  14224. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14225. * @returns this transform node
  14226. */
  14227. markAsDirty(property: string): TransformNode;
  14228. /**
  14229. * Returns the current mesh absolute position.
  14230. * Returns a Vector3.
  14231. */
  14232. readonly absolutePosition: Vector3;
  14233. /**
  14234. * Returns the current mesh absolute scaling.
  14235. * Returns a Vector3.
  14236. */
  14237. readonly absoluteScaling: Vector3;
  14238. /**
  14239. * Returns the current mesh absolute rotation.
  14240. * Returns a Quaternion.
  14241. */
  14242. readonly absoluteRotationQuaternion: Quaternion;
  14243. /**
  14244. * Sets a new matrix to apply before all other transformation
  14245. * @param matrix defines the transform matrix
  14246. * @returns the current TransformNode
  14247. */
  14248. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14249. /**
  14250. * Sets a new pivot matrix to the current node
  14251. * @param matrix defines the new pivot matrix to use
  14252. * @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
  14253. * @returns the current TransformNode
  14254. */
  14255. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14256. /**
  14257. * Returns the mesh pivot matrix.
  14258. * Default : Identity.
  14259. * @returns the matrix
  14260. */
  14261. getPivotMatrix(): Matrix;
  14262. /**
  14263. * Instantiate (when possible) or clone that node with its hierarchy
  14264. * @param newParent defines the new parent to use for the instance (or clone)
  14265. * @returns an instance (or a clone) of the current node with its hiearchy
  14266. */
  14267. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14268. /**
  14269. * Prevents the World matrix to be computed any longer
  14270. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14271. * @returns the TransformNode.
  14272. */
  14273. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14274. /**
  14275. * Allows back the World matrix computation.
  14276. * @returns the TransformNode.
  14277. */
  14278. unfreezeWorldMatrix(): this;
  14279. /**
  14280. * True if the World matrix has been frozen.
  14281. */
  14282. readonly isWorldMatrixFrozen: boolean;
  14283. /**
  14284. * Retuns the mesh absolute position in the World.
  14285. * @returns a Vector3.
  14286. */
  14287. getAbsolutePosition(): Vector3;
  14288. /**
  14289. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14290. * @param absolutePosition the absolute position to set
  14291. * @returns the TransformNode.
  14292. */
  14293. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14294. /**
  14295. * Sets the mesh position in its local space.
  14296. * @param vector3 the position to set in localspace
  14297. * @returns the TransformNode.
  14298. */
  14299. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14300. /**
  14301. * Returns the mesh position in the local space from the current World matrix values.
  14302. * @returns a new Vector3.
  14303. */
  14304. getPositionExpressedInLocalSpace(): Vector3;
  14305. /**
  14306. * Translates the mesh along the passed Vector3 in its local space.
  14307. * @param vector3 the distance to translate in localspace
  14308. * @returns the TransformNode.
  14309. */
  14310. locallyTranslate(vector3: Vector3): TransformNode;
  14311. private static _lookAtVectorCache;
  14312. /**
  14313. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14314. * @param targetPoint the position (must be in same space as current mesh) to look at
  14315. * @param yawCor optional yaw (y-axis) correction in radians
  14316. * @param pitchCor optional pitch (x-axis) correction in radians
  14317. * @param rollCor optional roll (z-axis) correction in radians
  14318. * @param space the choosen space of the target
  14319. * @returns the TransformNode.
  14320. */
  14321. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14322. /**
  14323. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14324. * This Vector3 is expressed in the World space.
  14325. * @param localAxis axis to rotate
  14326. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14327. */
  14328. getDirection(localAxis: Vector3): Vector3;
  14329. /**
  14330. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14331. * localAxis is expressed in the mesh local space.
  14332. * result is computed in the Wordl space from the mesh World matrix.
  14333. * @param localAxis axis to rotate
  14334. * @param result the resulting transformnode
  14335. * @returns this TransformNode.
  14336. */
  14337. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14338. /**
  14339. * Sets this transform node rotation to the given local axis.
  14340. * @param localAxis the axis in local space
  14341. * @param yawCor optional yaw (y-axis) correction in radians
  14342. * @param pitchCor optional pitch (x-axis) correction in radians
  14343. * @param rollCor optional roll (z-axis) correction in radians
  14344. * @returns this TransformNode
  14345. */
  14346. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14347. /**
  14348. * Sets a new pivot point to the current node
  14349. * @param point defines the new pivot point to use
  14350. * @param space defines if the point is in world or local space (local by default)
  14351. * @returns the current TransformNode
  14352. */
  14353. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14354. /**
  14355. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14356. * @returns the pivot point
  14357. */
  14358. getPivotPoint(): Vector3;
  14359. /**
  14360. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14361. * @param result the vector3 to store the result
  14362. * @returns this TransformNode.
  14363. */
  14364. getPivotPointToRef(result: Vector3): TransformNode;
  14365. /**
  14366. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14367. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14368. */
  14369. getAbsolutePivotPoint(): Vector3;
  14370. /**
  14371. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14372. * @param result vector3 to store the result
  14373. * @returns this TransformNode.
  14374. */
  14375. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14376. /**
  14377. * Defines the passed node as the parent of the current node.
  14378. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14379. * @see https://doc.babylonjs.com/how_to/parenting
  14380. * @param node the node ot set as the parent
  14381. * @returns this TransformNode.
  14382. */
  14383. setParent(node: Nullable<Node>): TransformNode;
  14384. private _nonUniformScaling;
  14385. /**
  14386. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14387. */
  14388. readonly nonUniformScaling: boolean;
  14389. /** @hidden */
  14390. _updateNonUniformScalingState(value: boolean): boolean;
  14391. /**
  14392. * Attach the current TransformNode to another TransformNode associated with a bone
  14393. * @param bone Bone affecting the TransformNode
  14394. * @param affectedTransformNode TransformNode associated with the bone
  14395. * @returns this object
  14396. */
  14397. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14398. /**
  14399. * Detach the transform node if its associated with a bone
  14400. * @returns this object
  14401. */
  14402. detachFromBone(): TransformNode;
  14403. private static _rotationAxisCache;
  14404. /**
  14405. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14406. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14407. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14408. * The passed axis is also normalized.
  14409. * @param axis the axis to rotate around
  14410. * @param amount the amount to rotate in radians
  14411. * @param space Space to rotate in (Default: local)
  14412. * @returns the TransformNode.
  14413. */
  14414. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14415. /**
  14416. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14417. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14418. * The passed axis is also normalized. .
  14419. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14420. * @param point the point to rotate around
  14421. * @param axis the axis to rotate around
  14422. * @param amount the amount to rotate in radians
  14423. * @returns the TransformNode
  14424. */
  14425. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14426. /**
  14427. * Translates the mesh along the axis vector for the passed distance in the given space.
  14428. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14429. * @param axis the axis to translate in
  14430. * @param distance the distance to translate
  14431. * @param space Space to rotate in (Default: local)
  14432. * @returns the TransformNode.
  14433. */
  14434. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14435. /**
  14436. * Adds a rotation step to the mesh current rotation.
  14437. * x, y, z are Euler angles expressed in radians.
  14438. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14439. * This means this rotation is made in the mesh local space only.
  14440. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14441. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14442. * ```javascript
  14443. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14444. * ```
  14445. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14446. * 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.
  14447. * @param x Rotation to add
  14448. * @param y Rotation to add
  14449. * @param z Rotation to add
  14450. * @returns the TransformNode.
  14451. */
  14452. addRotation(x: number, y: number, z: number): TransformNode;
  14453. /**
  14454. * @hidden
  14455. */
  14456. protected _getEffectiveParent(): Nullable<Node>;
  14457. /**
  14458. * Computes the world matrix of the node
  14459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14460. * @returns the world matrix
  14461. */
  14462. computeWorldMatrix(force?: boolean): Matrix;
  14463. protected _afterComputeWorldMatrix(): void;
  14464. /**
  14465. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14466. * @param func callback function to add
  14467. *
  14468. * @returns the TransformNode.
  14469. */
  14470. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14471. /**
  14472. * Removes a registered callback function.
  14473. * @param func callback function to remove
  14474. * @returns the TransformNode.
  14475. */
  14476. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14477. /**
  14478. * Gets the position of the current mesh in camera space
  14479. * @param camera defines the camera to use
  14480. * @returns a position
  14481. */
  14482. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14483. /**
  14484. * Returns the distance from the mesh to the active camera
  14485. * @param camera defines the camera to use
  14486. * @returns the distance
  14487. */
  14488. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14489. /**
  14490. * Clone the current transform node
  14491. * @param name Name of the new clone
  14492. * @param newParent New parent for the clone
  14493. * @param doNotCloneChildren Do not clone children hierarchy
  14494. * @returns the new transform node
  14495. */
  14496. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14497. /**
  14498. * Serializes the objects information.
  14499. * @param currentSerializationObject defines the object to serialize in
  14500. * @returns the serialized object
  14501. */
  14502. serialize(currentSerializationObject?: any): any;
  14503. /**
  14504. * Returns a new TransformNode object parsed from the source provided.
  14505. * @param parsedTransformNode is the source.
  14506. * @param scene the scne the object belongs to
  14507. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14508. * @returns a new TransformNode object parsed from the source provided.
  14509. */
  14510. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14511. /**
  14512. * Get all child-transformNodes of this node
  14513. * @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
  14514. * @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
  14515. * @returns an array of TransformNode
  14516. */
  14517. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14518. /**
  14519. * Releases resources associated with this transform node.
  14520. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14521. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14522. */
  14523. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14524. /**
  14525. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14526. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14527. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14528. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14529. * @returns the current mesh
  14530. */
  14531. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14532. private _syncAbsoluteScalingAndRotation;
  14533. }
  14534. }
  14535. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14536. import { Observable } from "babylonjs/Misc/observable";
  14537. import { Nullable } from "babylonjs/types";
  14538. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14539. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14541. import { Ray } from "babylonjs/Culling/ray";
  14542. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14543. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14544. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14545. /**
  14546. * Defines the types of pose enabled controllers that are supported
  14547. */
  14548. export enum PoseEnabledControllerType {
  14549. /**
  14550. * HTC Vive
  14551. */
  14552. VIVE = 0,
  14553. /**
  14554. * Oculus Rift
  14555. */
  14556. OCULUS = 1,
  14557. /**
  14558. * Windows mixed reality
  14559. */
  14560. WINDOWS = 2,
  14561. /**
  14562. * Samsung gear VR
  14563. */
  14564. GEAR_VR = 3,
  14565. /**
  14566. * Google Daydream
  14567. */
  14568. DAYDREAM = 4,
  14569. /**
  14570. * Generic
  14571. */
  14572. GENERIC = 5
  14573. }
  14574. /**
  14575. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14576. */
  14577. export interface MutableGamepadButton {
  14578. /**
  14579. * Value of the button/trigger
  14580. */
  14581. value: number;
  14582. /**
  14583. * If the button/trigger is currently touched
  14584. */
  14585. touched: boolean;
  14586. /**
  14587. * If the button/trigger is currently pressed
  14588. */
  14589. pressed: boolean;
  14590. }
  14591. /**
  14592. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14593. * @hidden
  14594. */
  14595. export interface ExtendedGamepadButton extends GamepadButton {
  14596. /**
  14597. * If the button/trigger is currently pressed
  14598. */
  14599. readonly pressed: boolean;
  14600. /**
  14601. * If the button/trigger is currently touched
  14602. */
  14603. readonly touched: boolean;
  14604. /**
  14605. * Value of the button/trigger
  14606. */
  14607. readonly value: number;
  14608. }
  14609. /** @hidden */
  14610. export interface _GamePadFactory {
  14611. /**
  14612. * Returns wether or not the current gamepad can be created for this type of controller.
  14613. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14614. * @returns true if it can be created, otherwise false
  14615. */
  14616. canCreate(gamepadInfo: any): boolean;
  14617. /**
  14618. * Creates a new instance of the Gamepad.
  14619. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14620. * @returns the new gamepad instance
  14621. */
  14622. create(gamepadInfo: any): Gamepad;
  14623. }
  14624. /**
  14625. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14626. */
  14627. export class PoseEnabledControllerHelper {
  14628. /** @hidden */
  14629. static _ControllerFactories: _GamePadFactory[];
  14630. /** @hidden */
  14631. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14632. /**
  14633. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14634. * @param vrGamepad the gamepad to initialized
  14635. * @returns a vr controller of the type the gamepad identified as
  14636. */
  14637. static InitiateController(vrGamepad: any): Gamepad;
  14638. }
  14639. /**
  14640. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14641. */
  14642. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14643. /**
  14644. * If the controller is used in a webXR session
  14645. */
  14646. isXR: boolean;
  14647. private _deviceRoomPosition;
  14648. private _deviceRoomRotationQuaternion;
  14649. /**
  14650. * The device position in babylon space
  14651. */
  14652. devicePosition: Vector3;
  14653. /**
  14654. * The device rotation in babylon space
  14655. */
  14656. deviceRotationQuaternion: Quaternion;
  14657. /**
  14658. * The scale factor of the device in babylon space
  14659. */
  14660. deviceScaleFactor: number;
  14661. /**
  14662. * (Likely devicePosition should be used instead) The device position in its room space
  14663. */
  14664. position: Vector3;
  14665. /**
  14666. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14667. */
  14668. rotationQuaternion: Quaternion;
  14669. /**
  14670. * The type of controller (Eg. Windows mixed reality)
  14671. */
  14672. controllerType: PoseEnabledControllerType;
  14673. protected _calculatedPosition: Vector3;
  14674. private _calculatedRotation;
  14675. /**
  14676. * The raw pose from the device
  14677. */
  14678. rawPose: DevicePose;
  14679. private _trackPosition;
  14680. private _maxRotationDistFromHeadset;
  14681. private _draggedRoomRotation;
  14682. /**
  14683. * @hidden
  14684. */
  14685. _disableTrackPosition(fixedPosition: Vector3): void;
  14686. /**
  14687. * Internal, the mesh attached to the controller
  14688. * @hidden
  14689. */
  14690. _mesh: Nullable<AbstractMesh>;
  14691. private _poseControlledCamera;
  14692. private _leftHandSystemQuaternion;
  14693. /**
  14694. * Internal, matrix used to convert room space to babylon space
  14695. * @hidden
  14696. */
  14697. _deviceToWorld: Matrix;
  14698. /**
  14699. * Node to be used when casting a ray from the controller
  14700. * @hidden
  14701. */
  14702. _pointingPoseNode: Nullable<TransformNode>;
  14703. /**
  14704. * Name of the child mesh that can be used to cast a ray from the controller
  14705. */
  14706. static readonly POINTING_POSE: string;
  14707. /**
  14708. * Creates a new PoseEnabledController from a gamepad
  14709. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14710. */
  14711. constructor(browserGamepad: any);
  14712. private _workingMatrix;
  14713. /**
  14714. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14715. */
  14716. update(): void;
  14717. /**
  14718. * Updates only the pose device and mesh without doing any button event checking
  14719. */
  14720. protected _updatePoseAndMesh(): void;
  14721. /**
  14722. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14723. * @param poseData raw pose fromthe device
  14724. */
  14725. updateFromDevice(poseData: DevicePose): void;
  14726. /**
  14727. * @hidden
  14728. */
  14729. _meshAttachedObservable: Observable<AbstractMesh>;
  14730. /**
  14731. * Attaches a mesh to the controller
  14732. * @param mesh the mesh to be attached
  14733. */
  14734. attachToMesh(mesh: AbstractMesh): void;
  14735. /**
  14736. * Attaches the controllers mesh to a camera
  14737. * @param camera the camera the mesh should be attached to
  14738. */
  14739. attachToPoseControlledCamera(camera: TargetCamera): void;
  14740. /**
  14741. * Disposes of the controller
  14742. */
  14743. dispose(): void;
  14744. /**
  14745. * The mesh that is attached to the controller
  14746. */
  14747. readonly mesh: Nullable<AbstractMesh>;
  14748. /**
  14749. * Gets the ray of the controller in the direction the controller is pointing
  14750. * @param length the length the resulting ray should be
  14751. * @returns a ray in the direction the controller is pointing
  14752. */
  14753. getForwardRay(length?: number): Ray;
  14754. }
  14755. }
  14756. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14757. import { Observable } from "babylonjs/Misc/observable";
  14758. import { Scene } from "babylonjs/scene";
  14759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14760. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14761. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14762. import { Nullable } from "babylonjs/types";
  14763. /**
  14764. * Defines the WebVRController object that represents controllers tracked in 3D space
  14765. */
  14766. export abstract class WebVRController extends PoseEnabledController {
  14767. /**
  14768. * Internal, the default controller model for the controller
  14769. */
  14770. protected _defaultModel: Nullable<AbstractMesh>;
  14771. /**
  14772. * Fired when the trigger state has changed
  14773. */
  14774. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14775. /**
  14776. * Fired when the main button state has changed
  14777. */
  14778. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14779. /**
  14780. * Fired when the secondary button state has changed
  14781. */
  14782. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14783. /**
  14784. * Fired when the pad state has changed
  14785. */
  14786. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14787. /**
  14788. * Fired when controllers stick values have changed
  14789. */
  14790. onPadValuesChangedObservable: Observable<StickValues>;
  14791. /**
  14792. * Array of button availible on the controller
  14793. */
  14794. protected _buttons: Array<MutableGamepadButton>;
  14795. private _onButtonStateChange;
  14796. /**
  14797. * Fired when a controller button's state has changed
  14798. * @param callback the callback containing the button that was modified
  14799. */
  14800. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14801. /**
  14802. * X and Y axis corresponding to the controllers joystick
  14803. */
  14804. pad: StickValues;
  14805. /**
  14806. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14807. */
  14808. hand: string;
  14809. /**
  14810. * The default controller model for the controller
  14811. */
  14812. readonly defaultModel: Nullable<AbstractMesh>;
  14813. /**
  14814. * Creates a new WebVRController from a gamepad
  14815. * @param vrGamepad the gamepad that the WebVRController should be created from
  14816. */
  14817. constructor(vrGamepad: any);
  14818. /**
  14819. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14820. */
  14821. update(): void;
  14822. /**
  14823. * Function to be called when a button is modified
  14824. */
  14825. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14826. /**
  14827. * Loads a mesh and attaches it to the controller
  14828. * @param scene the scene the mesh should be added to
  14829. * @param meshLoaded callback for when the mesh has been loaded
  14830. */
  14831. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14832. private _setButtonValue;
  14833. private _changes;
  14834. private _checkChanges;
  14835. /**
  14836. * Disposes of th webVRCOntroller
  14837. */
  14838. dispose(): void;
  14839. }
  14840. }
  14841. declare module "babylonjs/Lights/hemisphericLight" {
  14842. import { Nullable } from "babylonjs/types";
  14843. import { Scene } from "babylonjs/scene";
  14844. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14845. import { Color3 } from "babylonjs/Maths/math.color";
  14846. import { Effect } from "babylonjs/Materials/effect";
  14847. import { Light } from "babylonjs/Lights/light";
  14848. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14849. /**
  14850. * The HemisphericLight simulates the ambient environment light,
  14851. * so the passed direction is the light reflection direction, not the incoming direction.
  14852. */
  14853. export class HemisphericLight extends Light {
  14854. /**
  14855. * The groundColor is the light in the opposite direction to the one specified during creation.
  14856. * 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.
  14857. */
  14858. groundColor: Color3;
  14859. /**
  14860. * The light reflection direction, not the incoming direction.
  14861. */
  14862. direction: Vector3;
  14863. /**
  14864. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14865. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14866. * The HemisphericLight can't cast shadows.
  14867. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14868. * @param name The friendly name of the light
  14869. * @param direction The direction of the light reflection
  14870. * @param scene The scene the light belongs to
  14871. */
  14872. constructor(name: string, direction: Vector3, scene: Scene);
  14873. protected _buildUniformLayout(): void;
  14874. /**
  14875. * Returns the string "HemisphericLight".
  14876. * @return The class name
  14877. */
  14878. getClassName(): string;
  14879. /**
  14880. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14881. * Returns the updated direction.
  14882. * @param target The target the direction should point to
  14883. * @return The computed direction
  14884. */
  14885. setDirectionToTarget(target: Vector3): Vector3;
  14886. /**
  14887. * Returns the shadow generator associated to the light.
  14888. * @returns Always null for hemispheric lights because it does not support shadows.
  14889. */
  14890. getShadowGenerator(): Nullable<IShadowGenerator>;
  14891. /**
  14892. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14893. * @param effect The effect to update
  14894. * @param lightIndex The index of the light in the effect to update
  14895. * @returns The hemispheric light
  14896. */
  14897. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14898. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14899. /**
  14900. * Computes the world matrix of the node
  14901. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14902. * @param useWasUpdatedFlag defines a reserved property
  14903. * @returns the world matrix
  14904. */
  14905. computeWorldMatrix(): Matrix;
  14906. /**
  14907. * Returns the integer 3.
  14908. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14909. */
  14910. getTypeID(): number;
  14911. /**
  14912. * Prepares the list of defines specific to the light type.
  14913. * @param defines the list of defines
  14914. * @param lightIndex defines the index of the light for the effect
  14915. */
  14916. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14917. }
  14918. }
  14919. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14920. /** @hidden */
  14921. export var vrMultiviewToSingleviewPixelShader: {
  14922. name: string;
  14923. shader: string;
  14924. };
  14925. }
  14926. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14927. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14928. import { Scene } from "babylonjs/scene";
  14929. /**
  14930. * Renders to multiple views with a single draw call
  14931. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14932. */
  14933. export class MultiviewRenderTarget extends RenderTargetTexture {
  14934. /**
  14935. * Creates a multiview render target
  14936. * @param scene scene used with the render target
  14937. * @param size the size of the render target (used for each view)
  14938. */
  14939. constructor(scene: Scene, size?: number | {
  14940. width: number;
  14941. height: number;
  14942. } | {
  14943. ratio: number;
  14944. });
  14945. /**
  14946. * @hidden
  14947. * @param faceIndex the face index, if its a cube texture
  14948. */
  14949. _bindFrameBuffer(faceIndex?: number): void;
  14950. /**
  14951. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14952. * @returns the view count
  14953. */
  14954. getViewCount(): number;
  14955. }
  14956. }
  14957. declare module "babylonjs/Maths/math.frustum" {
  14958. import { Matrix } from "babylonjs/Maths/math.vector";
  14959. import { DeepImmutable } from "babylonjs/types";
  14960. import { Plane } from "babylonjs/Maths/math.plane";
  14961. /**
  14962. * Represents a camera frustum
  14963. */
  14964. export class Frustum {
  14965. /**
  14966. * Gets the planes representing the frustum
  14967. * @param transform matrix to be applied to the returned planes
  14968. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14969. */
  14970. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14971. /**
  14972. * Gets the near frustum plane transformed by the transform matrix
  14973. * @param transform transformation matrix to be applied to the resulting frustum plane
  14974. * @param frustumPlane the resuling frustum plane
  14975. */
  14976. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14977. /**
  14978. * Gets the far frustum plane transformed by the transform matrix
  14979. * @param transform transformation matrix to be applied to the resulting frustum plane
  14980. * @param frustumPlane the resuling frustum plane
  14981. */
  14982. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14983. /**
  14984. * Gets the left frustum plane transformed by the transform matrix
  14985. * @param transform transformation matrix to be applied to the resulting frustum plane
  14986. * @param frustumPlane the resuling frustum plane
  14987. */
  14988. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14989. /**
  14990. * Gets the right frustum plane transformed by the transform matrix
  14991. * @param transform transformation matrix to be applied to the resulting frustum plane
  14992. * @param frustumPlane the resuling frustum plane
  14993. */
  14994. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14995. /**
  14996. * Gets the top frustum plane transformed by the transform matrix
  14997. * @param transform transformation matrix to be applied to the resulting frustum plane
  14998. * @param frustumPlane the resuling frustum plane
  14999. */
  15000. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15001. /**
  15002. * Gets the bottom frustum plane transformed by the transform matrix
  15003. * @param transform transformation matrix to be applied to the resulting frustum plane
  15004. * @param frustumPlane the resuling frustum plane
  15005. */
  15006. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15007. /**
  15008. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15009. * @param transform transformation matrix to be applied to the resulting frustum planes
  15010. * @param frustumPlanes the resuling frustum planes
  15011. */
  15012. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15013. }
  15014. }
  15015. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15016. import { Camera } from "babylonjs/Cameras/camera";
  15017. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15018. import { Nullable } from "babylonjs/types";
  15019. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15020. import { Matrix } from "babylonjs/Maths/math.vector";
  15021. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15022. module "babylonjs/Engines/engine" {
  15023. interface Engine {
  15024. /**
  15025. * Creates a new multiview render target
  15026. * @param width defines the width of the texture
  15027. * @param height defines the height of the texture
  15028. * @returns the created multiview texture
  15029. */
  15030. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15031. /**
  15032. * Binds a multiview framebuffer to be drawn to
  15033. * @param multiviewTexture texture to bind
  15034. */
  15035. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15036. }
  15037. }
  15038. module "babylonjs/Cameras/camera" {
  15039. interface Camera {
  15040. /**
  15041. * @hidden
  15042. * 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)
  15043. */
  15044. _useMultiviewToSingleView: boolean;
  15045. /**
  15046. * @hidden
  15047. * 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)
  15048. */
  15049. _multiviewTexture: Nullable<RenderTargetTexture>;
  15050. /**
  15051. * @hidden
  15052. * ensures the multiview texture of the camera exists and has the specified width/height
  15053. * @param width height to set on the multiview texture
  15054. * @param height width to set on the multiview texture
  15055. */
  15056. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15057. }
  15058. }
  15059. module "babylonjs/scene" {
  15060. interface Scene {
  15061. /** @hidden */
  15062. _transformMatrixR: Matrix;
  15063. /** @hidden */
  15064. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15065. /** @hidden */
  15066. _createMultiviewUbo(): void;
  15067. /** @hidden */
  15068. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15069. /** @hidden */
  15070. _renderMultiviewToSingleView(camera: Camera): void;
  15071. }
  15072. }
  15073. }
  15074. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15075. import { Camera } from "babylonjs/Cameras/camera";
  15076. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15077. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15078. import "babylonjs/Engines/Extensions/engine.multiview";
  15079. /**
  15080. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15081. * This will not be used for webXR as it supports displaying texture arrays directly
  15082. */
  15083. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15084. /**
  15085. * Initializes a VRMultiviewToSingleview
  15086. * @param name name of the post process
  15087. * @param camera camera to be applied to
  15088. * @param scaleFactor scaling factor to the size of the output texture
  15089. */
  15090. constructor(name: string, camera: Camera, scaleFactor: number);
  15091. }
  15092. }
  15093. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15094. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15095. import { Nullable } from "babylonjs/types";
  15096. import { Size } from "babylonjs/Maths/math.size";
  15097. import { Observable } from "babylonjs/Misc/observable";
  15098. module "babylonjs/Engines/engine" {
  15099. interface Engine {
  15100. /** @hidden */
  15101. _vrDisplay: any;
  15102. /** @hidden */
  15103. _vrSupported: boolean;
  15104. /** @hidden */
  15105. _oldSize: Size;
  15106. /** @hidden */
  15107. _oldHardwareScaleFactor: number;
  15108. /** @hidden */
  15109. _vrExclusivePointerMode: boolean;
  15110. /** @hidden */
  15111. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15112. /** @hidden */
  15113. _onVRDisplayPointerRestricted: () => void;
  15114. /** @hidden */
  15115. _onVRDisplayPointerUnrestricted: () => void;
  15116. /** @hidden */
  15117. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15118. /** @hidden */
  15119. _onVrDisplayDisconnect: Nullable<() => void>;
  15120. /** @hidden */
  15121. _onVrDisplayPresentChange: Nullable<() => void>;
  15122. /**
  15123. * Observable signaled when VR display mode changes
  15124. */
  15125. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15126. /**
  15127. * Observable signaled when VR request present is complete
  15128. */
  15129. onVRRequestPresentComplete: Observable<boolean>;
  15130. /**
  15131. * Observable signaled when VR request present starts
  15132. */
  15133. onVRRequestPresentStart: Observable<Engine>;
  15134. /**
  15135. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15136. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15137. */
  15138. isInVRExclusivePointerMode: boolean;
  15139. /**
  15140. * Gets a boolean indicating if a webVR device was detected
  15141. * @returns true if a webVR device was detected
  15142. */
  15143. isVRDevicePresent(): boolean;
  15144. /**
  15145. * Gets the current webVR device
  15146. * @returns the current webVR device (or null)
  15147. */
  15148. getVRDevice(): any;
  15149. /**
  15150. * Initializes a webVR display and starts listening to display change events
  15151. * The onVRDisplayChangedObservable will be notified upon these changes
  15152. * @returns A promise containing a VRDisplay and if vr is supported
  15153. */
  15154. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15155. /** @hidden */
  15156. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15157. /**
  15158. * Call this function to switch to webVR mode
  15159. * Will do nothing if webVR is not supported or if there is no webVR device
  15160. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15161. */
  15162. enableVR(): void;
  15163. /** @hidden */
  15164. _onVRFullScreenTriggered(): void;
  15165. }
  15166. }
  15167. }
  15168. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15169. import { Nullable } from "babylonjs/types";
  15170. import { Observable } from "babylonjs/Misc/observable";
  15171. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15172. import { Scene } from "babylonjs/scene";
  15173. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15174. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15175. import { Node } from "babylonjs/node";
  15176. import { Ray } from "babylonjs/Culling/ray";
  15177. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15178. import "babylonjs/Engines/Extensions/engine.webVR";
  15179. /**
  15180. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15181. * IMPORTANT!! The data is right-hand data.
  15182. * @export
  15183. * @interface DevicePose
  15184. */
  15185. export interface DevicePose {
  15186. /**
  15187. * The position of the device, values in array are [x,y,z].
  15188. */
  15189. readonly position: Nullable<Float32Array>;
  15190. /**
  15191. * The linearVelocity of the device, values in array are [x,y,z].
  15192. */
  15193. readonly linearVelocity: Nullable<Float32Array>;
  15194. /**
  15195. * The linearAcceleration of the device, values in array are [x,y,z].
  15196. */
  15197. readonly linearAcceleration: Nullable<Float32Array>;
  15198. /**
  15199. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15200. */
  15201. readonly orientation: Nullable<Float32Array>;
  15202. /**
  15203. * The angularVelocity of the device, values in array are [x,y,z].
  15204. */
  15205. readonly angularVelocity: Nullable<Float32Array>;
  15206. /**
  15207. * The angularAcceleration of the device, values in array are [x,y,z].
  15208. */
  15209. readonly angularAcceleration: Nullable<Float32Array>;
  15210. }
  15211. /**
  15212. * Interface representing a pose controlled object in Babylon.
  15213. * A pose controlled object has both regular pose values as well as pose values
  15214. * from an external device such as a VR head mounted display
  15215. */
  15216. export interface PoseControlled {
  15217. /**
  15218. * The position of the object in babylon space.
  15219. */
  15220. position: Vector3;
  15221. /**
  15222. * The rotation quaternion of the object in babylon space.
  15223. */
  15224. rotationQuaternion: Quaternion;
  15225. /**
  15226. * The position of the device in babylon space.
  15227. */
  15228. devicePosition?: Vector3;
  15229. /**
  15230. * The rotation quaternion of the device in babylon space.
  15231. */
  15232. deviceRotationQuaternion: Quaternion;
  15233. /**
  15234. * The raw pose coming from the device.
  15235. */
  15236. rawPose: Nullable<DevicePose>;
  15237. /**
  15238. * The scale of the device to be used when translating from device space to babylon space.
  15239. */
  15240. deviceScaleFactor: number;
  15241. /**
  15242. * Updates the poseControlled values based on the input device pose.
  15243. * @param poseData the pose data to update the object with
  15244. */
  15245. updateFromDevice(poseData: DevicePose): void;
  15246. }
  15247. /**
  15248. * Set of options to customize the webVRCamera
  15249. */
  15250. export interface WebVROptions {
  15251. /**
  15252. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15253. */
  15254. trackPosition?: boolean;
  15255. /**
  15256. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15257. */
  15258. positionScale?: number;
  15259. /**
  15260. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15261. */
  15262. displayName?: string;
  15263. /**
  15264. * Should the native controller meshes be initialized. (default: true)
  15265. */
  15266. controllerMeshes?: boolean;
  15267. /**
  15268. * Creating a default HemiLight only on controllers. (default: true)
  15269. */
  15270. defaultLightingOnControllers?: boolean;
  15271. /**
  15272. * If you don't want to use the default VR button of the helper. (default: false)
  15273. */
  15274. useCustomVRButton?: boolean;
  15275. /**
  15276. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15277. */
  15278. customVRButton?: HTMLButtonElement;
  15279. /**
  15280. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15281. */
  15282. rayLength?: number;
  15283. /**
  15284. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15285. */
  15286. defaultHeight?: number;
  15287. /**
  15288. * If multiview should be used if availible (default: false)
  15289. */
  15290. useMultiview?: boolean;
  15291. }
  15292. /**
  15293. * This represents a WebVR camera.
  15294. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15295. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15296. */
  15297. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15298. private webVROptions;
  15299. /**
  15300. * @hidden
  15301. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15302. */
  15303. _vrDevice: any;
  15304. /**
  15305. * The rawPose of the vrDevice.
  15306. */
  15307. rawPose: Nullable<DevicePose>;
  15308. private _onVREnabled;
  15309. private _specsVersion;
  15310. private _attached;
  15311. private _frameData;
  15312. protected _descendants: Array<Node>;
  15313. private _deviceRoomPosition;
  15314. /** @hidden */
  15315. _deviceRoomRotationQuaternion: Quaternion;
  15316. private _standingMatrix;
  15317. /**
  15318. * Represents device position in babylon space.
  15319. */
  15320. devicePosition: Vector3;
  15321. /**
  15322. * Represents device rotation in babylon space.
  15323. */
  15324. deviceRotationQuaternion: Quaternion;
  15325. /**
  15326. * The scale of the device to be used when translating from device space to babylon space.
  15327. */
  15328. deviceScaleFactor: number;
  15329. private _deviceToWorld;
  15330. private _worldToDevice;
  15331. /**
  15332. * References to the webVR controllers for the vrDevice.
  15333. */
  15334. controllers: Array<WebVRController>;
  15335. /**
  15336. * Emits an event when a controller is attached.
  15337. */
  15338. onControllersAttachedObservable: Observable<WebVRController[]>;
  15339. /**
  15340. * Emits an event when a controller's mesh has been loaded;
  15341. */
  15342. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15343. /**
  15344. * Emits an event when the HMD's pose has been updated.
  15345. */
  15346. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15347. private _poseSet;
  15348. /**
  15349. * If the rig cameras be used as parent instead of this camera.
  15350. */
  15351. rigParenting: boolean;
  15352. private _lightOnControllers;
  15353. private _defaultHeight?;
  15354. /**
  15355. * Instantiates a WebVRFreeCamera.
  15356. * @param name The name of the WebVRFreeCamera
  15357. * @param position The starting anchor position for the camera
  15358. * @param scene The scene the camera belongs to
  15359. * @param webVROptions a set of customizable options for the webVRCamera
  15360. */
  15361. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15362. /**
  15363. * Gets the device distance from the ground in meters.
  15364. * @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.
  15365. */
  15366. deviceDistanceToRoomGround(): number;
  15367. /**
  15368. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15369. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15370. */
  15371. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15372. /**
  15373. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15374. * @returns A promise with a boolean set to if the standing matrix is supported.
  15375. */
  15376. useStandingMatrixAsync(): Promise<boolean>;
  15377. /**
  15378. * Disposes the camera
  15379. */
  15380. dispose(): void;
  15381. /**
  15382. * Gets a vrController by name.
  15383. * @param name The name of the controller to retreive
  15384. * @returns the controller matching the name specified or null if not found
  15385. */
  15386. getControllerByName(name: string): Nullable<WebVRController>;
  15387. private _leftController;
  15388. /**
  15389. * The controller corresponding to the users left hand.
  15390. */
  15391. readonly leftController: Nullable<WebVRController>;
  15392. private _rightController;
  15393. /**
  15394. * The controller corresponding to the users right hand.
  15395. */
  15396. readonly rightController: Nullable<WebVRController>;
  15397. /**
  15398. * Casts a ray forward from the vrCamera's gaze.
  15399. * @param length Length of the ray (default: 100)
  15400. * @returns the ray corresponding to the gaze
  15401. */
  15402. getForwardRay(length?: number): Ray;
  15403. /**
  15404. * @hidden
  15405. * Updates the camera based on device's frame data
  15406. */
  15407. _checkInputs(): void;
  15408. /**
  15409. * Updates the poseControlled values based on the input device pose.
  15410. * @param poseData Pose coming from the device
  15411. */
  15412. updateFromDevice(poseData: DevicePose): void;
  15413. private _htmlElementAttached;
  15414. private _detachIfAttached;
  15415. /**
  15416. * WebVR's attach control will start broadcasting frames to the device.
  15417. * Note that in certain browsers (chrome for example) this function must be called
  15418. * within a user-interaction callback. Example:
  15419. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15420. *
  15421. * @param element html element to attach the vrDevice to
  15422. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15423. */
  15424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15425. /**
  15426. * Detaches the camera from the html element and disables VR
  15427. *
  15428. * @param element html element to detach from
  15429. */
  15430. detachControl(element: HTMLElement): void;
  15431. /**
  15432. * @returns the name of this class
  15433. */
  15434. getClassName(): string;
  15435. /**
  15436. * Calls resetPose on the vrDisplay
  15437. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15438. */
  15439. resetToCurrentRotation(): void;
  15440. /**
  15441. * @hidden
  15442. * Updates the rig cameras (left and right eye)
  15443. */
  15444. _updateRigCameras(): void;
  15445. private _workingVector;
  15446. private _oneVector;
  15447. private _workingMatrix;
  15448. private updateCacheCalled;
  15449. private _correctPositionIfNotTrackPosition;
  15450. /**
  15451. * @hidden
  15452. * Updates the cached values of the camera
  15453. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15454. */
  15455. _updateCache(ignoreParentClass?: boolean): void;
  15456. /**
  15457. * @hidden
  15458. * Get current device position in babylon world
  15459. */
  15460. _computeDevicePosition(): void;
  15461. /**
  15462. * Updates the current device position and rotation in the babylon world
  15463. */
  15464. update(): void;
  15465. /**
  15466. * @hidden
  15467. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15468. * @returns an identity matrix
  15469. */
  15470. _getViewMatrix(): Matrix;
  15471. private _tmpMatrix;
  15472. /**
  15473. * This function is called by the two RIG cameras.
  15474. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15475. * @hidden
  15476. */
  15477. _getWebVRViewMatrix(): Matrix;
  15478. /** @hidden */
  15479. _getWebVRProjectionMatrix(): Matrix;
  15480. private _onGamepadConnectedObserver;
  15481. private _onGamepadDisconnectedObserver;
  15482. private _updateCacheWhenTrackingDisabledObserver;
  15483. /**
  15484. * Initializes the controllers and their meshes
  15485. */
  15486. initControllers(): void;
  15487. }
  15488. }
  15489. declare module "babylonjs/PostProcesses/postProcess" {
  15490. import { Nullable } from "babylonjs/types";
  15491. import { SmartArray } from "babylonjs/Misc/smartArray";
  15492. import { Observable } from "babylonjs/Misc/observable";
  15493. import { Vector2 } from "babylonjs/Maths/math.vector";
  15494. import { Camera } from "babylonjs/Cameras/camera";
  15495. import { Effect } from "babylonjs/Materials/effect";
  15496. import "babylonjs/Shaders/postprocess.vertex";
  15497. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15498. import { Engine } from "babylonjs/Engines/engine";
  15499. import { Color4 } from "babylonjs/Maths/math.color";
  15500. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15501. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15502. /**
  15503. * Size options for a post process
  15504. */
  15505. export type PostProcessOptions = {
  15506. width: number;
  15507. height: number;
  15508. };
  15509. /**
  15510. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15511. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15512. */
  15513. export class PostProcess {
  15514. /** Name of the PostProcess. */
  15515. name: string;
  15516. /**
  15517. * Gets or sets the unique id of the post process
  15518. */
  15519. uniqueId: number;
  15520. /**
  15521. * Width of the texture to apply the post process on
  15522. */
  15523. width: number;
  15524. /**
  15525. * Height of the texture to apply the post process on
  15526. */
  15527. height: number;
  15528. /**
  15529. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15530. * @hidden
  15531. */
  15532. _outputTexture: Nullable<InternalTexture>;
  15533. /**
  15534. * Sampling mode used by the shader
  15535. * See https://doc.babylonjs.com/classes/3.1/texture
  15536. */
  15537. renderTargetSamplingMode: number;
  15538. /**
  15539. * Clear color to use when screen clearing
  15540. */
  15541. clearColor: Color4;
  15542. /**
  15543. * If the buffer needs to be cleared before applying the post process. (default: true)
  15544. * Should be set to false if shader will overwrite all previous pixels.
  15545. */
  15546. autoClear: boolean;
  15547. /**
  15548. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15549. */
  15550. alphaMode: number;
  15551. /**
  15552. * Sets the setAlphaBlendConstants of the babylon engine
  15553. */
  15554. alphaConstants: Color4;
  15555. /**
  15556. * Animations to be used for the post processing
  15557. */
  15558. animations: import("babylonjs/Animations/animation").Animation[];
  15559. /**
  15560. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15561. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15562. */
  15563. enablePixelPerfectMode: boolean;
  15564. /**
  15565. * Force the postprocess to be applied without taking in account viewport
  15566. */
  15567. forceFullscreenViewport: boolean;
  15568. /**
  15569. * List of inspectable custom properties (used by the Inspector)
  15570. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15571. */
  15572. inspectableCustomProperties: IInspectable[];
  15573. /**
  15574. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15575. *
  15576. * | Value | Type | Description |
  15577. * | ----- | ----------------------------------- | ----------- |
  15578. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15579. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15580. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15581. *
  15582. */
  15583. scaleMode: number;
  15584. /**
  15585. * Force textures to be a power of two (default: false)
  15586. */
  15587. alwaysForcePOT: boolean;
  15588. private _samples;
  15589. /**
  15590. * Number of sample textures (default: 1)
  15591. */
  15592. samples: number;
  15593. /**
  15594. * Modify the scale of the post process to be the same as the viewport (default: false)
  15595. */
  15596. adaptScaleToCurrentViewport: boolean;
  15597. private _camera;
  15598. private _scene;
  15599. private _engine;
  15600. private _options;
  15601. private _reusable;
  15602. private _textureType;
  15603. /**
  15604. * Smart array of input and output textures for the post process.
  15605. * @hidden
  15606. */
  15607. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15608. /**
  15609. * The index in _textures that corresponds to the output texture.
  15610. * @hidden
  15611. */
  15612. _currentRenderTextureInd: number;
  15613. private _effect;
  15614. private _samplers;
  15615. private _fragmentUrl;
  15616. private _vertexUrl;
  15617. private _parameters;
  15618. private _scaleRatio;
  15619. protected _indexParameters: any;
  15620. private _shareOutputWithPostProcess;
  15621. private _texelSize;
  15622. private _forcedOutputTexture;
  15623. /**
  15624. * Returns the fragment url or shader name used in the post process.
  15625. * @returns the fragment url or name in the shader store.
  15626. */
  15627. getEffectName(): string;
  15628. /**
  15629. * An event triggered when the postprocess is activated.
  15630. */
  15631. onActivateObservable: Observable<Camera>;
  15632. private _onActivateObserver;
  15633. /**
  15634. * A function that is added to the onActivateObservable
  15635. */
  15636. onActivate: Nullable<(camera: Camera) => void>;
  15637. /**
  15638. * An event triggered when the postprocess changes its size.
  15639. */
  15640. onSizeChangedObservable: Observable<PostProcess>;
  15641. private _onSizeChangedObserver;
  15642. /**
  15643. * A function that is added to the onSizeChangedObservable
  15644. */
  15645. onSizeChanged: (postProcess: PostProcess) => void;
  15646. /**
  15647. * An event triggered when the postprocess applies its effect.
  15648. */
  15649. onApplyObservable: Observable<Effect>;
  15650. private _onApplyObserver;
  15651. /**
  15652. * A function that is added to the onApplyObservable
  15653. */
  15654. onApply: (effect: Effect) => void;
  15655. /**
  15656. * An event triggered before rendering the postprocess
  15657. */
  15658. onBeforeRenderObservable: Observable<Effect>;
  15659. private _onBeforeRenderObserver;
  15660. /**
  15661. * A function that is added to the onBeforeRenderObservable
  15662. */
  15663. onBeforeRender: (effect: Effect) => void;
  15664. /**
  15665. * An event triggered after rendering the postprocess
  15666. */
  15667. onAfterRenderObservable: Observable<Effect>;
  15668. private _onAfterRenderObserver;
  15669. /**
  15670. * A function that is added to the onAfterRenderObservable
  15671. */
  15672. onAfterRender: (efect: Effect) => void;
  15673. /**
  15674. * 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
  15675. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15676. */
  15677. inputTexture: InternalTexture;
  15678. /**
  15679. * Gets the camera which post process is applied to.
  15680. * @returns The camera the post process is applied to.
  15681. */
  15682. getCamera(): Camera;
  15683. /**
  15684. * Gets the texel size of the postprocess.
  15685. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15686. */
  15687. readonly texelSize: Vector2;
  15688. /**
  15689. * Creates a new instance PostProcess
  15690. * @param name The name of the PostProcess.
  15691. * @param fragmentUrl The url of the fragment shader to be used.
  15692. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15693. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15694. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15695. * @param camera The camera to apply the render pass to.
  15696. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15697. * @param engine The engine which the post process will be applied. (default: current engine)
  15698. * @param reusable If the post process can be reused on the same frame. (default: false)
  15699. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15700. * @param textureType Type of textures used when performing the post process. (default: 0)
  15701. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15702. * @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
  15703. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15704. */
  15705. constructor(
  15706. /** Name of the PostProcess. */
  15707. 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);
  15708. /**
  15709. * Gets a string idenfifying the name of the class
  15710. * @returns "PostProcess" string
  15711. */
  15712. getClassName(): string;
  15713. /**
  15714. * Gets the engine which this post process belongs to.
  15715. * @returns The engine the post process was enabled with.
  15716. */
  15717. getEngine(): Engine;
  15718. /**
  15719. * The effect that is created when initializing the post process.
  15720. * @returns The created effect corresponding the the postprocess.
  15721. */
  15722. getEffect(): Effect;
  15723. /**
  15724. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15725. * @param postProcess The post process to share the output with.
  15726. * @returns This post process.
  15727. */
  15728. shareOutputWith(postProcess: PostProcess): PostProcess;
  15729. /**
  15730. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15731. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15732. */
  15733. useOwnOutput(): void;
  15734. /**
  15735. * Updates the effect with the current post process compile time values and recompiles the shader.
  15736. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15737. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15738. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15739. * @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
  15740. * @param onCompiled Called when the shader has been compiled.
  15741. * @param onError Called if there is an error when compiling a shader.
  15742. */
  15743. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15744. /**
  15745. * The post process is reusable if it can be used multiple times within one frame.
  15746. * @returns If the post process is reusable
  15747. */
  15748. isReusable(): boolean;
  15749. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15750. markTextureDirty(): void;
  15751. /**
  15752. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15753. * 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.
  15754. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15755. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15756. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15757. * @returns The target texture that was bound to be written to.
  15758. */
  15759. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15760. /**
  15761. * If the post process is supported.
  15762. */
  15763. readonly isSupported: boolean;
  15764. /**
  15765. * The aspect ratio of the output texture.
  15766. */
  15767. readonly aspectRatio: number;
  15768. /**
  15769. * Get a value indicating if the post-process is ready to be used
  15770. * @returns true if the post-process is ready (shader is compiled)
  15771. */
  15772. isReady(): boolean;
  15773. /**
  15774. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15775. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15776. */
  15777. apply(): Nullable<Effect>;
  15778. private _disposeTextures;
  15779. /**
  15780. * Disposes the post process.
  15781. * @param camera The camera to dispose the post process on.
  15782. */
  15783. dispose(camera?: Camera): void;
  15784. }
  15785. }
  15786. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15787. /** @hidden */
  15788. export var kernelBlurVaryingDeclaration: {
  15789. name: string;
  15790. shader: string;
  15791. };
  15792. }
  15793. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15794. /** @hidden */
  15795. export var kernelBlurFragment: {
  15796. name: string;
  15797. shader: string;
  15798. };
  15799. }
  15800. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15801. /** @hidden */
  15802. export var kernelBlurFragment2: {
  15803. name: string;
  15804. shader: string;
  15805. };
  15806. }
  15807. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15808. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15809. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15810. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15811. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15812. /** @hidden */
  15813. export var kernelBlurPixelShader: {
  15814. name: string;
  15815. shader: string;
  15816. };
  15817. }
  15818. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15819. /** @hidden */
  15820. export var kernelBlurVertex: {
  15821. name: string;
  15822. shader: string;
  15823. };
  15824. }
  15825. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15826. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15827. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15828. /** @hidden */
  15829. export var kernelBlurVertexShader: {
  15830. name: string;
  15831. shader: string;
  15832. };
  15833. }
  15834. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15835. import { Vector2 } from "babylonjs/Maths/math.vector";
  15836. import { Nullable } from "babylonjs/types";
  15837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15838. import { Camera } from "babylonjs/Cameras/camera";
  15839. import { Effect } from "babylonjs/Materials/effect";
  15840. import { Engine } from "babylonjs/Engines/engine";
  15841. import "babylonjs/Shaders/kernelBlur.fragment";
  15842. import "babylonjs/Shaders/kernelBlur.vertex";
  15843. /**
  15844. * The Blur Post Process which blurs an image based on a kernel and direction.
  15845. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15846. */
  15847. export class BlurPostProcess extends PostProcess {
  15848. /** The direction in which to blur the image. */
  15849. direction: Vector2;
  15850. private blockCompilation;
  15851. protected _kernel: number;
  15852. protected _idealKernel: number;
  15853. protected _packedFloat: boolean;
  15854. private _staticDefines;
  15855. /**
  15856. * Sets the length in pixels of the blur sample region
  15857. */
  15858. /**
  15859. * Gets the length in pixels of the blur sample region
  15860. */
  15861. kernel: number;
  15862. /**
  15863. * Sets wether or not the blur needs to unpack/repack floats
  15864. */
  15865. /**
  15866. * Gets wether or not the blur is unpacking/repacking floats
  15867. */
  15868. packedFloat: boolean;
  15869. /**
  15870. * Creates a new instance BlurPostProcess
  15871. * @param name The name of the effect.
  15872. * @param direction The direction in which to blur the image.
  15873. * @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.
  15874. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15875. * @param camera The camera to apply the render pass to.
  15876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15877. * @param engine The engine which the post process will be applied. (default: current engine)
  15878. * @param reusable If the post process can be reused on the same frame. (default: false)
  15879. * @param textureType Type of textures used when performing the post process. (default: 0)
  15880. * @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)
  15881. */
  15882. constructor(name: string,
  15883. /** The direction in which to blur the image. */
  15884. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15885. /**
  15886. * Updates the effect with the current post process compile time values and recompiles the shader.
  15887. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15888. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15889. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15890. * @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
  15891. * @param onCompiled Called when the shader has been compiled.
  15892. * @param onError Called if there is an error when compiling a shader.
  15893. */
  15894. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15895. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15896. /**
  15897. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15898. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15899. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15900. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15901. * The gaps between physical kernels are compensated for in the weighting of the samples
  15902. * @param idealKernel Ideal blur kernel.
  15903. * @return Nearest best kernel.
  15904. */
  15905. protected _nearestBestKernel(idealKernel: number): number;
  15906. /**
  15907. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15908. * @param x The point on the Gaussian distribution to sample.
  15909. * @return the value of the Gaussian function at x.
  15910. */
  15911. protected _gaussianWeight(x: number): number;
  15912. /**
  15913. * Generates a string that can be used as a floating point number in GLSL.
  15914. * @param x Value to print.
  15915. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15916. * @return GLSL float string.
  15917. */
  15918. protected _glslFloat(x: number, decimalFigures?: number): string;
  15919. }
  15920. }
  15921. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15922. import { Scene } from "babylonjs/scene";
  15923. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15924. import { Plane } from "babylonjs/Maths/math.plane";
  15925. /**
  15926. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15927. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15928. * You can then easily use it as a reflectionTexture on a flat surface.
  15929. * In case the surface is not a plane, please consider relying on reflection probes.
  15930. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15931. */
  15932. export class MirrorTexture extends RenderTargetTexture {
  15933. private scene;
  15934. /**
  15935. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15936. * 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.
  15937. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15938. */
  15939. mirrorPlane: Plane;
  15940. /**
  15941. * Define the blur ratio used to blur the reflection if needed.
  15942. */
  15943. blurRatio: number;
  15944. /**
  15945. * Define the adaptive blur kernel used to blur the reflection if needed.
  15946. * This will autocompute the closest best match for the `blurKernel`
  15947. */
  15948. adaptiveBlurKernel: number;
  15949. /**
  15950. * Define the blur kernel used to blur the reflection if needed.
  15951. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15952. */
  15953. blurKernel: number;
  15954. /**
  15955. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15956. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15957. */
  15958. blurKernelX: number;
  15959. /**
  15960. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15961. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15962. */
  15963. blurKernelY: number;
  15964. private _autoComputeBlurKernel;
  15965. protected _onRatioRescale(): void;
  15966. private _updateGammaSpace;
  15967. private _imageProcessingConfigChangeObserver;
  15968. private _transformMatrix;
  15969. private _mirrorMatrix;
  15970. private _savedViewMatrix;
  15971. private _blurX;
  15972. private _blurY;
  15973. private _adaptiveBlurKernel;
  15974. private _blurKernelX;
  15975. private _blurKernelY;
  15976. private _blurRatio;
  15977. /**
  15978. * Instantiates a Mirror Texture.
  15979. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15980. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15981. * You can then easily use it as a reflectionTexture on a flat surface.
  15982. * In case the surface is not a plane, please consider relying on reflection probes.
  15983. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15984. * @param name
  15985. * @param size
  15986. * @param scene
  15987. * @param generateMipMaps
  15988. * @param type
  15989. * @param samplingMode
  15990. * @param generateDepthBuffer
  15991. */
  15992. constructor(name: string, size: number | {
  15993. width: number;
  15994. height: number;
  15995. } | {
  15996. ratio: number;
  15997. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15998. private _preparePostProcesses;
  15999. /**
  16000. * Clone the mirror texture.
  16001. * @returns the cloned texture
  16002. */
  16003. clone(): MirrorTexture;
  16004. /**
  16005. * Serialize the texture to a JSON representation you could use in Parse later on
  16006. * @returns the serialized JSON representation
  16007. */
  16008. serialize(): any;
  16009. /**
  16010. * Dispose the texture and release its associated resources.
  16011. */
  16012. dispose(): void;
  16013. }
  16014. }
  16015. declare module "babylonjs/Materials/Textures/texture" {
  16016. import { Observable } from "babylonjs/Misc/observable";
  16017. import { Nullable } from "babylonjs/types";
  16018. import { Matrix } from "babylonjs/Maths/math.vector";
  16019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16020. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16021. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16022. import { Scene } from "babylonjs/scene";
  16023. /**
  16024. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16025. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16026. */
  16027. export class Texture extends BaseTexture {
  16028. /**
  16029. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16030. */
  16031. static SerializeBuffers: boolean;
  16032. /** @hidden */
  16033. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16034. /** @hidden */
  16035. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16036. /** @hidden */
  16037. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16038. /** nearest is mag = nearest and min = nearest and mip = linear */
  16039. static readonly NEAREST_SAMPLINGMODE: number;
  16040. /** nearest is mag = nearest and min = nearest and mip = linear */
  16041. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16042. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16043. static readonly BILINEAR_SAMPLINGMODE: number;
  16044. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16045. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16046. /** Trilinear is mag = linear and min = linear and mip = linear */
  16047. static readonly TRILINEAR_SAMPLINGMODE: number;
  16048. /** Trilinear is mag = linear and min = linear and mip = linear */
  16049. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16050. /** mag = nearest and min = nearest and mip = nearest */
  16051. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16052. /** mag = nearest and min = linear and mip = nearest */
  16053. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16054. /** mag = nearest and min = linear and mip = linear */
  16055. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16056. /** mag = nearest and min = linear and mip = none */
  16057. static readonly NEAREST_LINEAR: number;
  16058. /** mag = nearest and min = nearest and mip = none */
  16059. static readonly NEAREST_NEAREST: number;
  16060. /** mag = linear and min = nearest and mip = nearest */
  16061. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16062. /** mag = linear and min = nearest and mip = linear */
  16063. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16064. /** mag = linear and min = linear and mip = none */
  16065. static readonly LINEAR_LINEAR: number;
  16066. /** mag = linear and min = nearest and mip = none */
  16067. static readonly LINEAR_NEAREST: number;
  16068. /** Explicit coordinates mode */
  16069. static readonly EXPLICIT_MODE: number;
  16070. /** Spherical coordinates mode */
  16071. static readonly SPHERICAL_MODE: number;
  16072. /** Planar coordinates mode */
  16073. static readonly PLANAR_MODE: number;
  16074. /** Cubic coordinates mode */
  16075. static readonly CUBIC_MODE: number;
  16076. /** Projection coordinates mode */
  16077. static readonly PROJECTION_MODE: number;
  16078. /** Inverse Cubic coordinates mode */
  16079. static readonly SKYBOX_MODE: number;
  16080. /** Inverse Cubic coordinates mode */
  16081. static readonly INVCUBIC_MODE: number;
  16082. /** Equirectangular coordinates mode */
  16083. static readonly EQUIRECTANGULAR_MODE: number;
  16084. /** Equirectangular Fixed coordinates mode */
  16085. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16086. /** Equirectangular Fixed Mirrored coordinates mode */
  16087. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16088. /** Texture is not repeating outside of 0..1 UVs */
  16089. static readonly CLAMP_ADDRESSMODE: number;
  16090. /** Texture is repeating outside of 0..1 UVs */
  16091. static readonly WRAP_ADDRESSMODE: number;
  16092. /** Texture is repeating and mirrored */
  16093. static readonly MIRROR_ADDRESSMODE: number;
  16094. /**
  16095. * 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
  16096. */
  16097. static UseSerializedUrlIfAny: boolean;
  16098. /**
  16099. * Define the url of the texture.
  16100. */
  16101. url: Nullable<string>;
  16102. /**
  16103. * Define an offset on the texture to offset the u coordinates of the UVs
  16104. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16105. */
  16106. uOffset: number;
  16107. /**
  16108. * Define an offset on the texture to offset the v coordinates of the UVs
  16109. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16110. */
  16111. vOffset: number;
  16112. /**
  16113. * Define an offset on the texture to scale the u coordinates of the UVs
  16114. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16115. */
  16116. uScale: number;
  16117. /**
  16118. * Define an offset on the texture to scale the v coordinates of the UVs
  16119. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16120. */
  16121. vScale: number;
  16122. /**
  16123. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16124. * @see http://doc.babylonjs.com/how_to/more_materials
  16125. */
  16126. uAng: number;
  16127. /**
  16128. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16129. * @see http://doc.babylonjs.com/how_to/more_materials
  16130. */
  16131. vAng: number;
  16132. /**
  16133. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16134. * @see http://doc.babylonjs.com/how_to/more_materials
  16135. */
  16136. wAng: number;
  16137. /**
  16138. * Defines the center of rotation (U)
  16139. */
  16140. uRotationCenter: number;
  16141. /**
  16142. * Defines the center of rotation (V)
  16143. */
  16144. vRotationCenter: number;
  16145. /**
  16146. * Defines the center of rotation (W)
  16147. */
  16148. wRotationCenter: number;
  16149. /**
  16150. * Are mip maps generated for this texture or not.
  16151. */
  16152. readonly noMipmap: boolean;
  16153. /**
  16154. * List of inspectable custom properties (used by the Inspector)
  16155. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16156. */
  16157. inspectableCustomProperties: Nullable<IInspectable[]>;
  16158. private _noMipmap;
  16159. /** @hidden */
  16160. _invertY: boolean;
  16161. private _rowGenerationMatrix;
  16162. private _cachedTextureMatrix;
  16163. private _projectionModeMatrix;
  16164. private _t0;
  16165. private _t1;
  16166. private _t2;
  16167. private _cachedUOffset;
  16168. private _cachedVOffset;
  16169. private _cachedUScale;
  16170. private _cachedVScale;
  16171. private _cachedUAng;
  16172. private _cachedVAng;
  16173. private _cachedWAng;
  16174. private _cachedProjectionMatrixId;
  16175. private _cachedCoordinatesMode;
  16176. /** @hidden */
  16177. protected _initialSamplingMode: number;
  16178. /** @hidden */
  16179. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16180. private _deleteBuffer;
  16181. protected _format: Nullable<number>;
  16182. private _delayedOnLoad;
  16183. private _delayedOnError;
  16184. private _mimeType?;
  16185. /**
  16186. * Observable triggered once the texture has been loaded.
  16187. */
  16188. onLoadObservable: Observable<Texture>;
  16189. protected _isBlocking: boolean;
  16190. /**
  16191. * Is the texture preventing material to render while loading.
  16192. * If false, a default texture will be used instead of the loading one during the preparation step.
  16193. */
  16194. isBlocking: boolean;
  16195. /**
  16196. * Get the current sampling mode associated with the texture.
  16197. */
  16198. readonly samplingMode: number;
  16199. /**
  16200. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16201. */
  16202. readonly invertY: boolean;
  16203. /**
  16204. * Instantiates a new texture.
  16205. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16206. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16207. * @param url defines the url of the picture to load as a texture
  16208. * @param scene defines the scene or engine the texture will belong to
  16209. * @param noMipmap defines if the texture will require mip maps or not
  16210. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16211. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16212. * @param onLoad defines a callback triggered when the texture has been loaded
  16213. * @param onError defines a callback triggered when an error occurred during the loading session
  16214. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16215. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16216. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16217. * @param mimeType defines an optional mime type information
  16218. */
  16219. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16220. /**
  16221. * Update the url (and optional buffer) of this texture if url was null during construction.
  16222. * @param url the url of the texture
  16223. * @param buffer the buffer of the texture (defaults to null)
  16224. * @param onLoad callback called when the texture is loaded (defaults to null)
  16225. */
  16226. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16227. /**
  16228. * Finish the loading sequence of a texture flagged as delayed load.
  16229. * @hidden
  16230. */
  16231. delayLoad(): void;
  16232. private _prepareRowForTextureGeneration;
  16233. /**
  16234. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16235. * @returns the transform matrix of the texture.
  16236. */
  16237. getTextureMatrix(): Matrix;
  16238. /**
  16239. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16240. * @returns The reflection texture transform
  16241. */
  16242. getReflectionTextureMatrix(): Matrix;
  16243. /**
  16244. * Clones the texture.
  16245. * @returns the cloned texture
  16246. */
  16247. clone(): Texture;
  16248. /**
  16249. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16250. * @returns The JSON representation of the texture
  16251. */
  16252. serialize(): any;
  16253. /**
  16254. * Get the current class name of the texture useful for serialization or dynamic coding.
  16255. * @returns "Texture"
  16256. */
  16257. getClassName(): string;
  16258. /**
  16259. * Dispose the texture and release its associated resources.
  16260. */
  16261. dispose(): void;
  16262. /**
  16263. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16264. * @param parsedTexture Define the JSON representation of the texture
  16265. * @param scene Define the scene the parsed texture should be instantiated in
  16266. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16267. * @returns The parsed texture if successful
  16268. */
  16269. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16270. /**
  16271. * Creates a texture from its base 64 representation.
  16272. * @param data Define the base64 payload without the data: prefix
  16273. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16274. * @param scene Define the scene the texture should belong to
  16275. * @param noMipmap Forces the texture to not create mip map information if true
  16276. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16277. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16278. * @param onLoad define a callback triggered when the texture has been loaded
  16279. * @param onError define a callback triggered when an error occurred during the loading session
  16280. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16281. * @returns the created texture
  16282. */
  16283. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16284. /**
  16285. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16286. * @param data Define the base64 payload without the data: prefix
  16287. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16288. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16289. * @param scene Define the scene the texture should belong to
  16290. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16291. * @param noMipmap Forces the texture to not create mip map information if true
  16292. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16293. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16294. * @param onLoad define a callback triggered when the texture has been loaded
  16295. * @param onError define a callback triggered when an error occurred during the loading session
  16296. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16297. * @returns the created texture
  16298. */
  16299. 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;
  16300. }
  16301. }
  16302. declare module "babylonjs/PostProcesses/postProcessManager" {
  16303. import { Nullable } from "babylonjs/types";
  16304. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16305. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16306. import { Scene } from "babylonjs/scene";
  16307. /**
  16308. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16309. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16310. */
  16311. export class PostProcessManager {
  16312. private _scene;
  16313. private _indexBuffer;
  16314. private _vertexBuffers;
  16315. /**
  16316. * Creates a new instance PostProcess
  16317. * @param scene The scene that the post process is associated with.
  16318. */
  16319. constructor(scene: Scene);
  16320. private _prepareBuffers;
  16321. private _buildIndexBuffer;
  16322. /**
  16323. * Rebuilds the vertex buffers of the manager.
  16324. * @hidden
  16325. */
  16326. _rebuild(): void;
  16327. /**
  16328. * Prepares a frame to be run through a post process.
  16329. * @param sourceTexture The input texture to the post procesess. (default: null)
  16330. * @param postProcesses An array of post processes to be run. (default: null)
  16331. * @returns True if the post processes were able to be run.
  16332. * @hidden
  16333. */
  16334. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16335. /**
  16336. * Manually render a set of post processes to a texture.
  16337. * @param postProcesses An array of post processes to be run.
  16338. * @param targetTexture The target texture to render to.
  16339. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16340. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16341. * @param lodLevel defines which lod of the texture to render to
  16342. */
  16343. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16344. /**
  16345. * Finalize the result of the output of the postprocesses.
  16346. * @param doNotPresent If true the result will not be displayed to the screen.
  16347. * @param targetTexture The target texture to render to.
  16348. * @param faceIndex The index of the face to bind the target texture to.
  16349. * @param postProcesses The array of post processes to render.
  16350. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16351. * @hidden
  16352. */
  16353. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16354. /**
  16355. * Disposes of the post process manager.
  16356. */
  16357. dispose(): void;
  16358. }
  16359. }
  16360. declare module "babylonjs/Misc/gradients" {
  16361. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16362. /** Interface used by value gradients (color, factor, ...) */
  16363. export interface IValueGradient {
  16364. /**
  16365. * Gets or sets the gradient value (between 0 and 1)
  16366. */
  16367. gradient: number;
  16368. }
  16369. /** Class used to store color4 gradient */
  16370. export class ColorGradient implements IValueGradient {
  16371. /**
  16372. * Gets or sets the gradient value (between 0 and 1)
  16373. */
  16374. gradient: number;
  16375. /**
  16376. * Gets or sets first associated color
  16377. */
  16378. color1: Color4;
  16379. /**
  16380. * Gets or sets second associated color
  16381. */
  16382. color2?: Color4;
  16383. /**
  16384. * Will get a color picked randomly between color1 and color2.
  16385. * If color2 is undefined then color1 will be used
  16386. * @param result defines the target Color4 to store the result in
  16387. */
  16388. getColorToRef(result: Color4): void;
  16389. }
  16390. /** Class used to store color 3 gradient */
  16391. export class Color3Gradient implements IValueGradient {
  16392. /**
  16393. * Gets or sets the gradient value (between 0 and 1)
  16394. */
  16395. gradient: number;
  16396. /**
  16397. * Gets or sets the associated color
  16398. */
  16399. color: Color3;
  16400. }
  16401. /** Class used to store factor gradient */
  16402. export class FactorGradient implements IValueGradient {
  16403. /**
  16404. * Gets or sets the gradient value (between 0 and 1)
  16405. */
  16406. gradient: number;
  16407. /**
  16408. * Gets or sets first associated factor
  16409. */
  16410. factor1: number;
  16411. /**
  16412. * Gets or sets second associated factor
  16413. */
  16414. factor2?: number;
  16415. /**
  16416. * Will get a number picked randomly between factor1 and factor2.
  16417. * If factor2 is undefined then factor1 will be used
  16418. * @returns the picked number
  16419. */
  16420. getFactor(): number;
  16421. }
  16422. /**
  16423. * Helper used to simplify some generic gradient tasks
  16424. */
  16425. export class GradientHelper {
  16426. /**
  16427. * Gets the current gradient from an array of IValueGradient
  16428. * @param ratio defines the current ratio to get
  16429. * @param gradients defines the array of IValueGradient
  16430. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16431. */
  16432. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16433. }
  16434. }
  16435. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16436. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16437. import { Nullable } from "babylonjs/types";
  16438. module "babylonjs/Engines/thinEngine" {
  16439. interface ThinEngine {
  16440. /**
  16441. * Creates a dynamic texture
  16442. * @param width defines the width of the texture
  16443. * @param height defines the height of the texture
  16444. * @param generateMipMaps defines if the engine should generate the mip levels
  16445. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16446. * @returns the dynamic texture inside an InternalTexture
  16447. */
  16448. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16449. /**
  16450. * Update the content of a dynamic texture
  16451. * @param texture defines the texture to update
  16452. * @param canvas defines the canvas containing the source
  16453. * @param invertY defines if data must be stored with Y axis inverted
  16454. * @param premulAlpha defines if alpha is stored as premultiplied
  16455. * @param format defines the format of the data
  16456. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16457. */
  16458. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16459. }
  16460. }
  16461. }
  16462. declare module "babylonjs/Misc/canvasGenerator" {
  16463. /**
  16464. * Helper class used to generate a canvas to manipulate images
  16465. */
  16466. export class CanvasGenerator {
  16467. /**
  16468. * Create a new canvas (or offscreen canvas depending on the context)
  16469. * @param width defines the expected width
  16470. * @param height defines the expected height
  16471. * @return a new canvas or offscreen canvas
  16472. */
  16473. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16474. }
  16475. }
  16476. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16477. import { Scene } from "babylonjs/scene";
  16478. import { Texture } from "babylonjs/Materials/Textures/texture";
  16479. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16480. /**
  16481. * A class extending Texture allowing drawing on a texture
  16482. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16483. */
  16484. export class DynamicTexture extends Texture {
  16485. private _generateMipMaps;
  16486. private _canvas;
  16487. private _context;
  16488. private _engine;
  16489. /**
  16490. * Creates a DynamicTexture
  16491. * @param name defines the name of the texture
  16492. * @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
  16493. * @param scene defines the scene where you want the texture
  16494. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16495. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16496. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16497. */
  16498. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16499. /**
  16500. * Get the current class name of the texture useful for serialization or dynamic coding.
  16501. * @returns "DynamicTexture"
  16502. */
  16503. getClassName(): string;
  16504. /**
  16505. * Gets the current state of canRescale
  16506. */
  16507. readonly canRescale: boolean;
  16508. private _recreate;
  16509. /**
  16510. * Scales the texture
  16511. * @param ratio the scale factor to apply to both width and height
  16512. */
  16513. scale(ratio: number): void;
  16514. /**
  16515. * Resizes the texture
  16516. * @param width the new width
  16517. * @param height the new height
  16518. */
  16519. scaleTo(width: number, height: number): void;
  16520. /**
  16521. * Gets the context of the canvas used by the texture
  16522. * @returns the canvas context of the dynamic texture
  16523. */
  16524. getContext(): CanvasRenderingContext2D;
  16525. /**
  16526. * Clears the texture
  16527. */
  16528. clear(): void;
  16529. /**
  16530. * Updates the texture
  16531. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16532. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16533. */
  16534. update(invertY?: boolean, premulAlpha?: boolean): void;
  16535. /**
  16536. * Draws text onto the texture
  16537. * @param text defines the text to be drawn
  16538. * @param x defines the placement of the text from the left
  16539. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16540. * @param font defines the font to be used with font-style, font-size, font-name
  16541. * @param color defines the color used for the text
  16542. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16543. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16544. * @param update defines whether texture is immediately update (default is true)
  16545. */
  16546. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16547. /**
  16548. * Clones the texture
  16549. * @returns the clone of the texture.
  16550. */
  16551. clone(): DynamicTexture;
  16552. /**
  16553. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16554. * @returns a serialized dynamic texture object
  16555. */
  16556. serialize(): any;
  16557. /** @hidden */
  16558. _rebuild(): void;
  16559. }
  16560. }
  16561. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16562. import { Scene } from "babylonjs/scene";
  16563. import { ISceneComponent } from "babylonjs/sceneComponent";
  16564. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16565. module "babylonjs/abstractScene" {
  16566. interface AbstractScene {
  16567. /**
  16568. * The list of procedural textures added to the scene
  16569. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16570. */
  16571. proceduralTextures: Array<ProceduralTexture>;
  16572. }
  16573. }
  16574. /**
  16575. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16576. * in a given scene.
  16577. */
  16578. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16579. /**
  16580. * The component name helpfull to identify the component in the list of scene components.
  16581. */
  16582. readonly name: string;
  16583. /**
  16584. * The scene the component belongs to.
  16585. */
  16586. scene: Scene;
  16587. /**
  16588. * Creates a new instance of the component for the given scene
  16589. * @param scene Defines the scene to register the component in
  16590. */
  16591. constructor(scene: Scene);
  16592. /**
  16593. * Registers the component in a given scene
  16594. */
  16595. register(): void;
  16596. /**
  16597. * Rebuilds the elements related to this component in case of
  16598. * context lost for instance.
  16599. */
  16600. rebuild(): void;
  16601. /**
  16602. * Disposes the component and the associated ressources.
  16603. */
  16604. dispose(): void;
  16605. private _beforeClear;
  16606. }
  16607. }
  16608. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16609. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16610. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16611. module "babylonjs/Engines/thinEngine" {
  16612. interface ThinEngine {
  16613. /**
  16614. * Creates a new render target cube texture
  16615. * @param size defines the size of the texture
  16616. * @param options defines the options used to create the texture
  16617. * @returns a new render target cube texture stored in an InternalTexture
  16618. */
  16619. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16620. }
  16621. }
  16622. }
  16623. declare module "babylonjs/Shaders/procedural.vertex" {
  16624. /** @hidden */
  16625. export var proceduralVertexShader: {
  16626. name: string;
  16627. shader: string;
  16628. };
  16629. }
  16630. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16631. import { Observable } from "babylonjs/Misc/observable";
  16632. import { Nullable } from "babylonjs/types";
  16633. import { Scene } from "babylonjs/scene";
  16634. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16635. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16636. import { Effect } from "babylonjs/Materials/effect";
  16637. import { Texture } from "babylonjs/Materials/Textures/texture";
  16638. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16639. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16640. import "babylonjs/Shaders/procedural.vertex";
  16641. /**
  16642. * 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.
  16643. * This is the base class of any Procedural texture and contains most of the shareable code.
  16644. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16645. */
  16646. export class ProceduralTexture extends Texture {
  16647. isCube: boolean;
  16648. /**
  16649. * Define if the texture is enabled or not (disabled texture will not render)
  16650. */
  16651. isEnabled: boolean;
  16652. /**
  16653. * Define if the texture must be cleared before rendering (default is true)
  16654. */
  16655. autoClear: boolean;
  16656. /**
  16657. * Callback called when the texture is generated
  16658. */
  16659. onGenerated: () => void;
  16660. /**
  16661. * Event raised when the texture is generated
  16662. */
  16663. onGeneratedObservable: Observable<ProceduralTexture>;
  16664. /** @hidden */
  16665. _generateMipMaps: boolean;
  16666. /** @hidden **/
  16667. _effect: Effect;
  16668. /** @hidden */
  16669. _textures: {
  16670. [key: string]: Texture;
  16671. };
  16672. private _size;
  16673. private _currentRefreshId;
  16674. private _refreshRate;
  16675. private _vertexBuffers;
  16676. private _indexBuffer;
  16677. private _uniforms;
  16678. private _samplers;
  16679. private _fragment;
  16680. private _floats;
  16681. private _ints;
  16682. private _floatsArrays;
  16683. private _colors3;
  16684. private _colors4;
  16685. private _vectors2;
  16686. private _vectors3;
  16687. private _matrices;
  16688. private _fallbackTexture;
  16689. private _fallbackTextureUsed;
  16690. private _engine;
  16691. private _cachedDefines;
  16692. private _contentUpdateId;
  16693. private _contentData;
  16694. /**
  16695. * Instantiates a new procedural texture.
  16696. * 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.
  16697. * This is the base class of any Procedural texture and contains most of the shareable code.
  16698. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16699. * @param name Define the name of the texture
  16700. * @param size Define the size of the texture to create
  16701. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16702. * @param scene Define the scene the texture belongs to
  16703. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16704. * @param generateMipMaps Define if the texture should creates mip maps or not
  16705. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16706. */
  16707. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16708. /**
  16709. * The effect that is created when initializing the post process.
  16710. * @returns The created effect corresponding the the postprocess.
  16711. */
  16712. getEffect(): Effect;
  16713. /**
  16714. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16715. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16716. */
  16717. getContent(): Nullable<ArrayBufferView>;
  16718. private _createIndexBuffer;
  16719. /** @hidden */
  16720. _rebuild(): void;
  16721. /**
  16722. * Resets the texture in order to recreate its associated resources.
  16723. * This can be called in case of context loss
  16724. */
  16725. reset(): void;
  16726. protected _getDefines(): string;
  16727. /**
  16728. * Is the texture ready to be used ? (rendered at least once)
  16729. * @returns true if ready, otherwise, false.
  16730. */
  16731. isReady(): boolean;
  16732. /**
  16733. * Resets the refresh counter of the texture and start bak from scratch.
  16734. * Could be useful to regenerate the texture if it is setup to render only once.
  16735. */
  16736. resetRefreshCounter(): void;
  16737. /**
  16738. * Set the fragment shader to use in order to render the texture.
  16739. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16740. */
  16741. setFragment(fragment: any): void;
  16742. /**
  16743. * Define the refresh rate of the texture or the rendering frequency.
  16744. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16745. */
  16746. refreshRate: number;
  16747. /** @hidden */
  16748. _shouldRender(): boolean;
  16749. /**
  16750. * Get the size the texture is rendering at.
  16751. * @returns the size (texture is always squared)
  16752. */
  16753. getRenderSize(): number;
  16754. /**
  16755. * Resize the texture to new value.
  16756. * @param size Define the new size the texture should have
  16757. * @param generateMipMaps Define whether the new texture should create mip maps
  16758. */
  16759. resize(size: number, generateMipMaps: boolean): void;
  16760. private _checkUniform;
  16761. /**
  16762. * Set a texture in the shader program used to render.
  16763. * @param name Define the name of the uniform samplers as defined in the shader
  16764. * @param texture Define the texture to bind to this sampler
  16765. * @return the texture itself allowing "fluent" like uniform updates
  16766. */
  16767. setTexture(name: string, texture: Texture): ProceduralTexture;
  16768. /**
  16769. * Set a float in the shader.
  16770. * @param name Define the name of the uniform as defined in the shader
  16771. * @param value Define the value to give to the uniform
  16772. * @return the texture itself allowing "fluent" like uniform updates
  16773. */
  16774. setFloat(name: string, value: number): ProceduralTexture;
  16775. /**
  16776. * Set a int in the shader.
  16777. * @param name Define the name of the uniform as defined in the shader
  16778. * @param value Define the value to give to the uniform
  16779. * @return the texture itself allowing "fluent" like uniform updates
  16780. */
  16781. setInt(name: string, value: number): ProceduralTexture;
  16782. /**
  16783. * Set an array of floats in the shader.
  16784. * @param name Define the name of the uniform as defined in the shader
  16785. * @param value Define the value to give to the uniform
  16786. * @return the texture itself allowing "fluent" like uniform updates
  16787. */
  16788. setFloats(name: string, value: number[]): ProceduralTexture;
  16789. /**
  16790. * Set a vec3 in the shader from a Color3.
  16791. * @param name Define the name of the uniform as defined in the shader
  16792. * @param value Define the value to give to the uniform
  16793. * @return the texture itself allowing "fluent" like uniform updates
  16794. */
  16795. setColor3(name: string, value: Color3): ProceduralTexture;
  16796. /**
  16797. * Set a vec4 in the shader from a Color4.
  16798. * @param name Define the name of the uniform as defined in the shader
  16799. * @param value Define the value to give to the uniform
  16800. * @return the texture itself allowing "fluent" like uniform updates
  16801. */
  16802. setColor4(name: string, value: Color4): ProceduralTexture;
  16803. /**
  16804. * Set a vec2 in the shader from a Vector2.
  16805. * @param name Define the name of the uniform as defined in the shader
  16806. * @param value Define the value to give to the uniform
  16807. * @return the texture itself allowing "fluent" like uniform updates
  16808. */
  16809. setVector2(name: string, value: Vector2): ProceduralTexture;
  16810. /**
  16811. * Set a vec3 in the shader from a Vector3.
  16812. * @param name Define the name of the uniform as defined in the shader
  16813. * @param value Define the value to give to the uniform
  16814. * @return the texture itself allowing "fluent" like uniform updates
  16815. */
  16816. setVector3(name: string, value: Vector3): ProceduralTexture;
  16817. /**
  16818. * Set a mat4 in the shader from a MAtrix.
  16819. * @param name Define the name of the uniform as defined in the shader
  16820. * @param value Define the value to give to the uniform
  16821. * @return the texture itself allowing "fluent" like uniform updates
  16822. */
  16823. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16824. /**
  16825. * Render the texture to its associated render target.
  16826. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16827. */
  16828. render(useCameraPostProcess?: boolean): void;
  16829. /**
  16830. * Clone the texture.
  16831. * @returns the cloned texture
  16832. */
  16833. clone(): ProceduralTexture;
  16834. /**
  16835. * Dispose the texture and release its asoociated resources.
  16836. */
  16837. dispose(): void;
  16838. }
  16839. }
  16840. declare module "babylonjs/Particles/baseParticleSystem" {
  16841. import { Nullable } from "babylonjs/types";
  16842. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16844. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16845. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16846. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16847. import { Scene } from "babylonjs/scene";
  16848. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16849. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16850. import { Texture } from "babylonjs/Materials/Textures/texture";
  16851. import { Color4 } from "babylonjs/Maths/math.color";
  16852. import { Animation } from "babylonjs/Animations/animation";
  16853. /**
  16854. * This represents the base class for particle system in Babylon.
  16855. * 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.
  16856. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16857. * @example https://doc.babylonjs.com/babylon101/particles
  16858. */
  16859. export class BaseParticleSystem {
  16860. /**
  16861. * Source color is added to the destination color without alpha affecting the result
  16862. */
  16863. static BLENDMODE_ONEONE: number;
  16864. /**
  16865. * Blend current color and particle color using particle’s alpha
  16866. */
  16867. static BLENDMODE_STANDARD: number;
  16868. /**
  16869. * Add current color and particle color multiplied by particle’s alpha
  16870. */
  16871. static BLENDMODE_ADD: number;
  16872. /**
  16873. * Multiply current color with particle color
  16874. */
  16875. static BLENDMODE_MULTIPLY: number;
  16876. /**
  16877. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16878. */
  16879. static BLENDMODE_MULTIPLYADD: number;
  16880. /**
  16881. * List of animations used by the particle system.
  16882. */
  16883. animations: Animation[];
  16884. /**
  16885. * The id of the Particle system.
  16886. */
  16887. id: string;
  16888. /**
  16889. * The friendly name of the Particle system.
  16890. */
  16891. name: string;
  16892. /**
  16893. * The rendering group used by the Particle system to chose when to render.
  16894. */
  16895. renderingGroupId: number;
  16896. /**
  16897. * The emitter represents the Mesh or position we are attaching the particle system to.
  16898. */
  16899. emitter: Nullable<AbstractMesh | Vector3>;
  16900. /**
  16901. * The maximum number of particles to emit per frame
  16902. */
  16903. emitRate: number;
  16904. /**
  16905. * If you want to launch only a few particles at once, that can be done, as well.
  16906. */
  16907. manualEmitCount: number;
  16908. /**
  16909. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16910. */
  16911. updateSpeed: number;
  16912. /**
  16913. * The amount of time the particle system is running (depends of the overall update speed).
  16914. */
  16915. targetStopDuration: number;
  16916. /**
  16917. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16918. */
  16919. disposeOnStop: boolean;
  16920. /**
  16921. * Minimum power of emitting particles.
  16922. */
  16923. minEmitPower: number;
  16924. /**
  16925. * Maximum power of emitting particles.
  16926. */
  16927. maxEmitPower: number;
  16928. /**
  16929. * Minimum life time of emitting particles.
  16930. */
  16931. minLifeTime: number;
  16932. /**
  16933. * Maximum life time of emitting particles.
  16934. */
  16935. maxLifeTime: number;
  16936. /**
  16937. * Minimum Size of emitting particles.
  16938. */
  16939. minSize: number;
  16940. /**
  16941. * Maximum Size of emitting particles.
  16942. */
  16943. maxSize: number;
  16944. /**
  16945. * Minimum scale of emitting particles on X axis.
  16946. */
  16947. minScaleX: number;
  16948. /**
  16949. * Maximum scale of emitting particles on X axis.
  16950. */
  16951. maxScaleX: number;
  16952. /**
  16953. * Minimum scale of emitting particles on Y axis.
  16954. */
  16955. minScaleY: number;
  16956. /**
  16957. * Maximum scale of emitting particles on Y axis.
  16958. */
  16959. maxScaleY: number;
  16960. /**
  16961. * Gets or sets the minimal initial rotation in radians.
  16962. */
  16963. minInitialRotation: number;
  16964. /**
  16965. * Gets or sets the maximal initial rotation in radians.
  16966. */
  16967. maxInitialRotation: number;
  16968. /**
  16969. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16970. */
  16971. minAngularSpeed: number;
  16972. /**
  16973. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16974. */
  16975. maxAngularSpeed: number;
  16976. /**
  16977. * The texture used to render each particle. (this can be a spritesheet)
  16978. */
  16979. particleTexture: Nullable<Texture>;
  16980. /**
  16981. * The layer mask we are rendering the particles through.
  16982. */
  16983. layerMask: number;
  16984. /**
  16985. * This can help using your own shader to render the particle system.
  16986. * The according effect will be created
  16987. */
  16988. customShader: any;
  16989. /**
  16990. * By default particle system starts as soon as they are created. This prevents the
  16991. * automatic start to happen and let you decide when to start emitting particles.
  16992. */
  16993. preventAutoStart: boolean;
  16994. private _noiseTexture;
  16995. /**
  16996. * Gets or sets a texture used to add random noise to particle positions
  16997. */
  16998. noiseTexture: Nullable<ProceduralTexture>;
  16999. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17000. noiseStrength: Vector3;
  17001. /**
  17002. * Callback triggered when the particle animation is ending.
  17003. */
  17004. onAnimationEnd: Nullable<() => void>;
  17005. /**
  17006. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17007. */
  17008. blendMode: number;
  17009. /**
  17010. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17011. * to override the particles.
  17012. */
  17013. forceDepthWrite: boolean;
  17014. /** 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 */
  17015. preWarmCycles: number;
  17016. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17017. preWarmStepOffset: number;
  17018. /**
  17019. * 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)
  17020. */
  17021. spriteCellChangeSpeed: number;
  17022. /**
  17023. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17024. */
  17025. startSpriteCellID: number;
  17026. /**
  17027. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17028. */
  17029. endSpriteCellID: number;
  17030. /**
  17031. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17032. */
  17033. spriteCellWidth: number;
  17034. /**
  17035. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17036. */
  17037. spriteCellHeight: number;
  17038. /**
  17039. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17040. */
  17041. spriteRandomStartCell: boolean;
  17042. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17043. translationPivot: Vector2;
  17044. /** @hidden */
  17045. protected _isAnimationSheetEnabled: boolean;
  17046. /**
  17047. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17048. */
  17049. beginAnimationOnStart: boolean;
  17050. /**
  17051. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17052. */
  17053. beginAnimationFrom: number;
  17054. /**
  17055. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17056. */
  17057. beginAnimationTo: number;
  17058. /**
  17059. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17060. */
  17061. beginAnimationLoop: boolean;
  17062. /**
  17063. * Gets or sets a world offset applied to all particles
  17064. */
  17065. worldOffset: Vector3;
  17066. /**
  17067. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17068. */
  17069. isAnimationSheetEnabled: boolean;
  17070. /**
  17071. * Get hosting scene
  17072. * @returns the scene
  17073. */
  17074. getScene(): Scene;
  17075. /**
  17076. * You can use gravity if you want to give an orientation to your particles.
  17077. */
  17078. gravity: Vector3;
  17079. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17080. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17081. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17082. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17083. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17084. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17085. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17086. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17087. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17088. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17089. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17090. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17091. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17092. /**
  17093. * Defines the delay in milliseconds before starting the system (0 by default)
  17094. */
  17095. startDelay: number;
  17096. /**
  17097. * Gets the current list of drag gradients.
  17098. * You must use addDragGradient and removeDragGradient to udpate this list
  17099. * @returns the list of drag gradients
  17100. */
  17101. getDragGradients(): Nullable<Array<FactorGradient>>;
  17102. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17103. limitVelocityDamping: number;
  17104. /**
  17105. * Gets the current list of limit velocity gradients.
  17106. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17107. * @returns the list of limit velocity gradients
  17108. */
  17109. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17110. /**
  17111. * Gets the current list of color gradients.
  17112. * You must use addColorGradient and removeColorGradient to udpate this list
  17113. * @returns the list of color gradients
  17114. */
  17115. getColorGradients(): Nullable<Array<ColorGradient>>;
  17116. /**
  17117. * Gets the current list of size gradients.
  17118. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17119. * @returns the list of size gradients
  17120. */
  17121. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17122. /**
  17123. * Gets the current list of color remap gradients.
  17124. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17125. * @returns the list of color remap gradients
  17126. */
  17127. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17128. /**
  17129. * Gets the current list of alpha remap gradients.
  17130. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17131. * @returns the list of alpha remap gradients
  17132. */
  17133. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17134. /**
  17135. * Gets the current list of life time gradients.
  17136. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17137. * @returns the list of life time gradients
  17138. */
  17139. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17140. /**
  17141. * Gets the current list of angular speed gradients.
  17142. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17143. * @returns the list of angular speed gradients
  17144. */
  17145. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17146. /**
  17147. * Gets the current list of velocity gradients.
  17148. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17149. * @returns the list of velocity gradients
  17150. */
  17151. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17152. /**
  17153. * Gets the current list of start size gradients.
  17154. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17155. * @returns the list of start size gradients
  17156. */
  17157. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17158. /**
  17159. * Gets the current list of emit rate gradients.
  17160. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17161. * @returns the list of emit rate gradients
  17162. */
  17163. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17164. /**
  17165. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17166. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17167. */
  17168. direction1: Vector3;
  17169. /**
  17170. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17171. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17172. */
  17173. direction2: Vector3;
  17174. /**
  17175. * 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.
  17176. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17177. */
  17178. minEmitBox: Vector3;
  17179. /**
  17180. * 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.
  17181. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17182. */
  17183. maxEmitBox: Vector3;
  17184. /**
  17185. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17186. */
  17187. color1: Color4;
  17188. /**
  17189. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17190. */
  17191. color2: Color4;
  17192. /**
  17193. * Color the particle will have at the end of its lifetime
  17194. */
  17195. colorDead: Color4;
  17196. /**
  17197. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17198. */
  17199. textureMask: Color4;
  17200. /**
  17201. * The particle emitter type defines the emitter used by the particle system.
  17202. * It can be for example box, sphere, or cone...
  17203. */
  17204. particleEmitterType: IParticleEmitterType;
  17205. /** @hidden */
  17206. _isSubEmitter: boolean;
  17207. /**
  17208. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17209. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17210. */
  17211. billboardMode: number;
  17212. protected _isBillboardBased: boolean;
  17213. /**
  17214. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17215. */
  17216. isBillboardBased: boolean;
  17217. /**
  17218. * The scene the particle system belongs to.
  17219. */
  17220. protected _scene: Scene;
  17221. /**
  17222. * Local cache of defines for image processing.
  17223. */
  17224. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17225. /**
  17226. * Default configuration related to image processing available in the standard Material.
  17227. */
  17228. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17229. /**
  17230. * Gets the image processing configuration used either in this material.
  17231. */
  17232. /**
  17233. * Sets the Default image processing configuration used either in the this material.
  17234. *
  17235. * If sets to null, the scene one is in use.
  17236. */
  17237. imageProcessingConfiguration: ImageProcessingConfiguration;
  17238. /**
  17239. * Attaches a new image processing configuration to the Standard Material.
  17240. * @param configuration
  17241. */
  17242. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17243. /** @hidden */
  17244. protected _reset(): void;
  17245. /** @hidden */
  17246. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17247. /**
  17248. * Instantiates a particle system.
  17249. * 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.
  17250. * @param name The name of the particle system
  17251. */
  17252. constructor(name: string);
  17253. /**
  17254. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17255. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17256. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17257. * @returns the emitter
  17258. */
  17259. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17260. /**
  17261. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17262. * @param radius The radius of the hemisphere to emit from
  17263. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17264. * @returns the emitter
  17265. */
  17266. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17267. /**
  17268. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17269. * @param radius The radius of the sphere to emit from
  17270. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17271. * @returns the emitter
  17272. */
  17273. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17274. /**
  17275. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17276. * @param radius The radius of the sphere to emit from
  17277. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17278. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17279. * @returns the emitter
  17280. */
  17281. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17282. /**
  17283. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17284. * @param radius The radius of the emission cylinder
  17285. * @param height The height of the emission cylinder
  17286. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17287. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17288. * @returns the emitter
  17289. */
  17290. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17291. /**
  17292. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17293. * @param radius The radius of the cylinder to emit from
  17294. * @param height The height of the emission cylinder
  17295. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17296. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17297. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17298. * @returns the emitter
  17299. */
  17300. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17301. /**
  17302. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17303. * @param radius The radius of the cone to emit from
  17304. * @param angle The base angle of the cone
  17305. * @returns the emitter
  17306. */
  17307. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17308. /**
  17309. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17310. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17311. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17312. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17313. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17314. * @returns the emitter
  17315. */
  17316. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17317. }
  17318. }
  17319. declare module "babylonjs/Particles/subEmitter" {
  17320. import { Scene } from "babylonjs/scene";
  17321. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17322. /**
  17323. * Type of sub emitter
  17324. */
  17325. export enum SubEmitterType {
  17326. /**
  17327. * Attached to the particle over it's lifetime
  17328. */
  17329. ATTACHED = 0,
  17330. /**
  17331. * Created when the particle dies
  17332. */
  17333. END = 1
  17334. }
  17335. /**
  17336. * Sub emitter class used to emit particles from an existing particle
  17337. */
  17338. export class SubEmitter {
  17339. /**
  17340. * the particle system to be used by the sub emitter
  17341. */
  17342. particleSystem: ParticleSystem;
  17343. /**
  17344. * Type of the submitter (Default: END)
  17345. */
  17346. type: SubEmitterType;
  17347. /**
  17348. * 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)
  17349. * Note: This only is supported when using an emitter of type Mesh
  17350. */
  17351. inheritDirection: boolean;
  17352. /**
  17353. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17354. */
  17355. inheritedVelocityAmount: number;
  17356. /**
  17357. * Creates a sub emitter
  17358. * @param particleSystem the particle system to be used by the sub emitter
  17359. */
  17360. constructor(
  17361. /**
  17362. * the particle system to be used by the sub emitter
  17363. */
  17364. particleSystem: ParticleSystem);
  17365. /**
  17366. * Clones the sub emitter
  17367. * @returns the cloned sub emitter
  17368. */
  17369. clone(): SubEmitter;
  17370. /**
  17371. * Serialize current object to a JSON object
  17372. * @returns the serialized object
  17373. */
  17374. serialize(): any;
  17375. /** @hidden */
  17376. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17377. /**
  17378. * Creates a new SubEmitter from a serialized JSON version
  17379. * @param serializationObject defines the JSON object to read from
  17380. * @param scene defines the hosting scene
  17381. * @param rootUrl defines the rootUrl for data loading
  17382. * @returns a new SubEmitter
  17383. */
  17384. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17385. /** Release associated resources */
  17386. dispose(): void;
  17387. }
  17388. }
  17389. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17390. /** @hidden */
  17391. export var clipPlaneFragmentDeclaration: {
  17392. name: string;
  17393. shader: string;
  17394. };
  17395. }
  17396. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17397. /** @hidden */
  17398. export var imageProcessingDeclaration: {
  17399. name: string;
  17400. shader: string;
  17401. };
  17402. }
  17403. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17404. /** @hidden */
  17405. export var imageProcessingFunctions: {
  17406. name: string;
  17407. shader: string;
  17408. };
  17409. }
  17410. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17411. /** @hidden */
  17412. export var clipPlaneFragment: {
  17413. name: string;
  17414. shader: string;
  17415. };
  17416. }
  17417. declare module "babylonjs/Shaders/particles.fragment" {
  17418. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17419. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17420. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17421. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17422. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17423. /** @hidden */
  17424. export var particlesPixelShader: {
  17425. name: string;
  17426. shader: string;
  17427. };
  17428. }
  17429. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17430. /** @hidden */
  17431. export var clipPlaneVertexDeclaration: {
  17432. name: string;
  17433. shader: string;
  17434. };
  17435. }
  17436. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17437. /** @hidden */
  17438. export var clipPlaneVertex: {
  17439. name: string;
  17440. shader: string;
  17441. };
  17442. }
  17443. declare module "babylonjs/Shaders/particles.vertex" {
  17444. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17445. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17446. /** @hidden */
  17447. export var particlesVertexShader: {
  17448. name: string;
  17449. shader: string;
  17450. };
  17451. }
  17452. declare module "babylonjs/Particles/particleSystem" {
  17453. import { Nullable } from "babylonjs/types";
  17454. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17455. import { Observable } from "babylonjs/Misc/observable";
  17456. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17457. import { Effect } from "babylonjs/Materials/effect";
  17458. import { Scene, IDisposable } from "babylonjs/scene";
  17459. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17460. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17461. import { Particle } from "babylonjs/Particles/particle";
  17462. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17463. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17464. import "babylonjs/Shaders/particles.fragment";
  17465. import "babylonjs/Shaders/particles.vertex";
  17466. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17467. /**
  17468. * This represents a particle system in Babylon.
  17469. * 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.
  17470. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17471. * @example https://doc.babylonjs.com/babylon101/particles
  17472. */
  17473. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17474. /**
  17475. * Billboard mode will only apply to Y axis
  17476. */
  17477. static readonly BILLBOARDMODE_Y: number;
  17478. /**
  17479. * Billboard mode will apply to all axes
  17480. */
  17481. static readonly BILLBOARDMODE_ALL: number;
  17482. /**
  17483. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17484. */
  17485. static readonly BILLBOARDMODE_STRETCHED: number;
  17486. /**
  17487. * This function can be defined to provide custom update for active particles.
  17488. * This function will be called instead of regular update (age, position, color, etc.).
  17489. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17490. */
  17491. updateFunction: (particles: Particle[]) => void;
  17492. private _emitterWorldMatrix;
  17493. /**
  17494. * This function can be defined to specify initial direction for every new particle.
  17495. * It by default use the emitterType defined function
  17496. */
  17497. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17498. /**
  17499. * This function can be defined to specify initial position for every new particle.
  17500. * It by default use the emitterType defined function
  17501. */
  17502. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17503. /**
  17504. * @hidden
  17505. */
  17506. _inheritedVelocityOffset: Vector3;
  17507. /**
  17508. * An event triggered when the system is disposed
  17509. */
  17510. onDisposeObservable: Observable<ParticleSystem>;
  17511. private _onDisposeObserver;
  17512. /**
  17513. * Sets a callback that will be triggered when the system is disposed
  17514. */
  17515. onDispose: () => void;
  17516. private _particles;
  17517. private _epsilon;
  17518. private _capacity;
  17519. private _stockParticles;
  17520. private _newPartsExcess;
  17521. private _vertexData;
  17522. private _vertexBuffer;
  17523. private _vertexBuffers;
  17524. private _spriteBuffer;
  17525. private _indexBuffer;
  17526. private _effect;
  17527. private _customEffect;
  17528. private _cachedDefines;
  17529. private _scaledColorStep;
  17530. private _colorDiff;
  17531. private _scaledDirection;
  17532. private _scaledGravity;
  17533. private _currentRenderId;
  17534. private _alive;
  17535. private _useInstancing;
  17536. private _started;
  17537. private _stopped;
  17538. private _actualFrame;
  17539. private _scaledUpdateSpeed;
  17540. private _vertexBufferSize;
  17541. /** @hidden */
  17542. _currentEmitRateGradient: Nullable<FactorGradient>;
  17543. /** @hidden */
  17544. _currentEmitRate1: number;
  17545. /** @hidden */
  17546. _currentEmitRate2: number;
  17547. /** @hidden */
  17548. _currentStartSizeGradient: Nullable<FactorGradient>;
  17549. /** @hidden */
  17550. _currentStartSize1: number;
  17551. /** @hidden */
  17552. _currentStartSize2: number;
  17553. private readonly _rawTextureWidth;
  17554. private _rampGradientsTexture;
  17555. private _useRampGradients;
  17556. /** Gets or sets a boolean indicating that ramp gradients must be used
  17557. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17558. */
  17559. useRampGradients: boolean;
  17560. /**
  17561. * 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.
  17562. * 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: [])
  17563. */
  17564. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17565. private _subEmitters;
  17566. /**
  17567. * @hidden
  17568. * If the particle systems emitter should be disposed when the particle system is disposed
  17569. */
  17570. _disposeEmitterOnDispose: boolean;
  17571. /**
  17572. * The current active Sub-systems, this property is used by the root particle system only.
  17573. */
  17574. activeSubSystems: Array<ParticleSystem>;
  17575. private _rootParticleSystem;
  17576. /**
  17577. * Gets the current list of active particles
  17578. */
  17579. readonly particles: Particle[];
  17580. /**
  17581. * Returns the string "ParticleSystem"
  17582. * @returns a string containing the class name
  17583. */
  17584. getClassName(): string;
  17585. /**
  17586. * Instantiates a particle system.
  17587. * 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.
  17588. * @param name The name of the particle system
  17589. * @param capacity The max number of particles alive at the same time
  17590. * @param scene The scene the particle system belongs to
  17591. * @param customEffect a custom effect used to change the way particles are rendered by default
  17592. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17593. * @param epsilon Offset used to render the particles
  17594. */
  17595. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17596. private _addFactorGradient;
  17597. private _removeFactorGradient;
  17598. /**
  17599. * Adds a new life time gradient
  17600. * @param gradient defines the gradient to use (between 0 and 1)
  17601. * @param factor defines the life time factor to affect to the specified gradient
  17602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17603. * @returns the current particle system
  17604. */
  17605. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17606. /**
  17607. * Remove a specific life time gradient
  17608. * @param gradient defines the gradient to remove
  17609. * @returns the current particle system
  17610. */
  17611. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17612. /**
  17613. * Adds a new size gradient
  17614. * @param gradient defines the gradient to use (between 0 and 1)
  17615. * @param factor defines the size factor to affect to the specified gradient
  17616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17617. * @returns the current particle system
  17618. */
  17619. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17620. /**
  17621. * Remove a specific size gradient
  17622. * @param gradient defines the gradient to remove
  17623. * @returns the current particle system
  17624. */
  17625. removeSizeGradient(gradient: number): IParticleSystem;
  17626. /**
  17627. * Adds a new color remap gradient
  17628. * @param gradient defines the gradient to use (between 0 and 1)
  17629. * @param min defines the color remap minimal range
  17630. * @param max defines the color remap maximal range
  17631. * @returns the current particle system
  17632. */
  17633. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17634. /**
  17635. * Remove a specific color remap gradient
  17636. * @param gradient defines the gradient to remove
  17637. * @returns the current particle system
  17638. */
  17639. removeColorRemapGradient(gradient: number): IParticleSystem;
  17640. /**
  17641. * Adds a new alpha remap gradient
  17642. * @param gradient defines the gradient to use (between 0 and 1)
  17643. * @param min defines the alpha remap minimal range
  17644. * @param max defines the alpha remap maximal range
  17645. * @returns the current particle system
  17646. */
  17647. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17648. /**
  17649. * Remove a specific alpha remap gradient
  17650. * @param gradient defines the gradient to remove
  17651. * @returns the current particle system
  17652. */
  17653. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17654. /**
  17655. * Adds a new angular speed gradient
  17656. * @param gradient defines the gradient to use (between 0 and 1)
  17657. * @param factor defines the angular speed to affect to the specified gradient
  17658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17659. * @returns the current particle system
  17660. */
  17661. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17662. /**
  17663. * Remove a specific angular speed gradient
  17664. * @param gradient defines the gradient to remove
  17665. * @returns the current particle system
  17666. */
  17667. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17668. /**
  17669. * Adds a new velocity gradient
  17670. * @param gradient defines the gradient to use (between 0 and 1)
  17671. * @param factor defines the velocity to affect to the specified gradient
  17672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17673. * @returns the current particle system
  17674. */
  17675. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17676. /**
  17677. * Remove a specific velocity gradient
  17678. * @param gradient defines the gradient to remove
  17679. * @returns the current particle system
  17680. */
  17681. removeVelocityGradient(gradient: number): IParticleSystem;
  17682. /**
  17683. * Adds a new limit velocity gradient
  17684. * @param gradient defines the gradient to use (between 0 and 1)
  17685. * @param factor defines the limit velocity value to affect to the specified gradient
  17686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17687. * @returns the current particle system
  17688. */
  17689. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17690. /**
  17691. * Remove a specific limit velocity gradient
  17692. * @param gradient defines the gradient to remove
  17693. * @returns the current particle system
  17694. */
  17695. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17696. /**
  17697. * Adds a new drag gradient
  17698. * @param gradient defines the gradient to use (between 0 and 1)
  17699. * @param factor defines the drag value to affect to the specified gradient
  17700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17701. * @returns the current particle system
  17702. */
  17703. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17704. /**
  17705. * Remove a specific drag gradient
  17706. * @param gradient defines the gradient to remove
  17707. * @returns the current particle system
  17708. */
  17709. removeDragGradient(gradient: number): IParticleSystem;
  17710. /**
  17711. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17712. * @param gradient defines the gradient to use (between 0 and 1)
  17713. * @param factor defines the emit rate value to affect to the specified gradient
  17714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17715. * @returns the current particle system
  17716. */
  17717. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17718. /**
  17719. * Remove a specific emit rate gradient
  17720. * @param gradient defines the gradient to remove
  17721. * @returns the current particle system
  17722. */
  17723. removeEmitRateGradient(gradient: number): IParticleSystem;
  17724. /**
  17725. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17726. * @param gradient defines the gradient to use (between 0 and 1)
  17727. * @param factor defines the start size value to affect to the specified gradient
  17728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17729. * @returns the current particle system
  17730. */
  17731. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17732. /**
  17733. * Remove a specific start size gradient
  17734. * @param gradient defines the gradient to remove
  17735. * @returns the current particle system
  17736. */
  17737. removeStartSizeGradient(gradient: number): IParticleSystem;
  17738. private _createRampGradientTexture;
  17739. /**
  17740. * Gets the current list of ramp gradients.
  17741. * You must use addRampGradient and removeRampGradient to udpate this list
  17742. * @returns the list of ramp gradients
  17743. */
  17744. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17745. /**
  17746. * Adds a new ramp gradient used to remap particle colors
  17747. * @param gradient defines the gradient to use (between 0 and 1)
  17748. * @param color defines the color to affect to the specified gradient
  17749. * @returns the current particle system
  17750. */
  17751. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17752. /**
  17753. * Remove a specific ramp gradient
  17754. * @param gradient defines the gradient to remove
  17755. * @returns the current particle system
  17756. */
  17757. removeRampGradient(gradient: number): ParticleSystem;
  17758. /**
  17759. * Adds a new color gradient
  17760. * @param gradient defines the gradient to use (between 0 and 1)
  17761. * @param color1 defines the color to affect to the specified gradient
  17762. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17763. * @returns this particle system
  17764. */
  17765. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17766. /**
  17767. * Remove a specific color gradient
  17768. * @param gradient defines the gradient to remove
  17769. * @returns this particle system
  17770. */
  17771. removeColorGradient(gradient: number): IParticleSystem;
  17772. private _fetchR;
  17773. protected _reset(): void;
  17774. private _resetEffect;
  17775. private _createVertexBuffers;
  17776. private _createIndexBuffer;
  17777. /**
  17778. * Gets the maximum number of particles active at the same time.
  17779. * @returns The max number of active particles.
  17780. */
  17781. getCapacity(): number;
  17782. /**
  17783. * Gets whether there are still active particles in the system.
  17784. * @returns True if it is alive, otherwise false.
  17785. */
  17786. isAlive(): boolean;
  17787. /**
  17788. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17789. * @returns True if it has been started, otherwise false.
  17790. */
  17791. isStarted(): boolean;
  17792. private _prepareSubEmitterInternalArray;
  17793. /**
  17794. * Starts the particle system and begins to emit
  17795. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17796. */
  17797. start(delay?: number): void;
  17798. /**
  17799. * Stops the particle system.
  17800. * @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.
  17801. */
  17802. stop(stopSubEmitters?: boolean): void;
  17803. /**
  17804. * Remove all active particles
  17805. */
  17806. reset(): void;
  17807. /**
  17808. * @hidden (for internal use only)
  17809. */
  17810. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17811. /**
  17812. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17813. * Its lifetime will start back at 0.
  17814. */
  17815. recycleParticle: (particle: Particle) => void;
  17816. private _stopSubEmitters;
  17817. private _createParticle;
  17818. private _removeFromRoot;
  17819. private _emitFromParticle;
  17820. private _update;
  17821. /** @hidden */
  17822. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17823. /** @hidden */
  17824. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17825. /** @hidden */
  17826. private _getEffect;
  17827. /**
  17828. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17829. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17830. */
  17831. animate(preWarmOnly?: boolean): void;
  17832. private _appendParticleVertices;
  17833. /**
  17834. * Rebuilds the particle system.
  17835. */
  17836. rebuild(): void;
  17837. /**
  17838. * Is this system ready to be used/rendered
  17839. * @return true if the system is ready
  17840. */
  17841. isReady(): boolean;
  17842. private _render;
  17843. /**
  17844. * Renders the particle system in its current state.
  17845. * @returns the current number of particles
  17846. */
  17847. render(): number;
  17848. /**
  17849. * Disposes the particle system and free the associated resources
  17850. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17851. */
  17852. dispose(disposeTexture?: boolean): void;
  17853. /**
  17854. * Clones the particle system.
  17855. * @param name The name of the cloned object
  17856. * @param newEmitter The new emitter to use
  17857. * @returns the cloned particle system
  17858. */
  17859. clone(name: string, newEmitter: any): ParticleSystem;
  17860. /**
  17861. * Serializes the particle system to a JSON object.
  17862. * @returns the JSON object
  17863. */
  17864. serialize(): any;
  17865. /** @hidden */
  17866. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17867. /** @hidden */
  17868. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17869. /**
  17870. * Parses a JSON object to create a particle system.
  17871. * @param parsedParticleSystem The JSON object to parse
  17872. * @param scene The scene to create the particle system in
  17873. * @param rootUrl The root url to use to load external dependencies like texture
  17874. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17875. * @returns the Parsed particle system
  17876. */
  17877. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17878. }
  17879. }
  17880. declare module "babylonjs/Particles/particle" {
  17881. import { Nullable } from "babylonjs/types";
  17882. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17883. import { Color4 } from "babylonjs/Maths/math.color";
  17884. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17885. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17886. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17887. /**
  17888. * A particle represents one of the element emitted by a particle system.
  17889. * This is mainly define by its coordinates, direction, velocity and age.
  17890. */
  17891. export class Particle {
  17892. /**
  17893. * The particle system the particle belongs to.
  17894. */
  17895. particleSystem: ParticleSystem;
  17896. private static _Count;
  17897. /**
  17898. * Unique ID of the particle
  17899. */
  17900. id: number;
  17901. /**
  17902. * The world position of the particle in the scene.
  17903. */
  17904. position: Vector3;
  17905. /**
  17906. * The world direction of the particle in the scene.
  17907. */
  17908. direction: Vector3;
  17909. /**
  17910. * The color of the particle.
  17911. */
  17912. color: Color4;
  17913. /**
  17914. * The color change of the particle per step.
  17915. */
  17916. colorStep: Color4;
  17917. /**
  17918. * Defines how long will the life of the particle be.
  17919. */
  17920. lifeTime: number;
  17921. /**
  17922. * The current age of the particle.
  17923. */
  17924. age: number;
  17925. /**
  17926. * The current size of the particle.
  17927. */
  17928. size: number;
  17929. /**
  17930. * The current scale of the particle.
  17931. */
  17932. scale: Vector2;
  17933. /**
  17934. * The current angle of the particle.
  17935. */
  17936. angle: number;
  17937. /**
  17938. * Defines how fast is the angle changing.
  17939. */
  17940. angularSpeed: number;
  17941. /**
  17942. * Defines the cell index used by the particle to be rendered from a sprite.
  17943. */
  17944. cellIndex: number;
  17945. /**
  17946. * The information required to support color remapping
  17947. */
  17948. remapData: Vector4;
  17949. /** @hidden */
  17950. _randomCellOffset?: number;
  17951. /** @hidden */
  17952. _initialDirection: Nullable<Vector3>;
  17953. /** @hidden */
  17954. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17955. /** @hidden */
  17956. _initialStartSpriteCellID: number;
  17957. /** @hidden */
  17958. _initialEndSpriteCellID: number;
  17959. /** @hidden */
  17960. _currentColorGradient: Nullable<ColorGradient>;
  17961. /** @hidden */
  17962. _currentColor1: Color4;
  17963. /** @hidden */
  17964. _currentColor2: Color4;
  17965. /** @hidden */
  17966. _currentSizeGradient: Nullable<FactorGradient>;
  17967. /** @hidden */
  17968. _currentSize1: number;
  17969. /** @hidden */
  17970. _currentSize2: number;
  17971. /** @hidden */
  17972. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17973. /** @hidden */
  17974. _currentAngularSpeed1: number;
  17975. /** @hidden */
  17976. _currentAngularSpeed2: number;
  17977. /** @hidden */
  17978. _currentVelocityGradient: Nullable<FactorGradient>;
  17979. /** @hidden */
  17980. _currentVelocity1: number;
  17981. /** @hidden */
  17982. _currentVelocity2: number;
  17983. /** @hidden */
  17984. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17985. /** @hidden */
  17986. _currentLimitVelocity1: number;
  17987. /** @hidden */
  17988. _currentLimitVelocity2: number;
  17989. /** @hidden */
  17990. _currentDragGradient: Nullable<FactorGradient>;
  17991. /** @hidden */
  17992. _currentDrag1: number;
  17993. /** @hidden */
  17994. _currentDrag2: number;
  17995. /** @hidden */
  17996. _randomNoiseCoordinates1: Vector3;
  17997. /** @hidden */
  17998. _randomNoiseCoordinates2: Vector3;
  17999. /**
  18000. * Creates a new instance Particle
  18001. * @param particleSystem the particle system the particle belongs to
  18002. */
  18003. constructor(
  18004. /**
  18005. * The particle system the particle belongs to.
  18006. */
  18007. particleSystem: ParticleSystem);
  18008. private updateCellInfoFromSystem;
  18009. /**
  18010. * Defines how the sprite cell index is updated for the particle
  18011. */
  18012. updateCellIndex(): void;
  18013. /** @hidden */
  18014. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18015. /** @hidden */
  18016. _inheritParticleInfoToSubEmitters(): void;
  18017. /** @hidden */
  18018. _reset(): void;
  18019. /**
  18020. * Copy the properties of particle to another one.
  18021. * @param other the particle to copy the information to.
  18022. */
  18023. copyTo(other: Particle): void;
  18024. }
  18025. }
  18026. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18027. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18028. import { Effect } from "babylonjs/Materials/effect";
  18029. import { Particle } from "babylonjs/Particles/particle";
  18030. /**
  18031. * Particle emitter represents a volume emitting particles.
  18032. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18033. */
  18034. export interface IParticleEmitterType {
  18035. /**
  18036. * Called by the particle System when the direction is computed for the created particle.
  18037. * @param worldMatrix is the world matrix of the particle system
  18038. * @param directionToUpdate is the direction vector to update with the result
  18039. * @param particle is the particle we are computed the direction for
  18040. */
  18041. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18042. /**
  18043. * Called by the particle System when the position is computed for the created particle.
  18044. * @param worldMatrix is the world matrix of the particle system
  18045. * @param positionToUpdate is the position vector to update with the result
  18046. * @param particle is the particle we are computed the position for
  18047. */
  18048. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18049. /**
  18050. * Clones the current emitter and returns a copy of it
  18051. * @returns the new emitter
  18052. */
  18053. clone(): IParticleEmitterType;
  18054. /**
  18055. * Called by the GPUParticleSystem to setup the update shader
  18056. * @param effect defines the update shader
  18057. */
  18058. applyToShader(effect: Effect): void;
  18059. /**
  18060. * Returns a string to use to update the GPU particles update shader
  18061. * @returns the effect defines string
  18062. */
  18063. getEffectDefines(): string;
  18064. /**
  18065. * Returns a string representing the class name
  18066. * @returns a string containing the class name
  18067. */
  18068. getClassName(): string;
  18069. /**
  18070. * Serializes the particle system to a JSON object.
  18071. * @returns the JSON object
  18072. */
  18073. serialize(): any;
  18074. /**
  18075. * Parse properties from a JSON object
  18076. * @param serializationObject defines the JSON object
  18077. */
  18078. parse(serializationObject: any): void;
  18079. }
  18080. }
  18081. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18082. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18083. import { Effect } from "babylonjs/Materials/effect";
  18084. import { Particle } from "babylonjs/Particles/particle";
  18085. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18086. /**
  18087. * Particle emitter emitting particles from the inside of a box.
  18088. * It emits the particles randomly between 2 given directions.
  18089. */
  18090. export class BoxParticleEmitter implements IParticleEmitterType {
  18091. /**
  18092. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18093. */
  18094. direction1: Vector3;
  18095. /**
  18096. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18097. */
  18098. direction2: Vector3;
  18099. /**
  18100. * 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.
  18101. */
  18102. minEmitBox: Vector3;
  18103. /**
  18104. * 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.
  18105. */
  18106. maxEmitBox: Vector3;
  18107. /**
  18108. * Creates a new instance BoxParticleEmitter
  18109. */
  18110. constructor();
  18111. /**
  18112. * Called by the particle System when the direction is computed for the created particle.
  18113. * @param worldMatrix is the world matrix of the particle system
  18114. * @param directionToUpdate is the direction vector to update with the result
  18115. * @param particle is the particle we are computed the direction for
  18116. */
  18117. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18118. /**
  18119. * Called by the particle System when the position is computed for the created particle.
  18120. * @param worldMatrix is the world matrix of the particle system
  18121. * @param positionToUpdate is the position vector to update with the result
  18122. * @param particle is the particle we are computed the position for
  18123. */
  18124. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18125. /**
  18126. * Clones the current emitter and returns a copy of it
  18127. * @returns the new emitter
  18128. */
  18129. clone(): BoxParticleEmitter;
  18130. /**
  18131. * Called by the GPUParticleSystem to setup the update shader
  18132. * @param effect defines the update shader
  18133. */
  18134. applyToShader(effect: Effect): void;
  18135. /**
  18136. * Returns a string to use to update the GPU particles update shader
  18137. * @returns a string containng the defines string
  18138. */
  18139. getEffectDefines(): string;
  18140. /**
  18141. * Returns the string "BoxParticleEmitter"
  18142. * @returns a string containing the class name
  18143. */
  18144. getClassName(): string;
  18145. /**
  18146. * Serializes the particle system to a JSON object.
  18147. * @returns the JSON object
  18148. */
  18149. serialize(): any;
  18150. /**
  18151. * Parse properties from a JSON object
  18152. * @param serializationObject defines the JSON object
  18153. */
  18154. parse(serializationObject: any): void;
  18155. }
  18156. }
  18157. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18158. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18159. import { Effect } from "babylonjs/Materials/effect";
  18160. import { Particle } from "babylonjs/Particles/particle";
  18161. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18162. /**
  18163. * Particle emitter emitting particles from the inside of a cone.
  18164. * It emits the particles alongside the cone volume from the base to the particle.
  18165. * The emission direction might be randomized.
  18166. */
  18167. export class ConeParticleEmitter implements IParticleEmitterType {
  18168. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18169. directionRandomizer: number;
  18170. private _radius;
  18171. private _angle;
  18172. private _height;
  18173. /**
  18174. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18175. */
  18176. radiusRange: number;
  18177. /**
  18178. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18179. */
  18180. heightRange: number;
  18181. /**
  18182. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18183. */
  18184. emitFromSpawnPointOnly: boolean;
  18185. /**
  18186. * Gets or sets the radius of the emission cone
  18187. */
  18188. radius: number;
  18189. /**
  18190. * Gets or sets the angle of the emission cone
  18191. */
  18192. angle: number;
  18193. private _buildHeight;
  18194. /**
  18195. * Creates a new instance ConeParticleEmitter
  18196. * @param radius the radius of the emission cone (1 by default)
  18197. * @param angle the cone base angle (PI by default)
  18198. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18199. */
  18200. constructor(radius?: number, angle?: number,
  18201. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18202. directionRandomizer?: number);
  18203. /**
  18204. * Called by the particle System when the direction is computed for the created particle.
  18205. * @param worldMatrix is the world matrix of the particle system
  18206. * @param directionToUpdate is the direction vector to update with the result
  18207. * @param particle is the particle we are computed the direction for
  18208. */
  18209. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18210. /**
  18211. * Called by the particle System when the position is computed for the created particle.
  18212. * @param worldMatrix is the world matrix of the particle system
  18213. * @param positionToUpdate is the position vector to update with the result
  18214. * @param particle is the particle we are computed the position for
  18215. */
  18216. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18217. /**
  18218. * Clones the current emitter and returns a copy of it
  18219. * @returns the new emitter
  18220. */
  18221. clone(): ConeParticleEmitter;
  18222. /**
  18223. * Called by the GPUParticleSystem to setup the update shader
  18224. * @param effect defines the update shader
  18225. */
  18226. applyToShader(effect: Effect): void;
  18227. /**
  18228. * Returns a string to use to update the GPU particles update shader
  18229. * @returns a string containng the defines string
  18230. */
  18231. getEffectDefines(): string;
  18232. /**
  18233. * Returns the string "ConeParticleEmitter"
  18234. * @returns a string containing the class name
  18235. */
  18236. getClassName(): string;
  18237. /**
  18238. * Serializes the particle system to a JSON object.
  18239. * @returns the JSON object
  18240. */
  18241. serialize(): any;
  18242. /**
  18243. * Parse properties from a JSON object
  18244. * @param serializationObject defines the JSON object
  18245. */
  18246. parse(serializationObject: any): void;
  18247. }
  18248. }
  18249. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18250. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18251. import { Effect } from "babylonjs/Materials/effect";
  18252. import { Particle } from "babylonjs/Particles/particle";
  18253. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18254. /**
  18255. * Particle emitter emitting particles from the inside of a cylinder.
  18256. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18257. */
  18258. export class CylinderParticleEmitter implements IParticleEmitterType {
  18259. /**
  18260. * The radius of the emission cylinder.
  18261. */
  18262. radius: number;
  18263. /**
  18264. * The height of the emission cylinder.
  18265. */
  18266. height: number;
  18267. /**
  18268. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18269. */
  18270. radiusRange: number;
  18271. /**
  18272. * How much to randomize the particle direction [0-1].
  18273. */
  18274. directionRandomizer: number;
  18275. /**
  18276. * Creates a new instance CylinderParticleEmitter
  18277. * @param radius the radius of the emission cylinder (1 by default)
  18278. * @param height the height of the emission cylinder (1 by default)
  18279. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18280. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18281. */
  18282. constructor(
  18283. /**
  18284. * The radius of the emission cylinder.
  18285. */
  18286. radius?: number,
  18287. /**
  18288. * The height of the emission cylinder.
  18289. */
  18290. height?: number,
  18291. /**
  18292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18293. */
  18294. radiusRange?: number,
  18295. /**
  18296. * How much to randomize the particle direction [0-1].
  18297. */
  18298. directionRandomizer?: number);
  18299. /**
  18300. * Called by the particle System when the direction is computed for the created particle.
  18301. * @param worldMatrix is the world matrix of the particle system
  18302. * @param directionToUpdate is the direction vector to update with the result
  18303. * @param particle is the particle we are computed the direction for
  18304. */
  18305. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18306. /**
  18307. * Called by the particle System when the position is computed for the created particle.
  18308. * @param worldMatrix is the world matrix of the particle system
  18309. * @param positionToUpdate is the position vector to update with the result
  18310. * @param particle is the particle we are computed the position for
  18311. */
  18312. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18313. /**
  18314. * Clones the current emitter and returns a copy of it
  18315. * @returns the new emitter
  18316. */
  18317. clone(): CylinderParticleEmitter;
  18318. /**
  18319. * Called by the GPUParticleSystem to setup the update shader
  18320. * @param effect defines the update shader
  18321. */
  18322. applyToShader(effect: Effect): void;
  18323. /**
  18324. * Returns a string to use to update the GPU particles update shader
  18325. * @returns a string containng the defines string
  18326. */
  18327. getEffectDefines(): string;
  18328. /**
  18329. * Returns the string "CylinderParticleEmitter"
  18330. * @returns a string containing the class name
  18331. */
  18332. getClassName(): string;
  18333. /**
  18334. * Serializes the particle system to a JSON object.
  18335. * @returns the JSON object
  18336. */
  18337. serialize(): any;
  18338. /**
  18339. * Parse properties from a JSON object
  18340. * @param serializationObject defines the JSON object
  18341. */
  18342. parse(serializationObject: any): void;
  18343. }
  18344. /**
  18345. * Particle emitter emitting particles from the inside of a cylinder.
  18346. * It emits the particles randomly between two vectors.
  18347. */
  18348. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18349. /**
  18350. * The min limit of the emission direction.
  18351. */
  18352. direction1: Vector3;
  18353. /**
  18354. * The max limit of the emission direction.
  18355. */
  18356. direction2: Vector3;
  18357. /**
  18358. * Creates a new instance CylinderDirectedParticleEmitter
  18359. * @param radius the radius of the emission cylinder (1 by default)
  18360. * @param height the height of the emission cylinder (1 by default)
  18361. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18362. * @param direction1 the min limit of the emission direction (up vector by default)
  18363. * @param direction2 the max limit of the emission direction (up vector by default)
  18364. */
  18365. constructor(radius?: number, height?: number, radiusRange?: number,
  18366. /**
  18367. * The min limit of the emission direction.
  18368. */
  18369. direction1?: Vector3,
  18370. /**
  18371. * The max limit of the emission direction.
  18372. */
  18373. direction2?: Vector3);
  18374. /**
  18375. * Called by the particle System when the direction is computed for the created particle.
  18376. * @param worldMatrix is the world matrix of the particle system
  18377. * @param directionToUpdate is the direction vector to update with the result
  18378. * @param particle is the particle we are computed the direction for
  18379. */
  18380. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18381. /**
  18382. * Clones the current emitter and returns a copy of it
  18383. * @returns the new emitter
  18384. */
  18385. clone(): CylinderDirectedParticleEmitter;
  18386. /**
  18387. * Called by the GPUParticleSystem to setup the update shader
  18388. * @param effect defines the update shader
  18389. */
  18390. applyToShader(effect: Effect): void;
  18391. /**
  18392. * Returns a string to use to update the GPU particles update shader
  18393. * @returns a string containng the defines string
  18394. */
  18395. getEffectDefines(): string;
  18396. /**
  18397. * Returns the string "CylinderDirectedParticleEmitter"
  18398. * @returns a string containing the class name
  18399. */
  18400. getClassName(): string;
  18401. /**
  18402. * Serializes the particle system to a JSON object.
  18403. * @returns the JSON object
  18404. */
  18405. serialize(): any;
  18406. /**
  18407. * Parse properties from a JSON object
  18408. * @param serializationObject defines the JSON object
  18409. */
  18410. parse(serializationObject: any): void;
  18411. }
  18412. }
  18413. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18414. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18415. import { Effect } from "babylonjs/Materials/effect";
  18416. import { Particle } from "babylonjs/Particles/particle";
  18417. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18418. /**
  18419. * Particle emitter emitting particles from the inside of a hemisphere.
  18420. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18421. */
  18422. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18423. /**
  18424. * The radius of the emission hemisphere.
  18425. */
  18426. radius: number;
  18427. /**
  18428. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18429. */
  18430. radiusRange: number;
  18431. /**
  18432. * How much to randomize the particle direction [0-1].
  18433. */
  18434. directionRandomizer: number;
  18435. /**
  18436. * Creates a new instance HemisphericParticleEmitter
  18437. * @param radius the radius of the emission hemisphere (1 by default)
  18438. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18439. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18440. */
  18441. constructor(
  18442. /**
  18443. * The radius of the emission hemisphere.
  18444. */
  18445. radius?: number,
  18446. /**
  18447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18448. */
  18449. radiusRange?: number,
  18450. /**
  18451. * How much to randomize the particle direction [0-1].
  18452. */
  18453. directionRandomizer?: number);
  18454. /**
  18455. * Called by the particle System when the direction is computed for the created particle.
  18456. * @param worldMatrix is the world matrix of the particle system
  18457. * @param directionToUpdate is the direction vector to update with the result
  18458. * @param particle is the particle we are computed the direction for
  18459. */
  18460. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18461. /**
  18462. * Called by the particle System when the position is computed for the created particle.
  18463. * @param worldMatrix is the world matrix of the particle system
  18464. * @param positionToUpdate is the position vector to update with the result
  18465. * @param particle is the particle we are computed the position for
  18466. */
  18467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18468. /**
  18469. * Clones the current emitter and returns a copy of it
  18470. * @returns the new emitter
  18471. */
  18472. clone(): HemisphericParticleEmitter;
  18473. /**
  18474. * Called by the GPUParticleSystem to setup the update shader
  18475. * @param effect defines the update shader
  18476. */
  18477. applyToShader(effect: Effect): void;
  18478. /**
  18479. * Returns a string to use to update the GPU particles update shader
  18480. * @returns a string containng the defines string
  18481. */
  18482. getEffectDefines(): string;
  18483. /**
  18484. * Returns the string "HemisphericParticleEmitter"
  18485. * @returns a string containing the class name
  18486. */
  18487. getClassName(): string;
  18488. /**
  18489. * Serializes the particle system to a JSON object.
  18490. * @returns the JSON object
  18491. */
  18492. serialize(): any;
  18493. /**
  18494. * Parse properties from a JSON object
  18495. * @param serializationObject defines the JSON object
  18496. */
  18497. parse(serializationObject: any): void;
  18498. }
  18499. }
  18500. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18501. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18502. import { Effect } from "babylonjs/Materials/effect";
  18503. import { Particle } from "babylonjs/Particles/particle";
  18504. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18505. /**
  18506. * Particle emitter emitting particles from a point.
  18507. * It emits the particles randomly between 2 given directions.
  18508. */
  18509. export class PointParticleEmitter implements IParticleEmitterType {
  18510. /**
  18511. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18512. */
  18513. direction1: Vector3;
  18514. /**
  18515. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18516. */
  18517. direction2: Vector3;
  18518. /**
  18519. * Creates a new instance PointParticleEmitter
  18520. */
  18521. constructor();
  18522. /**
  18523. * Called by the particle System when the direction is computed for the created particle.
  18524. * @param worldMatrix is the world matrix of the particle system
  18525. * @param directionToUpdate is the direction vector to update with the result
  18526. * @param particle is the particle we are computed the direction for
  18527. */
  18528. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18529. /**
  18530. * Called by the particle System when the position is computed for the created particle.
  18531. * @param worldMatrix is the world matrix of the particle system
  18532. * @param positionToUpdate is the position vector to update with the result
  18533. * @param particle is the particle we are computed the position for
  18534. */
  18535. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18536. /**
  18537. * Clones the current emitter and returns a copy of it
  18538. * @returns the new emitter
  18539. */
  18540. clone(): PointParticleEmitter;
  18541. /**
  18542. * Called by the GPUParticleSystem to setup the update shader
  18543. * @param effect defines the update shader
  18544. */
  18545. applyToShader(effect: Effect): void;
  18546. /**
  18547. * Returns a string to use to update the GPU particles update shader
  18548. * @returns a string containng the defines string
  18549. */
  18550. getEffectDefines(): string;
  18551. /**
  18552. * Returns the string "PointParticleEmitter"
  18553. * @returns a string containing the class name
  18554. */
  18555. getClassName(): string;
  18556. /**
  18557. * Serializes the particle system to a JSON object.
  18558. * @returns the JSON object
  18559. */
  18560. serialize(): any;
  18561. /**
  18562. * Parse properties from a JSON object
  18563. * @param serializationObject defines the JSON object
  18564. */
  18565. parse(serializationObject: any): void;
  18566. }
  18567. }
  18568. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18569. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18570. import { Effect } from "babylonjs/Materials/effect";
  18571. import { Particle } from "babylonjs/Particles/particle";
  18572. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18573. /**
  18574. * Particle emitter emitting particles from the inside of a sphere.
  18575. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18576. */
  18577. export class SphereParticleEmitter implements IParticleEmitterType {
  18578. /**
  18579. * The radius of the emission sphere.
  18580. */
  18581. radius: number;
  18582. /**
  18583. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18584. */
  18585. radiusRange: number;
  18586. /**
  18587. * How much to randomize the particle direction [0-1].
  18588. */
  18589. directionRandomizer: number;
  18590. /**
  18591. * Creates a new instance SphereParticleEmitter
  18592. * @param radius the radius of the emission sphere (1 by default)
  18593. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18594. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18595. */
  18596. constructor(
  18597. /**
  18598. * The radius of the emission sphere.
  18599. */
  18600. radius?: number,
  18601. /**
  18602. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18603. */
  18604. radiusRange?: number,
  18605. /**
  18606. * How much to randomize the particle direction [0-1].
  18607. */
  18608. directionRandomizer?: number);
  18609. /**
  18610. * Called by the particle System when the direction is computed for the created particle.
  18611. * @param worldMatrix is the world matrix of the particle system
  18612. * @param directionToUpdate is the direction vector to update with the result
  18613. * @param particle is the particle we are computed the direction for
  18614. */
  18615. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18616. /**
  18617. * Called by the particle System when the position is computed for the created particle.
  18618. * @param worldMatrix is the world matrix of the particle system
  18619. * @param positionToUpdate is the position vector to update with the result
  18620. * @param particle is the particle we are computed the position for
  18621. */
  18622. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18623. /**
  18624. * Clones the current emitter and returns a copy of it
  18625. * @returns the new emitter
  18626. */
  18627. clone(): SphereParticleEmitter;
  18628. /**
  18629. * Called by the GPUParticleSystem to setup the update shader
  18630. * @param effect defines the update shader
  18631. */
  18632. applyToShader(effect: Effect): void;
  18633. /**
  18634. * Returns a string to use to update the GPU particles update shader
  18635. * @returns a string containng the defines string
  18636. */
  18637. getEffectDefines(): string;
  18638. /**
  18639. * Returns the string "SphereParticleEmitter"
  18640. * @returns a string containing the class name
  18641. */
  18642. getClassName(): string;
  18643. /**
  18644. * Serializes the particle system to a JSON object.
  18645. * @returns the JSON object
  18646. */
  18647. serialize(): any;
  18648. /**
  18649. * Parse properties from a JSON object
  18650. * @param serializationObject defines the JSON object
  18651. */
  18652. parse(serializationObject: any): void;
  18653. }
  18654. /**
  18655. * Particle emitter emitting particles from the inside of a sphere.
  18656. * It emits the particles randomly between two vectors.
  18657. */
  18658. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18659. /**
  18660. * The min limit of the emission direction.
  18661. */
  18662. direction1: Vector3;
  18663. /**
  18664. * The max limit of the emission direction.
  18665. */
  18666. direction2: Vector3;
  18667. /**
  18668. * Creates a new instance SphereDirectedParticleEmitter
  18669. * @param radius the radius of the emission sphere (1 by default)
  18670. * @param direction1 the min limit of the emission direction (up vector by default)
  18671. * @param direction2 the max limit of the emission direction (up vector by default)
  18672. */
  18673. constructor(radius?: number,
  18674. /**
  18675. * The min limit of the emission direction.
  18676. */
  18677. direction1?: Vector3,
  18678. /**
  18679. * The max limit of the emission direction.
  18680. */
  18681. direction2?: Vector3);
  18682. /**
  18683. * Called by the particle System when the direction is computed for the created particle.
  18684. * @param worldMatrix is the world matrix of the particle system
  18685. * @param directionToUpdate is the direction vector to update with the result
  18686. * @param particle is the particle we are computed the direction for
  18687. */
  18688. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18689. /**
  18690. * Clones the current emitter and returns a copy of it
  18691. * @returns the new emitter
  18692. */
  18693. clone(): SphereDirectedParticleEmitter;
  18694. /**
  18695. * Called by the GPUParticleSystem to setup the update shader
  18696. * @param effect defines the update shader
  18697. */
  18698. applyToShader(effect: Effect): void;
  18699. /**
  18700. * Returns a string to use to update the GPU particles update shader
  18701. * @returns a string containng the defines string
  18702. */
  18703. getEffectDefines(): string;
  18704. /**
  18705. * Returns the string "SphereDirectedParticleEmitter"
  18706. * @returns a string containing the class name
  18707. */
  18708. getClassName(): string;
  18709. /**
  18710. * Serializes the particle system to a JSON object.
  18711. * @returns the JSON object
  18712. */
  18713. serialize(): any;
  18714. /**
  18715. * Parse properties from a JSON object
  18716. * @param serializationObject defines the JSON object
  18717. */
  18718. parse(serializationObject: any): void;
  18719. }
  18720. }
  18721. declare module "babylonjs/Particles/EmitterTypes/index" {
  18722. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18723. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18724. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18725. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18726. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18727. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18728. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18729. }
  18730. declare module "babylonjs/Particles/IParticleSystem" {
  18731. import { Nullable } from "babylonjs/types";
  18732. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18733. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18735. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18736. import { Texture } from "babylonjs/Materials/Textures/texture";
  18737. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18738. import { Scene } from "babylonjs/scene";
  18739. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18740. import { Animation } from "babylonjs/Animations/animation";
  18741. /**
  18742. * Interface representing a particle system in Babylon.js.
  18743. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18744. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18745. */
  18746. export interface IParticleSystem {
  18747. /**
  18748. * List of animations used by the particle system.
  18749. */
  18750. animations: Animation[];
  18751. /**
  18752. * The id of the Particle system.
  18753. */
  18754. id: string;
  18755. /**
  18756. * The name of the Particle system.
  18757. */
  18758. name: string;
  18759. /**
  18760. * The emitter represents the Mesh or position we are attaching the particle system to.
  18761. */
  18762. emitter: Nullable<AbstractMesh | Vector3>;
  18763. /**
  18764. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18765. */
  18766. isBillboardBased: boolean;
  18767. /**
  18768. * The rendering group used by the Particle system to chose when to render.
  18769. */
  18770. renderingGroupId: number;
  18771. /**
  18772. * The layer mask we are rendering the particles through.
  18773. */
  18774. layerMask: number;
  18775. /**
  18776. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18777. */
  18778. updateSpeed: number;
  18779. /**
  18780. * The amount of time the particle system is running (depends of the overall update speed).
  18781. */
  18782. targetStopDuration: number;
  18783. /**
  18784. * The texture used to render each particle. (this can be a spritesheet)
  18785. */
  18786. particleTexture: Nullable<Texture>;
  18787. /**
  18788. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18789. */
  18790. blendMode: number;
  18791. /**
  18792. * Minimum life time of emitting particles.
  18793. */
  18794. minLifeTime: number;
  18795. /**
  18796. * Maximum life time of emitting particles.
  18797. */
  18798. maxLifeTime: number;
  18799. /**
  18800. * Minimum Size of emitting particles.
  18801. */
  18802. minSize: number;
  18803. /**
  18804. * Maximum Size of emitting particles.
  18805. */
  18806. maxSize: number;
  18807. /**
  18808. * Minimum scale of emitting particles on X axis.
  18809. */
  18810. minScaleX: number;
  18811. /**
  18812. * Maximum scale of emitting particles on X axis.
  18813. */
  18814. maxScaleX: number;
  18815. /**
  18816. * Minimum scale of emitting particles on Y axis.
  18817. */
  18818. minScaleY: number;
  18819. /**
  18820. * Maximum scale of emitting particles on Y axis.
  18821. */
  18822. maxScaleY: number;
  18823. /**
  18824. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18825. */
  18826. color1: Color4;
  18827. /**
  18828. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18829. */
  18830. color2: Color4;
  18831. /**
  18832. * Color the particle will have at the end of its lifetime.
  18833. */
  18834. colorDead: Color4;
  18835. /**
  18836. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18837. */
  18838. emitRate: number;
  18839. /**
  18840. * You can use gravity if you want to give an orientation to your particles.
  18841. */
  18842. gravity: Vector3;
  18843. /**
  18844. * Minimum power of emitting particles.
  18845. */
  18846. minEmitPower: number;
  18847. /**
  18848. * Maximum power of emitting particles.
  18849. */
  18850. maxEmitPower: number;
  18851. /**
  18852. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18853. */
  18854. minAngularSpeed: number;
  18855. /**
  18856. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18857. */
  18858. maxAngularSpeed: number;
  18859. /**
  18860. * Gets or sets the minimal initial rotation in radians.
  18861. */
  18862. minInitialRotation: number;
  18863. /**
  18864. * Gets or sets the maximal initial rotation in radians.
  18865. */
  18866. maxInitialRotation: number;
  18867. /**
  18868. * The particle emitter type defines the emitter used by the particle system.
  18869. * It can be for example box, sphere, or cone...
  18870. */
  18871. particleEmitterType: Nullable<IParticleEmitterType>;
  18872. /**
  18873. * Defines the delay in milliseconds before starting the system (0 by default)
  18874. */
  18875. startDelay: number;
  18876. /**
  18877. * 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
  18878. */
  18879. preWarmCycles: number;
  18880. /**
  18881. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18882. */
  18883. preWarmStepOffset: number;
  18884. /**
  18885. * 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)
  18886. */
  18887. spriteCellChangeSpeed: number;
  18888. /**
  18889. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18890. */
  18891. startSpriteCellID: number;
  18892. /**
  18893. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18894. */
  18895. endSpriteCellID: number;
  18896. /**
  18897. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18898. */
  18899. spriteCellWidth: number;
  18900. /**
  18901. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18902. */
  18903. spriteCellHeight: number;
  18904. /**
  18905. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18906. */
  18907. spriteRandomStartCell: boolean;
  18908. /**
  18909. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18910. */
  18911. isAnimationSheetEnabled: boolean;
  18912. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18913. translationPivot: Vector2;
  18914. /**
  18915. * Gets or sets a texture used to add random noise to particle positions
  18916. */
  18917. noiseTexture: Nullable<BaseTexture>;
  18918. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18919. noiseStrength: Vector3;
  18920. /**
  18921. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18922. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18923. */
  18924. billboardMode: number;
  18925. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18926. limitVelocityDamping: number;
  18927. /**
  18928. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18929. */
  18930. beginAnimationOnStart: boolean;
  18931. /**
  18932. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18933. */
  18934. beginAnimationFrom: number;
  18935. /**
  18936. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18937. */
  18938. beginAnimationTo: number;
  18939. /**
  18940. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18941. */
  18942. beginAnimationLoop: boolean;
  18943. /**
  18944. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18945. */
  18946. disposeOnStop: boolean;
  18947. /**
  18948. * Gets the maximum number of particles active at the same time.
  18949. * @returns The max number of active particles.
  18950. */
  18951. getCapacity(): number;
  18952. /**
  18953. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18954. * @returns True if it has been started, otherwise false.
  18955. */
  18956. isStarted(): boolean;
  18957. /**
  18958. * Animates the particle system for this frame.
  18959. */
  18960. animate(): void;
  18961. /**
  18962. * Renders the particle system in its current state.
  18963. * @returns the current number of particles
  18964. */
  18965. render(): number;
  18966. /**
  18967. * Dispose the particle system and frees its associated resources.
  18968. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18969. */
  18970. dispose(disposeTexture?: boolean): void;
  18971. /**
  18972. * Clones the particle system.
  18973. * @param name The name of the cloned object
  18974. * @param newEmitter The new emitter to use
  18975. * @returns the cloned particle system
  18976. */
  18977. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18978. /**
  18979. * Serializes the particle system to a JSON object.
  18980. * @returns the JSON object
  18981. */
  18982. serialize(): any;
  18983. /**
  18984. * Rebuild the particle system
  18985. */
  18986. rebuild(): void;
  18987. /**
  18988. * Starts the particle system and begins to emit
  18989. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18990. */
  18991. start(delay?: number): void;
  18992. /**
  18993. * Stops the particle system.
  18994. */
  18995. stop(): void;
  18996. /**
  18997. * Remove all active particles
  18998. */
  18999. reset(): void;
  19000. /**
  19001. * Is this system ready to be used/rendered
  19002. * @return true if the system is ready
  19003. */
  19004. isReady(): boolean;
  19005. /**
  19006. * Adds a new color gradient
  19007. * @param gradient defines the gradient to use (between 0 and 1)
  19008. * @param color1 defines the color to affect to the specified gradient
  19009. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19010. * @returns the current particle system
  19011. */
  19012. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19013. /**
  19014. * Remove a specific color gradient
  19015. * @param gradient defines the gradient to remove
  19016. * @returns the current particle system
  19017. */
  19018. removeColorGradient(gradient: number): IParticleSystem;
  19019. /**
  19020. * Adds a new size gradient
  19021. * @param gradient defines the gradient to use (between 0 and 1)
  19022. * @param factor defines the size factor to affect to the specified gradient
  19023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19024. * @returns the current particle system
  19025. */
  19026. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19027. /**
  19028. * Remove a specific size gradient
  19029. * @param gradient defines the gradient to remove
  19030. * @returns the current particle system
  19031. */
  19032. removeSizeGradient(gradient: number): IParticleSystem;
  19033. /**
  19034. * Gets the current list of color gradients.
  19035. * You must use addColorGradient and removeColorGradient to udpate this list
  19036. * @returns the list of color gradients
  19037. */
  19038. getColorGradients(): Nullable<Array<ColorGradient>>;
  19039. /**
  19040. * Gets the current list of size gradients.
  19041. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19042. * @returns the list of size gradients
  19043. */
  19044. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19045. /**
  19046. * Gets the current list of angular speed gradients.
  19047. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19048. * @returns the list of angular speed gradients
  19049. */
  19050. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19051. /**
  19052. * Adds a new angular speed gradient
  19053. * @param gradient defines the gradient to use (between 0 and 1)
  19054. * @param factor defines the angular speed to affect to the specified gradient
  19055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19056. * @returns the current particle system
  19057. */
  19058. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19059. /**
  19060. * Remove a specific angular speed gradient
  19061. * @param gradient defines the gradient to remove
  19062. * @returns the current particle system
  19063. */
  19064. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19065. /**
  19066. * Gets the current list of velocity gradients.
  19067. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19068. * @returns the list of velocity gradients
  19069. */
  19070. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19071. /**
  19072. * Adds a new velocity gradient
  19073. * @param gradient defines the gradient to use (between 0 and 1)
  19074. * @param factor defines the velocity to affect to the specified gradient
  19075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19076. * @returns the current particle system
  19077. */
  19078. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19079. /**
  19080. * Remove a specific velocity gradient
  19081. * @param gradient defines the gradient to remove
  19082. * @returns the current particle system
  19083. */
  19084. removeVelocityGradient(gradient: number): IParticleSystem;
  19085. /**
  19086. * Gets the current list of limit velocity gradients.
  19087. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19088. * @returns the list of limit velocity gradients
  19089. */
  19090. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19091. /**
  19092. * Adds a new limit velocity gradient
  19093. * @param gradient defines the gradient to use (between 0 and 1)
  19094. * @param factor defines the limit velocity to affect to the specified gradient
  19095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19096. * @returns the current particle system
  19097. */
  19098. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19099. /**
  19100. * Remove a specific limit velocity gradient
  19101. * @param gradient defines the gradient to remove
  19102. * @returns the current particle system
  19103. */
  19104. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19105. /**
  19106. * Adds a new drag gradient
  19107. * @param gradient defines the gradient to use (between 0 and 1)
  19108. * @param factor defines the drag to affect to the specified gradient
  19109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19110. * @returns the current particle system
  19111. */
  19112. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19113. /**
  19114. * Remove a specific drag gradient
  19115. * @param gradient defines the gradient to remove
  19116. * @returns the current particle system
  19117. */
  19118. removeDragGradient(gradient: number): IParticleSystem;
  19119. /**
  19120. * Gets the current list of drag gradients.
  19121. * You must use addDragGradient and removeDragGradient to udpate this list
  19122. * @returns the list of drag gradients
  19123. */
  19124. getDragGradients(): Nullable<Array<FactorGradient>>;
  19125. /**
  19126. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19127. * @param gradient defines the gradient to use (between 0 and 1)
  19128. * @param factor defines the emit rate to affect to the specified gradient
  19129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19130. * @returns the current particle system
  19131. */
  19132. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19133. /**
  19134. * Remove a specific emit rate gradient
  19135. * @param gradient defines the gradient to remove
  19136. * @returns the current particle system
  19137. */
  19138. removeEmitRateGradient(gradient: number): IParticleSystem;
  19139. /**
  19140. * Gets the current list of emit rate gradients.
  19141. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19142. * @returns the list of emit rate gradients
  19143. */
  19144. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19145. /**
  19146. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19147. * @param gradient defines the gradient to use (between 0 and 1)
  19148. * @param factor defines the start size to affect to the specified gradient
  19149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19150. * @returns the current particle system
  19151. */
  19152. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19153. /**
  19154. * Remove a specific start size gradient
  19155. * @param gradient defines the gradient to remove
  19156. * @returns the current particle system
  19157. */
  19158. removeStartSizeGradient(gradient: number): IParticleSystem;
  19159. /**
  19160. * Gets the current list of start size gradients.
  19161. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19162. * @returns the list of start size gradients
  19163. */
  19164. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19165. /**
  19166. * Adds a new life time gradient
  19167. * @param gradient defines the gradient to use (between 0 and 1)
  19168. * @param factor defines the life time factor to affect to the specified gradient
  19169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19170. * @returns the current particle system
  19171. */
  19172. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19173. /**
  19174. * Remove a specific life time gradient
  19175. * @param gradient defines the gradient to remove
  19176. * @returns the current particle system
  19177. */
  19178. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19179. /**
  19180. * Gets the current list of life time gradients.
  19181. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19182. * @returns the list of life time gradients
  19183. */
  19184. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19185. /**
  19186. * Gets the current list of color gradients.
  19187. * You must use addColorGradient and removeColorGradient to udpate this list
  19188. * @returns the list of color gradients
  19189. */
  19190. getColorGradients(): Nullable<Array<ColorGradient>>;
  19191. /**
  19192. * Adds a new ramp gradient used to remap particle colors
  19193. * @param gradient defines the gradient to use (between 0 and 1)
  19194. * @param color defines the color to affect to the specified gradient
  19195. * @returns the current particle system
  19196. */
  19197. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19198. /**
  19199. * Gets the current list of ramp gradients.
  19200. * You must use addRampGradient and removeRampGradient to udpate this list
  19201. * @returns the list of ramp gradients
  19202. */
  19203. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19204. /** Gets or sets a boolean indicating that ramp gradients must be used
  19205. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19206. */
  19207. useRampGradients: boolean;
  19208. /**
  19209. * Adds a new color remap gradient
  19210. * @param gradient defines the gradient to use (between 0 and 1)
  19211. * @param min defines the color remap minimal range
  19212. * @param max defines the color remap maximal range
  19213. * @returns the current particle system
  19214. */
  19215. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19216. /**
  19217. * Gets the current list of color remap gradients.
  19218. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19219. * @returns the list of color remap gradients
  19220. */
  19221. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19222. /**
  19223. * Adds a new alpha remap gradient
  19224. * @param gradient defines the gradient to use (between 0 and 1)
  19225. * @param min defines the alpha remap minimal range
  19226. * @param max defines the alpha remap maximal range
  19227. * @returns the current particle system
  19228. */
  19229. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19230. /**
  19231. * Gets the current list of alpha remap gradients.
  19232. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19233. * @returns the list of alpha remap gradients
  19234. */
  19235. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19236. /**
  19237. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19238. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19239. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19240. * @returns the emitter
  19241. */
  19242. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19243. /**
  19244. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19245. * @param radius The radius of the hemisphere to emit from
  19246. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19247. * @returns the emitter
  19248. */
  19249. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19250. /**
  19251. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19252. * @param radius The radius of the sphere to emit from
  19253. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19254. * @returns the emitter
  19255. */
  19256. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19257. /**
  19258. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19259. * @param radius The radius of the sphere to emit from
  19260. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19261. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19262. * @returns the emitter
  19263. */
  19264. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19265. /**
  19266. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19267. * @param radius The radius of the emission cylinder
  19268. * @param height The height of the emission cylinder
  19269. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19270. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19271. * @returns the emitter
  19272. */
  19273. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19274. /**
  19275. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19276. * @param radius The radius of the cylinder to emit from
  19277. * @param height The height of the emission cylinder
  19278. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19279. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19280. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19281. * @returns the emitter
  19282. */
  19283. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19284. /**
  19285. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19286. * @param radius The radius of the cone to emit from
  19287. * @param angle The base angle of the cone
  19288. * @returns the emitter
  19289. */
  19290. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19291. /**
  19292. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19293. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19294. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19295. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19296. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19297. * @returns the emitter
  19298. */
  19299. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19300. /**
  19301. * Get hosting scene
  19302. * @returns the scene
  19303. */
  19304. getScene(): Scene;
  19305. }
  19306. }
  19307. declare module "babylonjs/Meshes/instancedMesh" {
  19308. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19309. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19310. import { Camera } from "babylonjs/Cameras/camera";
  19311. import { Node } from "babylonjs/node";
  19312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19313. import { Mesh } from "babylonjs/Meshes/mesh";
  19314. import { Material } from "babylonjs/Materials/material";
  19315. import { Skeleton } from "babylonjs/Bones/skeleton";
  19316. import { Light } from "babylonjs/Lights/light";
  19317. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19318. /**
  19319. * Creates an instance based on a source mesh.
  19320. */
  19321. export class InstancedMesh extends AbstractMesh {
  19322. private _sourceMesh;
  19323. private _currentLOD;
  19324. /** @hidden */
  19325. _indexInSourceMeshInstanceArray: number;
  19326. constructor(name: string, source: Mesh);
  19327. /**
  19328. * Returns the string "InstancedMesh".
  19329. */
  19330. getClassName(): string;
  19331. /** Gets the list of lights affecting that mesh */
  19332. readonly lightSources: Light[];
  19333. _resyncLightSources(): void;
  19334. _resyncLighSource(light: Light): void;
  19335. _removeLightSource(light: Light, dispose: boolean): void;
  19336. /**
  19337. * If the source mesh receives shadows
  19338. */
  19339. readonly receiveShadows: boolean;
  19340. /**
  19341. * The material of the source mesh
  19342. */
  19343. readonly material: Nullable<Material>;
  19344. /**
  19345. * Visibility of the source mesh
  19346. */
  19347. readonly visibility: number;
  19348. /**
  19349. * Skeleton of the source mesh
  19350. */
  19351. readonly skeleton: Nullable<Skeleton>;
  19352. /**
  19353. * Rendering ground id of the source mesh
  19354. */
  19355. renderingGroupId: number;
  19356. /**
  19357. * Returns the total number of vertices (integer).
  19358. */
  19359. getTotalVertices(): number;
  19360. /**
  19361. * Returns a positive integer : the total number of indices in this mesh geometry.
  19362. * @returns the numner of indices or zero if the mesh has no geometry.
  19363. */
  19364. getTotalIndices(): number;
  19365. /**
  19366. * The source mesh of the instance
  19367. */
  19368. readonly sourceMesh: Mesh;
  19369. /**
  19370. * Is this node ready to be used/rendered
  19371. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19372. * @return {boolean} is it ready
  19373. */
  19374. isReady(completeCheck?: boolean): boolean;
  19375. /**
  19376. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19377. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19378. * @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.
  19379. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19380. */
  19381. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19382. /**
  19383. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19384. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19385. * The `data` are either a numeric array either a Float32Array.
  19386. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19387. * 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).
  19388. * Note that a new underlying VertexBuffer object is created each call.
  19389. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19390. *
  19391. * Possible `kind` values :
  19392. * - VertexBuffer.PositionKind
  19393. * - VertexBuffer.UVKind
  19394. * - VertexBuffer.UV2Kind
  19395. * - VertexBuffer.UV3Kind
  19396. * - VertexBuffer.UV4Kind
  19397. * - VertexBuffer.UV5Kind
  19398. * - VertexBuffer.UV6Kind
  19399. * - VertexBuffer.ColorKind
  19400. * - VertexBuffer.MatricesIndicesKind
  19401. * - VertexBuffer.MatricesIndicesExtraKind
  19402. * - VertexBuffer.MatricesWeightsKind
  19403. * - VertexBuffer.MatricesWeightsExtraKind
  19404. *
  19405. * Returns the Mesh.
  19406. */
  19407. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19408. /**
  19409. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19410. * If the mesh has no geometry, it is simply returned as it is.
  19411. * The `data` are either a numeric array either a Float32Array.
  19412. * No new underlying VertexBuffer object is created.
  19413. * 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.
  19414. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19415. *
  19416. * Possible `kind` values :
  19417. * - VertexBuffer.PositionKind
  19418. * - VertexBuffer.UVKind
  19419. * - VertexBuffer.UV2Kind
  19420. * - VertexBuffer.UV3Kind
  19421. * - VertexBuffer.UV4Kind
  19422. * - VertexBuffer.UV5Kind
  19423. * - VertexBuffer.UV6Kind
  19424. * - VertexBuffer.ColorKind
  19425. * - VertexBuffer.MatricesIndicesKind
  19426. * - VertexBuffer.MatricesIndicesExtraKind
  19427. * - VertexBuffer.MatricesWeightsKind
  19428. * - VertexBuffer.MatricesWeightsExtraKind
  19429. *
  19430. * Returns the Mesh.
  19431. */
  19432. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19433. /**
  19434. * Sets the mesh indices.
  19435. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19436. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19437. * This method creates a new index buffer each call.
  19438. * Returns the Mesh.
  19439. */
  19440. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19441. /**
  19442. * Boolean : True if the mesh owns the requested kind of data.
  19443. */
  19444. isVerticesDataPresent(kind: string): boolean;
  19445. /**
  19446. * Returns an array of indices (IndicesArray).
  19447. */
  19448. getIndices(): Nullable<IndicesArray>;
  19449. readonly _positions: Nullable<Vector3[]>;
  19450. /**
  19451. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19452. * This means the mesh underlying bounding box and sphere are recomputed.
  19453. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19454. * @returns the current mesh
  19455. */
  19456. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19457. /** @hidden */
  19458. _preActivate(): InstancedMesh;
  19459. /** @hidden */
  19460. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19461. /** @hidden */
  19462. _postActivate(): void;
  19463. getWorldMatrix(): Matrix;
  19464. readonly isAnInstance: boolean;
  19465. /**
  19466. * Returns the current associated LOD AbstractMesh.
  19467. */
  19468. getLOD(camera: Camera): AbstractMesh;
  19469. /** @hidden */
  19470. _syncSubMeshes(): InstancedMesh;
  19471. /** @hidden */
  19472. _generatePointsArray(): boolean;
  19473. /**
  19474. * Creates a new InstancedMesh from the current mesh.
  19475. * - name (string) : the cloned mesh name
  19476. * - newParent (optional Node) : the optional Node to parent the clone to.
  19477. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19478. *
  19479. * Returns the clone.
  19480. */
  19481. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19482. /**
  19483. * Disposes the InstancedMesh.
  19484. * Returns nothing.
  19485. */
  19486. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19487. }
  19488. module "babylonjs/Meshes/mesh" {
  19489. interface Mesh {
  19490. /**
  19491. * Register a custom buffer that will be instanced
  19492. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19493. * @param kind defines the buffer kind
  19494. * @param stride defines the stride in floats
  19495. */
  19496. registerInstancedBuffer(kind: string, stride: number): void;
  19497. /** @hidden */
  19498. _userInstancedBuffersStorage: {
  19499. data: {
  19500. [key: string]: Float32Array;
  19501. };
  19502. sizes: {
  19503. [key: string]: number;
  19504. };
  19505. vertexBuffers: {
  19506. [key: string]: Nullable<VertexBuffer>;
  19507. };
  19508. strides: {
  19509. [key: string]: number;
  19510. };
  19511. };
  19512. }
  19513. }
  19514. module "babylonjs/Meshes/abstractMesh" {
  19515. interface AbstractMesh {
  19516. /**
  19517. * Object used to store instanced buffers defined by user
  19518. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19519. */
  19520. instancedBuffers: {
  19521. [key: string]: any;
  19522. };
  19523. }
  19524. }
  19525. }
  19526. declare module "babylonjs/Materials/shaderMaterial" {
  19527. import { Scene } from "babylonjs/scene";
  19528. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19530. import { Mesh } from "babylonjs/Meshes/mesh";
  19531. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19532. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19533. import { Texture } from "babylonjs/Materials/Textures/texture";
  19534. import { Material } from "babylonjs/Materials/material";
  19535. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19536. /**
  19537. * Defines the options associated with the creation of a shader material.
  19538. */
  19539. export interface IShaderMaterialOptions {
  19540. /**
  19541. * Does the material work in alpha blend mode
  19542. */
  19543. needAlphaBlending: boolean;
  19544. /**
  19545. * Does the material work in alpha test mode
  19546. */
  19547. needAlphaTesting: boolean;
  19548. /**
  19549. * The list of attribute names used in the shader
  19550. */
  19551. attributes: string[];
  19552. /**
  19553. * The list of unifrom names used in the shader
  19554. */
  19555. uniforms: string[];
  19556. /**
  19557. * The list of UBO names used in the shader
  19558. */
  19559. uniformBuffers: string[];
  19560. /**
  19561. * The list of sampler names used in the shader
  19562. */
  19563. samplers: string[];
  19564. /**
  19565. * The list of defines used in the shader
  19566. */
  19567. defines: string[];
  19568. }
  19569. /**
  19570. * 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.
  19571. *
  19572. * This returned material effects how the mesh will look based on the code in the shaders.
  19573. *
  19574. * @see http://doc.babylonjs.com/how_to/shader_material
  19575. */
  19576. export class ShaderMaterial extends Material {
  19577. private _shaderPath;
  19578. private _options;
  19579. private _textures;
  19580. private _textureArrays;
  19581. private _floats;
  19582. private _ints;
  19583. private _floatsArrays;
  19584. private _colors3;
  19585. private _colors3Arrays;
  19586. private _colors4;
  19587. private _colors4Arrays;
  19588. private _vectors2;
  19589. private _vectors3;
  19590. private _vectors4;
  19591. private _matrices;
  19592. private _matrices3x3;
  19593. private _matrices2x2;
  19594. private _vectors2Arrays;
  19595. private _vectors3Arrays;
  19596. private _vectors4Arrays;
  19597. private _cachedWorldViewMatrix;
  19598. private _cachedWorldViewProjectionMatrix;
  19599. private _renderId;
  19600. /**
  19601. * Instantiate a new shader material.
  19602. * 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.
  19603. * This returned material effects how the mesh will look based on the code in the shaders.
  19604. * @see http://doc.babylonjs.com/how_to/shader_material
  19605. * @param name Define the name of the material in the scene
  19606. * @param scene Define the scene the material belongs to
  19607. * @param shaderPath Defines the route to the shader code in one of three ways:
  19608. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19609. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19610. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19611. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19612. * @param options Define the options used to create the shader
  19613. */
  19614. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19615. /**
  19616. * Gets the options used to compile the shader.
  19617. * They can be modified to trigger a new compilation
  19618. */
  19619. readonly options: IShaderMaterialOptions;
  19620. /**
  19621. * Gets the current class name of the material e.g. "ShaderMaterial"
  19622. * Mainly use in serialization.
  19623. * @returns the class name
  19624. */
  19625. getClassName(): string;
  19626. /**
  19627. * Specifies if the material will require alpha blending
  19628. * @returns a boolean specifying if alpha blending is needed
  19629. */
  19630. needAlphaBlending(): boolean;
  19631. /**
  19632. * Specifies if this material should be rendered in alpha test mode
  19633. * @returns a boolean specifying if an alpha test is needed.
  19634. */
  19635. needAlphaTesting(): boolean;
  19636. private _checkUniform;
  19637. /**
  19638. * Set a texture in the shader.
  19639. * @param name Define the name of the uniform samplers as defined in the shader
  19640. * @param texture Define the texture to bind to this sampler
  19641. * @return the material itself allowing "fluent" like uniform updates
  19642. */
  19643. setTexture(name: string, texture: Texture): ShaderMaterial;
  19644. /**
  19645. * Set a texture array in the shader.
  19646. * @param name Define the name of the uniform sampler array as defined in the shader
  19647. * @param textures Define the list of textures to bind to this sampler
  19648. * @return the material itself allowing "fluent" like uniform updates
  19649. */
  19650. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19651. /**
  19652. * Set a float in the shader.
  19653. * @param name Define the name of the uniform as defined in the shader
  19654. * @param value Define the value to give to the uniform
  19655. * @return the material itself allowing "fluent" like uniform updates
  19656. */
  19657. setFloat(name: string, value: number): ShaderMaterial;
  19658. /**
  19659. * Set a int in the shader.
  19660. * @param name Define the name of the uniform as defined in the shader
  19661. * @param value Define the value to give to the uniform
  19662. * @return the material itself allowing "fluent" like uniform updates
  19663. */
  19664. setInt(name: string, value: number): ShaderMaterial;
  19665. /**
  19666. * Set an array of floats in the shader.
  19667. * @param name Define the name of the uniform as defined in the shader
  19668. * @param value Define the value to give to the uniform
  19669. * @return the material itself allowing "fluent" like uniform updates
  19670. */
  19671. setFloats(name: string, value: number[]): ShaderMaterial;
  19672. /**
  19673. * Set a vec3 in the shader from a Color3.
  19674. * @param name Define the name of the uniform as defined in the shader
  19675. * @param value Define the value to give to the uniform
  19676. * @return the material itself allowing "fluent" like uniform updates
  19677. */
  19678. setColor3(name: string, value: Color3): ShaderMaterial;
  19679. /**
  19680. * Set a vec3 array in the shader from a Color3 array.
  19681. * @param name Define the name of the uniform as defined in the shader
  19682. * @param value Define the value to give to the uniform
  19683. * @return the material itself allowing "fluent" like uniform updates
  19684. */
  19685. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19686. /**
  19687. * Set a vec4 in the shader from a Color4.
  19688. * @param name Define the name of the uniform as defined in the shader
  19689. * @param value Define the value to give to the uniform
  19690. * @return the material itself allowing "fluent" like uniform updates
  19691. */
  19692. setColor4(name: string, value: Color4): ShaderMaterial;
  19693. /**
  19694. * Set a vec4 array in the shader from a Color4 array.
  19695. * @param name Define the name of the uniform as defined in the shader
  19696. * @param value Define the value to give to the uniform
  19697. * @return the material itself allowing "fluent" like uniform updates
  19698. */
  19699. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19700. /**
  19701. * Set a vec2 in the shader from a Vector2.
  19702. * @param name Define the name of the uniform as defined in the shader
  19703. * @param value Define the value to give to the uniform
  19704. * @return the material itself allowing "fluent" like uniform updates
  19705. */
  19706. setVector2(name: string, value: Vector2): ShaderMaterial;
  19707. /**
  19708. * Set a vec3 in the shader from a Vector3.
  19709. * @param name Define the name of the uniform as defined in the shader
  19710. * @param value Define the value to give to the uniform
  19711. * @return the material itself allowing "fluent" like uniform updates
  19712. */
  19713. setVector3(name: string, value: Vector3): ShaderMaterial;
  19714. /**
  19715. * Set a vec4 in the shader from a Vector4.
  19716. * @param name Define the name of the uniform as defined in the shader
  19717. * @param value Define the value to give to the uniform
  19718. * @return the material itself allowing "fluent" like uniform updates
  19719. */
  19720. setVector4(name: string, value: Vector4): ShaderMaterial;
  19721. /**
  19722. * Set a mat4 in the shader from a Matrix.
  19723. * @param name Define the name of the uniform as defined in the shader
  19724. * @param value Define the value to give to the uniform
  19725. * @return the material itself allowing "fluent" like uniform updates
  19726. */
  19727. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19728. /**
  19729. * Set a mat3 in the shader from a Float32Array.
  19730. * @param name Define the name of the uniform as defined in the shader
  19731. * @param value Define the value to give to the uniform
  19732. * @return the material itself allowing "fluent" like uniform updates
  19733. */
  19734. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19735. /**
  19736. * Set a mat2 in the shader from a Float32Array.
  19737. * @param name Define the name of the uniform as defined in the shader
  19738. * @param value Define the value to give to the uniform
  19739. * @return the material itself allowing "fluent" like uniform updates
  19740. */
  19741. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19742. /**
  19743. * Set a vec2 array in the shader from a number array.
  19744. * @param name Define the name of the uniform as defined in the shader
  19745. * @param value Define the value to give to the uniform
  19746. * @return the material itself allowing "fluent" like uniform updates
  19747. */
  19748. setArray2(name: string, value: number[]): ShaderMaterial;
  19749. /**
  19750. * Set a vec3 array in the shader from a number array.
  19751. * @param name Define the name of the uniform as defined in the shader
  19752. * @param value Define the value to give to the uniform
  19753. * @return the material itself allowing "fluent" like uniform updates
  19754. */
  19755. setArray3(name: string, value: number[]): ShaderMaterial;
  19756. /**
  19757. * Set a vec4 array in the shader from a number array.
  19758. * @param name Define the name of the uniform as defined in the shader
  19759. * @param value Define the value to give to the uniform
  19760. * @return the material itself allowing "fluent" like uniform updates
  19761. */
  19762. setArray4(name: string, value: number[]): ShaderMaterial;
  19763. private _checkCache;
  19764. /**
  19765. * Specifies that the submesh is ready to be used
  19766. * @param mesh defines the mesh to check
  19767. * @param subMesh defines which submesh to check
  19768. * @param useInstances specifies that instances should be used
  19769. * @returns a boolean indicating that the submesh is ready or not
  19770. */
  19771. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19772. /**
  19773. * Checks if the material is ready to render the requested mesh
  19774. * @param mesh Define the mesh to render
  19775. * @param useInstances Define whether or not the material is used with instances
  19776. * @returns true if ready, otherwise false
  19777. */
  19778. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19779. /**
  19780. * Binds the world matrix to the material
  19781. * @param world defines the world transformation matrix
  19782. */
  19783. bindOnlyWorldMatrix(world: Matrix): void;
  19784. /**
  19785. * Binds the material to the mesh
  19786. * @param world defines the world transformation matrix
  19787. * @param mesh defines the mesh to bind the material to
  19788. */
  19789. bind(world: Matrix, mesh?: Mesh): void;
  19790. /**
  19791. * Gets the active textures from the material
  19792. * @returns an array of textures
  19793. */
  19794. getActiveTextures(): BaseTexture[];
  19795. /**
  19796. * Specifies if the material uses a texture
  19797. * @param texture defines the texture to check against the material
  19798. * @returns a boolean specifying if the material uses the texture
  19799. */
  19800. hasTexture(texture: BaseTexture): boolean;
  19801. /**
  19802. * Makes a duplicate of the material, and gives it a new name
  19803. * @param name defines the new name for the duplicated material
  19804. * @returns the cloned material
  19805. */
  19806. clone(name: string): ShaderMaterial;
  19807. /**
  19808. * Disposes the material
  19809. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19810. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19811. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19812. */
  19813. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19814. /**
  19815. * Serializes this material in a JSON representation
  19816. * @returns the serialized material object
  19817. */
  19818. serialize(): any;
  19819. /**
  19820. * Creates a shader material from parsed shader material data
  19821. * @param source defines the JSON represnetation of the material
  19822. * @param scene defines the hosting scene
  19823. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19824. * @returns a new material
  19825. */
  19826. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19827. }
  19828. }
  19829. declare module "babylonjs/Shaders/color.fragment" {
  19830. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19831. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19832. /** @hidden */
  19833. export var colorPixelShader: {
  19834. name: string;
  19835. shader: string;
  19836. };
  19837. }
  19838. declare module "babylonjs/Shaders/color.vertex" {
  19839. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19840. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19841. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19842. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19843. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19844. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19845. /** @hidden */
  19846. export var colorVertexShader: {
  19847. name: string;
  19848. shader: string;
  19849. };
  19850. }
  19851. declare module "babylonjs/Meshes/linesMesh" {
  19852. import { Nullable } from "babylonjs/types";
  19853. import { Scene } from "babylonjs/scene";
  19854. import { Color3 } from "babylonjs/Maths/math.color";
  19855. import { Node } from "babylonjs/node";
  19856. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19857. import { Mesh } from "babylonjs/Meshes/mesh";
  19858. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19859. import { Effect } from "babylonjs/Materials/effect";
  19860. import { Material } from "babylonjs/Materials/material";
  19861. import "babylonjs/Shaders/color.fragment";
  19862. import "babylonjs/Shaders/color.vertex";
  19863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19864. /**
  19865. * Line mesh
  19866. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19867. */
  19868. export class LinesMesh extends Mesh {
  19869. /**
  19870. * If vertex color should be applied to the mesh
  19871. */
  19872. readonly useVertexColor?: boolean | undefined;
  19873. /**
  19874. * If vertex alpha should be applied to the mesh
  19875. */
  19876. readonly useVertexAlpha?: boolean | undefined;
  19877. /**
  19878. * Color of the line (Default: White)
  19879. */
  19880. color: Color3;
  19881. /**
  19882. * Alpha of the line (Default: 1)
  19883. */
  19884. alpha: number;
  19885. /**
  19886. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19887. * This margin is expressed in world space coordinates, so its value may vary.
  19888. * Default value is 0.1
  19889. */
  19890. intersectionThreshold: number;
  19891. private _colorShader;
  19892. private color4;
  19893. /**
  19894. * Creates a new LinesMesh
  19895. * @param name defines the name
  19896. * @param scene defines the hosting scene
  19897. * @param parent defines the parent mesh if any
  19898. * @param source defines the optional source LinesMesh used to clone data from
  19899. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19900. * When false, achieved by calling a clone(), also passing False.
  19901. * This will make creation of children, recursive.
  19902. * @param useVertexColor defines if this LinesMesh supports vertex color
  19903. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19904. */
  19905. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19906. /**
  19907. * If vertex color should be applied to the mesh
  19908. */
  19909. useVertexColor?: boolean | undefined,
  19910. /**
  19911. * If vertex alpha should be applied to the mesh
  19912. */
  19913. useVertexAlpha?: boolean | undefined);
  19914. private _addClipPlaneDefine;
  19915. private _removeClipPlaneDefine;
  19916. isReady(): boolean;
  19917. /**
  19918. * Returns the string "LineMesh"
  19919. */
  19920. getClassName(): string;
  19921. /**
  19922. * @hidden
  19923. */
  19924. /**
  19925. * @hidden
  19926. */
  19927. material: Material;
  19928. /**
  19929. * @hidden
  19930. */
  19931. readonly checkCollisions: boolean;
  19932. /** @hidden */
  19933. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19934. /** @hidden */
  19935. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19936. /**
  19937. * Disposes of the line mesh
  19938. * @param doNotRecurse If children should be disposed
  19939. */
  19940. dispose(doNotRecurse?: boolean): void;
  19941. /**
  19942. * Returns a new LineMesh object cloned from the current one.
  19943. */
  19944. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19945. /**
  19946. * Creates a new InstancedLinesMesh object from the mesh model.
  19947. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19948. * @param name defines the name of the new instance
  19949. * @returns a new InstancedLinesMesh
  19950. */
  19951. createInstance(name: string): InstancedLinesMesh;
  19952. }
  19953. /**
  19954. * Creates an instance based on a source LinesMesh
  19955. */
  19956. export class InstancedLinesMesh extends InstancedMesh {
  19957. /**
  19958. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19959. * This margin is expressed in world space coordinates, so its value may vary.
  19960. * Initilized with the intersectionThreshold value of the source LinesMesh
  19961. */
  19962. intersectionThreshold: number;
  19963. constructor(name: string, source: LinesMesh);
  19964. /**
  19965. * Returns the string "InstancedLinesMesh".
  19966. */
  19967. getClassName(): string;
  19968. }
  19969. }
  19970. declare module "babylonjs/Shaders/line.fragment" {
  19971. /** @hidden */
  19972. export var linePixelShader: {
  19973. name: string;
  19974. shader: string;
  19975. };
  19976. }
  19977. declare module "babylonjs/Shaders/line.vertex" {
  19978. /** @hidden */
  19979. export var lineVertexShader: {
  19980. name: string;
  19981. shader: string;
  19982. };
  19983. }
  19984. declare module "babylonjs/Rendering/edgesRenderer" {
  19985. import { Nullable } from "babylonjs/types";
  19986. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19988. import { Vector3 } from "babylonjs/Maths/math.vector";
  19989. import { IDisposable } from "babylonjs/scene";
  19990. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19991. import "babylonjs/Shaders/line.fragment";
  19992. import "babylonjs/Shaders/line.vertex";
  19993. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19994. module "babylonjs/Meshes/abstractMesh" {
  19995. interface AbstractMesh {
  19996. /**
  19997. * Gets the edgesRenderer associated with the mesh
  19998. */
  19999. edgesRenderer: Nullable<EdgesRenderer>;
  20000. }
  20001. }
  20002. module "babylonjs/Meshes/linesMesh" {
  20003. interface LinesMesh {
  20004. /**
  20005. * Enables the edge rendering mode on the mesh.
  20006. * This mode makes the mesh edges visible
  20007. * @param epsilon defines the maximal distance between two angles to detect a face
  20008. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20009. * @returns the currentAbstractMesh
  20010. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20011. */
  20012. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20013. }
  20014. }
  20015. module "babylonjs/Meshes/linesMesh" {
  20016. interface InstancedLinesMesh {
  20017. /**
  20018. * Enables the edge rendering mode on the mesh.
  20019. * This mode makes the mesh edges visible
  20020. * @param epsilon defines the maximal distance between two angles to detect a face
  20021. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20022. * @returns the current InstancedLinesMesh
  20023. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20024. */
  20025. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20026. }
  20027. }
  20028. /**
  20029. * Defines the minimum contract an Edges renderer should follow.
  20030. */
  20031. export interface IEdgesRenderer extends IDisposable {
  20032. /**
  20033. * Gets or sets a boolean indicating if the edgesRenderer is active
  20034. */
  20035. isEnabled: boolean;
  20036. /**
  20037. * Renders the edges of the attached mesh,
  20038. */
  20039. render(): void;
  20040. /**
  20041. * Checks wether or not the edges renderer is ready to render.
  20042. * @return true if ready, otherwise false.
  20043. */
  20044. isReady(): boolean;
  20045. }
  20046. /**
  20047. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20048. */
  20049. export class EdgesRenderer implements IEdgesRenderer {
  20050. /**
  20051. * Define the size of the edges with an orthographic camera
  20052. */
  20053. edgesWidthScalerForOrthographic: number;
  20054. /**
  20055. * Define the size of the edges with a perspective camera
  20056. */
  20057. edgesWidthScalerForPerspective: number;
  20058. protected _source: AbstractMesh;
  20059. protected _linesPositions: number[];
  20060. protected _linesNormals: number[];
  20061. protected _linesIndices: number[];
  20062. protected _epsilon: number;
  20063. protected _indicesCount: number;
  20064. protected _lineShader: ShaderMaterial;
  20065. protected _ib: DataBuffer;
  20066. protected _buffers: {
  20067. [key: string]: Nullable<VertexBuffer>;
  20068. };
  20069. protected _checkVerticesInsteadOfIndices: boolean;
  20070. private _meshRebuildObserver;
  20071. private _meshDisposeObserver;
  20072. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20073. isEnabled: boolean;
  20074. /**
  20075. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20076. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20077. * @param source Mesh used to create edges
  20078. * @param epsilon sum of angles in adjacency to check for edge
  20079. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20080. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20081. */
  20082. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20083. protected _prepareRessources(): void;
  20084. /** @hidden */
  20085. _rebuild(): void;
  20086. /**
  20087. * Releases the required resources for the edges renderer
  20088. */
  20089. dispose(): void;
  20090. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20091. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20092. /**
  20093. * Checks if the pair of p0 and p1 is en edge
  20094. * @param faceIndex
  20095. * @param edge
  20096. * @param faceNormals
  20097. * @param p0
  20098. * @param p1
  20099. * @private
  20100. */
  20101. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20102. /**
  20103. * push line into the position, normal and index buffer
  20104. * @protected
  20105. */
  20106. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20107. /**
  20108. * Generates lines edges from adjacencjes
  20109. * @private
  20110. */
  20111. _generateEdgesLines(): void;
  20112. /**
  20113. * Checks wether or not the edges renderer is ready to render.
  20114. * @return true if ready, otherwise false.
  20115. */
  20116. isReady(): boolean;
  20117. /**
  20118. * Renders the edges of the attached mesh,
  20119. */
  20120. render(): void;
  20121. }
  20122. /**
  20123. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20124. */
  20125. export class LineEdgesRenderer extends EdgesRenderer {
  20126. /**
  20127. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20128. * @param source LineMesh used to generate edges
  20129. * @param epsilon not important (specified angle for edge detection)
  20130. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20131. */
  20132. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20133. /**
  20134. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20135. */
  20136. _generateEdgesLines(): void;
  20137. }
  20138. }
  20139. declare module "babylonjs/Rendering/renderingGroup" {
  20140. import { SmartArray } from "babylonjs/Misc/smartArray";
  20141. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20143. import { Nullable } from "babylonjs/types";
  20144. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20145. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20146. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20147. import { Material } from "babylonjs/Materials/material";
  20148. import { Scene } from "babylonjs/scene";
  20149. /**
  20150. * This represents the object necessary to create a rendering group.
  20151. * This is exclusively used and created by the rendering manager.
  20152. * To modify the behavior, you use the available helpers in your scene or meshes.
  20153. * @hidden
  20154. */
  20155. export class RenderingGroup {
  20156. index: number;
  20157. private static _zeroVector;
  20158. private _scene;
  20159. private _opaqueSubMeshes;
  20160. private _transparentSubMeshes;
  20161. private _alphaTestSubMeshes;
  20162. private _depthOnlySubMeshes;
  20163. private _particleSystems;
  20164. private _spriteManagers;
  20165. private _opaqueSortCompareFn;
  20166. private _alphaTestSortCompareFn;
  20167. private _transparentSortCompareFn;
  20168. private _renderOpaque;
  20169. private _renderAlphaTest;
  20170. private _renderTransparent;
  20171. /** @hidden */
  20172. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20173. onBeforeTransparentRendering: () => void;
  20174. /**
  20175. * Set the opaque sort comparison function.
  20176. * If null the sub meshes will be render in the order they were created
  20177. */
  20178. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20179. /**
  20180. * Set the alpha test sort comparison function.
  20181. * If null the sub meshes will be render in the order they were created
  20182. */
  20183. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20184. /**
  20185. * Set the transparent sort comparison function.
  20186. * If null the sub meshes will be render in the order they were created
  20187. */
  20188. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20189. /**
  20190. * Creates a new rendering group.
  20191. * @param index The rendering group index
  20192. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20193. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20194. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20195. */
  20196. 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>);
  20197. /**
  20198. * Render all the sub meshes contained in the group.
  20199. * @param customRenderFunction Used to override the default render behaviour of the group.
  20200. * @returns true if rendered some submeshes.
  20201. */
  20202. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20203. /**
  20204. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20205. * @param subMeshes The submeshes to render
  20206. */
  20207. private renderOpaqueSorted;
  20208. /**
  20209. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20210. * @param subMeshes The submeshes to render
  20211. */
  20212. private renderAlphaTestSorted;
  20213. /**
  20214. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20215. * @param subMeshes The submeshes to render
  20216. */
  20217. private renderTransparentSorted;
  20218. /**
  20219. * Renders the submeshes in a specified order.
  20220. * @param subMeshes The submeshes to sort before render
  20221. * @param sortCompareFn The comparison function use to sort
  20222. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20223. * @param transparent Specifies to activate blending if true
  20224. */
  20225. private static renderSorted;
  20226. /**
  20227. * Renders the submeshes in the order they were dispatched (no sort applied).
  20228. * @param subMeshes The submeshes to render
  20229. */
  20230. private static renderUnsorted;
  20231. /**
  20232. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20233. * are rendered back to front if in the same alpha index.
  20234. *
  20235. * @param a The first submesh
  20236. * @param b The second submesh
  20237. * @returns The result of the comparison
  20238. */
  20239. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20240. /**
  20241. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20242. * are rendered back to front.
  20243. *
  20244. * @param a The first submesh
  20245. * @param b The second submesh
  20246. * @returns The result of the comparison
  20247. */
  20248. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20249. /**
  20250. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20251. * are rendered front to back (prevent overdraw).
  20252. *
  20253. * @param a The first submesh
  20254. * @param b The second submesh
  20255. * @returns The result of the comparison
  20256. */
  20257. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20258. /**
  20259. * Resets the different lists of submeshes to prepare a new frame.
  20260. */
  20261. prepare(): void;
  20262. dispose(): void;
  20263. /**
  20264. * Inserts the submesh in its correct queue depending on its material.
  20265. * @param subMesh The submesh to dispatch
  20266. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20267. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20268. */
  20269. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20270. dispatchSprites(spriteManager: ISpriteManager): void;
  20271. dispatchParticles(particleSystem: IParticleSystem): void;
  20272. private _renderParticles;
  20273. private _renderSprites;
  20274. }
  20275. }
  20276. declare module "babylonjs/Rendering/renderingManager" {
  20277. import { Nullable } from "babylonjs/types";
  20278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20279. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20280. import { SmartArray } from "babylonjs/Misc/smartArray";
  20281. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20282. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20283. import { Material } from "babylonjs/Materials/material";
  20284. import { Scene } from "babylonjs/scene";
  20285. import { Camera } from "babylonjs/Cameras/camera";
  20286. /**
  20287. * Interface describing the different options available in the rendering manager
  20288. * regarding Auto Clear between groups.
  20289. */
  20290. export interface IRenderingManagerAutoClearSetup {
  20291. /**
  20292. * Defines whether or not autoclear is enable.
  20293. */
  20294. autoClear: boolean;
  20295. /**
  20296. * Defines whether or not to autoclear the depth buffer.
  20297. */
  20298. depth: boolean;
  20299. /**
  20300. * Defines whether or not to autoclear the stencil buffer.
  20301. */
  20302. stencil: boolean;
  20303. }
  20304. /**
  20305. * This class is used by the onRenderingGroupObservable
  20306. */
  20307. export class RenderingGroupInfo {
  20308. /**
  20309. * The Scene that being rendered
  20310. */
  20311. scene: Scene;
  20312. /**
  20313. * The camera currently used for the rendering pass
  20314. */
  20315. camera: Nullable<Camera>;
  20316. /**
  20317. * The ID of the renderingGroup being processed
  20318. */
  20319. renderingGroupId: number;
  20320. }
  20321. /**
  20322. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20323. * It is enable to manage the different groups as well as the different necessary sort functions.
  20324. * This should not be used directly aside of the few static configurations
  20325. */
  20326. export class RenderingManager {
  20327. /**
  20328. * The max id used for rendering groups (not included)
  20329. */
  20330. static MAX_RENDERINGGROUPS: number;
  20331. /**
  20332. * The min id used for rendering groups (included)
  20333. */
  20334. static MIN_RENDERINGGROUPS: number;
  20335. /**
  20336. * Used to globally prevent autoclearing scenes.
  20337. */
  20338. static AUTOCLEAR: boolean;
  20339. /**
  20340. * @hidden
  20341. */
  20342. _useSceneAutoClearSetup: boolean;
  20343. private _scene;
  20344. private _renderingGroups;
  20345. private _depthStencilBufferAlreadyCleaned;
  20346. private _autoClearDepthStencil;
  20347. private _customOpaqueSortCompareFn;
  20348. private _customAlphaTestSortCompareFn;
  20349. private _customTransparentSortCompareFn;
  20350. private _renderingGroupInfo;
  20351. /**
  20352. * Instantiates a new rendering group for a particular scene
  20353. * @param scene Defines the scene the groups belongs to
  20354. */
  20355. constructor(scene: Scene);
  20356. private _clearDepthStencilBuffer;
  20357. /**
  20358. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20359. * @hidden
  20360. */
  20361. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20362. /**
  20363. * Resets the different information of the group to prepare a new frame
  20364. * @hidden
  20365. */
  20366. reset(): void;
  20367. /**
  20368. * Dispose and release the group and its associated resources.
  20369. * @hidden
  20370. */
  20371. dispose(): void;
  20372. /**
  20373. * Clear the info related to rendering groups preventing retention points during dispose.
  20374. */
  20375. freeRenderingGroups(): void;
  20376. private _prepareRenderingGroup;
  20377. /**
  20378. * Add a sprite manager to the rendering manager in order to render it this frame.
  20379. * @param spriteManager Define the sprite manager to render
  20380. */
  20381. dispatchSprites(spriteManager: ISpriteManager): void;
  20382. /**
  20383. * Add a particle system to the rendering manager in order to render it this frame.
  20384. * @param particleSystem Define the particle system to render
  20385. */
  20386. dispatchParticles(particleSystem: IParticleSystem): void;
  20387. /**
  20388. * Add a submesh to the manager in order to render it this frame
  20389. * @param subMesh The submesh to dispatch
  20390. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20391. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20392. */
  20393. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20394. /**
  20395. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20396. * This allowed control for front to back rendering or reversly depending of the special needs.
  20397. *
  20398. * @param renderingGroupId The rendering group id corresponding to its index
  20399. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20400. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20401. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20402. */
  20403. 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;
  20404. /**
  20405. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20406. *
  20407. * @param renderingGroupId The rendering group id corresponding to its index
  20408. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20409. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20410. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20411. */
  20412. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20413. /**
  20414. * Gets the current auto clear configuration for one rendering group of the rendering
  20415. * manager.
  20416. * @param index the rendering group index to get the information for
  20417. * @returns The auto clear setup for the requested rendering group
  20418. */
  20419. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20420. }
  20421. }
  20422. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20423. import { Observable } from "babylonjs/Misc/observable";
  20424. import { SmartArray } from "babylonjs/Misc/smartArray";
  20425. import { Nullable } from "babylonjs/types";
  20426. import { Camera } from "babylonjs/Cameras/camera";
  20427. import { Scene } from "babylonjs/scene";
  20428. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20429. import { Color4 } from "babylonjs/Maths/math.color";
  20430. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20432. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20433. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20434. import { Texture } from "babylonjs/Materials/Textures/texture";
  20435. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20436. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20437. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20438. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20439. import { Engine } from "babylonjs/Engines/engine";
  20440. /**
  20441. * This Helps creating a texture that will be created from a camera in your scene.
  20442. * It is basically a dynamic texture that could be used to create special effects for instance.
  20443. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20444. */
  20445. export class RenderTargetTexture extends Texture {
  20446. isCube: boolean;
  20447. /**
  20448. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20449. */
  20450. static readonly REFRESHRATE_RENDER_ONCE: number;
  20451. /**
  20452. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20453. */
  20454. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20455. /**
  20456. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20457. * the central point of your effect and can save a lot of performances.
  20458. */
  20459. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20460. /**
  20461. * Use this predicate to dynamically define the list of mesh you want to render.
  20462. * If set, the renderList property will be overwritten.
  20463. */
  20464. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20465. private _renderList;
  20466. /**
  20467. * Use this list to define the list of mesh you want to render.
  20468. */
  20469. renderList: Nullable<Array<AbstractMesh>>;
  20470. private _hookArray;
  20471. /**
  20472. * Define if particles should be rendered in your texture.
  20473. */
  20474. renderParticles: boolean;
  20475. /**
  20476. * Define if sprites should be rendered in your texture.
  20477. */
  20478. renderSprites: boolean;
  20479. /**
  20480. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20481. */
  20482. coordinatesMode: number;
  20483. /**
  20484. * Define the camera used to render the texture.
  20485. */
  20486. activeCamera: Nullable<Camera>;
  20487. /**
  20488. * Override the render function of the texture with your own one.
  20489. */
  20490. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20491. /**
  20492. * Define if camera post processes should be use while rendering the texture.
  20493. */
  20494. useCameraPostProcesses: boolean;
  20495. /**
  20496. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20497. */
  20498. ignoreCameraViewport: boolean;
  20499. private _postProcessManager;
  20500. private _postProcesses;
  20501. private _resizeObserver;
  20502. /**
  20503. * An event triggered when the texture is unbind.
  20504. */
  20505. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20506. /**
  20507. * An event triggered when the texture is unbind.
  20508. */
  20509. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20510. private _onAfterUnbindObserver;
  20511. /**
  20512. * Set a after unbind callback in the texture.
  20513. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20514. */
  20515. onAfterUnbind: () => void;
  20516. /**
  20517. * An event triggered before rendering the texture
  20518. */
  20519. onBeforeRenderObservable: Observable<number>;
  20520. private _onBeforeRenderObserver;
  20521. /**
  20522. * Set a before render callback in the texture.
  20523. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20524. */
  20525. onBeforeRender: (faceIndex: number) => void;
  20526. /**
  20527. * An event triggered after rendering the texture
  20528. */
  20529. onAfterRenderObservable: Observable<number>;
  20530. private _onAfterRenderObserver;
  20531. /**
  20532. * Set a after render callback in the texture.
  20533. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20534. */
  20535. onAfterRender: (faceIndex: number) => void;
  20536. /**
  20537. * An event triggered after the texture clear
  20538. */
  20539. onClearObservable: Observable<Engine>;
  20540. private _onClearObserver;
  20541. /**
  20542. * Set a clear callback in the texture.
  20543. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20544. */
  20545. onClear: (Engine: Engine) => void;
  20546. /**
  20547. * An event triggered when the texture is resized.
  20548. */
  20549. onResizeObservable: Observable<RenderTargetTexture>;
  20550. /**
  20551. * Define the clear color of the Render Target if it should be different from the scene.
  20552. */
  20553. clearColor: Color4;
  20554. protected _size: number | {
  20555. width: number;
  20556. height: number;
  20557. };
  20558. protected _initialSizeParameter: number | {
  20559. width: number;
  20560. height: number;
  20561. } | {
  20562. ratio: number;
  20563. };
  20564. protected _sizeRatio: Nullable<number>;
  20565. /** @hidden */
  20566. _generateMipMaps: boolean;
  20567. protected _renderingManager: RenderingManager;
  20568. /** @hidden */
  20569. _waitingRenderList: string[];
  20570. protected _doNotChangeAspectRatio: boolean;
  20571. protected _currentRefreshId: number;
  20572. protected _refreshRate: number;
  20573. protected _textureMatrix: Matrix;
  20574. protected _samples: number;
  20575. protected _renderTargetOptions: RenderTargetCreationOptions;
  20576. /**
  20577. * Gets render target creation options that were used.
  20578. */
  20579. readonly renderTargetOptions: RenderTargetCreationOptions;
  20580. protected _engine: Engine;
  20581. protected _onRatioRescale(): void;
  20582. /**
  20583. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20584. * It must define where the camera used to render the texture is set
  20585. */
  20586. boundingBoxPosition: Vector3;
  20587. private _boundingBoxSize;
  20588. /**
  20589. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20590. * When defined, the cubemap will switch to local mode
  20591. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20592. * @example https://www.babylonjs-playground.com/#RNASML
  20593. */
  20594. boundingBoxSize: Vector3;
  20595. /**
  20596. * In case the RTT has been created with a depth texture, get the associated
  20597. * depth texture.
  20598. * Otherwise, return null.
  20599. */
  20600. depthStencilTexture: Nullable<InternalTexture>;
  20601. /**
  20602. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20603. * or used a shadow, depth texture...
  20604. * @param name The friendly name of the texture
  20605. * @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)
  20606. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20607. * @param generateMipMaps True if mip maps need to be generated after render.
  20608. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20609. * @param type The type of the buffer in the RTT (int, half float, float...)
  20610. * @param isCube True if a cube texture needs to be created
  20611. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20612. * @param generateDepthBuffer True to generate a depth buffer
  20613. * @param generateStencilBuffer True to generate a stencil buffer
  20614. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20615. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20616. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20617. */
  20618. constructor(name: string, size: number | {
  20619. width: number;
  20620. height: number;
  20621. } | {
  20622. ratio: number;
  20623. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20624. /**
  20625. * Creates a depth stencil texture.
  20626. * This is only available in WebGL 2 or with the depth texture extension available.
  20627. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20628. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20629. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20630. */
  20631. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20632. private _processSizeParameter;
  20633. /**
  20634. * Define the number of samples to use in case of MSAA.
  20635. * It defaults to one meaning no MSAA has been enabled.
  20636. */
  20637. samples: number;
  20638. /**
  20639. * Resets the refresh counter of the texture and start bak from scratch.
  20640. * Could be useful to regenerate the texture if it is setup to render only once.
  20641. */
  20642. resetRefreshCounter(): void;
  20643. /**
  20644. * Define the refresh rate of the texture or the rendering frequency.
  20645. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20646. */
  20647. refreshRate: number;
  20648. /**
  20649. * Adds a post process to the render target rendering passes.
  20650. * @param postProcess define the post process to add
  20651. */
  20652. addPostProcess(postProcess: PostProcess): void;
  20653. /**
  20654. * Clear all the post processes attached to the render target
  20655. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20656. */
  20657. clearPostProcesses(dispose?: boolean): void;
  20658. /**
  20659. * Remove one of the post process from the list of attached post processes to the texture
  20660. * @param postProcess define the post process to remove from the list
  20661. */
  20662. removePostProcess(postProcess: PostProcess): void;
  20663. /** @hidden */
  20664. _shouldRender(): boolean;
  20665. /**
  20666. * Gets the actual render size of the texture.
  20667. * @returns the width of the render size
  20668. */
  20669. getRenderSize(): number;
  20670. /**
  20671. * Gets the actual render width of the texture.
  20672. * @returns the width of the render size
  20673. */
  20674. getRenderWidth(): number;
  20675. /**
  20676. * Gets the actual render height of the texture.
  20677. * @returns the height of the render size
  20678. */
  20679. getRenderHeight(): number;
  20680. /**
  20681. * Get if the texture can be rescaled or not.
  20682. */
  20683. readonly canRescale: boolean;
  20684. /**
  20685. * Resize the texture using a ratio.
  20686. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20687. */
  20688. scale(ratio: number): void;
  20689. /**
  20690. * Get the texture reflection matrix used to rotate/transform the reflection.
  20691. * @returns the reflection matrix
  20692. */
  20693. getReflectionTextureMatrix(): Matrix;
  20694. /**
  20695. * Resize the texture to a new desired size.
  20696. * Be carrefull as it will recreate all the data in the new texture.
  20697. * @param size Define the new size. It can be:
  20698. * - a number for squared texture,
  20699. * - an object containing { width: number, height: number }
  20700. * - or an object containing a ratio { ratio: number }
  20701. */
  20702. resize(size: number | {
  20703. width: number;
  20704. height: number;
  20705. } | {
  20706. ratio: number;
  20707. }): void;
  20708. /**
  20709. * Renders all the objects from the render list into the texture.
  20710. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20711. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20712. */
  20713. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20714. private _bestReflectionRenderTargetDimension;
  20715. /**
  20716. * @hidden
  20717. * @param faceIndex face index to bind to if this is a cubetexture
  20718. */
  20719. _bindFrameBuffer(faceIndex?: number): void;
  20720. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20721. private renderToTarget;
  20722. /**
  20723. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20724. * This allowed control for front to back rendering or reversly depending of the special needs.
  20725. *
  20726. * @param renderingGroupId The rendering group id corresponding to its index
  20727. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20728. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20729. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20730. */
  20731. 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;
  20732. /**
  20733. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20734. *
  20735. * @param renderingGroupId The rendering group id corresponding to its index
  20736. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20737. */
  20738. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20739. /**
  20740. * Clones the texture.
  20741. * @returns the cloned texture
  20742. */
  20743. clone(): RenderTargetTexture;
  20744. /**
  20745. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20746. * @returns The JSON representation of the texture
  20747. */
  20748. serialize(): any;
  20749. /**
  20750. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20751. */
  20752. disposeFramebufferObjects(): void;
  20753. /**
  20754. * Dispose the texture and release its associated resources.
  20755. */
  20756. dispose(): void;
  20757. /** @hidden */
  20758. _rebuild(): void;
  20759. /**
  20760. * Clear the info related to rendering groups preventing retention point in material dispose.
  20761. */
  20762. freeRenderingGroups(): void;
  20763. /**
  20764. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20765. * @returns the view count
  20766. */
  20767. getViewCount(): number;
  20768. }
  20769. }
  20770. declare module "babylonjs/Materials/material" {
  20771. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20772. import { SmartArray } from "babylonjs/Misc/smartArray";
  20773. import { Observable } from "babylonjs/Misc/observable";
  20774. import { Nullable } from "babylonjs/types";
  20775. import { Scene } from "babylonjs/scene";
  20776. import { Matrix } from "babylonjs/Maths/math.vector";
  20777. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20779. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20780. import { Effect } from "babylonjs/Materials/effect";
  20781. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20782. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20783. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20784. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20785. import { Mesh } from "babylonjs/Meshes/mesh";
  20786. import { Animation } from "babylonjs/Animations/animation";
  20787. /**
  20788. * Options for compiling materials.
  20789. */
  20790. export interface IMaterialCompilationOptions {
  20791. /**
  20792. * Defines whether clip planes are enabled.
  20793. */
  20794. clipPlane: boolean;
  20795. /**
  20796. * Defines whether instances are enabled.
  20797. */
  20798. useInstances: boolean;
  20799. }
  20800. /**
  20801. * Base class for the main features of a material in Babylon.js
  20802. */
  20803. export class Material implements IAnimatable {
  20804. /**
  20805. * Returns the triangle fill mode
  20806. */
  20807. static readonly TriangleFillMode: number;
  20808. /**
  20809. * Returns the wireframe mode
  20810. */
  20811. static readonly WireFrameFillMode: number;
  20812. /**
  20813. * Returns the point fill mode
  20814. */
  20815. static readonly PointFillMode: number;
  20816. /**
  20817. * Returns the point list draw mode
  20818. */
  20819. static readonly PointListDrawMode: number;
  20820. /**
  20821. * Returns the line list draw mode
  20822. */
  20823. static readonly LineListDrawMode: number;
  20824. /**
  20825. * Returns the line loop draw mode
  20826. */
  20827. static readonly LineLoopDrawMode: number;
  20828. /**
  20829. * Returns the line strip draw mode
  20830. */
  20831. static readonly LineStripDrawMode: number;
  20832. /**
  20833. * Returns the triangle strip draw mode
  20834. */
  20835. static readonly TriangleStripDrawMode: number;
  20836. /**
  20837. * Returns the triangle fan draw mode
  20838. */
  20839. static readonly TriangleFanDrawMode: number;
  20840. /**
  20841. * Stores the clock-wise side orientation
  20842. */
  20843. static readonly ClockWiseSideOrientation: number;
  20844. /**
  20845. * Stores the counter clock-wise side orientation
  20846. */
  20847. static readonly CounterClockWiseSideOrientation: number;
  20848. /**
  20849. * The dirty texture flag value
  20850. */
  20851. static readonly TextureDirtyFlag: number;
  20852. /**
  20853. * The dirty light flag value
  20854. */
  20855. static readonly LightDirtyFlag: number;
  20856. /**
  20857. * The dirty fresnel flag value
  20858. */
  20859. static readonly FresnelDirtyFlag: number;
  20860. /**
  20861. * The dirty attribute flag value
  20862. */
  20863. static readonly AttributesDirtyFlag: number;
  20864. /**
  20865. * The dirty misc flag value
  20866. */
  20867. static readonly MiscDirtyFlag: number;
  20868. /**
  20869. * The all dirty flag value
  20870. */
  20871. static readonly AllDirtyFlag: number;
  20872. /**
  20873. * The ID of the material
  20874. */
  20875. id: string;
  20876. /**
  20877. * Gets or sets the unique id of the material
  20878. */
  20879. uniqueId: number;
  20880. /**
  20881. * The name of the material
  20882. */
  20883. name: string;
  20884. /**
  20885. * Gets or sets user defined metadata
  20886. */
  20887. metadata: any;
  20888. /**
  20889. * For internal use only. Please do not use.
  20890. */
  20891. reservedDataStore: any;
  20892. /**
  20893. * Specifies if the ready state should be checked on each call
  20894. */
  20895. checkReadyOnEveryCall: boolean;
  20896. /**
  20897. * Specifies if the ready state should be checked once
  20898. */
  20899. checkReadyOnlyOnce: boolean;
  20900. /**
  20901. * The state of the material
  20902. */
  20903. state: string;
  20904. /**
  20905. * The alpha value of the material
  20906. */
  20907. protected _alpha: number;
  20908. /**
  20909. * List of inspectable custom properties (used by the Inspector)
  20910. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20911. */
  20912. inspectableCustomProperties: IInspectable[];
  20913. /**
  20914. * Sets the alpha value of the material
  20915. */
  20916. /**
  20917. * Gets the alpha value of the material
  20918. */
  20919. alpha: number;
  20920. /**
  20921. * Specifies if back face culling is enabled
  20922. */
  20923. protected _backFaceCulling: boolean;
  20924. /**
  20925. * Sets the back-face culling state
  20926. */
  20927. /**
  20928. * Gets the back-face culling state
  20929. */
  20930. backFaceCulling: boolean;
  20931. /**
  20932. * Stores the value for side orientation
  20933. */
  20934. sideOrientation: number;
  20935. /**
  20936. * Callback triggered when the material is compiled
  20937. */
  20938. onCompiled: Nullable<(effect: Effect) => void>;
  20939. /**
  20940. * Callback triggered when an error occurs
  20941. */
  20942. onError: Nullable<(effect: Effect, errors: string) => void>;
  20943. /**
  20944. * Callback triggered to get the render target textures
  20945. */
  20946. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20947. /**
  20948. * Gets a boolean indicating that current material needs to register RTT
  20949. */
  20950. readonly hasRenderTargetTextures: boolean;
  20951. /**
  20952. * Specifies if the material should be serialized
  20953. */
  20954. doNotSerialize: boolean;
  20955. /**
  20956. * @hidden
  20957. */
  20958. _storeEffectOnSubMeshes: boolean;
  20959. /**
  20960. * Stores the animations for the material
  20961. */
  20962. animations: Nullable<Array<Animation>>;
  20963. /**
  20964. * An event triggered when the material is disposed
  20965. */
  20966. onDisposeObservable: Observable<Material>;
  20967. /**
  20968. * An observer which watches for dispose events
  20969. */
  20970. private _onDisposeObserver;
  20971. private _onUnBindObservable;
  20972. /**
  20973. * Called during a dispose event
  20974. */
  20975. onDispose: () => void;
  20976. private _onBindObservable;
  20977. /**
  20978. * An event triggered when the material is bound
  20979. */
  20980. readonly onBindObservable: Observable<AbstractMesh>;
  20981. /**
  20982. * An observer which watches for bind events
  20983. */
  20984. private _onBindObserver;
  20985. /**
  20986. * Called during a bind event
  20987. */
  20988. onBind: (Mesh: AbstractMesh) => void;
  20989. /**
  20990. * An event triggered when the material is unbound
  20991. */
  20992. readonly onUnBindObservable: Observable<Material>;
  20993. /**
  20994. * Stores the value of the alpha mode
  20995. */
  20996. private _alphaMode;
  20997. /**
  20998. * Sets the value of the alpha mode.
  20999. *
  21000. * | Value | Type | Description |
  21001. * | --- | --- | --- |
  21002. * | 0 | ALPHA_DISABLE | |
  21003. * | 1 | ALPHA_ADD | |
  21004. * | 2 | ALPHA_COMBINE | |
  21005. * | 3 | ALPHA_SUBTRACT | |
  21006. * | 4 | ALPHA_MULTIPLY | |
  21007. * | 5 | ALPHA_MAXIMIZED | |
  21008. * | 6 | ALPHA_ONEONE | |
  21009. * | 7 | ALPHA_PREMULTIPLIED | |
  21010. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21011. * | 9 | ALPHA_INTERPOLATE | |
  21012. * | 10 | ALPHA_SCREENMODE | |
  21013. *
  21014. */
  21015. /**
  21016. * Gets the value of the alpha mode
  21017. */
  21018. alphaMode: number;
  21019. /**
  21020. * Stores the state of the need depth pre-pass value
  21021. */
  21022. private _needDepthPrePass;
  21023. /**
  21024. * Sets the need depth pre-pass value
  21025. */
  21026. /**
  21027. * Gets the depth pre-pass value
  21028. */
  21029. needDepthPrePass: boolean;
  21030. /**
  21031. * Specifies if depth writing should be disabled
  21032. */
  21033. disableDepthWrite: boolean;
  21034. /**
  21035. * Specifies if depth writing should be forced
  21036. */
  21037. forceDepthWrite: boolean;
  21038. /**
  21039. * Specifies if there should be a separate pass for culling
  21040. */
  21041. separateCullingPass: boolean;
  21042. /**
  21043. * Stores the state specifing if fog should be enabled
  21044. */
  21045. private _fogEnabled;
  21046. /**
  21047. * Sets the state for enabling fog
  21048. */
  21049. /**
  21050. * Gets the value of the fog enabled state
  21051. */
  21052. fogEnabled: boolean;
  21053. /**
  21054. * Stores the size of points
  21055. */
  21056. pointSize: number;
  21057. /**
  21058. * Stores the z offset value
  21059. */
  21060. zOffset: number;
  21061. /**
  21062. * Gets a value specifying if wireframe mode is enabled
  21063. */
  21064. /**
  21065. * Sets the state of wireframe mode
  21066. */
  21067. wireframe: boolean;
  21068. /**
  21069. * Gets the value specifying if point clouds are enabled
  21070. */
  21071. /**
  21072. * Sets the state of point cloud mode
  21073. */
  21074. pointsCloud: boolean;
  21075. /**
  21076. * Gets the material fill mode
  21077. */
  21078. /**
  21079. * Sets the material fill mode
  21080. */
  21081. fillMode: number;
  21082. /**
  21083. * @hidden
  21084. * Stores the effects for the material
  21085. */
  21086. _effect: Nullable<Effect>;
  21087. /**
  21088. * @hidden
  21089. * Specifies if the material was previously ready
  21090. */
  21091. _wasPreviouslyReady: boolean;
  21092. /**
  21093. * Specifies if uniform buffers should be used
  21094. */
  21095. private _useUBO;
  21096. /**
  21097. * Stores a reference to the scene
  21098. */
  21099. private _scene;
  21100. /**
  21101. * Stores the fill mode state
  21102. */
  21103. private _fillMode;
  21104. /**
  21105. * Specifies if the depth write state should be cached
  21106. */
  21107. private _cachedDepthWriteState;
  21108. /**
  21109. * Stores the uniform buffer
  21110. */
  21111. protected _uniformBuffer: UniformBuffer;
  21112. /** @hidden */
  21113. _indexInSceneMaterialArray: number;
  21114. /** @hidden */
  21115. meshMap: Nullable<{
  21116. [id: string]: AbstractMesh | undefined;
  21117. }>;
  21118. /**
  21119. * Creates a material instance
  21120. * @param name defines the name of the material
  21121. * @param scene defines the scene to reference
  21122. * @param doNotAdd specifies if the material should be added to the scene
  21123. */
  21124. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21125. /**
  21126. * Returns a string representation of the current material
  21127. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21128. * @returns a string with material information
  21129. */
  21130. toString(fullDetails?: boolean): string;
  21131. /**
  21132. * Gets the class name of the material
  21133. * @returns a string with the class name of the material
  21134. */
  21135. getClassName(): string;
  21136. /**
  21137. * Specifies if updates for the material been locked
  21138. */
  21139. readonly isFrozen: boolean;
  21140. /**
  21141. * Locks updates for the material
  21142. */
  21143. freeze(): void;
  21144. /**
  21145. * Unlocks updates for the material
  21146. */
  21147. unfreeze(): void;
  21148. /**
  21149. * Specifies if the material is ready to be used
  21150. * @param mesh defines the mesh to check
  21151. * @param useInstances specifies if instances should be used
  21152. * @returns a boolean indicating if the material is ready to be used
  21153. */
  21154. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21155. /**
  21156. * Specifies that the submesh is ready to be used
  21157. * @param mesh defines the mesh to check
  21158. * @param subMesh defines which submesh to check
  21159. * @param useInstances specifies that instances should be used
  21160. * @returns a boolean indicating that the submesh is ready or not
  21161. */
  21162. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21163. /**
  21164. * Returns the material effect
  21165. * @returns the effect associated with the material
  21166. */
  21167. getEffect(): Nullable<Effect>;
  21168. /**
  21169. * Returns the current scene
  21170. * @returns a Scene
  21171. */
  21172. getScene(): Scene;
  21173. /**
  21174. * Specifies if the material will require alpha blending
  21175. * @returns a boolean specifying if alpha blending is needed
  21176. */
  21177. needAlphaBlending(): boolean;
  21178. /**
  21179. * Specifies if the mesh will require alpha blending
  21180. * @param mesh defines the mesh to check
  21181. * @returns a boolean specifying if alpha blending is needed for the mesh
  21182. */
  21183. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21184. /**
  21185. * Specifies if this material should be rendered in alpha test mode
  21186. * @returns a boolean specifying if an alpha test is needed.
  21187. */
  21188. needAlphaTesting(): boolean;
  21189. /**
  21190. * Gets the texture used for the alpha test
  21191. * @returns the texture to use for alpha testing
  21192. */
  21193. getAlphaTestTexture(): Nullable<BaseTexture>;
  21194. /**
  21195. * Marks the material to indicate that it needs to be re-calculated
  21196. */
  21197. markDirty(): void;
  21198. /** @hidden */
  21199. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21200. /**
  21201. * Binds the material to the mesh
  21202. * @param world defines the world transformation matrix
  21203. * @param mesh defines the mesh to bind the material to
  21204. */
  21205. bind(world: Matrix, mesh?: Mesh): void;
  21206. /**
  21207. * Binds the submesh to the material
  21208. * @param world defines the world transformation matrix
  21209. * @param mesh defines the mesh containing the submesh
  21210. * @param subMesh defines the submesh to bind the material to
  21211. */
  21212. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21213. /**
  21214. * Binds the world matrix to the material
  21215. * @param world defines the world transformation matrix
  21216. */
  21217. bindOnlyWorldMatrix(world: Matrix): void;
  21218. /**
  21219. * Binds the scene's uniform buffer to the effect.
  21220. * @param effect defines the effect to bind to the scene uniform buffer
  21221. * @param sceneUbo defines the uniform buffer storing scene data
  21222. */
  21223. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21224. /**
  21225. * Binds the view matrix to the effect
  21226. * @param effect defines the effect to bind the view matrix to
  21227. */
  21228. bindView(effect: Effect): void;
  21229. /**
  21230. * Binds the view projection matrix to the effect
  21231. * @param effect defines the effect to bind the view projection matrix to
  21232. */
  21233. bindViewProjection(effect: Effect): void;
  21234. /**
  21235. * Specifies if material alpha testing should be turned on for the mesh
  21236. * @param mesh defines the mesh to check
  21237. */
  21238. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21239. /**
  21240. * Processes to execute after binding the material to a mesh
  21241. * @param mesh defines the rendered mesh
  21242. */
  21243. protected _afterBind(mesh?: Mesh): void;
  21244. /**
  21245. * Unbinds the material from the mesh
  21246. */
  21247. unbind(): void;
  21248. /**
  21249. * Gets the active textures from the material
  21250. * @returns an array of textures
  21251. */
  21252. getActiveTextures(): BaseTexture[];
  21253. /**
  21254. * Specifies if the material uses a texture
  21255. * @param texture defines the texture to check against the material
  21256. * @returns a boolean specifying if the material uses the texture
  21257. */
  21258. hasTexture(texture: BaseTexture): boolean;
  21259. /**
  21260. * Makes a duplicate of the material, and gives it a new name
  21261. * @param name defines the new name for the duplicated material
  21262. * @returns the cloned material
  21263. */
  21264. clone(name: string): Nullable<Material>;
  21265. /**
  21266. * Gets the meshes bound to the material
  21267. * @returns an array of meshes bound to the material
  21268. */
  21269. getBindedMeshes(): AbstractMesh[];
  21270. /**
  21271. * Force shader compilation
  21272. * @param mesh defines the mesh associated with this material
  21273. * @param onCompiled defines a function to execute once the material is compiled
  21274. * @param options defines the options to configure the compilation
  21275. * @param onError defines a function to execute if the material fails compiling
  21276. */
  21277. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21278. /**
  21279. * Force shader compilation
  21280. * @param mesh defines the mesh that will use this material
  21281. * @param options defines additional options for compiling the shaders
  21282. * @returns a promise that resolves when the compilation completes
  21283. */
  21284. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21285. private static readonly _AllDirtyCallBack;
  21286. private static readonly _ImageProcessingDirtyCallBack;
  21287. private static readonly _TextureDirtyCallBack;
  21288. private static readonly _FresnelDirtyCallBack;
  21289. private static readonly _MiscDirtyCallBack;
  21290. private static readonly _LightsDirtyCallBack;
  21291. private static readonly _AttributeDirtyCallBack;
  21292. private static _FresnelAndMiscDirtyCallBack;
  21293. private static _TextureAndMiscDirtyCallBack;
  21294. private static readonly _DirtyCallbackArray;
  21295. private static readonly _RunDirtyCallBacks;
  21296. /**
  21297. * Marks a define in the material to indicate that it needs to be re-computed
  21298. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21299. */
  21300. markAsDirty(flag: number): void;
  21301. /**
  21302. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21303. * @param func defines a function which checks material defines against the submeshes
  21304. */
  21305. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21306. /**
  21307. * Indicates that we need to re-calculated for all submeshes
  21308. */
  21309. protected _markAllSubMeshesAsAllDirty(): void;
  21310. /**
  21311. * Indicates that image processing needs to be re-calculated for all submeshes
  21312. */
  21313. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21314. /**
  21315. * Indicates that textures need to be re-calculated for all submeshes
  21316. */
  21317. protected _markAllSubMeshesAsTexturesDirty(): void;
  21318. /**
  21319. * Indicates that fresnel needs to be re-calculated for all submeshes
  21320. */
  21321. protected _markAllSubMeshesAsFresnelDirty(): void;
  21322. /**
  21323. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21324. */
  21325. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21326. /**
  21327. * Indicates that lights need to be re-calculated for all submeshes
  21328. */
  21329. protected _markAllSubMeshesAsLightsDirty(): void;
  21330. /**
  21331. * Indicates that attributes need to be re-calculated for all submeshes
  21332. */
  21333. protected _markAllSubMeshesAsAttributesDirty(): void;
  21334. /**
  21335. * Indicates that misc needs to be re-calculated for all submeshes
  21336. */
  21337. protected _markAllSubMeshesAsMiscDirty(): void;
  21338. /**
  21339. * Indicates that textures and misc need to be re-calculated for all submeshes
  21340. */
  21341. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21342. /**
  21343. * Disposes the material
  21344. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21345. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21346. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21347. */
  21348. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21349. /** @hidden */
  21350. private releaseVertexArrayObject;
  21351. /**
  21352. * Serializes this material
  21353. * @returns the serialized material object
  21354. */
  21355. serialize(): any;
  21356. /**
  21357. * Creates a material from parsed material data
  21358. * @param parsedMaterial defines parsed material data
  21359. * @param scene defines the hosting scene
  21360. * @param rootUrl defines the root URL to use to load textures
  21361. * @returns a new material
  21362. */
  21363. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21364. }
  21365. }
  21366. declare module "babylonjs/Materials/multiMaterial" {
  21367. import { Nullable } from "babylonjs/types";
  21368. import { Scene } from "babylonjs/scene";
  21369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21370. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21371. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21372. import { Material } from "babylonjs/Materials/material";
  21373. /**
  21374. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21375. * separate meshes. This can be use to improve performances.
  21376. * @see http://doc.babylonjs.com/how_to/multi_materials
  21377. */
  21378. export class MultiMaterial extends Material {
  21379. private _subMaterials;
  21380. /**
  21381. * Gets or Sets the list of Materials used within the multi material.
  21382. * They need to be ordered according to the submeshes order in the associated mesh
  21383. */
  21384. subMaterials: Nullable<Material>[];
  21385. /**
  21386. * Function used to align with Node.getChildren()
  21387. * @returns the list of Materials used within the multi material
  21388. */
  21389. getChildren(): Nullable<Material>[];
  21390. /**
  21391. * Instantiates a new Multi Material
  21392. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21393. * separate meshes. This can be use to improve performances.
  21394. * @see http://doc.babylonjs.com/how_to/multi_materials
  21395. * @param name Define the name in the scene
  21396. * @param scene Define the scene the material belongs to
  21397. */
  21398. constructor(name: string, scene: Scene);
  21399. private _hookArray;
  21400. /**
  21401. * Get one of the submaterial by its index in the submaterials array
  21402. * @param index The index to look the sub material at
  21403. * @returns The Material if the index has been defined
  21404. */
  21405. getSubMaterial(index: number): Nullable<Material>;
  21406. /**
  21407. * Get the list of active textures for the whole sub materials list.
  21408. * @returns All the textures that will be used during the rendering
  21409. */
  21410. getActiveTextures(): BaseTexture[];
  21411. /**
  21412. * Gets the current class name of the material e.g. "MultiMaterial"
  21413. * Mainly use in serialization.
  21414. * @returns the class name
  21415. */
  21416. getClassName(): string;
  21417. /**
  21418. * Checks if the material is ready to render the requested sub mesh
  21419. * @param mesh Define the mesh the submesh belongs to
  21420. * @param subMesh Define the sub mesh to look readyness for
  21421. * @param useInstances Define whether or not the material is used with instances
  21422. * @returns true if ready, otherwise false
  21423. */
  21424. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21425. /**
  21426. * Clones the current material and its related sub materials
  21427. * @param name Define the name of the newly cloned material
  21428. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21429. * @returns the cloned material
  21430. */
  21431. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21432. /**
  21433. * Serializes the materials into a JSON representation.
  21434. * @returns the JSON representation
  21435. */
  21436. serialize(): any;
  21437. /**
  21438. * Dispose the material and release its associated resources
  21439. * @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)
  21440. * @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)
  21441. * @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)
  21442. */
  21443. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21444. /**
  21445. * Creates a MultiMaterial from parsed MultiMaterial data.
  21446. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21447. * @param scene defines the hosting scene
  21448. * @returns a new MultiMaterial
  21449. */
  21450. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21451. }
  21452. }
  21453. declare module "babylonjs/Meshes/subMesh" {
  21454. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21455. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21456. import { Engine } from "babylonjs/Engines/engine";
  21457. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21458. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21459. import { Effect } from "babylonjs/Materials/effect";
  21460. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21461. import { Plane } from "babylonjs/Maths/math.plane";
  21462. import { Collider } from "babylonjs/Collisions/collider";
  21463. import { Material } from "babylonjs/Materials/material";
  21464. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21466. import { Mesh } from "babylonjs/Meshes/mesh";
  21467. import { Ray } from "babylonjs/Culling/ray";
  21468. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21469. /**
  21470. * Base class for submeshes
  21471. */
  21472. export class BaseSubMesh {
  21473. /** @hidden */
  21474. _materialDefines: Nullable<MaterialDefines>;
  21475. /** @hidden */
  21476. _materialEffect: Nullable<Effect>;
  21477. /**
  21478. * Gets associated effect
  21479. */
  21480. readonly effect: Nullable<Effect>;
  21481. /**
  21482. * Sets associated effect (effect used to render this submesh)
  21483. * @param effect defines the effect to associate with
  21484. * @param defines defines the set of defines used to compile this effect
  21485. */
  21486. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21487. }
  21488. /**
  21489. * Defines a subdivision inside a mesh
  21490. */
  21491. export class SubMesh extends BaseSubMesh implements ICullable {
  21492. /** the material index to use */
  21493. materialIndex: number;
  21494. /** vertex index start */
  21495. verticesStart: number;
  21496. /** vertices count */
  21497. verticesCount: number;
  21498. /** index start */
  21499. indexStart: number;
  21500. /** indices count */
  21501. indexCount: number;
  21502. /** @hidden */
  21503. _linesIndexCount: number;
  21504. private _mesh;
  21505. private _renderingMesh;
  21506. private _boundingInfo;
  21507. private _linesIndexBuffer;
  21508. /** @hidden */
  21509. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21510. /** @hidden */
  21511. _trianglePlanes: Plane[];
  21512. /** @hidden */
  21513. _lastColliderTransformMatrix: Nullable<Matrix>;
  21514. /** @hidden */
  21515. _renderId: number;
  21516. /** @hidden */
  21517. _alphaIndex: number;
  21518. /** @hidden */
  21519. _distanceToCamera: number;
  21520. /** @hidden */
  21521. _id: number;
  21522. private _currentMaterial;
  21523. /**
  21524. * Add a new submesh to a mesh
  21525. * @param materialIndex defines the material index to use
  21526. * @param verticesStart defines vertex index start
  21527. * @param verticesCount defines vertices count
  21528. * @param indexStart defines index start
  21529. * @param indexCount defines indices count
  21530. * @param mesh defines the parent mesh
  21531. * @param renderingMesh defines an optional rendering mesh
  21532. * @param createBoundingBox defines if bounding box should be created for this submesh
  21533. * @returns the new submesh
  21534. */
  21535. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21536. /**
  21537. * Creates a new submesh
  21538. * @param materialIndex defines the material index to use
  21539. * @param verticesStart defines vertex index start
  21540. * @param verticesCount defines vertices count
  21541. * @param indexStart defines index start
  21542. * @param indexCount defines indices count
  21543. * @param mesh defines the parent mesh
  21544. * @param renderingMesh defines an optional rendering mesh
  21545. * @param createBoundingBox defines if bounding box should be created for this submesh
  21546. */
  21547. constructor(
  21548. /** the material index to use */
  21549. materialIndex: number,
  21550. /** vertex index start */
  21551. verticesStart: number,
  21552. /** vertices count */
  21553. verticesCount: number,
  21554. /** index start */
  21555. indexStart: number,
  21556. /** indices count */
  21557. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21558. /**
  21559. * Returns true if this submesh covers the entire parent mesh
  21560. * @ignorenaming
  21561. */
  21562. readonly IsGlobal: boolean;
  21563. /**
  21564. * Returns the submesh BoudingInfo object
  21565. * @returns current bounding info (or mesh's one if the submesh is global)
  21566. */
  21567. getBoundingInfo(): BoundingInfo;
  21568. /**
  21569. * Sets the submesh BoundingInfo
  21570. * @param boundingInfo defines the new bounding info to use
  21571. * @returns the SubMesh
  21572. */
  21573. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21574. /**
  21575. * Returns the mesh of the current submesh
  21576. * @return the parent mesh
  21577. */
  21578. getMesh(): AbstractMesh;
  21579. /**
  21580. * Returns the rendering mesh of the submesh
  21581. * @returns the rendering mesh (could be different from parent mesh)
  21582. */
  21583. getRenderingMesh(): Mesh;
  21584. /**
  21585. * Returns the submesh material
  21586. * @returns null or the current material
  21587. */
  21588. getMaterial(): Nullable<Material>;
  21589. /**
  21590. * Sets a new updated BoundingInfo object to the submesh
  21591. * @param data defines an optional position array to use to determine the bounding info
  21592. * @returns the SubMesh
  21593. */
  21594. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21595. /** @hidden */
  21596. _checkCollision(collider: Collider): boolean;
  21597. /**
  21598. * Updates the submesh BoundingInfo
  21599. * @param world defines the world matrix to use to update the bounding info
  21600. * @returns the submesh
  21601. */
  21602. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21603. /**
  21604. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21605. * @param frustumPlanes defines the frustum planes
  21606. * @returns true if the submesh is intersecting with the frustum
  21607. */
  21608. isInFrustum(frustumPlanes: Plane[]): boolean;
  21609. /**
  21610. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21611. * @param frustumPlanes defines the frustum planes
  21612. * @returns true if the submesh is inside the frustum
  21613. */
  21614. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21615. /**
  21616. * Renders the submesh
  21617. * @param enableAlphaMode defines if alpha needs to be used
  21618. * @returns the submesh
  21619. */
  21620. render(enableAlphaMode: boolean): SubMesh;
  21621. /**
  21622. * @hidden
  21623. */
  21624. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21625. /**
  21626. * Checks if the submesh intersects with a ray
  21627. * @param ray defines the ray to test
  21628. * @returns true is the passed ray intersects the submesh bounding box
  21629. */
  21630. canIntersects(ray: Ray): boolean;
  21631. /**
  21632. * Intersects current submesh with a ray
  21633. * @param ray defines the ray to test
  21634. * @param positions defines mesh's positions array
  21635. * @param indices defines mesh's indices array
  21636. * @param fastCheck defines if only bounding info should be used
  21637. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21638. * @returns intersection info or null if no intersection
  21639. */
  21640. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21641. /** @hidden */
  21642. private _intersectLines;
  21643. /** @hidden */
  21644. private _intersectUnIndexedLines;
  21645. /** @hidden */
  21646. private _intersectTriangles;
  21647. /** @hidden */
  21648. private _intersectUnIndexedTriangles;
  21649. /** @hidden */
  21650. _rebuild(): void;
  21651. /**
  21652. * Creates a new submesh from the passed mesh
  21653. * @param newMesh defines the new hosting mesh
  21654. * @param newRenderingMesh defines an optional rendering mesh
  21655. * @returns the new submesh
  21656. */
  21657. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21658. /**
  21659. * Release associated resources
  21660. */
  21661. dispose(): void;
  21662. /**
  21663. * Gets the class name
  21664. * @returns the string "SubMesh".
  21665. */
  21666. getClassName(): string;
  21667. /**
  21668. * Creates a new submesh from indices data
  21669. * @param materialIndex the index of the main mesh material
  21670. * @param startIndex the index where to start the copy in the mesh indices array
  21671. * @param indexCount the number of indices to copy then from the startIndex
  21672. * @param mesh the main mesh to create the submesh from
  21673. * @param renderingMesh the optional rendering mesh
  21674. * @returns a new submesh
  21675. */
  21676. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21677. }
  21678. }
  21679. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21680. /**
  21681. * Class used to represent data loading progression
  21682. */
  21683. export class SceneLoaderFlags {
  21684. private static _ForceFullSceneLoadingForIncremental;
  21685. private static _ShowLoadingScreen;
  21686. private static _CleanBoneMatrixWeights;
  21687. private static _loggingLevel;
  21688. /**
  21689. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21690. */
  21691. static ForceFullSceneLoadingForIncremental: boolean;
  21692. /**
  21693. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21694. */
  21695. static ShowLoadingScreen: boolean;
  21696. /**
  21697. * Defines the current logging level (while loading the scene)
  21698. * @ignorenaming
  21699. */
  21700. static loggingLevel: number;
  21701. /**
  21702. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21703. */
  21704. static CleanBoneMatrixWeights: boolean;
  21705. }
  21706. }
  21707. declare module "babylonjs/Meshes/geometry" {
  21708. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21709. import { Scene } from "babylonjs/scene";
  21710. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21711. import { Engine } from "babylonjs/Engines/engine";
  21712. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21713. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21714. import { Effect } from "babylonjs/Materials/effect";
  21715. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21716. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21717. import { Mesh } from "babylonjs/Meshes/mesh";
  21718. /**
  21719. * Class used to store geometry data (vertex buffers + index buffer)
  21720. */
  21721. export class Geometry implements IGetSetVerticesData {
  21722. /**
  21723. * Gets or sets the ID of the geometry
  21724. */
  21725. id: string;
  21726. /**
  21727. * Gets or sets the unique ID of the geometry
  21728. */
  21729. uniqueId: number;
  21730. /**
  21731. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21732. */
  21733. delayLoadState: number;
  21734. /**
  21735. * Gets the file containing the data to load when running in delay load state
  21736. */
  21737. delayLoadingFile: Nullable<string>;
  21738. /**
  21739. * Callback called when the geometry is updated
  21740. */
  21741. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21742. private _scene;
  21743. private _engine;
  21744. private _meshes;
  21745. private _totalVertices;
  21746. /** @hidden */
  21747. _indices: IndicesArray;
  21748. /** @hidden */
  21749. _vertexBuffers: {
  21750. [key: string]: VertexBuffer;
  21751. };
  21752. private _isDisposed;
  21753. private _extend;
  21754. private _boundingBias;
  21755. /** @hidden */
  21756. _delayInfo: Array<string>;
  21757. private _indexBuffer;
  21758. private _indexBufferIsUpdatable;
  21759. /** @hidden */
  21760. _boundingInfo: Nullable<BoundingInfo>;
  21761. /** @hidden */
  21762. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21763. /** @hidden */
  21764. _softwareSkinningFrameId: number;
  21765. private _vertexArrayObjects;
  21766. private _updatable;
  21767. /** @hidden */
  21768. _positions: Nullable<Vector3[]>;
  21769. /**
  21770. * 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
  21771. */
  21772. /**
  21773. * 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
  21774. */
  21775. boundingBias: Vector2;
  21776. /**
  21777. * Static function used to attach a new empty geometry to a mesh
  21778. * @param mesh defines the mesh to attach the geometry to
  21779. * @returns the new Geometry
  21780. */
  21781. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21782. /**
  21783. * Creates a new geometry
  21784. * @param id defines the unique ID
  21785. * @param scene defines the hosting scene
  21786. * @param vertexData defines the VertexData used to get geometry data
  21787. * @param updatable defines if geometry must be updatable (false by default)
  21788. * @param mesh defines the mesh that will be associated with the geometry
  21789. */
  21790. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21791. /**
  21792. * Gets the current extend of the geometry
  21793. */
  21794. readonly extend: {
  21795. minimum: Vector3;
  21796. maximum: Vector3;
  21797. };
  21798. /**
  21799. * Gets the hosting scene
  21800. * @returns the hosting Scene
  21801. */
  21802. getScene(): Scene;
  21803. /**
  21804. * Gets the hosting engine
  21805. * @returns the hosting Engine
  21806. */
  21807. getEngine(): Engine;
  21808. /**
  21809. * Defines if the geometry is ready to use
  21810. * @returns true if the geometry is ready to be used
  21811. */
  21812. isReady(): boolean;
  21813. /**
  21814. * Gets a value indicating that the geometry should not be serialized
  21815. */
  21816. readonly doNotSerialize: boolean;
  21817. /** @hidden */
  21818. _rebuild(): void;
  21819. /**
  21820. * Affects all geometry data in one call
  21821. * @param vertexData defines the geometry data
  21822. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21823. */
  21824. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21825. /**
  21826. * Set specific vertex data
  21827. * @param kind defines the data kind (Position, normal, etc...)
  21828. * @param data defines the vertex data to use
  21829. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21830. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21831. */
  21832. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21833. /**
  21834. * Removes a specific vertex data
  21835. * @param kind defines the data kind (Position, normal, etc...)
  21836. */
  21837. removeVerticesData(kind: string): void;
  21838. /**
  21839. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21840. * @param buffer defines the vertex buffer to use
  21841. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21842. */
  21843. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21844. /**
  21845. * Update a specific vertex buffer
  21846. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21847. * It will do nothing if the buffer is not updatable
  21848. * @param kind defines the data kind (Position, normal, etc...)
  21849. * @param data defines the data to use
  21850. * @param offset defines the offset in the target buffer where to store the data
  21851. * @param useBytes set to true if the offset is in bytes
  21852. */
  21853. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21854. /**
  21855. * Update a specific vertex buffer
  21856. * This function will create a new buffer if the current one is not updatable
  21857. * @param kind defines the data kind (Position, normal, etc...)
  21858. * @param data defines the data to use
  21859. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21860. */
  21861. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21862. private _updateBoundingInfo;
  21863. /** @hidden */
  21864. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21865. /**
  21866. * Gets total number of vertices
  21867. * @returns the total number of vertices
  21868. */
  21869. getTotalVertices(): number;
  21870. /**
  21871. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21872. * @param kind defines the data kind (Position, normal, etc...)
  21873. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21874. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21875. * @returns a float array containing vertex data
  21876. */
  21877. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21878. /**
  21879. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21880. * @param kind defines the data kind (Position, normal, etc...)
  21881. * @returns true if the vertex buffer with the specified kind is updatable
  21882. */
  21883. isVertexBufferUpdatable(kind: string): boolean;
  21884. /**
  21885. * Gets a specific vertex buffer
  21886. * @param kind defines the data kind (Position, normal, etc...)
  21887. * @returns a VertexBuffer
  21888. */
  21889. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21890. /**
  21891. * Returns all vertex buffers
  21892. * @return an object holding all vertex buffers indexed by kind
  21893. */
  21894. getVertexBuffers(): Nullable<{
  21895. [key: string]: VertexBuffer;
  21896. }>;
  21897. /**
  21898. * Gets a boolean indicating if specific vertex buffer is present
  21899. * @param kind defines the data kind (Position, normal, etc...)
  21900. * @returns true if data is present
  21901. */
  21902. isVerticesDataPresent(kind: string): boolean;
  21903. /**
  21904. * Gets a list of all attached data kinds (Position, normal, etc...)
  21905. * @returns a list of string containing all kinds
  21906. */
  21907. getVerticesDataKinds(): string[];
  21908. /**
  21909. * Update index buffer
  21910. * @param indices defines the indices to store in the index buffer
  21911. * @param offset defines the offset in the target buffer where to store the data
  21912. * @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)
  21913. */
  21914. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21915. /**
  21916. * Creates a new index buffer
  21917. * @param indices defines the indices to store in the index buffer
  21918. * @param totalVertices defines the total number of vertices (could be null)
  21919. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21920. */
  21921. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21922. /**
  21923. * Return the total number of indices
  21924. * @returns the total number of indices
  21925. */
  21926. getTotalIndices(): number;
  21927. /**
  21928. * Gets the index buffer array
  21929. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21930. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21931. * @returns the index buffer array
  21932. */
  21933. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21934. /**
  21935. * Gets the index buffer
  21936. * @return the index buffer
  21937. */
  21938. getIndexBuffer(): Nullable<DataBuffer>;
  21939. /** @hidden */
  21940. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21941. /**
  21942. * Release the associated resources for a specific mesh
  21943. * @param mesh defines the source mesh
  21944. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21945. */
  21946. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21947. /**
  21948. * Apply current geometry to a given mesh
  21949. * @param mesh defines the mesh to apply geometry to
  21950. */
  21951. applyToMesh(mesh: Mesh): void;
  21952. private _updateExtend;
  21953. private _applyToMesh;
  21954. private notifyUpdate;
  21955. /**
  21956. * Load the geometry if it was flagged as delay loaded
  21957. * @param scene defines the hosting scene
  21958. * @param onLoaded defines a callback called when the geometry is loaded
  21959. */
  21960. load(scene: Scene, onLoaded?: () => void): void;
  21961. private _queueLoad;
  21962. /**
  21963. * Invert the geometry to move from a right handed system to a left handed one.
  21964. */
  21965. toLeftHanded(): void;
  21966. /** @hidden */
  21967. _resetPointsArrayCache(): void;
  21968. /** @hidden */
  21969. _generatePointsArray(): boolean;
  21970. /**
  21971. * Gets a value indicating if the geometry is disposed
  21972. * @returns true if the geometry was disposed
  21973. */
  21974. isDisposed(): boolean;
  21975. private _disposeVertexArrayObjects;
  21976. /**
  21977. * Free all associated resources
  21978. */
  21979. dispose(): void;
  21980. /**
  21981. * Clone the current geometry into a new geometry
  21982. * @param id defines the unique ID of the new geometry
  21983. * @returns a new geometry object
  21984. */
  21985. copy(id: string): Geometry;
  21986. /**
  21987. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21988. * @return a JSON representation of the current geometry data (without the vertices data)
  21989. */
  21990. serialize(): any;
  21991. private toNumberArray;
  21992. /**
  21993. * Serialize all vertices data into a JSON oject
  21994. * @returns a JSON representation of the current geometry data
  21995. */
  21996. serializeVerticeData(): any;
  21997. /**
  21998. * Extracts a clone of a mesh geometry
  21999. * @param mesh defines the source mesh
  22000. * @param id defines the unique ID of the new geometry object
  22001. * @returns the new geometry object
  22002. */
  22003. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22004. /**
  22005. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22006. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22007. * Be aware Math.random() could cause collisions, but:
  22008. * "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"
  22009. * @returns a string containing a new GUID
  22010. */
  22011. static RandomId(): string;
  22012. /** @hidden */
  22013. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22014. private static _CleanMatricesWeights;
  22015. /**
  22016. * Create a new geometry from persisted data (Using .babylon file format)
  22017. * @param parsedVertexData defines the persisted data
  22018. * @param scene defines the hosting scene
  22019. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22020. * @returns the new geometry object
  22021. */
  22022. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22023. }
  22024. }
  22025. declare module "babylonjs/Meshes/mesh.vertexData" {
  22026. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22027. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22028. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22029. import { Geometry } from "babylonjs/Meshes/geometry";
  22030. import { Mesh } from "babylonjs/Meshes/mesh";
  22031. /**
  22032. * Define an interface for all classes that will get and set the data on vertices
  22033. */
  22034. export interface IGetSetVerticesData {
  22035. /**
  22036. * Gets a boolean indicating if specific vertex data is present
  22037. * @param kind defines the vertex data kind to use
  22038. * @returns true is data kind is present
  22039. */
  22040. isVerticesDataPresent(kind: string): boolean;
  22041. /**
  22042. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22043. * @param kind defines the data kind (Position, normal, etc...)
  22044. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22045. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22046. * @returns a float array containing vertex data
  22047. */
  22048. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22049. /**
  22050. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22051. * @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.
  22052. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22053. * @returns the indices array or an empty array if the mesh has no geometry
  22054. */
  22055. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22056. /**
  22057. * Set specific vertex data
  22058. * @param kind defines the data kind (Position, normal, etc...)
  22059. * @param data defines the vertex data to use
  22060. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22061. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22062. */
  22063. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22064. /**
  22065. * Update a specific associated vertex buffer
  22066. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22067. * - VertexBuffer.PositionKind
  22068. * - VertexBuffer.UVKind
  22069. * - VertexBuffer.UV2Kind
  22070. * - VertexBuffer.UV3Kind
  22071. * - VertexBuffer.UV4Kind
  22072. * - VertexBuffer.UV5Kind
  22073. * - VertexBuffer.UV6Kind
  22074. * - VertexBuffer.ColorKind
  22075. * - VertexBuffer.MatricesIndicesKind
  22076. * - VertexBuffer.MatricesIndicesExtraKind
  22077. * - VertexBuffer.MatricesWeightsKind
  22078. * - VertexBuffer.MatricesWeightsExtraKind
  22079. * @param data defines the data source
  22080. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22081. * @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)
  22082. */
  22083. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22084. /**
  22085. * Creates a new index buffer
  22086. * @param indices defines the indices to store in the index buffer
  22087. * @param totalVertices defines the total number of vertices (could be null)
  22088. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22089. */
  22090. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22091. }
  22092. /**
  22093. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22094. */
  22095. export class VertexData {
  22096. /**
  22097. * Mesh side orientation : usually the external or front surface
  22098. */
  22099. static readonly FRONTSIDE: number;
  22100. /**
  22101. * Mesh side orientation : usually the internal or back surface
  22102. */
  22103. static readonly BACKSIDE: number;
  22104. /**
  22105. * Mesh side orientation : both internal and external or front and back surfaces
  22106. */
  22107. static readonly DOUBLESIDE: number;
  22108. /**
  22109. * Mesh side orientation : by default, `FRONTSIDE`
  22110. */
  22111. static readonly DEFAULTSIDE: number;
  22112. /**
  22113. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22114. */
  22115. positions: Nullable<FloatArray>;
  22116. /**
  22117. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22118. */
  22119. normals: Nullable<FloatArray>;
  22120. /**
  22121. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22122. */
  22123. tangents: Nullable<FloatArray>;
  22124. /**
  22125. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22126. */
  22127. uvs: Nullable<FloatArray>;
  22128. /**
  22129. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22130. */
  22131. uvs2: Nullable<FloatArray>;
  22132. /**
  22133. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22134. */
  22135. uvs3: Nullable<FloatArray>;
  22136. /**
  22137. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22138. */
  22139. uvs4: Nullable<FloatArray>;
  22140. /**
  22141. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22142. */
  22143. uvs5: Nullable<FloatArray>;
  22144. /**
  22145. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22146. */
  22147. uvs6: Nullable<FloatArray>;
  22148. /**
  22149. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22150. */
  22151. colors: Nullable<FloatArray>;
  22152. /**
  22153. * 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).
  22154. */
  22155. matricesIndices: Nullable<FloatArray>;
  22156. /**
  22157. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22158. */
  22159. matricesWeights: Nullable<FloatArray>;
  22160. /**
  22161. * An array extending the number of possible indices
  22162. */
  22163. matricesIndicesExtra: Nullable<FloatArray>;
  22164. /**
  22165. * An array extending the number of possible weights when the number of indices is extended
  22166. */
  22167. matricesWeightsExtra: Nullable<FloatArray>;
  22168. /**
  22169. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22170. */
  22171. indices: Nullable<IndicesArray>;
  22172. /**
  22173. * Uses the passed data array to set the set the values for the specified kind of data
  22174. * @param data a linear array of floating numbers
  22175. * @param kind the type of data that is being set, eg positions, colors etc
  22176. */
  22177. set(data: FloatArray, kind: string): void;
  22178. /**
  22179. * Associates the vertexData to the passed Mesh.
  22180. * Sets it as updatable or not (default `false`)
  22181. * @param mesh the mesh the vertexData is applied to
  22182. * @param updatable when used and having the value true allows new data to update the vertexData
  22183. * @returns the VertexData
  22184. */
  22185. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22186. /**
  22187. * Associates the vertexData to the passed Geometry.
  22188. * Sets it as updatable or not (default `false`)
  22189. * @param geometry the geometry the vertexData is applied to
  22190. * @param updatable when used and having the value true allows new data to update the vertexData
  22191. * @returns VertexData
  22192. */
  22193. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22194. /**
  22195. * Updates the associated mesh
  22196. * @param mesh the mesh to be updated
  22197. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22198. * @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
  22199. * @returns VertexData
  22200. */
  22201. updateMesh(mesh: Mesh): VertexData;
  22202. /**
  22203. * Updates the associated geometry
  22204. * @param geometry the geometry to be updated
  22205. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22206. * @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
  22207. * @returns VertexData.
  22208. */
  22209. updateGeometry(geometry: Geometry): VertexData;
  22210. private _applyTo;
  22211. private _update;
  22212. /**
  22213. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22214. * @param matrix the transforming matrix
  22215. * @returns the VertexData
  22216. */
  22217. transform(matrix: Matrix): VertexData;
  22218. /**
  22219. * Merges the passed VertexData into the current one
  22220. * @param other the VertexData to be merged into the current one
  22221. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22222. * @returns the modified VertexData
  22223. */
  22224. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22225. private _mergeElement;
  22226. private _validate;
  22227. /**
  22228. * Serializes the VertexData
  22229. * @returns a serialized object
  22230. */
  22231. serialize(): any;
  22232. /**
  22233. * Extracts the vertexData from a mesh
  22234. * @param mesh the mesh from which to extract the VertexData
  22235. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22236. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22237. * @returns the object VertexData associated to the passed mesh
  22238. */
  22239. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22240. /**
  22241. * Extracts the vertexData from the geometry
  22242. * @param geometry the geometry from which to extract the VertexData
  22243. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22244. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22245. * @returns the object VertexData associated to the passed mesh
  22246. */
  22247. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22248. private static _ExtractFrom;
  22249. /**
  22250. * Creates the VertexData for a Ribbon
  22251. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22252. * * pathArray array of paths, each of which an array of successive Vector3
  22253. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22254. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22255. * * 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
  22256. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22257. * * 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)
  22258. * * 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)
  22259. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22260. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22261. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22262. * @returns the VertexData of the ribbon
  22263. */
  22264. static CreateRibbon(options: {
  22265. pathArray: Vector3[][];
  22266. closeArray?: boolean;
  22267. closePath?: boolean;
  22268. offset?: number;
  22269. sideOrientation?: number;
  22270. frontUVs?: Vector4;
  22271. backUVs?: Vector4;
  22272. invertUV?: boolean;
  22273. uvs?: Vector2[];
  22274. colors?: Color4[];
  22275. }): VertexData;
  22276. /**
  22277. * Creates the VertexData for a box
  22278. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22279. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22280. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22281. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22282. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22283. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22284. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22286. * * 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)
  22287. * * 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)
  22288. * @returns the VertexData of the box
  22289. */
  22290. static CreateBox(options: {
  22291. size?: number;
  22292. width?: number;
  22293. height?: number;
  22294. depth?: number;
  22295. faceUV?: Vector4[];
  22296. faceColors?: Color4[];
  22297. sideOrientation?: number;
  22298. frontUVs?: Vector4;
  22299. backUVs?: Vector4;
  22300. }): VertexData;
  22301. /**
  22302. * Creates the VertexData for a tiled box
  22303. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22304. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22305. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22306. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22308. * @returns the VertexData of the box
  22309. */
  22310. static CreateTiledBox(options: {
  22311. pattern?: number;
  22312. width?: number;
  22313. height?: number;
  22314. depth?: number;
  22315. tileSize?: number;
  22316. tileWidth?: number;
  22317. tileHeight?: number;
  22318. alignHorizontal?: number;
  22319. alignVertical?: number;
  22320. faceUV?: Vector4[];
  22321. faceColors?: Color4[];
  22322. sideOrientation?: number;
  22323. }): VertexData;
  22324. /**
  22325. * Creates the VertexData for a tiled plane
  22326. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22327. * * pattern a limited pattern arrangement depending on the number
  22328. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22329. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22330. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22331. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22332. * * 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)
  22333. * * 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)
  22334. * @returns the VertexData of the tiled plane
  22335. */
  22336. static CreateTiledPlane(options: {
  22337. pattern?: number;
  22338. tileSize?: number;
  22339. tileWidth?: number;
  22340. tileHeight?: number;
  22341. size?: number;
  22342. width?: number;
  22343. height?: number;
  22344. alignHorizontal?: number;
  22345. alignVertical?: number;
  22346. sideOrientation?: number;
  22347. frontUVs?: Vector4;
  22348. backUVs?: Vector4;
  22349. }): VertexData;
  22350. /**
  22351. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22352. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22353. * * segments sets the number of horizontal strips optional, default 32
  22354. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22355. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22356. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22357. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22358. * * 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
  22359. * * 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
  22360. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22361. * * 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)
  22362. * * 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)
  22363. * @returns the VertexData of the ellipsoid
  22364. */
  22365. static CreateSphere(options: {
  22366. segments?: number;
  22367. diameter?: number;
  22368. diameterX?: number;
  22369. diameterY?: number;
  22370. diameterZ?: number;
  22371. arc?: number;
  22372. slice?: number;
  22373. sideOrientation?: number;
  22374. frontUVs?: Vector4;
  22375. backUVs?: Vector4;
  22376. }): VertexData;
  22377. /**
  22378. * Creates the VertexData for a cylinder, cone or prism
  22379. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22380. * * height sets the height (y direction) of the cylinder, optional, default 2
  22381. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22382. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22383. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22384. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22385. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22386. * * 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
  22387. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22388. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22389. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22390. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22391. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22392. * * 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)
  22393. * * 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)
  22394. * @returns the VertexData of the cylinder, cone or prism
  22395. */
  22396. static CreateCylinder(options: {
  22397. height?: number;
  22398. diameterTop?: number;
  22399. diameterBottom?: number;
  22400. diameter?: number;
  22401. tessellation?: number;
  22402. subdivisions?: number;
  22403. arc?: number;
  22404. faceColors?: Color4[];
  22405. faceUV?: Vector4[];
  22406. hasRings?: boolean;
  22407. enclose?: boolean;
  22408. sideOrientation?: number;
  22409. frontUVs?: Vector4;
  22410. backUVs?: Vector4;
  22411. }): VertexData;
  22412. /**
  22413. * Creates the VertexData for a torus
  22414. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22415. * * diameter the diameter of the torus, optional default 1
  22416. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22417. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22418. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22419. * * 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)
  22420. * * 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)
  22421. * @returns the VertexData of the torus
  22422. */
  22423. static CreateTorus(options: {
  22424. diameter?: number;
  22425. thickness?: number;
  22426. tessellation?: number;
  22427. sideOrientation?: number;
  22428. frontUVs?: Vector4;
  22429. backUVs?: Vector4;
  22430. }): VertexData;
  22431. /**
  22432. * Creates the VertexData of the LineSystem
  22433. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22434. * - lines an array of lines, each line being an array of successive Vector3
  22435. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22436. * @returns the VertexData of the LineSystem
  22437. */
  22438. static CreateLineSystem(options: {
  22439. lines: Vector3[][];
  22440. colors?: Nullable<Color4[][]>;
  22441. }): VertexData;
  22442. /**
  22443. * Create the VertexData for a DashedLines
  22444. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22445. * - points an array successive Vector3
  22446. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22447. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22448. * - dashNb the intended total number of dashes, optional, default 200
  22449. * @returns the VertexData for the DashedLines
  22450. */
  22451. static CreateDashedLines(options: {
  22452. points: Vector3[];
  22453. dashSize?: number;
  22454. gapSize?: number;
  22455. dashNb?: number;
  22456. }): VertexData;
  22457. /**
  22458. * Creates the VertexData for a Ground
  22459. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22460. * - width the width (x direction) of the ground, optional, default 1
  22461. * - height the height (z direction) of the ground, optional, default 1
  22462. * - subdivisions the number of subdivisions per side, optional, default 1
  22463. * @returns the VertexData of the Ground
  22464. */
  22465. static CreateGround(options: {
  22466. width?: number;
  22467. height?: number;
  22468. subdivisions?: number;
  22469. subdivisionsX?: number;
  22470. subdivisionsY?: number;
  22471. }): VertexData;
  22472. /**
  22473. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22474. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22475. * * xmin the ground minimum X coordinate, optional, default -1
  22476. * * zmin the ground minimum Z coordinate, optional, default -1
  22477. * * xmax the ground maximum X coordinate, optional, default 1
  22478. * * zmax the ground maximum Z coordinate, optional, default 1
  22479. * * 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}
  22480. * * 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}
  22481. * @returns the VertexData of the TiledGround
  22482. */
  22483. static CreateTiledGround(options: {
  22484. xmin: number;
  22485. zmin: number;
  22486. xmax: number;
  22487. zmax: number;
  22488. subdivisions?: {
  22489. w: number;
  22490. h: number;
  22491. };
  22492. precision?: {
  22493. w: number;
  22494. h: number;
  22495. };
  22496. }): VertexData;
  22497. /**
  22498. * Creates the VertexData of the Ground designed from a heightmap
  22499. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22500. * * width the width (x direction) of the ground
  22501. * * height the height (z direction) of the ground
  22502. * * subdivisions the number of subdivisions per side
  22503. * * minHeight the minimum altitude on the ground, optional, default 0
  22504. * * maxHeight the maximum altitude on the ground, optional default 1
  22505. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22506. * * buffer the array holding the image color data
  22507. * * bufferWidth the width of image
  22508. * * bufferHeight the height of image
  22509. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22510. * @returns the VertexData of the Ground designed from a heightmap
  22511. */
  22512. static CreateGroundFromHeightMap(options: {
  22513. width: number;
  22514. height: number;
  22515. subdivisions: number;
  22516. minHeight: number;
  22517. maxHeight: number;
  22518. colorFilter: Color3;
  22519. buffer: Uint8Array;
  22520. bufferWidth: number;
  22521. bufferHeight: number;
  22522. alphaFilter: number;
  22523. }): VertexData;
  22524. /**
  22525. * Creates the VertexData for a Plane
  22526. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22527. * * size sets the width and height of the plane to the value of size, optional default 1
  22528. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22529. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22530. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22531. * * 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)
  22532. * * 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)
  22533. * @returns the VertexData of the box
  22534. */
  22535. static CreatePlane(options: {
  22536. size?: number;
  22537. width?: number;
  22538. height?: number;
  22539. sideOrientation?: number;
  22540. frontUVs?: Vector4;
  22541. backUVs?: Vector4;
  22542. }): VertexData;
  22543. /**
  22544. * Creates the VertexData of the Disc or regular Polygon
  22545. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22546. * * radius the radius of the disc, optional default 0.5
  22547. * * tessellation the number of polygon sides, optional, default 64
  22548. * * 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
  22549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22550. * * 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)
  22551. * * 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)
  22552. * @returns the VertexData of the box
  22553. */
  22554. static CreateDisc(options: {
  22555. radius?: number;
  22556. tessellation?: number;
  22557. arc?: number;
  22558. sideOrientation?: number;
  22559. frontUVs?: Vector4;
  22560. backUVs?: Vector4;
  22561. }): VertexData;
  22562. /**
  22563. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22564. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22565. * @param polygon a mesh built from polygonTriangulation.build()
  22566. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22567. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22568. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22569. * @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)
  22570. * @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)
  22571. * @returns the VertexData of the Polygon
  22572. */
  22573. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22574. /**
  22575. * Creates the VertexData of the IcoSphere
  22576. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22577. * * radius the radius of the IcoSphere, optional default 1
  22578. * * radiusX allows stretching in the x direction, optional, default radius
  22579. * * radiusY allows stretching in the y direction, optional, default radius
  22580. * * radiusZ allows stretching in the z direction, optional, default radius
  22581. * * flat when true creates a flat shaded mesh, optional, default true
  22582. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22583. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22584. * * 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)
  22585. * * 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)
  22586. * @returns the VertexData of the IcoSphere
  22587. */
  22588. static CreateIcoSphere(options: {
  22589. radius?: number;
  22590. radiusX?: number;
  22591. radiusY?: number;
  22592. radiusZ?: number;
  22593. flat?: boolean;
  22594. subdivisions?: number;
  22595. sideOrientation?: number;
  22596. frontUVs?: Vector4;
  22597. backUVs?: Vector4;
  22598. }): VertexData;
  22599. /**
  22600. * Creates the VertexData for a Polyhedron
  22601. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22602. * * type provided types are:
  22603. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22604. * * 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)
  22605. * * size the size of the IcoSphere, optional default 1
  22606. * * sizeX allows stretching in the x direction, optional, default size
  22607. * * sizeY allows stretching in the y direction, optional, default size
  22608. * * sizeZ allows stretching in the z direction, optional, default size
  22609. * * 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
  22610. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22611. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22612. * * flat when true creates a flat shaded mesh, optional, default true
  22613. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22614. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22615. * * 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)
  22616. * * 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)
  22617. * @returns the VertexData of the Polyhedron
  22618. */
  22619. static CreatePolyhedron(options: {
  22620. type?: number;
  22621. size?: number;
  22622. sizeX?: number;
  22623. sizeY?: number;
  22624. sizeZ?: number;
  22625. custom?: any;
  22626. faceUV?: Vector4[];
  22627. faceColors?: Color4[];
  22628. flat?: boolean;
  22629. sideOrientation?: number;
  22630. frontUVs?: Vector4;
  22631. backUVs?: Vector4;
  22632. }): VertexData;
  22633. /**
  22634. * Creates the VertexData for a TorusKnot
  22635. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22636. * * radius the radius of the torus knot, optional, default 2
  22637. * * tube the thickness of the tube, optional, default 0.5
  22638. * * radialSegments the number of sides on each tube segments, optional, default 32
  22639. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22640. * * p the number of windings around the z axis, optional, default 2
  22641. * * q the number of windings around the x axis, optional, default 3
  22642. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22643. * * 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)
  22644. * * 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)
  22645. * @returns the VertexData of the Torus Knot
  22646. */
  22647. static CreateTorusKnot(options: {
  22648. radius?: number;
  22649. tube?: number;
  22650. radialSegments?: number;
  22651. tubularSegments?: number;
  22652. p?: number;
  22653. q?: number;
  22654. sideOrientation?: number;
  22655. frontUVs?: Vector4;
  22656. backUVs?: Vector4;
  22657. }): VertexData;
  22658. /**
  22659. * Compute normals for given positions and indices
  22660. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22661. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22662. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22663. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22664. * * facetNormals : optional array of facet normals (vector3)
  22665. * * facetPositions : optional array of facet positions (vector3)
  22666. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22667. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22668. * * bInfo : optional bounding info, required for facetPartitioning computation
  22669. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22670. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22671. * * useRightHandedSystem: optional boolean to for right handed system computation
  22672. * * depthSort : optional boolean to enable the facet depth sort computation
  22673. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22674. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22675. */
  22676. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22677. facetNormals?: any;
  22678. facetPositions?: any;
  22679. facetPartitioning?: any;
  22680. ratio?: number;
  22681. bInfo?: any;
  22682. bbSize?: Vector3;
  22683. subDiv?: any;
  22684. useRightHandedSystem?: boolean;
  22685. depthSort?: boolean;
  22686. distanceTo?: Vector3;
  22687. depthSortedFacets?: any;
  22688. }): void;
  22689. /** @hidden */
  22690. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22691. /**
  22692. * Applies VertexData created from the imported parameters to the geometry
  22693. * @param parsedVertexData the parsed data from an imported file
  22694. * @param geometry the geometry to apply the VertexData to
  22695. */
  22696. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22697. }
  22698. }
  22699. declare module "babylonjs/Morph/morphTarget" {
  22700. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22701. import { Observable } from "babylonjs/Misc/observable";
  22702. import { Nullable, FloatArray } from "babylonjs/types";
  22703. import { Scene } from "babylonjs/scene";
  22704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22705. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22706. /**
  22707. * Defines a target to use with MorphTargetManager
  22708. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22709. */
  22710. export class MorphTarget implements IAnimatable {
  22711. /** defines the name of the target */
  22712. name: string;
  22713. /**
  22714. * Gets or sets the list of animations
  22715. */
  22716. animations: import("babylonjs/Animations/animation").Animation[];
  22717. private _scene;
  22718. private _positions;
  22719. private _normals;
  22720. private _tangents;
  22721. private _uvs;
  22722. private _influence;
  22723. /**
  22724. * Observable raised when the influence changes
  22725. */
  22726. onInfluenceChanged: Observable<boolean>;
  22727. /** @hidden */
  22728. _onDataLayoutChanged: Observable<void>;
  22729. /**
  22730. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22731. */
  22732. influence: number;
  22733. /**
  22734. * Gets or sets the id of the morph Target
  22735. */
  22736. id: string;
  22737. private _animationPropertiesOverride;
  22738. /**
  22739. * Gets or sets the animation properties override
  22740. */
  22741. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22742. /**
  22743. * Creates a new MorphTarget
  22744. * @param name defines the name of the target
  22745. * @param influence defines the influence to use
  22746. * @param scene defines the scene the morphtarget belongs to
  22747. */
  22748. constructor(
  22749. /** defines the name of the target */
  22750. name: string, influence?: number, scene?: Nullable<Scene>);
  22751. /**
  22752. * Gets a boolean defining if the target contains position data
  22753. */
  22754. readonly hasPositions: boolean;
  22755. /**
  22756. * Gets a boolean defining if the target contains normal data
  22757. */
  22758. readonly hasNormals: boolean;
  22759. /**
  22760. * Gets a boolean defining if the target contains tangent data
  22761. */
  22762. readonly hasTangents: boolean;
  22763. /**
  22764. * Gets a boolean defining if the target contains texture coordinates data
  22765. */
  22766. readonly hasUVs: boolean;
  22767. /**
  22768. * Affects position data to this target
  22769. * @param data defines the position data to use
  22770. */
  22771. setPositions(data: Nullable<FloatArray>): void;
  22772. /**
  22773. * Gets the position data stored in this target
  22774. * @returns a FloatArray containing the position data (or null if not present)
  22775. */
  22776. getPositions(): Nullable<FloatArray>;
  22777. /**
  22778. * Affects normal data to this target
  22779. * @param data defines the normal data to use
  22780. */
  22781. setNormals(data: Nullable<FloatArray>): void;
  22782. /**
  22783. * Gets the normal data stored in this target
  22784. * @returns a FloatArray containing the normal data (or null if not present)
  22785. */
  22786. getNormals(): Nullable<FloatArray>;
  22787. /**
  22788. * Affects tangent data to this target
  22789. * @param data defines the tangent data to use
  22790. */
  22791. setTangents(data: Nullable<FloatArray>): void;
  22792. /**
  22793. * Gets the tangent data stored in this target
  22794. * @returns a FloatArray containing the tangent data (or null if not present)
  22795. */
  22796. getTangents(): Nullable<FloatArray>;
  22797. /**
  22798. * Affects texture coordinates data to this target
  22799. * @param data defines the texture coordinates data to use
  22800. */
  22801. setUVs(data: Nullable<FloatArray>): void;
  22802. /**
  22803. * Gets the texture coordinates data stored in this target
  22804. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22805. */
  22806. getUVs(): Nullable<FloatArray>;
  22807. /**
  22808. * Serializes the current target into a Serialization object
  22809. * @returns the serialized object
  22810. */
  22811. serialize(): any;
  22812. /**
  22813. * Returns the string "MorphTarget"
  22814. * @returns "MorphTarget"
  22815. */
  22816. getClassName(): string;
  22817. /**
  22818. * Creates a new target from serialized data
  22819. * @param serializationObject defines the serialized data to use
  22820. * @returns a new MorphTarget
  22821. */
  22822. static Parse(serializationObject: any): MorphTarget;
  22823. /**
  22824. * Creates a MorphTarget from mesh data
  22825. * @param mesh defines the source mesh
  22826. * @param name defines the name to use for the new target
  22827. * @param influence defines the influence to attach to the target
  22828. * @returns a new MorphTarget
  22829. */
  22830. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22831. }
  22832. }
  22833. declare module "babylonjs/Morph/morphTargetManager" {
  22834. import { Nullable } from "babylonjs/types";
  22835. import { Scene } from "babylonjs/scene";
  22836. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22837. /**
  22838. * This class is used to deform meshes using morphing between different targets
  22839. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22840. */
  22841. export class MorphTargetManager {
  22842. private _targets;
  22843. private _targetInfluenceChangedObservers;
  22844. private _targetDataLayoutChangedObservers;
  22845. private _activeTargets;
  22846. private _scene;
  22847. private _influences;
  22848. private _supportsNormals;
  22849. private _supportsTangents;
  22850. private _supportsUVs;
  22851. private _vertexCount;
  22852. private _uniqueId;
  22853. private _tempInfluences;
  22854. /**
  22855. * Gets or sets a boolean indicating if normals must be morphed
  22856. */
  22857. enableNormalMorphing: boolean;
  22858. /**
  22859. * Gets or sets a boolean indicating if tangents must be morphed
  22860. */
  22861. enableTangentMorphing: boolean;
  22862. /**
  22863. * Gets or sets a boolean indicating if UV must be morphed
  22864. */
  22865. enableUVMorphing: boolean;
  22866. /**
  22867. * Creates a new MorphTargetManager
  22868. * @param scene defines the current scene
  22869. */
  22870. constructor(scene?: Nullable<Scene>);
  22871. /**
  22872. * Gets the unique ID of this manager
  22873. */
  22874. readonly uniqueId: number;
  22875. /**
  22876. * Gets the number of vertices handled by this manager
  22877. */
  22878. readonly vertexCount: number;
  22879. /**
  22880. * Gets a boolean indicating if this manager supports morphing of normals
  22881. */
  22882. readonly supportsNormals: boolean;
  22883. /**
  22884. * Gets a boolean indicating if this manager supports morphing of tangents
  22885. */
  22886. readonly supportsTangents: boolean;
  22887. /**
  22888. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22889. */
  22890. readonly supportsUVs: boolean;
  22891. /**
  22892. * Gets the number of targets stored in this manager
  22893. */
  22894. readonly numTargets: number;
  22895. /**
  22896. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22897. */
  22898. readonly numInfluencers: number;
  22899. /**
  22900. * Gets the list of influences (one per target)
  22901. */
  22902. readonly influences: Float32Array;
  22903. /**
  22904. * Gets the active target at specified index. An active target is a target with an influence > 0
  22905. * @param index defines the index to check
  22906. * @returns the requested target
  22907. */
  22908. getActiveTarget(index: number): MorphTarget;
  22909. /**
  22910. * Gets the target at specified index
  22911. * @param index defines the index to check
  22912. * @returns the requested target
  22913. */
  22914. getTarget(index: number): MorphTarget;
  22915. /**
  22916. * Add a new target to this manager
  22917. * @param target defines the target to add
  22918. */
  22919. addTarget(target: MorphTarget): void;
  22920. /**
  22921. * Removes a target from the manager
  22922. * @param target defines the target to remove
  22923. */
  22924. removeTarget(target: MorphTarget): void;
  22925. /**
  22926. * Serializes the current manager into a Serialization object
  22927. * @returns the serialized object
  22928. */
  22929. serialize(): any;
  22930. private _syncActiveTargets;
  22931. /**
  22932. * Syncrhonize the targets with all the meshes using this morph target manager
  22933. */
  22934. synchronize(): void;
  22935. /**
  22936. * Creates a new MorphTargetManager from serialized data
  22937. * @param serializationObject defines the serialized data
  22938. * @param scene defines the hosting scene
  22939. * @returns the new MorphTargetManager
  22940. */
  22941. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22942. }
  22943. }
  22944. declare module "babylonjs/Meshes/meshLODLevel" {
  22945. import { Mesh } from "babylonjs/Meshes/mesh";
  22946. import { Nullable } from "babylonjs/types";
  22947. /**
  22948. * Class used to represent a specific level of detail of a mesh
  22949. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22950. */
  22951. export class MeshLODLevel {
  22952. /** Defines the distance where this level should start being displayed */
  22953. distance: number;
  22954. /** Defines the mesh to use to render this level */
  22955. mesh: Nullable<Mesh>;
  22956. /**
  22957. * Creates a new LOD level
  22958. * @param distance defines the distance where this level should star being displayed
  22959. * @param mesh defines the mesh to use to render this level
  22960. */
  22961. constructor(
  22962. /** Defines the distance where this level should start being displayed */
  22963. distance: number,
  22964. /** Defines the mesh to use to render this level */
  22965. mesh: Nullable<Mesh>);
  22966. }
  22967. }
  22968. declare module "babylonjs/Meshes/groundMesh" {
  22969. import { Scene } from "babylonjs/scene";
  22970. import { Vector3 } from "babylonjs/Maths/math.vector";
  22971. import { Mesh } from "babylonjs/Meshes/mesh";
  22972. /**
  22973. * Mesh representing the gorund
  22974. */
  22975. export class GroundMesh extends Mesh {
  22976. /** If octree should be generated */
  22977. generateOctree: boolean;
  22978. private _heightQuads;
  22979. /** @hidden */
  22980. _subdivisionsX: number;
  22981. /** @hidden */
  22982. _subdivisionsY: number;
  22983. /** @hidden */
  22984. _width: number;
  22985. /** @hidden */
  22986. _height: number;
  22987. /** @hidden */
  22988. _minX: number;
  22989. /** @hidden */
  22990. _maxX: number;
  22991. /** @hidden */
  22992. _minZ: number;
  22993. /** @hidden */
  22994. _maxZ: number;
  22995. constructor(name: string, scene: Scene);
  22996. /**
  22997. * "GroundMesh"
  22998. * @returns "GroundMesh"
  22999. */
  23000. getClassName(): string;
  23001. /**
  23002. * The minimum of x and y subdivisions
  23003. */
  23004. readonly subdivisions: number;
  23005. /**
  23006. * X subdivisions
  23007. */
  23008. readonly subdivisionsX: number;
  23009. /**
  23010. * Y subdivisions
  23011. */
  23012. readonly subdivisionsY: number;
  23013. /**
  23014. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23015. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23016. * @param chunksCount the number of subdivisions for x and y
  23017. * @param octreeBlocksSize (Default: 32)
  23018. */
  23019. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23020. /**
  23021. * Returns a height (y) value in the Worl system :
  23022. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23023. * @param x x coordinate
  23024. * @param z z coordinate
  23025. * @returns the ground y position if (x, z) are outside the ground surface.
  23026. */
  23027. getHeightAtCoordinates(x: number, z: number): number;
  23028. /**
  23029. * Returns a normalized vector (Vector3) orthogonal to the ground
  23030. * at the ground coordinates (x, z) expressed in the World system.
  23031. * @param x x coordinate
  23032. * @param z z coordinate
  23033. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23034. */
  23035. getNormalAtCoordinates(x: number, z: number): Vector3;
  23036. /**
  23037. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23038. * at the ground coordinates (x, z) expressed in the World system.
  23039. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23040. * @param x x coordinate
  23041. * @param z z coordinate
  23042. * @param ref vector to store the result
  23043. * @returns the GroundMesh.
  23044. */
  23045. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23046. /**
  23047. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23048. * if the ground has been updated.
  23049. * This can be used in the render loop.
  23050. * @returns the GroundMesh.
  23051. */
  23052. updateCoordinateHeights(): GroundMesh;
  23053. private _getFacetAt;
  23054. private _initHeightQuads;
  23055. private _computeHeightQuads;
  23056. /**
  23057. * Serializes this ground mesh
  23058. * @param serializationObject object to write serialization to
  23059. */
  23060. serialize(serializationObject: any): void;
  23061. /**
  23062. * Parses a serialized ground mesh
  23063. * @param parsedMesh the serialized mesh
  23064. * @param scene the scene to create the ground mesh in
  23065. * @returns the created ground mesh
  23066. */
  23067. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23068. }
  23069. }
  23070. declare module "babylonjs/Physics/physicsJoint" {
  23071. import { Vector3 } from "babylonjs/Maths/math.vector";
  23072. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23073. /**
  23074. * Interface for Physics-Joint data
  23075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23076. */
  23077. export interface PhysicsJointData {
  23078. /**
  23079. * The main pivot of the joint
  23080. */
  23081. mainPivot?: Vector3;
  23082. /**
  23083. * The connected pivot of the joint
  23084. */
  23085. connectedPivot?: Vector3;
  23086. /**
  23087. * The main axis of the joint
  23088. */
  23089. mainAxis?: Vector3;
  23090. /**
  23091. * The connected axis of the joint
  23092. */
  23093. connectedAxis?: Vector3;
  23094. /**
  23095. * The collision of the joint
  23096. */
  23097. collision?: boolean;
  23098. /**
  23099. * Native Oimo/Cannon/Energy data
  23100. */
  23101. nativeParams?: any;
  23102. }
  23103. /**
  23104. * This is a holder class for the physics joint created by the physics plugin
  23105. * It holds a set of functions to control the underlying joint
  23106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23107. */
  23108. export class PhysicsJoint {
  23109. /**
  23110. * The type of the physics joint
  23111. */
  23112. type: number;
  23113. /**
  23114. * The data for the physics joint
  23115. */
  23116. jointData: PhysicsJointData;
  23117. private _physicsJoint;
  23118. protected _physicsPlugin: IPhysicsEnginePlugin;
  23119. /**
  23120. * Initializes the physics joint
  23121. * @param type The type of the physics joint
  23122. * @param jointData The data for the physics joint
  23123. */
  23124. constructor(
  23125. /**
  23126. * The type of the physics joint
  23127. */
  23128. type: number,
  23129. /**
  23130. * The data for the physics joint
  23131. */
  23132. jointData: PhysicsJointData);
  23133. /**
  23134. * Gets the physics joint
  23135. */
  23136. /**
  23137. * Sets the physics joint
  23138. */
  23139. physicsJoint: any;
  23140. /**
  23141. * Sets the physics plugin
  23142. */
  23143. physicsPlugin: IPhysicsEnginePlugin;
  23144. /**
  23145. * Execute a function that is physics-plugin specific.
  23146. * @param {Function} func the function that will be executed.
  23147. * It accepts two parameters: the physics world and the physics joint
  23148. */
  23149. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23150. /**
  23151. * Distance-Joint type
  23152. */
  23153. static DistanceJoint: number;
  23154. /**
  23155. * Hinge-Joint type
  23156. */
  23157. static HingeJoint: number;
  23158. /**
  23159. * Ball-and-Socket joint type
  23160. */
  23161. static BallAndSocketJoint: number;
  23162. /**
  23163. * Wheel-Joint type
  23164. */
  23165. static WheelJoint: number;
  23166. /**
  23167. * Slider-Joint type
  23168. */
  23169. static SliderJoint: number;
  23170. /**
  23171. * Prismatic-Joint type
  23172. */
  23173. static PrismaticJoint: number;
  23174. /**
  23175. * Universal-Joint type
  23176. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23177. */
  23178. static UniversalJoint: number;
  23179. /**
  23180. * Hinge-Joint 2 type
  23181. */
  23182. static Hinge2Joint: number;
  23183. /**
  23184. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23185. */
  23186. static PointToPointJoint: number;
  23187. /**
  23188. * Spring-Joint type
  23189. */
  23190. static SpringJoint: number;
  23191. /**
  23192. * Lock-Joint type
  23193. */
  23194. static LockJoint: number;
  23195. }
  23196. /**
  23197. * A class representing a physics distance joint
  23198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23199. */
  23200. export class DistanceJoint extends PhysicsJoint {
  23201. /**
  23202. *
  23203. * @param jointData The data for the Distance-Joint
  23204. */
  23205. constructor(jointData: DistanceJointData);
  23206. /**
  23207. * Update the predefined distance.
  23208. * @param maxDistance The maximum preferred distance
  23209. * @param minDistance The minimum preferred distance
  23210. */
  23211. updateDistance(maxDistance: number, minDistance?: number): void;
  23212. }
  23213. /**
  23214. * Represents a Motor-Enabled Joint
  23215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23216. */
  23217. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23218. /**
  23219. * Initializes the Motor-Enabled Joint
  23220. * @param type The type of the joint
  23221. * @param jointData The physica joint data for the joint
  23222. */
  23223. constructor(type: number, jointData: PhysicsJointData);
  23224. /**
  23225. * Set the motor values.
  23226. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23227. * @param force the force to apply
  23228. * @param maxForce max force for this motor.
  23229. */
  23230. setMotor(force?: number, maxForce?: number): void;
  23231. /**
  23232. * Set the motor's limits.
  23233. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23234. * @param upperLimit The upper limit of the motor
  23235. * @param lowerLimit The lower limit of the motor
  23236. */
  23237. setLimit(upperLimit: number, lowerLimit?: number): void;
  23238. }
  23239. /**
  23240. * This class represents a single physics Hinge-Joint
  23241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23242. */
  23243. export class HingeJoint extends MotorEnabledJoint {
  23244. /**
  23245. * Initializes the Hinge-Joint
  23246. * @param jointData The joint data for the Hinge-Joint
  23247. */
  23248. constructor(jointData: PhysicsJointData);
  23249. /**
  23250. * Set the motor values.
  23251. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23252. * @param {number} force the force to apply
  23253. * @param {number} maxForce max force for this motor.
  23254. */
  23255. setMotor(force?: number, maxForce?: number): void;
  23256. /**
  23257. * Set the motor's limits.
  23258. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23259. * @param upperLimit The upper limit of the motor
  23260. * @param lowerLimit The lower limit of the motor
  23261. */
  23262. setLimit(upperLimit: number, lowerLimit?: number): void;
  23263. }
  23264. /**
  23265. * This class represents a dual hinge physics joint (same as wheel joint)
  23266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23267. */
  23268. export class Hinge2Joint extends MotorEnabledJoint {
  23269. /**
  23270. * Initializes the Hinge2-Joint
  23271. * @param jointData The joint data for the Hinge2-Joint
  23272. */
  23273. constructor(jointData: PhysicsJointData);
  23274. /**
  23275. * Set the motor values.
  23276. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23277. * @param {number} targetSpeed the speed the motor is to reach
  23278. * @param {number} maxForce max force for this motor.
  23279. * @param {motorIndex} the motor's index, 0 or 1.
  23280. */
  23281. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23282. /**
  23283. * Set the motor limits.
  23284. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23285. * @param {number} upperLimit the upper limit
  23286. * @param {number} lowerLimit lower limit
  23287. * @param {motorIndex} the motor's index, 0 or 1.
  23288. */
  23289. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23290. }
  23291. /**
  23292. * Interface for a motor enabled joint
  23293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23294. */
  23295. export interface IMotorEnabledJoint {
  23296. /**
  23297. * Physics joint
  23298. */
  23299. physicsJoint: any;
  23300. /**
  23301. * Sets the motor of the motor-enabled joint
  23302. * @param force The force of the motor
  23303. * @param maxForce The maximum force of the motor
  23304. * @param motorIndex The index of the motor
  23305. */
  23306. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23307. /**
  23308. * Sets the limit of the motor
  23309. * @param upperLimit The upper limit of the motor
  23310. * @param lowerLimit The lower limit of the motor
  23311. * @param motorIndex The index of the motor
  23312. */
  23313. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23314. }
  23315. /**
  23316. * Joint data for a Distance-Joint
  23317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23318. */
  23319. export interface DistanceJointData extends PhysicsJointData {
  23320. /**
  23321. * Max distance the 2 joint objects can be apart
  23322. */
  23323. maxDistance: number;
  23324. }
  23325. /**
  23326. * Joint data from a spring joint
  23327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23328. */
  23329. export interface SpringJointData extends PhysicsJointData {
  23330. /**
  23331. * Length of the spring
  23332. */
  23333. length: number;
  23334. /**
  23335. * Stiffness of the spring
  23336. */
  23337. stiffness: number;
  23338. /**
  23339. * Damping of the spring
  23340. */
  23341. damping: number;
  23342. /** this callback will be called when applying the force to the impostors. */
  23343. forceApplicationCallback: () => void;
  23344. }
  23345. }
  23346. declare module "babylonjs/Physics/physicsRaycastResult" {
  23347. import { Vector3 } from "babylonjs/Maths/math.vector";
  23348. /**
  23349. * Holds the data for the raycast result
  23350. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23351. */
  23352. export class PhysicsRaycastResult {
  23353. private _hasHit;
  23354. private _hitDistance;
  23355. private _hitNormalWorld;
  23356. private _hitPointWorld;
  23357. private _rayFromWorld;
  23358. private _rayToWorld;
  23359. /**
  23360. * Gets if there was a hit
  23361. */
  23362. readonly hasHit: boolean;
  23363. /**
  23364. * Gets the distance from the hit
  23365. */
  23366. readonly hitDistance: number;
  23367. /**
  23368. * Gets the hit normal/direction in the world
  23369. */
  23370. readonly hitNormalWorld: Vector3;
  23371. /**
  23372. * Gets the hit point in the world
  23373. */
  23374. readonly hitPointWorld: Vector3;
  23375. /**
  23376. * Gets the ray "start point" of the ray in the world
  23377. */
  23378. readonly rayFromWorld: Vector3;
  23379. /**
  23380. * Gets the ray "end point" of the ray in the world
  23381. */
  23382. readonly rayToWorld: Vector3;
  23383. /**
  23384. * Sets the hit data (normal & point in world space)
  23385. * @param hitNormalWorld defines the normal in world space
  23386. * @param hitPointWorld defines the point in world space
  23387. */
  23388. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23389. /**
  23390. * Sets the distance from the start point to the hit point
  23391. * @param distance
  23392. */
  23393. setHitDistance(distance: number): void;
  23394. /**
  23395. * Calculates the distance manually
  23396. */
  23397. calculateHitDistance(): void;
  23398. /**
  23399. * Resets all the values to default
  23400. * @param from The from point on world space
  23401. * @param to The to point on world space
  23402. */
  23403. reset(from?: Vector3, to?: Vector3): void;
  23404. }
  23405. /**
  23406. * Interface for the size containing width and height
  23407. */
  23408. interface IXYZ {
  23409. /**
  23410. * X
  23411. */
  23412. x: number;
  23413. /**
  23414. * Y
  23415. */
  23416. y: number;
  23417. /**
  23418. * Z
  23419. */
  23420. z: number;
  23421. }
  23422. }
  23423. declare module "babylonjs/Physics/IPhysicsEngine" {
  23424. import { Nullable } from "babylonjs/types";
  23425. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23427. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23428. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23429. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23430. /**
  23431. * Interface used to describe a physics joint
  23432. */
  23433. export interface PhysicsImpostorJoint {
  23434. /** Defines the main impostor to which the joint is linked */
  23435. mainImpostor: PhysicsImpostor;
  23436. /** Defines the impostor that is connected to the main impostor using this joint */
  23437. connectedImpostor: PhysicsImpostor;
  23438. /** Defines the joint itself */
  23439. joint: PhysicsJoint;
  23440. }
  23441. /** @hidden */
  23442. export interface IPhysicsEnginePlugin {
  23443. world: any;
  23444. name: string;
  23445. setGravity(gravity: Vector3): void;
  23446. setTimeStep(timeStep: number): void;
  23447. getTimeStep(): number;
  23448. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23449. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23450. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23451. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23452. removePhysicsBody(impostor: PhysicsImpostor): void;
  23453. generateJoint(joint: PhysicsImpostorJoint): void;
  23454. removeJoint(joint: PhysicsImpostorJoint): void;
  23455. isSupported(): boolean;
  23456. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23457. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23458. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23459. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23460. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23461. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23462. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23463. getBodyMass(impostor: PhysicsImpostor): number;
  23464. getBodyFriction(impostor: PhysicsImpostor): number;
  23465. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23466. getBodyRestitution(impostor: PhysicsImpostor): number;
  23467. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23468. getBodyPressure?(impostor: PhysicsImpostor): number;
  23469. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23470. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23471. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23472. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23473. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23474. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23475. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23476. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23477. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23478. sleepBody(impostor: PhysicsImpostor): void;
  23479. wakeUpBody(impostor: PhysicsImpostor): void;
  23480. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23481. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23482. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23483. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23484. getRadius(impostor: PhysicsImpostor): number;
  23485. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23486. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23487. dispose(): void;
  23488. }
  23489. /**
  23490. * Interface used to define a physics engine
  23491. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23492. */
  23493. export interface IPhysicsEngine {
  23494. /**
  23495. * Gets the gravity vector used by the simulation
  23496. */
  23497. gravity: Vector3;
  23498. /**
  23499. * Sets the gravity vector used by the simulation
  23500. * @param gravity defines the gravity vector to use
  23501. */
  23502. setGravity(gravity: Vector3): void;
  23503. /**
  23504. * Set the time step of the physics engine.
  23505. * Default is 1/60.
  23506. * To slow it down, enter 1/600 for example.
  23507. * To speed it up, 1/30
  23508. * @param newTimeStep the new timestep to apply to this world.
  23509. */
  23510. setTimeStep(newTimeStep: number): void;
  23511. /**
  23512. * Get the time step of the physics engine.
  23513. * @returns the current time step
  23514. */
  23515. getTimeStep(): number;
  23516. /**
  23517. * Release all resources
  23518. */
  23519. dispose(): void;
  23520. /**
  23521. * Gets the name of the current physics plugin
  23522. * @returns the name of the plugin
  23523. */
  23524. getPhysicsPluginName(): string;
  23525. /**
  23526. * Adding a new impostor for the impostor tracking.
  23527. * This will be done by the impostor itself.
  23528. * @param impostor the impostor to add
  23529. */
  23530. addImpostor(impostor: PhysicsImpostor): void;
  23531. /**
  23532. * Remove an impostor from the engine.
  23533. * This impostor and its mesh will not longer be updated by the physics engine.
  23534. * @param impostor the impostor to remove
  23535. */
  23536. removeImpostor(impostor: PhysicsImpostor): void;
  23537. /**
  23538. * Add a joint to the physics engine
  23539. * @param mainImpostor defines the main impostor to which the joint is added.
  23540. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23541. * @param joint defines the joint that will connect both impostors.
  23542. */
  23543. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23544. /**
  23545. * Removes a joint from the simulation
  23546. * @param mainImpostor defines the impostor used with the joint
  23547. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23548. * @param joint defines the joint to remove
  23549. */
  23550. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23551. /**
  23552. * Gets the current plugin used to run the simulation
  23553. * @returns current plugin
  23554. */
  23555. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23556. /**
  23557. * Gets the list of physic impostors
  23558. * @returns an array of PhysicsImpostor
  23559. */
  23560. getImpostors(): Array<PhysicsImpostor>;
  23561. /**
  23562. * Gets the impostor for a physics enabled object
  23563. * @param object defines the object impersonated by the impostor
  23564. * @returns the PhysicsImpostor or null if not found
  23565. */
  23566. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23567. /**
  23568. * Gets the impostor for a physics body object
  23569. * @param body defines physics body used by the impostor
  23570. * @returns the PhysicsImpostor or null if not found
  23571. */
  23572. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23573. /**
  23574. * Does a raycast in the physics world
  23575. * @param from when should the ray start?
  23576. * @param to when should the ray end?
  23577. * @returns PhysicsRaycastResult
  23578. */
  23579. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23580. /**
  23581. * Called by the scene. No need to call it.
  23582. * @param delta defines the timespam between frames
  23583. */
  23584. _step(delta: number): void;
  23585. }
  23586. }
  23587. declare module "babylonjs/Physics/physicsImpostor" {
  23588. import { Nullable, IndicesArray } from "babylonjs/types";
  23589. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23590. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23592. import { Scene } from "babylonjs/scene";
  23593. import { Bone } from "babylonjs/Bones/bone";
  23594. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23595. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23596. import { Space } from "babylonjs/Maths/math.axis";
  23597. /**
  23598. * The interface for the physics imposter parameters
  23599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23600. */
  23601. export interface PhysicsImpostorParameters {
  23602. /**
  23603. * The mass of the physics imposter
  23604. */
  23605. mass: number;
  23606. /**
  23607. * The friction of the physics imposter
  23608. */
  23609. friction?: number;
  23610. /**
  23611. * The coefficient of restitution of the physics imposter
  23612. */
  23613. restitution?: number;
  23614. /**
  23615. * The native options of the physics imposter
  23616. */
  23617. nativeOptions?: any;
  23618. /**
  23619. * Specifies if the parent should be ignored
  23620. */
  23621. ignoreParent?: boolean;
  23622. /**
  23623. * Specifies if bi-directional transformations should be disabled
  23624. */
  23625. disableBidirectionalTransformation?: boolean;
  23626. /**
  23627. * The pressure inside the physics imposter, soft object only
  23628. */
  23629. pressure?: number;
  23630. /**
  23631. * The stiffness the physics imposter, soft object only
  23632. */
  23633. stiffness?: number;
  23634. /**
  23635. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23636. */
  23637. velocityIterations?: number;
  23638. /**
  23639. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23640. */
  23641. positionIterations?: number;
  23642. /**
  23643. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23644. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23645. * Add to fix multiple points
  23646. */
  23647. fixedPoints?: number;
  23648. /**
  23649. * The collision margin around a soft object
  23650. */
  23651. margin?: number;
  23652. /**
  23653. * The collision margin around a soft object
  23654. */
  23655. damping?: number;
  23656. /**
  23657. * The path for a rope based on an extrusion
  23658. */
  23659. path?: any;
  23660. /**
  23661. * The shape of an extrusion used for a rope based on an extrusion
  23662. */
  23663. shape?: any;
  23664. }
  23665. /**
  23666. * Interface for a physics-enabled object
  23667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23668. */
  23669. export interface IPhysicsEnabledObject {
  23670. /**
  23671. * The position of the physics-enabled object
  23672. */
  23673. position: Vector3;
  23674. /**
  23675. * The rotation of the physics-enabled object
  23676. */
  23677. rotationQuaternion: Nullable<Quaternion>;
  23678. /**
  23679. * The scale of the physics-enabled object
  23680. */
  23681. scaling: Vector3;
  23682. /**
  23683. * The rotation of the physics-enabled object
  23684. */
  23685. rotation?: Vector3;
  23686. /**
  23687. * The parent of the physics-enabled object
  23688. */
  23689. parent?: any;
  23690. /**
  23691. * The bounding info of the physics-enabled object
  23692. * @returns The bounding info of the physics-enabled object
  23693. */
  23694. getBoundingInfo(): BoundingInfo;
  23695. /**
  23696. * Computes the world matrix
  23697. * @param force Specifies if the world matrix should be computed by force
  23698. * @returns A world matrix
  23699. */
  23700. computeWorldMatrix(force: boolean): Matrix;
  23701. /**
  23702. * Gets the world matrix
  23703. * @returns A world matrix
  23704. */
  23705. getWorldMatrix?(): Matrix;
  23706. /**
  23707. * Gets the child meshes
  23708. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23709. * @returns An array of abstract meshes
  23710. */
  23711. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23712. /**
  23713. * Gets the vertex data
  23714. * @param kind The type of vertex data
  23715. * @returns A nullable array of numbers, or a float32 array
  23716. */
  23717. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23718. /**
  23719. * Gets the indices from the mesh
  23720. * @returns A nullable array of index arrays
  23721. */
  23722. getIndices?(): Nullable<IndicesArray>;
  23723. /**
  23724. * Gets the scene from the mesh
  23725. * @returns the indices array or null
  23726. */
  23727. getScene?(): Scene;
  23728. /**
  23729. * Gets the absolute position from the mesh
  23730. * @returns the absolute position
  23731. */
  23732. getAbsolutePosition(): Vector3;
  23733. /**
  23734. * Gets the absolute pivot point from the mesh
  23735. * @returns the absolute pivot point
  23736. */
  23737. getAbsolutePivotPoint(): Vector3;
  23738. /**
  23739. * Rotates the mesh
  23740. * @param axis The axis of rotation
  23741. * @param amount The amount of rotation
  23742. * @param space The space of the rotation
  23743. * @returns The rotation transform node
  23744. */
  23745. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23746. /**
  23747. * Translates the mesh
  23748. * @param axis The axis of translation
  23749. * @param distance The distance of translation
  23750. * @param space The space of the translation
  23751. * @returns The transform node
  23752. */
  23753. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23754. /**
  23755. * Sets the absolute position of the mesh
  23756. * @param absolutePosition The absolute position of the mesh
  23757. * @returns The transform node
  23758. */
  23759. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23760. /**
  23761. * Gets the class name of the mesh
  23762. * @returns The class name
  23763. */
  23764. getClassName(): string;
  23765. }
  23766. /**
  23767. * Represents a physics imposter
  23768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23769. */
  23770. export class PhysicsImpostor {
  23771. /**
  23772. * The physics-enabled object used as the physics imposter
  23773. */
  23774. object: IPhysicsEnabledObject;
  23775. /**
  23776. * The type of the physics imposter
  23777. */
  23778. type: number;
  23779. private _options;
  23780. private _scene?;
  23781. /**
  23782. * The default object size of the imposter
  23783. */
  23784. static DEFAULT_OBJECT_SIZE: Vector3;
  23785. /**
  23786. * The identity quaternion of the imposter
  23787. */
  23788. static IDENTITY_QUATERNION: Quaternion;
  23789. /** @hidden */
  23790. _pluginData: any;
  23791. private _physicsEngine;
  23792. private _physicsBody;
  23793. private _bodyUpdateRequired;
  23794. private _onBeforePhysicsStepCallbacks;
  23795. private _onAfterPhysicsStepCallbacks;
  23796. /** @hidden */
  23797. _onPhysicsCollideCallbacks: Array<{
  23798. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23799. otherImpostors: Array<PhysicsImpostor>;
  23800. }>;
  23801. private _deltaPosition;
  23802. private _deltaRotation;
  23803. private _deltaRotationConjugated;
  23804. /** @hidden */
  23805. _isFromLine: boolean;
  23806. private _parent;
  23807. private _isDisposed;
  23808. private static _tmpVecs;
  23809. private static _tmpQuat;
  23810. /**
  23811. * Specifies if the physics imposter is disposed
  23812. */
  23813. readonly isDisposed: boolean;
  23814. /**
  23815. * Gets the mass of the physics imposter
  23816. */
  23817. mass: number;
  23818. /**
  23819. * Gets the coefficient of friction
  23820. */
  23821. /**
  23822. * Sets the coefficient of friction
  23823. */
  23824. friction: number;
  23825. /**
  23826. * Gets the coefficient of restitution
  23827. */
  23828. /**
  23829. * Sets the coefficient of restitution
  23830. */
  23831. restitution: number;
  23832. /**
  23833. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23834. */
  23835. /**
  23836. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23837. */
  23838. pressure: number;
  23839. /**
  23840. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23841. */
  23842. /**
  23843. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23844. */
  23845. stiffness: number;
  23846. /**
  23847. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23848. */
  23849. /**
  23850. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23851. */
  23852. velocityIterations: number;
  23853. /**
  23854. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23855. */
  23856. /**
  23857. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23858. */
  23859. positionIterations: number;
  23860. /**
  23861. * The unique id of the physics imposter
  23862. * set by the physics engine when adding this impostor to the array
  23863. */
  23864. uniqueId: number;
  23865. /**
  23866. * @hidden
  23867. */
  23868. soft: boolean;
  23869. /**
  23870. * @hidden
  23871. */
  23872. segments: number;
  23873. private _joints;
  23874. /**
  23875. * Initializes the physics imposter
  23876. * @param object The physics-enabled object used as the physics imposter
  23877. * @param type The type of the physics imposter
  23878. * @param _options The options for the physics imposter
  23879. * @param _scene The Babylon scene
  23880. */
  23881. constructor(
  23882. /**
  23883. * The physics-enabled object used as the physics imposter
  23884. */
  23885. object: IPhysicsEnabledObject,
  23886. /**
  23887. * The type of the physics imposter
  23888. */
  23889. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23890. /**
  23891. * This function will completly initialize this impostor.
  23892. * It will create a new body - but only if this mesh has no parent.
  23893. * If it has, this impostor will not be used other than to define the impostor
  23894. * of the child mesh.
  23895. * @hidden
  23896. */
  23897. _init(): void;
  23898. private _getPhysicsParent;
  23899. /**
  23900. * Should a new body be generated.
  23901. * @returns boolean specifying if body initialization is required
  23902. */
  23903. isBodyInitRequired(): boolean;
  23904. /**
  23905. * Sets the updated scaling
  23906. * @param updated Specifies if the scaling is updated
  23907. */
  23908. setScalingUpdated(): void;
  23909. /**
  23910. * Force a regeneration of this or the parent's impostor's body.
  23911. * Use under cautious - This will remove all joints already implemented.
  23912. */
  23913. forceUpdate(): void;
  23914. /**
  23915. * Gets the body that holds this impostor. Either its own, or its parent.
  23916. */
  23917. /**
  23918. * Set the physics body. Used mainly by the physics engine/plugin
  23919. */
  23920. physicsBody: any;
  23921. /**
  23922. * Get the parent of the physics imposter
  23923. * @returns Physics imposter or null
  23924. */
  23925. /**
  23926. * Sets the parent of the physics imposter
  23927. */
  23928. parent: Nullable<PhysicsImpostor>;
  23929. /**
  23930. * Resets the update flags
  23931. */
  23932. resetUpdateFlags(): void;
  23933. /**
  23934. * Gets the object extend size
  23935. * @returns the object extend size
  23936. */
  23937. getObjectExtendSize(): Vector3;
  23938. /**
  23939. * Gets the object center
  23940. * @returns The object center
  23941. */
  23942. getObjectCenter(): Vector3;
  23943. /**
  23944. * Get a specific parametes from the options parameter
  23945. * @param paramName The object parameter name
  23946. * @returns The object parameter
  23947. */
  23948. getParam(paramName: string): any;
  23949. /**
  23950. * Sets a specific parameter in the options given to the physics plugin
  23951. * @param paramName The parameter name
  23952. * @param value The value of the parameter
  23953. */
  23954. setParam(paramName: string, value: number): void;
  23955. /**
  23956. * Specifically change the body's mass option. Won't recreate the physics body object
  23957. * @param mass The mass of the physics imposter
  23958. */
  23959. setMass(mass: number): void;
  23960. /**
  23961. * Gets the linear velocity
  23962. * @returns linear velocity or null
  23963. */
  23964. getLinearVelocity(): Nullable<Vector3>;
  23965. /**
  23966. * Sets the linear velocity
  23967. * @param velocity linear velocity or null
  23968. */
  23969. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23970. /**
  23971. * Gets the angular velocity
  23972. * @returns angular velocity or null
  23973. */
  23974. getAngularVelocity(): Nullable<Vector3>;
  23975. /**
  23976. * Sets the angular velocity
  23977. * @param velocity The velocity or null
  23978. */
  23979. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23980. /**
  23981. * Execute a function with the physics plugin native code
  23982. * Provide a function the will have two variables - the world object and the physics body object
  23983. * @param func The function to execute with the physics plugin native code
  23984. */
  23985. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23986. /**
  23987. * Register a function that will be executed before the physics world is stepping forward
  23988. * @param func The function to execute before the physics world is stepped forward
  23989. */
  23990. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23991. /**
  23992. * Unregister a function that will be executed before the physics world is stepping forward
  23993. * @param func The function to execute before the physics world is stepped forward
  23994. */
  23995. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23996. /**
  23997. * Register a function that will be executed after the physics step
  23998. * @param func The function to execute after physics step
  23999. */
  24000. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24001. /**
  24002. * Unregisters a function that will be executed after the physics step
  24003. * @param func The function to execute after physics step
  24004. */
  24005. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24006. /**
  24007. * register a function that will be executed when this impostor collides against a different body
  24008. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24009. * @param func Callback that is executed on collision
  24010. */
  24011. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24012. /**
  24013. * Unregisters the physics imposter on contact
  24014. * @param collideAgainst The physics object to collide against
  24015. * @param func Callback to execute on collision
  24016. */
  24017. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24018. private _tmpQuat;
  24019. private _tmpQuat2;
  24020. /**
  24021. * Get the parent rotation
  24022. * @returns The parent rotation
  24023. */
  24024. getParentsRotation(): Quaternion;
  24025. /**
  24026. * this function is executed by the physics engine.
  24027. */
  24028. beforeStep: () => void;
  24029. /**
  24030. * this function is executed by the physics engine
  24031. */
  24032. afterStep: () => void;
  24033. /**
  24034. * Legacy collision detection event support
  24035. */
  24036. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24037. /**
  24038. * event and body object due to cannon's event-based architecture.
  24039. */
  24040. onCollide: (e: {
  24041. body: any;
  24042. }) => void;
  24043. /**
  24044. * Apply a force
  24045. * @param force The force to apply
  24046. * @param contactPoint The contact point for the force
  24047. * @returns The physics imposter
  24048. */
  24049. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24050. /**
  24051. * Apply an impulse
  24052. * @param force The impulse force
  24053. * @param contactPoint The contact point for the impulse force
  24054. * @returns The physics imposter
  24055. */
  24056. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24057. /**
  24058. * A help function to create a joint
  24059. * @param otherImpostor A physics imposter used to create a joint
  24060. * @param jointType The type of joint
  24061. * @param jointData The data for the joint
  24062. * @returns The physics imposter
  24063. */
  24064. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24065. /**
  24066. * Add a joint to this impostor with a different impostor
  24067. * @param otherImpostor A physics imposter used to add a joint
  24068. * @param joint The joint to add
  24069. * @returns The physics imposter
  24070. */
  24071. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24072. /**
  24073. * Add an anchor to a cloth impostor
  24074. * @param otherImpostor rigid impostor to anchor to
  24075. * @param width ratio across width from 0 to 1
  24076. * @param height ratio up height from 0 to 1
  24077. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24078. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24079. * @returns impostor the soft imposter
  24080. */
  24081. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24082. /**
  24083. * Add a hook to a rope impostor
  24084. * @param otherImpostor rigid impostor to anchor to
  24085. * @param length ratio across rope from 0 to 1
  24086. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24087. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24088. * @returns impostor the rope imposter
  24089. */
  24090. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24091. /**
  24092. * Will keep this body still, in a sleep mode.
  24093. * @returns the physics imposter
  24094. */
  24095. sleep(): PhysicsImpostor;
  24096. /**
  24097. * Wake the body up.
  24098. * @returns The physics imposter
  24099. */
  24100. wakeUp(): PhysicsImpostor;
  24101. /**
  24102. * Clones the physics imposter
  24103. * @param newObject The physics imposter clones to this physics-enabled object
  24104. * @returns A nullable physics imposter
  24105. */
  24106. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24107. /**
  24108. * Disposes the physics imposter
  24109. */
  24110. dispose(): void;
  24111. /**
  24112. * Sets the delta position
  24113. * @param position The delta position amount
  24114. */
  24115. setDeltaPosition(position: Vector3): void;
  24116. /**
  24117. * Sets the delta rotation
  24118. * @param rotation The delta rotation amount
  24119. */
  24120. setDeltaRotation(rotation: Quaternion): void;
  24121. /**
  24122. * Gets the box size of the physics imposter and stores the result in the input parameter
  24123. * @param result Stores the box size
  24124. * @returns The physics imposter
  24125. */
  24126. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24127. /**
  24128. * Gets the radius of the physics imposter
  24129. * @returns Radius of the physics imposter
  24130. */
  24131. getRadius(): number;
  24132. /**
  24133. * Sync a bone with this impostor
  24134. * @param bone The bone to sync to the impostor.
  24135. * @param boneMesh The mesh that the bone is influencing.
  24136. * @param jointPivot The pivot of the joint / bone in local space.
  24137. * @param distToJoint Optional distance from the impostor to the joint.
  24138. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24139. */
  24140. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24141. /**
  24142. * Sync impostor to a bone
  24143. * @param bone The bone that the impostor will be synced to.
  24144. * @param boneMesh The mesh that the bone is influencing.
  24145. * @param jointPivot The pivot of the joint / bone in local space.
  24146. * @param distToJoint Optional distance from the impostor to the joint.
  24147. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24148. * @param boneAxis Optional vector3 axis the bone is aligned with
  24149. */
  24150. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24151. /**
  24152. * No-Imposter type
  24153. */
  24154. static NoImpostor: number;
  24155. /**
  24156. * Sphere-Imposter type
  24157. */
  24158. static SphereImpostor: number;
  24159. /**
  24160. * Box-Imposter type
  24161. */
  24162. static BoxImpostor: number;
  24163. /**
  24164. * Plane-Imposter type
  24165. */
  24166. static PlaneImpostor: number;
  24167. /**
  24168. * Mesh-imposter type
  24169. */
  24170. static MeshImpostor: number;
  24171. /**
  24172. * Capsule-Impostor type (Ammo.js plugin only)
  24173. */
  24174. static CapsuleImpostor: number;
  24175. /**
  24176. * Cylinder-Imposter type
  24177. */
  24178. static CylinderImpostor: number;
  24179. /**
  24180. * Particle-Imposter type
  24181. */
  24182. static ParticleImpostor: number;
  24183. /**
  24184. * Heightmap-Imposter type
  24185. */
  24186. static HeightmapImpostor: number;
  24187. /**
  24188. * ConvexHull-Impostor type (Ammo.js plugin only)
  24189. */
  24190. static ConvexHullImpostor: number;
  24191. /**
  24192. * Rope-Imposter type
  24193. */
  24194. static RopeImpostor: number;
  24195. /**
  24196. * Cloth-Imposter type
  24197. */
  24198. static ClothImpostor: number;
  24199. /**
  24200. * Softbody-Imposter type
  24201. */
  24202. static SoftbodyImpostor: number;
  24203. }
  24204. }
  24205. declare module "babylonjs/Meshes/mesh" {
  24206. import { Observable } from "babylonjs/Misc/observable";
  24207. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24208. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24209. import { Camera } from "babylonjs/Cameras/camera";
  24210. import { Scene } from "babylonjs/scene";
  24211. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24212. import { Color4 } from "babylonjs/Maths/math.color";
  24213. import { Engine } from "babylonjs/Engines/engine";
  24214. import { Node } from "babylonjs/node";
  24215. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24216. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24217. import { Buffer } from "babylonjs/Meshes/buffer";
  24218. import { Geometry } from "babylonjs/Meshes/geometry";
  24219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24220. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24221. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24222. import { Effect } from "babylonjs/Materials/effect";
  24223. import { Material } from "babylonjs/Materials/material";
  24224. import { Skeleton } from "babylonjs/Bones/skeleton";
  24225. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24226. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24227. import { Path3D } from "babylonjs/Maths/math.path";
  24228. import { Plane } from "babylonjs/Maths/math.plane";
  24229. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24230. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24231. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24232. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24233. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24234. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24235. /**
  24236. * @hidden
  24237. **/
  24238. export class _CreationDataStorage {
  24239. closePath?: boolean;
  24240. closeArray?: boolean;
  24241. idx: number[];
  24242. dashSize: number;
  24243. gapSize: number;
  24244. path3D: Path3D;
  24245. pathArray: Vector3[][];
  24246. arc: number;
  24247. radius: number;
  24248. cap: number;
  24249. tessellation: number;
  24250. }
  24251. /**
  24252. * @hidden
  24253. **/
  24254. class _InstanceDataStorage {
  24255. visibleInstances: any;
  24256. batchCache: _InstancesBatch;
  24257. instancesBufferSize: number;
  24258. instancesBuffer: Nullable<Buffer>;
  24259. instancesData: Float32Array;
  24260. overridenInstanceCount: number;
  24261. isFrozen: boolean;
  24262. previousBatch: Nullable<_InstancesBatch>;
  24263. hardwareInstancedRendering: boolean;
  24264. sideOrientation: number;
  24265. }
  24266. /**
  24267. * @hidden
  24268. **/
  24269. export class _InstancesBatch {
  24270. mustReturn: boolean;
  24271. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24272. renderSelf: boolean[];
  24273. hardwareInstancedRendering: boolean[];
  24274. }
  24275. /**
  24276. * Class used to represent renderable models
  24277. */
  24278. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24279. /**
  24280. * Mesh side orientation : usually the external or front surface
  24281. */
  24282. static readonly FRONTSIDE: number;
  24283. /**
  24284. * Mesh side orientation : usually the internal or back surface
  24285. */
  24286. static readonly BACKSIDE: number;
  24287. /**
  24288. * Mesh side orientation : both internal and external or front and back surfaces
  24289. */
  24290. static readonly DOUBLESIDE: number;
  24291. /**
  24292. * Mesh side orientation : by default, `FRONTSIDE`
  24293. */
  24294. static readonly DEFAULTSIDE: number;
  24295. /**
  24296. * Mesh cap setting : no cap
  24297. */
  24298. static readonly NO_CAP: number;
  24299. /**
  24300. * Mesh cap setting : one cap at the beginning of the mesh
  24301. */
  24302. static readonly CAP_START: number;
  24303. /**
  24304. * Mesh cap setting : one cap at the end of the mesh
  24305. */
  24306. static readonly CAP_END: number;
  24307. /**
  24308. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24309. */
  24310. static readonly CAP_ALL: number;
  24311. /**
  24312. * Mesh pattern setting : no flip or rotate
  24313. */
  24314. static readonly NO_FLIP: number;
  24315. /**
  24316. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24317. */
  24318. static readonly FLIP_TILE: number;
  24319. /**
  24320. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24321. */
  24322. static readonly ROTATE_TILE: number;
  24323. /**
  24324. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24325. */
  24326. static readonly FLIP_ROW: number;
  24327. /**
  24328. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24329. */
  24330. static readonly ROTATE_ROW: number;
  24331. /**
  24332. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24333. */
  24334. static readonly FLIP_N_ROTATE_TILE: number;
  24335. /**
  24336. * Mesh pattern setting : rotate pattern and rotate
  24337. */
  24338. static readonly FLIP_N_ROTATE_ROW: number;
  24339. /**
  24340. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24341. */
  24342. static readonly CENTER: number;
  24343. /**
  24344. * Mesh tile positioning : part tiles on left
  24345. */
  24346. static readonly LEFT: number;
  24347. /**
  24348. * Mesh tile positioning : part tiles on right
  24349. */
  24350. static readonly RIGHT: number;
  24351. /**
  24352. * Mesh tile positioning : part tiles on top
  24353. */
  24354. static readonly TOP: number;
  24355. /**
  24356. * Mesh tile positioning : part tiles on bottom
  24357. */
  24358. static readonly BOTTOM: number;
  24359. /**
  24360. * Gets the default side orientation.
  24361. * @param orientation the orientation to value to attempt to get
  24362. * @returns the default orientation
  24363. * @hidden
  24364. */
  24365. static _GetDefaultSideOrientation(orientation?: number): number;
  24366. private _internalMeshDataInfo;
  24367. /**
  24368. * An event triggered before rendering the mesh
  24369. */
  24370. readonly onBeforeRenderObservable: Observable<Mesh>;
  24371. /**
  24372. * An event triggered before binding the mesh
  24373. */
  24374. readonly onBeforeBindObservable: Observable<Mesh>;
  24375. /**
  24376. * An event triggered after rendering the mesh
  24377. */
  24378. readonly onAfterRenderObservable: Observable<Mesh>;
  24379. /**
  24380. * An event triggered before drawing the mesh
  24381. */
  24382. readonly onBeforeDrawObservable: Observable<Mesh>;
  24383. private _onBeforeDrawObserver;
  24384. /**
  24385. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24386. */
  24387. onBeforeDraw: () => void;
  24388. readonly hasInstances: boolean;
  24389. /**
  24390. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24391. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24392. */
  24393. delayLoadState: number;
  24394. /**
  24395. * Gets the list of instances created from this mesh
  24396. * it is not supposed to be modified manually.
  24397. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24398. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24399. */
  24400. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24401. /**
  24402. * Gets the file containing delay loading data for this mesh
  24403. */
  24404. delayLoadingFile: string;
  24405. /** @hidden */
  24406. _binaryInfo: any;
  24407. /**
  24408. * User defined function used to change how LOD level selection is done
  24409. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24410. */
  24411. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24412. /**
  24413. * Gets or sets the morph target manager
  24414. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24415. */
  24416. morphTargetManager: Nullable<MorphTargetManager>;
  24417. /** @hidden */
  24418. _creationDataStorage: Nullable<_CreationDataStorage>;
  24419. /** @hidden */
  24420. _geometry: Nullable<Geometry>;
  24421. /** @hidden */
  24422. _delayInfo: Array<string>;
  24423. /** @hidden */
  24424. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24425. /** @hidden */
  24426. _instanceDataStorage: _InstanceDataStorage;
  24427. private _effectiveMaterial;
  24428. /** @hidden */
  24429. _shouldGenerateFlatShading: boolean;
  24430. /** @hidden */
  24431. _originalBuilderSideOrientation: number;
  24432. /**
  24433. * Use this property to change the original side orientation defined at construction time
  24434. */
  24435. overrideMaterialSideOrientation: Nullable<number>;
  24436. /**
  24437. * Gets the source mesh (the one used to clone this one from)
  24438. */
  24439. readonly source: Nullable<Mesh>;
  24440. /**
  24441. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24442. */
  24443. isUnIndexed: boolean;
  24444. /**
  24445. * @constructor
  24446. * @param name The value used by scene.getMeshByName() to do a lookup.
  24447. * @param scene The scene to add this mesh to.
  24448. * @param parent The parent of this mesh, if it has one
  24449. * @param source An optional Mesh from which geometry is shared, cloned.
  24450. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24451. * When false, achieved by calling a clone(), also passing False.
  24452. * This will make creation of children, recursive.
  24453. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24454. */
  24455. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24456. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24457. /**
  24458. * Gets the class name
  24459. * @returns the string "Mesh".
  24460. */
  24461. getClassName(): string;
  24462. /** @hidden */
  24463. readonly _isMesh: boolean;
  24464. /**
  24465. * Returns a description of this mesh
  24466. * @param fullDetails define if full details about this mesh must be used
  24467. * @returns a descriptive string representing this mesh
  24468. */
  24469. toString(fullDetails?: boolean): string;
  24470. /** @hidden */
  24471. _unBindEffect(): void;
  24472. /**
  24473. * Gets a boolean indicating if this mesh has LOD
  24474. */
  24475. readonly hasLODLevels: boolean;
  24476. /**
  24477. * Gets the list of MeshLODLevel associated with the current mesh
  24478. * @returns an array of MeshLODLevel
  24479. */
  24480. getLODLevels(): MeshLODLevel[];
  24481. private _sortLODLevels;
  24482. /**
  24483. * Add a mesh as LOD level triggered at the given distance.
  24484. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24485. * @param distance The distance from the center of the object to show this level
  24486. * @param mesh The mesh to be added as LOD level (can be null)
  24487. * @return This mesh (for chaining)
  24488. */
  24489. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24490. /**
  24491. * Returns the LOD level mesh at the passed distance or null if not found.
  24492. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24493. * @param distance The distance from the center of the object to show this level
  24494. * @returns a Mesh or `null`
  24495. */
  24496. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24497. /**
  24498. * Remove a mesh from the LOD array
  24499. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24500. * @param mesh defines the mesh to be removed
  24501. * @return This mesh (for chaining)
  24502. */
  24503. removeLODLevel(mesh: Mesh): Mesh;
  24504. /**
  24505. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24506. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24507. * @param camera defines the camera to use to compute distance
  24508. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24509. * @return This mesh (for chaining)
  24510. */
  24511. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24512. /**
  24513. * Gets the mesh internal Geometry object
  24514. */
  24515. readonly geometry: Nullable<Geometry>;
  24516. /**
  24517. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24518. * @returns the total number of vertices
  24519. */
  24520. getTotalVertices(): number;
  24521. /**
  24522. * Returns the content of an associated vertex buffer
  24523. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24524. * - VertexBuffer.PositionKind
  24525. * - VertexBuffer.UVKind
  24526. * - VertexBuffer.UV2Kind
  24527. * - VertexBuffer.UV3Kind
  24528. * - VertexBuffer.UV4Kind
  24529. * - VertexBuffer.UV5Kind
  24530. * - VertexBuffer.UV6Kind
  24531. * - VertexBuffer.ColorKind
  24532. * - VertexBuffer.MatricesIndicesKind
  24533. * - VertexBuffer.MatricesIndicesExtraKind
  24534. * - VertexBuffer.MatricesWeightsKind
  24535. * - VertexBuffer.MatricesWeightsExtraKind
  24536. * @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
  24537. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24538. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24539. */
  24540. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24541. /**
  24542. * Returns the mesh VertexBuffer object from the requested `kind`
  24543. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24544. * - VertexBuffer.PositionKind
  24545. * - VertexBuffer.NormalKind
  24546. * - VertexBuffer.UVKind
  24547. * - VertexBuffer.UV2Kind
  24548. * - VertexBuffer.UV3Kind
  24549. * - VertexBuffer.UV4Kind
  24550. * - VertexBuffer.UV5Kind
  24551. * - VertexBuffer.UV6Kind
  24552. * - VertexBuffer.ColorKind
  24553. * - VertexBuffer.MatricesIndicesKind
  24554. * - VertexBuffer.MatricesIndicesExtraKind
  24555. * - VertexBuffer.MatricesWeightsKind
  24556. * - VertexBuffer.MatricesWeightsExtraKind
  24557. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24558. */
  24559. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24560. /**
  24561. * Tests if a specific vertex buffer is associated with this mesh
  24562. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24563. * - VertexBuffer.PositionKind
  24564. * - VertexBuffer.NormalKind
  24565. * - VertexBuffer.UVKind
  24566. * - VertexBuffer.UV2Kind
  24567. * - VertexBuffer.UV3Kind
  24568. * - VertexBuffer.UV4Kind
  24569. * - VertexBuffer.UV5Kind
  24570. * - VertexBuffer.UV6Kind
  24571. * - VertexBuffer.ColorKind
  24572. * - VertexBuffer.MatricesIndicesKind
  24573. * - VertexBuffer.MatricesIndicesExtraKind
  24574. * - VertexBuffer.MatricesWeightsKind
  24575. * - VertexBuffer.MatricesWeightsExtraKind
  24576. * @returns a boolean
  24577. */
  24578. isVerticesDataPresent(kind: string): boolean;
  24579. /**
  24580. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24581. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24582. * - VertexBuffer.PositionKind
  24583. * - VertexBuffer.UVKind
  24584. * - VertexBuffer.UV2Kind
  24585. * - VertexBuffer.UV3Kind
  24586. * - VertexBuffer.UV4Kind
  24587. * - VertexBuffer.UV5Kind
  24588. * - VertexBuffer.UV6Kind
  24589. * - VertexBuffer.ColorKind
  24590. * - VertexBuffer.MatricesIndicesKind
  24591. * - VertexBuffer.MatricesIndicesExtraKind
  24592. * - VertexBuffer.MatricesWeightsKind
  24593. * - VertexBuffer.MatricesWeightsExtraKind
  24594. * @returns a boolean
  24595. */
  24596. isVertexBufferUpdatable(kind: string): boolean;
  24597. /**
  24598. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24599. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24600. * - VertexBuffer.PositionKind
  24601. * - VertexBuffer.NormalKind
  24602. * - VertexBuffer.UVKind
  24603. * - VertexBuffer.UV2Kind
  24604. * - VertexBuffer.UV3Kind
  24605. * - VertexBuffer.UV4Kind
  24606. * - VertexBuffer.UV5Kind
  24607. * - VertexBuffer.UV6Kind
  24608. * - VertexBuffer.ColorKind
  24609. * - VertexBuffer.MatricesIndicesKind
  24610. * - VertexBuffer.MatricesIndicesExtraKind
  24611. * - VertexBuffer.MatricesWeightsKind
  24612. * - VertexBuffer.MatricesWeightsExtraKind
  24613. * @returns an array of strings
  24614. */
  24615. getVerticesDataKinds(): string[];
  24616. /**
  24617. * Returns a positive integer : the total number of indices in this mesh geometry.
  24618. * @returns the numner of indices or zero if the mesh has no geometry.
  24619. */
  24620. getTotalIndices(): number;
  24621. /**
  24622. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24623. * @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.
  24624. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24625. * @returns the indices array or an empty array if the mesh has no geometry
  24626. */
  24627. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24628. readonly isBlocked: boolean;
  24629. /**
  24630. * Determine if the current mesh is ready to be rendered
  24631. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24632. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24633. * @returns true if all associated assets are ready (material, textures, shaders)
  24634. */
  24635. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24636. /**
  24637. * 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.
  24638. */
  24639. readonly areNormalsFrozen: boolean;
  24640. /**
  24641. * 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.
  24642. * @returns the current mesh
  24643. */
  24644. freezeNormals(): Mesh;
  24645. /**
  24646. * 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
  24647. * @returns the current mesh
  24648. */
  24649. unfreezeNormals(): Mesh;
  24650. /**
  24651. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24652. */
  24653. overridenInstanceCount: number;
  24654. /** @hidden */
  24655. _preActivate(): Mesh;
  24656. /** @hidden */
  24657. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24658. /** @hidden */
  24659. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24660. /**
  24661. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24662. * This means the mesh underlying bounding box and sphere are recomputed.
  24663. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24664. * @returns the current mesh
  24665. */
  24666. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24667. /** @hidden */
  24668. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24669. /**
  24670. * This function will subdivide the mesh into multiple submeshes
  24671. * @param count defines the expected number of submeshes
  24672. */
  24673. subdivide(count: number): void;
  24674. /**
  24675. * Copy a FloatArray into a specific associated vertex buffer
  24676. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24677. * - VertexBuffer.PositionKind
  24678. * - VertexBuffer.UVKind
  24679. * - VertexBuffer.UV2Kind
  24680. * - VertexBuffer.UV3Kind
  24681. * - VertexBuffer.UV4Kind
  24682. * - VertexBuffer.UV5Kind
  24683. * - VertexBuffer.UV6Kind
  24684. * - VertexBuffer.ColorKind
  24685. * - VertexBuffer.MatricesIndicesKind
  24686. * - VertexBuffer.MatricesIndicesExtraKind
  24687. * - VertexBuffer.MatricesWeightsKind
  24688. * - VertexBuffer.MatricesWeightsExtraKind
  24689. * @param data defines the data source
  24690. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24691. * @param stride defines the data stride size (can be null)
  24692. * @returns the current mesh
  24693. */
  24694. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24695. /**
  24696. * Delete a vertex buffer associated with this mesh
  24697. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24698. * - VertexBuffer.PositionKind
  24699. * - VertexBuffer.UVKind
  24700. * - VertexBuffer.UV2Kind
  24701. * - VertexBuffer.UV3Kind
  24702. * - VertexBuffer.UV4Kind
  24703. * - VertexBuffer.UV5Kind
  24704. * - VertexBuffer.UV6Kind
  24705. * - VertexBuffer.ColorKind
  24706. * - VertexBuffer.MatricesIndicesKind
  24707. * - VertexBuffer.MatricesIndicesExtraKind
  24708. * - VertexBuffer.MatricesWeightsKind
  24709. * - VertexBuffer.MatricesWeightsExtraKind
  24710. */
  24711. removeVerticesData(kind: string): void;
  24712. /**
  24713. * Flags an associated vertex buffer as updatable
  24714. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24715. * - VertexBuffer.PositionKind
  24716. * - VertexBuffer.UVKind
  24717. * - VertexBuffer.UV2Kind
  24718. * - VertexBuffer.UV3Kind
  24719. * - VertexBuffer.UV4Kind
  24720. * - VertexBuffer.UV5Kind
  24721. * - VertexBuffer.UV6Kind
  24722. * - VertexBuffer.ColorKind
  24723. * - VertexBuffer.MatricesIndicesKind
  24724. * - VertexBuffer.MatricesIndicesExtraKind
  24725. * - VertexBuffer.MatricesWeightsKind
  24726. * - VertexBuffer.MatricesWeightsExtraKind
  24727. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24728. */
  24729. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24730. /**
  24731. * Sets the mesh global Vertex Buffer
  24732. * @param buffer defines the buffer to use
  24733. * @returns the current mesh
  24734. */
  24735. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24736. /**
  24737. * Update a specific associated vertex buffer
  24738. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24739. * - VertexBuffer.PositionKind
  24740. * - VertexBuffer.UVKind
  24741. * - VertexBuffer.UV2Kind
  24742. * - VertexBuffer.UV3Kind
  24743. * - VertexBuffer.UV4Kind
  24744. * - VertexBuffer.UV5Kind
  24745. * - VertexBuffer.UV6Kind
  24746. * - VertexBuffer.ColorKind
  24747. * - VertexBuffer.MatricesIndicesKind
  24748. * - VertexBuffer.MatricesIndicesExtraKind
  24749. * - VertexBuffer.MatricesWeightsKind
  24750. * - VertexBuffer.MatricesWeightsExtraKind
  24751. * @param data defines the data source
  24752. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24753. * @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)
  24754. * @returns the current mesh
  24755. */
  24756. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24757. /**
  24758. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24759. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24760. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24761. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24762. * @returns the current mesh
  24763. */
  24764. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24765. /**
  24766. * Creates a un-shared specific occurence of the geometry for the mesh.
  24767. * @returns the current mesh
  24768. */
  24769. makeGeometryUnique(): Mesh;
  24770. /**
  24771. * Set the index buffer of this mesh
  24772. * @param indices defines the source data
  24773. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24774. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24775. * @returns the current mesh
  24776. */
  24777. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24778. /**
  24779. * Update the current index buffer
  24780. * @param indices defines the source data
  24781. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24782. * @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)
  24783. * @returns the current mesh
  24784. */
  24785. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24786. /**
  24787. * Invert the geometry to move from a right handed system to a left handed one.
  24788. * @returns the current mesh
  24789. */
  24790. toLeftHanded(): Mesh;
  24791. /** @hidden */
  24792. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24793. /** @hidden */
  24794. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24795. /**
  24796. * Registers for this mesh a javascript function called just before the rendering process
  24797. * @param func defines the function to call before rendering this mesh
  24798. * @returns the current mesh
  24799. */
  24800. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24801. /**
  24802. * Disposes a previously registered javascript function called before the rendering
  24803. * @param func defines the function to remove
  24804. * @returns the current mesh
  24805. */
  24806. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24807. /**
  24808. * Registers for this mesh a javascript function called just after the rendering is complete
  24809. * @param func defines the function to call after rendering this mesh
  24810. * @returns the current mesh
  24811. */
  24812. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24813. /**
  24814. * Disposes a previously registered javascript function called after the rendering.
  24815. * @param func defines the function to remove
  24816. * @returns the current mesh
  24817. */
  24818. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24819. /** @hidden */
  24820. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24821. /** @hidden */
  24822. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24823. /** @hidden */
  24824. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24825. /** @hidden */
  24826. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24827. /** @hidden */
  24828. _rebuild(): void;
  24829. /** @hidden */
  24830. _freeze(): void;
  24831. /** @hidden */
  24832. _unFreeze(): void;
  24833. /**
  24834. * 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
  24835. * @param subMesh defines the subMesh to render
  24836. * @param enableAlphaMode defines if alpha mode can be changed
  24837. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24838. * @returns the current mesh
  24839. */
  24840. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24841. private _onBeforeDraw;
  24842. /**
  24843. * Renormalize the mesh and patch it up if there are no weights
  24844. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24845. * However in the case of zero weights then we set just a single influence to 1.
  24846. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24847. */
  24848. cleanMatrixWeights(): void;
  24849. private normalizeSkinFourWeights;
  24850. private normalizeSkinWeightsAndExtra;
  24851. /**
  24852. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24853. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24854. * the user know there was an issue with importing the mesh
  24855. * @returns a validation object with skinned, valid and report string
  24856. */
  24857. validateSkinning(): {
  24858. skinned: boolean;
  24859. valid: boolean;
  24860. report: string;
  24861. };
  24862. /** @hidden */
  24863. _checkDelayState(): Mesh;
  24864. private _queueLoad;
  24865. /**
  24866. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24867. * A mesh is in the frustum if its bounding box intersects the frustum
  24868. * @param frustumPlanes defines the frustum to test
  24869. * @returns true if the mesh is in the frustum planes
  24870. */
  24871. isInFrustum(frustumPlanes: Plane[]): boolean;
  24872. /**
  24873. * Sets the mesh material by the material or multiMaterial `id` property
  24874. * @param id is a string identifying the material or the multiMaterial
  24875. * @returns the current mesh
  24876. */
  24877. setMaterialByID(id: string): Mesh;
  24878. /**
  24879. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24880. * @returns an array of IAnimatable
  24881. */
  24882. getAnimatables(): IAnimatable[];
  24883. /**
  24884. * Modifies the mesh geometry according to the passed transformation matrix.
  24885. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24886. * The mesh normals are modified using the same transformation.
  24887. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24888. * @param transform defines the transform matrix to use
  24889. * @see http://doc.babylonjs.com/resources/baking_transformations
  24890. * @returns the current mesh
  24891. */
  24892. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24893. /**
  24894. * Modifies the mesh geometry according to its own current World Matrix.
  24895. * The mesh World Matrix is then reset.
  24896. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24897. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24898. * @see http://doc.babylonjs.com/resources/baking_transformations
  24899. * @returns the current mesh
  24900. */
  24901. bakeCurrentTransformIntoVertices(): Mesh;
  24902. /** @hidden */
  24903. readonly _positions: Nullable<Vector3[]>;
  24904. /** @hidden */
  24905. _resetPointsArrayCache(): Mesh;
  24906. /** @hidden */
  24907. _generatePointsArray(): boolean;
  24908. /**
  24909. * Returns a new Mesh object generated from the current mesh properties.
  24910. * This method must not get confused with createInstance()
  24911. * @param name is a string, the name given to the new mesh
  24912. * @param newParent can be any Node object (default `null`)
  24913. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24914. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24915. * @returns a new mesh
  24916. */
  24917. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24918. /**
  24919. * Releases resources associated with this mesh.
  24920. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24921. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24922. */
  24923. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24924. /** @hidden */
  24925. _disposeInstanceSpecificData(): void;
  24926. /**
  24927. * Modifies the mesh geometry according to a displacement map.
  24928. * 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.
  24929. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24930. * @param url is a string, the URL from the image file is to be downloaded.
  24931. * @param minHeight is the lower limit of the displacement.
  24932. * @param maxHeight is the upper limit of the displacement.
  24933. * @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.
  24934. * @param uvOffset is an optional vector2 used to offset UV.
  24935. * @param uvScale is an optional vector2 used to scale UV.
  24936. * @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.
  24937. * @returns the Mesh.
  24938. */
  24939. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24940. /**
  24941. * Modifies the mesh geometry according to a displacementMap buffer.
  24942. * 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.
  24943. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24944. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24945. * @param heightMapWidth is the width of the buffer image.
  24946. * @param heightMapHeight is the height of the buffer image.
  24947. * @param minHeight is the lower limit of the displacement.
  24948. * @param maxHeight is the upper limit of the displacement.
  24949. * @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.
  24950. * @param uvOffset is an optional vector2 used to offset UV.
  24951. * @param uvScale is an optional vector2 used to scale UV.
  24952. * @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.
  24953. * @returns the Mesh.
  24954. */
  24955. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24956. /**
  24957. * Modify the mesh to get a flat shading rendering.
  24958. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24959. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24960. * @returns current mesh
  24961. */
  24962. convertToFlatShadedMesh(): Mesh;
  24963. /**
  24964. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24965. * In other words, more vertices, no more indices and a single bigger VBO.
  24966. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24967. * @returns current mesh
  24968. */
  24969. convertToUnIndexedMesh(): Mesh;
  24970. /**
  24971. * Inverses facet orientations.
  24972. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24973. * @param flipNormals will also inverts the normals
  24974. * @returns current mesh
  24975. */
  24976. flipFaces(flipNormals?: boolean): Mesh;
  24977. /**
  24978. * Increase the number of facets and hence vertices in a mesh
  24979. * Vertex normals are interpolated from existing vertex normals
  24980. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24981. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24982. */
  24983. increaseVertices(numberPerEdge: number): void;
  24984. /**
  24985. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24986. * This will undo any application of covertToFlatShadedMesh
  24987. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24988. */
  24989. forceSharedVertices(): void;
  24990. /** @hidden */
  24991. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24992. /** @hidden */
  24993. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24994. /**
  24995. * Creates a new InstancedMesh object from the mesh model.
  24996. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24997. * @param name defines the name of the new instance
  24998. * @returns a new InstancedMesh
  24999. */
  25000. createInstance(name: string): InstancedMesh;
  25001. /**
  25002. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25003. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25004. * @returns the current mesh
  25005. */
  25006. synchronizeInstances(): Mesh;
  25007. /**
  25008. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25009. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25010. * This should be used together with the simplification to avoid disappearing triangles.
  25011. * @param successCallback an optional success callback to be called after the optimization finished.
  25012. * @returns the current mesh
  25013. */
  25014. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25015. /**
  25016. * Serialize current mesh
  25017. * @param serializationObject defines the object which will receive the serialization data
  25018. */
  25019. serialize(serializationObject: any): void;
  25020. /** @hidden */
  25021. _syncGeometryWithMorphTargetManager(): void;
  25022. /** @hidden */
  25023. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25024. /**
  25025. * Returns a new Mesh object parsed from the source provided.
  25026. * @param parsedMesh is the source
  25027. * @param scene defines the hosting scene
  25028. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25029. * @returns a new Mesh
  25030. */
  25031. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25032. /**
  25033. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25034. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25035. * @param name defines the name of the mesh to create
  25036. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25037. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25038. * @param closePath creates a seam between the first and the last points of each path of the path array
  25039. * @param offset is taken in account only if the `pathArray` is containing a single path
  25040. * @param scene defines the hosting scene
  25041. * @param updatable defines if the mesh must be flagged as updatable
  25042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25043. * @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)
  25044. * @returns a new Mesh
  25045. */
  25046. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25047. /**
  25048. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25049. * @param name defines the name of the mesh to create
  25050. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25051. * @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
  25052. * @param scene defines the hosting scene
  25053. * @param updatable defines if the mesh must be flagged as updatable
  25054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25055. * @returns a new Mesh
  25056. */
  25057. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25058. /**
  25059. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25060. * @param name defines the name of the mesh to create
  25061. * @param size sets the size (float) of each box side (default 1)
  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 CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25068. /**
  25069. * Creates a sphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25072. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25073. * @param scene defines the hosting scene
  25074. * @param updatable defines if the mesh must be flagged as updatable
  25075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25076. * @returns a new Mesh
  25077. */
  25078. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25079. /**
  25080. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25081. * @param name defines the name of the mesh to create
  25082. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25083. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25084. * @param scene defines the hosting scene
  25085. * @returns a new Mesh
  25086. */
  25087. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25088. /**
  25089. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25090. * @param name defines the name of the mesh to create
  25091. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25092. * @param diameterTop set the top cap diameter (floats, default 1)
  25093. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25094. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25095. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25096. * @param scene defines the hosting scene
  25097. * @param updatable defines if the mesh must be flagged as updatable
  25098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25099. * @returns a new Mesh
  25100. */
  25101. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25102. /**
  25103. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25104. * @param name defines the name of the mesh to create
  25105. * @param diameter sets the diameter size (float) of the torus (default 1)
  25106. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25107. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25108. * @param scene defines the hosting scene
  25109. * @param updatable defines if the mesh must be flagged as updatable
  25110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25111. * @returns a new Mesh
  25112. */
  25113. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25114. /**
  25115. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25116. * @param name defines the name of the mesh to create
  25117. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25118. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25119. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25120. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25121. * @param p the number of windings on X axis (positive integers, default 2)
  25122. * @param q the number of windings on Y axis (positive integers, default 3)
  25123. * @param scene defines the hosting scene
  25124. * @param updatable defines if the mesh must be flagged as updatable
  25125. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25126. * @returns a new Mesh
  25127. */
  25128. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25129. /**
  25130. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25131. * @param name defines the name of the mesh to create
  25132. * @param points is an array successive Vector3
  25133. * @param scene defines the hosting scene
  25134. * @param updatable defines if the mesh must be flagged as updatable
  25135. * @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).
  25136. * @returns a new Mesh
  25137. */
  25138. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25139. /**
  25140. * Creates a dashed 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 dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25144. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25145. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25146. * @param scene defines the hosting scene
  25147. * @param updatable defines if the mesh must be flagged as updatable
  25148. * @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)
  25149. * @returns a new Mesh
  25150. */
  25151. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25152. /**
  25153. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25154. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25155. * 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.
  25156. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25157. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25158. * Remember you can only change the shape positions, not their number when updating a polygon.
  25159. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25160. * @param name defines the name of the mesh to create
  25161. * @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
  25162. * @param scene defines the hosting scene
  25163. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25164. * @param updatable defines if the mesh must be flagged as updatable
  25165. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25166. * @param earcutInjection can be used to inject your own earcut reference
  25167. * @returns a new Mesh
  25168. */
  25169. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25170. /**
  25171. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25172. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25173. * @param name defines the name of the mesh to create
  25174. * @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
  25175. * @param depth defines the height of extrusion
  25176. * @param scene defines the hosting scene
  25177. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25178. * @param updatable defines if the mesh must be flagged as updatable
  25179. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25180. * @param earcutInjection can be used to inject your own earcut reference
  25181. * @returns a new Mesh
  25182. */
  25183. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25184. /**
  25185. * Creates an extruded shape mesh.
  25186. * 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
  25187. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25188. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25189. * @param name defines the name of the mesh to create
  25190. * @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
  25191. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25192. * @param scale is the value to scale the shape
  25193. * @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
  25194. * @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
  25195. * @param scene defines the hosting scene
  25196. * @param updatable defines if the mesh must be flagged as updatable
  25197. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25198. * @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)
  25199. * @returns a new Mesh
  25200. */
  25201. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25202. /**
  25203. * Creates an custom extruded shape mesh.
  25204. * The custom extrusion is a parametric shape.
  25205. * It has no predefined shape. Its final shape will depend on the input parameters.
  25206. * Please consider using the same method from the MeshBuilder class instead
  25207. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25208. * @param name defines the name of the mesh to create
  25209. * @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
  25210. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25211. * @param scaleFunction is a custom Javascript function called on each path point
  25212. * @param rotationFunction is a custom Javascript function called on each path point
  25213. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25214. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25215. * @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
  25216. * @param scene defines the hosting scene
  25217. * @param updatable defines if the mesh must be flagged as updatable
  25218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25219. * @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)
  25220. * @returns a new Mesh
  25221. */
  25222. 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;
  25223. /**
  25224. * Creates lathe mesh.
  25225. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25226. * Please consider using the same method from the MeshBuilder class instead
  25227. * @param name defines the name of the mesh to create
  25228. * @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
  25229. * @param radius is the radius value of the lathe
  25230. * @param tessellation is the side number of the lathe.
  25231. * @param scene defines the hosting scene
  25232. * @param updatable defines if the mesh must be flagged as updatable
  25233. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25234. * @returns a new Mesh
  25235. */
  25236. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25237. /**
  25238. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25239. * @param name defines the name of the mesh to create
  25240. * @param size sets the size (float) of both sides of the plane at once (default 1)
  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 CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25247. /**
  25248. * Creates a ground mesh.
  25249. * Please consider using the same method from the MeshBuilder class instead
  25250. * @param name defines the name of the mesh to create
  25251. * @param width set the width of the ground
  25252. * @param height set the height of the ground
  25253. * @param subdivisions sets the number of subdivisions per side
  25254. * @param scene defines the hosting scene
  25255. * @param updatable defines if the mesh must be flagged as updatable
  25256. * @returns a new Mesh
  25257. */
  25258. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25259. /**
  25260. * Creates a tiled ground mesh.
  25261. * Please consider using the same method from the MeshBuilder class instead
  25262. * @param name defines the name of the mesh to create
  25263. * @param xmin set the ground minimum X coordinate
  25264. * @param zmin set the ground minimum Y coordinate
  25265. * @param xmax set the ground maximum X coordinate
  25266. * @param zmax set the ground maximum Z coordinate
  25267. * @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
  25268. * @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
  25269. * @param scene defines the hosting scene
  25270. * @param updatable defines if the mesh must be flagged as updatable
  25271. * @returns a new Mesh
  25272. */
  25273. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25274. w: number;
  25275. h: number;
  25276. }, precision: {
  25277. w: number;
  25278. h: number;
  25279. }, scene: Scene, updatable?: boolean): Mesh;
  25280. /**
  25281. * Creates a ground mesh from a height map.
  25282. * Please consider using the same method from the MeshBuilder class instead
  25283. * @see http://doc.babylonjs.com/babylon101/height_map
  25284. * @param name defines the name of the mesh to create
  25285. * @param url sets the URL of the height map image resource
  25286. * @param width set the ground width size
  25287. * @param height set the ground height size
  25288. * @param subdivisions sets the number of subdivision per side
  25289. * @param minHeight is the minimum altitude on the ground
  25290. * @param maxHeight is the maximum altitude on the ground
  25291. * @param scene defines the hosting scene
  25292. * @param updatable defines if the mesh must be flagged as updatable
  25293. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25294. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25295. * @returns a new Mesh
  25296. */
  25297. 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;
  25298. /**
  25299. * Creates a tube mesh.
  25300. * The tube is a parametric shape.
  25301. * It has no predefined shape. Its final shape will depend on the input parameters.
  25302. * Please consider using the same method from the MeshBuilder class instead
  25303. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25304. * @param name defines the name of the mesh to create
  25305. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25306. * @param radius sets the tube radius size
  25307. * @param tessellation is the number of sides on the tubular surface
  25308. * @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
  25309. * @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
  25310. * @param scene defines the hosting scene
  25311. * @param updatable defines if the mesh must be flagged as updatable
  25312. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25313. * @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)
  25314. * @returns a new Mesh
  25315. */
  25316. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25317. (i: number, distance: number): number;
  25318. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25319. /**
  25320. * Creates a polyhedron mesh.
  25321. * Please consider using the same method from the MeshBuilder class instead.
  25322. * * 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
  25323. * * The parameter `size` (positive float, default 1) sets the polygon size
  25324. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25325. * * 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`
  25326. * * 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
  25327. * * 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)`)
  25328. * * 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
  25329. * * 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
  25330. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25331. * * If you create a double-sided mesh, you can choose what parts of 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
  25332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25333. * @param name defines the name of the mesh to create
  25334. * @param options defines the options used to create the mesh
  25335. * @param scene defines the hosting scene
  25336. * @returns a new Mesh
  25337. */
  25338. static CreatePolyhedron(name: string, options: {
  25339. type?: number;
  25340. size?: number;
  25341. sizeX?: number;
  25342. sizeY?: number;
  25343. sizeZ?: number;
  25344. custom?: any;
  25345. faceUV?: Vector4[];
  25346. faceColors?: Color4[];
  25347. updatable?: boolean;
  25348. sideOrientation?: number;
  25349. }, scene: Scene): Mesh;
  25350. /**
  25351. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25352. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25353. * * 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`)
  25354. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25355. * * 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
  25356. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25357. * * If you create a double-sided mesh, you can choose what parts of 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
  25358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25359. * @param name defines the name of the mesh
  25360. * @param options defines the options used to create the mesh
  25361. * @param scene defines the hosting scene
  25362. * @returns a new Mesh
  25363. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25364. */
  25365. static CreateIcoSphere(name: string, options: {
  25366. radius?: number;
  25367. flat?: boolean;
  25368. subdivisions?: number;
  25369. sideOrientation?: number;
  25370. updatable?: boolean;
  25371. }, scene: Scene): Mesh;
  25372. /**
  25373. * Creates a decal mesh.
  25374. * Please consider using the same method from the MeshBuilder class instead.
  25375. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25376. * @param name defines the name of the mesh
  25377. * @param sourceMesh defines the mesh receiving the decal
  25378. * @param position sets the position of the decal in world coordinates
  25379. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25380. * @param size sets the decal scaling
  25381. * @param angle sets the angle to rotate the decal
  25382. * @returns a new Mesh
  25383. */
  25384. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25385. /**
  25386. * Prepare internal position array for software CPU skinning
  25387. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25388. */
  25389. setPositionsForCPUSkinning(): Float32Array;
  25390. /**
  25391. * Prepare internal normal array for software CPU skinning
  25392. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25393. */
  25394. setNormalsForCPUSkinning(): Float32Array;
  25395. /**
  25396. * Updates the vertex buffer by applying transformation from the bones
  25397. * @param skeleton defines the skeleton to apply to current mesh
  25398. * @returns the current mesh
  25399. */
  25400. applySkeleton(skeleton: Skeleton): Mesh;
  25401. /**
  25402. * 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
  25403. * @param meshes defines the list of meshes to scan
  25404. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25405. */
  25406. static MinMax(meshes: AbstractMesh[]): {
  25407. min: Vector3;
  25408. max: Vector3;
  25409. };
  25410. /**
  25411. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25412. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25413. * @returns a vector3
  25414. */
  25415. static Center(meshesOrMinMaxVector: {
  25416. min: Vector3;
  25417. max: Vector3;
  25418. } | AbstractMesh[]): Vector3;
  25419. /**
  25420. * Merge the array of meshes into a single mesh for performance reasons.
  25421. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25422. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25423. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25424. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25425. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25426. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25427. * @returns a new mesh
  25428. */
  25429. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25430. /** @hidden */
  25431. addInstance(instance: InstancedMesh): void;
  25432. /** @hidden */
  25433. removeInstance(instance: InstancedMesh): void;
  25434. }
  25435. }
  25436. declare module "babylonjs/Cameras/camera" {
  25437. import { SmartArray } from "babylonjs/Misc/smartArray";
  25438. import { Observable } from "babylonjs/Misc/observable";
  25439. import { Nullable } from "babylonjs/types";
  25440. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25441. import { Scene } from "babylonjs/scene";
  25442. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25443. import { Node } from "babylonjs/node";
  25444. import { Mesh } from "babylonjs/Meshes/mesh";
  25445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25446. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25447. import { Viewport } from "babylonjs/Maths/math.viewport";
  25448. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25449. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25450. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25451. import { Ray } from "babylonjs/Culling/ray";
  25452. /**
  25453. * This is the base class of all the camera used in the application.
  25454. * @see http://doc.babylonjs.com/features/cameras
  25455. */
  25456. export class Camera extends Node {
  25457. /** @hidden */
  25458. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25459. /**
  25460. * This is the default projection mode used by the cameras.
  25461. * It helps recreating a feeling of perspective and better appreciate depth.
  25462. * This is the best way to simulate real life cameras.
  25463. */
  25464. static readonly PERSPECTIVE_CAMERA: number;
  25465. /**
  25466. * This helps creating camera with an orthographic mode.
  25467. * 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.
  25468. */
  25469. static readonly ORTHOGRAPHIC_CAMERA: number;
  25470. /**
  25471. * This is the default FOV mode for perspective cameras.
  25472. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25473. */
  25474. static readonly FOVMODE_VERTICAL_FIXED: number;
  25475. /**
  25476. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25477. */
  25478. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25479. /**
  25480. * This specifies ther is no need for a camera rig.
  25481. * Basically only one eye is rendered corresponding to the camera.
  25482. */
  25483. static readonly RIG_MODE_NONE: number;
  25484. /**
  25485. * Simulates a camera Rig with one blue eye and one red eye.
  25486. * This can be use with 3d blue and red glasses.
  25487. */
  25488. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25489. /**
  25490. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25491. */
  25492. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25493. /**
  25494. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25495. */
  25496. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25497. /**
  25498. * Defines that both eyes of the camera will be rendered over under each other.
  25499. */
  25500. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25501. /**
  25502. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25503. */
  25504. static readonly RIG_MODE_VR: number;
  25505. /**
  25506. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25507. */
  25508. static readonly RIG_MODE_WEBVR: number;
  25509. /**
  25510. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25511. */
  25512. static readonly RIG_MODE_CUSTOM: number;
  25513. /**
  25514. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25515. */
  25516. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25517. /**
  25518. * Define the input manager associated with the camera.
  25519. */
  25520. inputs: CameraInputsManager<Camera>;
  25521. /** @hidden */
  25522. _position: Vector3;
  25523. /**
  25524. * Define the current local position of the camera in the scene
  25525. */
  25526. position: Vector3;
  25527. /**
  25528. * The vector the camera should consider as up.
  25529. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25530. */
  25531. upVector: Vector3;
  25532. /**
  25533. * Define the current limit on the left side for an orthographic camera
  25534. * In scene unit
  25535. */
  25536. orthoLeft: Nullable<number>;
  25537. /**
  25538. * Define the current limit on the right side for an orthographic camera
  25539. * In scene unit
  25540. */
  25541. orthoRight: Nullable<number>;
  25542. /**
  25543. * Define the current limit on the bottom side for an orthographic camera
  25544. * In scene unit
  25545. */
  25546. orthoBottom: Nullable<number>;
  25547. /**
  25548. * Define the current limit on the top side for an orthographic camera
  25549. * In scene unit
  25550. */
  25551. orthoTop: Nullable<number>;
  25552. /**
  25553. * Field Of View is set in Radians. (default is 0.8)
  25554. */
  25555. fov: number;
  25556. /**
  25557. * Define the minimum distance the camera can see from.
  25558. * This is important to note that the depth buffer are not infinite and the closer it starts
  25559. * the more your scene might encounter depth fighting issue.
  25560. */
  25561. minZ: number;
  25562. /**
  25563. * Define the maximum distance the camera can see to.
  25564. * This is important to note that the depth buffer are not infinite and the further it end
  25565. * the more your scene might encounter depth fighting issue.
  25566. */
  25567. maxZ: number;
  25568. /**
  25569. * Define the default inertia of the camera.
  25570. * This helps giving a smooth feeling to the camera movement.
  25571. */
  25572. inertia: number;
  25573. /**
  25574. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25575. */
  25576. mode: number;
  25577. /**
  25578. * Define wether the camera is intermediate.
  25579. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25580. */
  25581. isIntermediate: boolean;
  25582. /**
  25583. * Define the viewport of the camera.
  25584. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25585. */
  25586. viewport: Viewport;
  25587. /**
  25588. * Restricts the camera to viewing objects with the same layerMask.
  25589. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25590. */
  25591. layerMask: number;
  25592. /**
  25593. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25594. */
  25595. fovMode: number;
  25596. /**
  25597. * Rig mode of the camera.
  25598. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25599. * This is normally controlled byt the camera themselves as internal use.
  25600. */
  25601. cameraRigMode: number;
  25602. /**
  25603. * Defines the distance between both "eyes" in case of a RIG
  25604. */
  25605. interaxialDistance: number;
  25606. /**
  25607. * Defines if stereoscopic rendering is done side by side or over under.
  25608. */
  25609. isStereoscopicSideBySide: boolean;
  25610. /**
  25611. * 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
  25612. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25613. * else in the scene. (Eg. security camera)
  25614. *
  25615. * 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)
  25616. */
  25617. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25618. /**
  25619. * When set, the camera will render to this render target instead of the default canvas
  25620. *
  25621. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25622. */
  25623. outputRenderTarget: Nullable<RenderTargetTexture>;
  25624. /**
  25625. * Observable triggered when the camera view matrix has changed.
  25626. */
  25627. onViewMatrixChangedObservable: Observable<Camera>;
  25628. /**
  25629. * Observable triggered when the camera Projection matrix has changed.
  25630. */
  25631. onProjectionMatrixChangedObservable: Observable<Camera>;
  25632. /**
  25633. * Observable triggered when the inputs have been processed.
  25634. */
  25635. onAfterCheckInputsObservable: Observable<Camera>;
  25636. /**
  25637. * Observable triggered when reset has been called and applied to the camera.
  25638. */
  25639. onRestoreStateObservable: Observable<Camera>;
  25640. /** @hidden */
  25641. _cameraRigParams: any;
  25642. /** @hidden */
  25643. _rigCameras: Camera[];
  25644. /** @hidden */
  25645. _rigPostProcess: Nullable<PostProcess>;
  25646. protected _webvrViewMatrix: Matrix;
  25647. /** @hidden */
  25648. _skipRendering: boolean;
  25649. /** @hidden */
  25650. _projectionMatrix: Matrix;
  25651. /** @hidden */
  25652. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25653. /** @hidden */
  25654. _activeMeshes: SmartArray<AbstractMesh>;
  25655. protected _globalPosition: Vector3;
  25656. /** @hidden */
  25657. _computedViewMatrix: Matrix;
  25658. private _doNotComputeProjectionMatrix;
  25659. private _transformMatrix;
  25660. private _frustumPlanes;
  25661. private _refreshFrustumPlanes;
  25662. private _storedFov;
  25663. private _stateStored;
  25664. /**
  25665. * Instantiates a new camera object.
  25666. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25667. * @see http://doc.babylonjs.com/features/cameras
  25668. * @param name Defines the name of the camera in the scene
  25669. * @param position Defines the position of the camera
  25670. * @param scene Defines the scene the camera belongs too
  25671. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25672. */
  25673. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25674. /**
  25675. * Store current camera state (fov, position, etc..)
  25676. * @returns the camera
  25677. */
  25678. storeState(): Camera;
  25679. /**
  25680. * Restores the camera state values if it has been stored. You must call storeState() first
  25681. */
  25682. protected _restoreStateValues(): boolean;
  25683. /**
  25684. * Restored camera state. You must call storeState() first.
  25685. * @returns true if restored and false otherwise
  25686. */
  25687. restoreState(): boolean;
  25688. /**
  25689. * Gets the class name of the camera.
  25690. * @returns the class name
  25691. */
  25692. getClassName(): string;
  25693. /** @hidden */
  25694. readonly _isCamera: boolean;
  25695. /**
  25696. * Gets a string representation of the camera useful for debug purpose.
  25697. * @param fullDetails Defines that a more verboe level of logging is required
  25698. * @returns the string representation
  25699. */
  25700. toString(fullDetails?: boolean): string;
  25701. /**
  25702. * Gets the current world space position of the camera.
  25703. */
  25704. readonly globalPosition: Vector3;
  25705. /**
  25706. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25707. * @returns the active meshe list
  25708. */
  25709. getActiveMeshes(): SmartArray<AbstractMesh>;
  25710. /**
  25711. * Check wether a mesh is part of the current active mesh list of the camera
  25712. * @param mesh Defines the mesh to check
  25713. * @returns true if active, false otherwise
  25714. */
  25715. isActiveMesh(mesh: Mesh): boolean;
  25716. /**
  25717. * Is this camera ready to be used/rendered
  25718. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25719. * @return true if the camera is ready
  25720. */
  25721. isReady(completeCheck?: boolean): boolean;
  25722. /** @hidden */
  25723. _initCache(): void;
  25724. /** @hidden */
  25725. _updateCache(ignoreParentClass?: boolean): void;
  25726. /** @hidden */
  25727. _isSynchronized(): boolean;
  25728. /** @hidden */
  25729. _isSynchronizedViewMatrix(): boolean;
  25730. /** @hidden */
  25731. _isSynchronizedProjectionMatrix(): boolean;
  25732. /**
  25733. * Attach the input controls to a specific dom element to get the input from.
  25734. * @param element Defines the element the controls should be listened from
  25735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25736. */
  25737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25738. /**
  25739. * Detach the current controls from the specified dom element.
  25740. * @param element Defines the element to stop listening the inputs from
  25741. */
  25742. detachControl(element: HTMLElement): void;
  25743. /**
  25744. * Update the camera state according to the different inputs gathered during the frame.
  25745. */
  25746. update(): void;
  25747. /** @hidden */
  25748. _checkInputs(): void;
  25749. /** @hidden */
  25750. readonly rigCameras: Camera[];
  25751. /**
  25752. * Gets the post process used by the rig cameras
  25753. */
  25754. readonly rigPostProcess: Nullable<PostProcess>;
  25755. /**
  25756. * Internal, gets the first post proces.
  25757. * @returns the first post process to be run on this camera.
  25758. */
  25759. _getFirstPostProcess(): Nullable<PostProcess>;
  25760. private _cascadePostProcessesToRigCams;
  25761. /**
  25762. * Attach a post process to the camera.
  25763. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25764. * @param postProcess The post process to attach to the camera
  25765. * @param insertAt The position of the post process in case several of them are in use in the scene
  25766. * @returns the position the post process has been inserted at
  25767. */
  25768. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25769. /**
  25770. * Detach a post process to the camera.
  25771. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25772. * @param postProcess The post process to detach from the camera
  25773. */
  25774. detachPostProcess(postProcess: PostProcess): void;
  25775. /**
  25776. * Gets the current world matrix of the camera
  25777. */
  25778. getWorldMatrix(): Matrix;
  25779. /** @hidden */
  25780. _getViewMatrix(): Matrix;
  25781. /**
  25782. * Gets the current view matrix of the camera.
  25783. * @param force forces the camera to recompute the matrix without looking at the cached state
  25784. * @returns the view matrix
  25785. */
  25786. getViewMatrix(force?: boolean): Matrix;
  25787. /**
  25788. * Freeze the projection matrix.
  25789. * It will prevent the cache check of the camera projection compute and can speed up perf
  25790. * if no parameter of the camera are meant to change
  25791. * @param projection Defines manually a projection if necessary
  25792. */
  25793. freezeProjectionMatrix(projection?: Matrix): void;
  25794. /**
  25795. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25796. */
  25797. unfreezeProjectionMatrix(): void;
  25798. /**
  25799. * Gets the current projection matrix of the camera.
  25800. * @param force forces the camera to recompute the matrix without looking at the cached state
  25801. * @returns the projection matrix
  25802. */
  25803. getProjectionMatrix(force?: boolean): Matrix;
  25804. /**
  25805. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25806. * @returns a Matrix
  25807. */
  25808. getTransformationMatrix(): Matrix;
  25809. private _updateFrustumPlanes;
  25810. /**
  25811. * Checks if a cullable object (mesh...) is in the camera frustum
  25812. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25813. * @param target The object to check
  25814. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25815. * @returns true if the object is in frustum otherwise false
  25816. */
  25817. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25818. /**
  25819. * Checks if a cullable object (mesh...) is in the camera frustum
  25820. * Unlike isInFrustum this cheks the full bounding box
  25821. * @param target The object to check
  25822. * @returns true if the object is in frustum otherwise false
  25823. */
  25824. isCompletelyInFrustum(target: ICullable): boolean;
  25825. /**
  25826. * Gets a ray in the forward direction from the camera.
  25827. * @param length Defines the length of the ray to create
  25828. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25829. * @param origin Defines the start point of the ray which defaults to the camera position
  25830. * @returns the forward ray
  25831. */
  25832. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25833. /**
  25834. * Releases resources associated with this node.
  25835. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25836. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25837. */
  25838. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25839. /** @hidden */
  25840. _isLeftCamera: boolean;
  25841. /**
  25842. * Gets the left camera of a rig setup in case of Rigged Camera
  25843. */
  25844. readonly isLeftCamera: boolean;
  25845. /** @hidden */
  25846. _isRightCamera: boolean;
  25847. /**
  25848. * Gets the right camera of a rig setup in case of Rigged Camera
  25849. */
  25850. readonly isRightCamera: boolean;
  25851. /**
  25852. * Gets the left camera of a rig setup in case of Rigged Camera
  25853. */
  25854. readonly leftCamera: Nullable<FreeCamera>;
  25855. /**
  25856. * Gets the right camera of a rig setup in case of Rigged Camera
  25857. */
  25858. readonly rightCamera: Nullable<FreeCamera>;
  25859. /**
  25860. * Gets the left camera target of a rig setup in case of Rigged Camera
  25861. * @returns the target position
  25862. */
  25863. getLeftTarget(): Nullable<Vector3>;
  25864. /**
  25865. * Gets the right camera target of a rig setup in case of Rigged Camera
  25866. * @returns the target position
  25867. */
  25868. getRightTarget(): Nullable<Vector3>;
  25869. /**
  25870. * @hidden
  25871. */
  25872. setCameraRigMode(mode: number, rigParams: any): void;
  25873. /** @hidden */
  25874. static _setStereoscopicRigMode(camera: Camera): void;
  25875. /** @hidden */
  25876. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25877. /** @hidden */
  25878. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25879. /** @hidden */
  25880. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25881. /** @hidden */
  25882. _getVRProjectionMatrix(): Matrix;
  25883. protected _updateCameraRotationMatrix(): void;
  25884. protected _updateWebVRCameraRotationMatrix(): void;
  25885. /**
  25886. * This function MUST be overwritten by the different WebVR cameras available.
  25887. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25888. * @hidden
  25889. */
  25890. _getWebVRProjectionMatrix(): Matrix;
  25891. /**
  25892. * This function MUST be overwritten by the different WebVR cameras available.
  25893. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25894. * @hidden
  25895. */
  25896. _getWebVRViewMatrix(): Matrix;
  25897. /** @hidden */
  25898. setCameraRigParameter(name: string, value: any): void;
  25899. /**
  25900. * needs to be overridden by children so sub has required properties to be copied
  25901. * @hidden
  25902. */
  25903. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25904. /**
  25905. * May need to be overridden by children
  25906. * @hidden
  25907. */
  25908. _updateRigCameras(): void;
  25909. /** @hidden */
  25910. _setupInputs(): void;
  25911. /**
  25912. * Serialiaze the camera setup to a json represention
  25913. * @returns the JSON representation
  25914. */
  25915. serialize(): any;
  25916. /**
  25917. * Clones the current camera.
  25918. * @param name The cloned camera name
  25919. * @returns the cloned camera
  25920. */
  25921. clone(name: string): Camera;
  25922. /**
  25923. * Gets the direction of the camera relative to a given local axis.
  25924. * @param localAxis Defines the reference axis to provide a relative direction.
  25925. * @return the direction
  25926. */
  25927. getDirection(localAxis: Vector3): Vector3;
  25928. /**
  25929. * Returns the current camera absolute rotation
  25930. */
  25931. readonly absoluteRotation: Quaternion;
  25932. /**
  25933. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25934. * @param localAxis Defines the reference axis to provide a relative direction.
  25935. * @param result Defines the vector to store the result in
  25936. */
  25937. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25938. /**
  25939. * Gets a camera constructor for a given camera type
  25940. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25941. * @param name The name of the camera the result will be able to instantiate
  25942. * @param scene The scene the result will construct the camera in
  25943. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25944. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25945. * @returns a factory method to construc the camera
  25946. */
  25947. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25948. /**
  25949. * Compute the world matrix of the camera.
  25950. * @returns the camera workd matrix
  25951. */
  25952. computeWorldMatrix(): Matrix;
  25953. /**
  25954. * Parse a JSON and creates the camera from the parsed information
  25955. * @param parsedCamera The JSON to parse
  25956. * @param scene The scene to instantiate the camera in
  25957. * @returns the newly constructed camera
  25958. */
  25959. static Parse(parsedCamera: any, scene: Scene): Camera;
  25960. }
  25961. }
  25962. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25963. import { Nullable } from "babylonjs/types";
  25964. import { Scene } from "babylonjs/scene";
  25965. import { Vector4 } from "babylonjs/Maths/math.vector";
  25966. import { Mesh } from "babylonjs/Meshes/mesh";
  25967. /**
  25968. * Class containing static functions to help procedurally build meshes
  25969. */
  25970. export class DiscBuilder {
  25971. /**
  25972. * Creates a plane polygonal mesh. By default, this is a disc
  25973. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25974. * * 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
  25975. * * 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
  25976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25979. * @param name defines the name of the mesh
  25980. * @param options defines the options used to create the mesh
  25981. * @param scene defines the hosting scene
  25982. * @returns the plane polygonal mesh
  25983. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25984. */
  25985. static CreateDisc(name: string, options: {
  25986. radius?: number;
  25987. tessellation?: number;
  25988. arc?: number;
  25989. updatable?: boolean;
  25990. sideOrientation?: number;
  25991. frontUVs?: Vector4;
  25992. backUVs?: Vector4;
  25993. }, scene?: Nullable<Scene>): Mesh;
  25994. }
  25995. }
  25996. declare module "babylonjs/Particles/solidParticleSystem" {
  25997. import { Vector3 } from "babylonjs/Maths/math.vector";
  25998. import { Mesh } from "babylonjs/Meshes/mesh";
  25999. import { Scene, IDisposable } from "babylonjs/scene";
  26000. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26001. /**
  26002. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26003. *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.
  26004. * The SPS is also a particle system. It provides some methods to manage the particles.
  26005. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26006. *
  26007. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26008. */
  26009. export class SolidParticleSystem implements IDisposable {
  26010. /**
  26011. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26012. * Example : var p = SPS.particles[i];
  26013. */
  26014. particles: SolidParticle[];
  26015. /**
  26016. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26017. */
  26018. nbParticles: number;
  26019. /**
  26020. * If the particles must ever face the camera (default false). Useful for planar particles.
  26021. */
  26022. billboard: boolean;
  26023. /**
  26024. * Recompute normals when adding a shape
  26025. */
  26026. recomputeNormals: boolean;
  26027. /**
  26028. * This a counter ofr your own usage. It's not set by any SPS functions.
  26029. */
  26030. counter: number;
  26031. /**
  26032. * The SPS name. This name is also given to the underlying mesh.
  26033. */
  26034. name: string;
  26035. /**
  26036. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26037. */
  26038. mesh: Mesh;
  26039. /**
  26040. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26041. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26042. */
  26043. vars: any;
  26044. /**
  26045. * This array is populated when the SPS is set as 'pickable'.
  26046. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26047. * Each element of this array is an object `{idx: int, faceId: int}`.
  26048. * `idx` is the picked particle index in the `SPS.particles` array
  26049. * `faceId` is the picked face index counted within this particle.
  26050. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26051. */
  26052. pickedParticles: {
  26053. idx: number;
  26054. faceId: number;
  26055. }[];
  26056. /**
  26057. * This array is populated when `enableDepthSort` is set to true.
  26058. * Each element of this array is an instance of the class DepthSortedParticle.
  26059. */
  26060. depthSortedParticles: DepthSortedParticle[];
  26061. /**
  26062. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26063. * @hidden
  26064. */
  26065. _bSphereOnly: boolean;
  26066. /**
  26067. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26068. * @hidden
  26069. */
  26070. _bSphereRadiusFactor: number;
  26071. private _scene;
  26072. private _positions;
  26073. private _indices;
  26074. private _normals;
  26075. private _colors;
  26076. private _uvs;
  26077. private _indices32;
  26078. private _positions32;
  26079. private _normals32;
  26080. private _fixedNormal32;
  26081. private _colors32;
  26082. private _uvs32;
  26083. private _index;
  26084. private _updatable;
  26085. private _pickable;
  26086. private _isVisibilityBoxLocked;
  26087. private _alwaysVisible;
  26088. private _depthSort;
  26089. private _expandable;
  26090. private _shapeCounter;
  26091. private _copy;
  26092. private _color;
  26093. private _computeParticleColor;
  26094. private _computeParticleTexture;
  26095. private _computeParticleRotation;
  26096. private _computeParticleVertex;
  26097. private _computeBoundingBox;
  26098. private _depthSortParticles;
  26099. private _camera;
  26100. private _mustUnrotateFixedNormals;
  26101. private _particlesIntersect;
  26102. private _needs32Bits;
  26103. private _isNotBuilt;
  26104. /**
  26105. * Creates a SPS (Solid Particle System) object.
  26106. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26107. * @param scene (Scene) is the scene in which the SPS is added.
  26108. * @param options defines the options of the sps e.g.
  26109. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26110. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26111. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26112. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26113. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26114. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26115. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26116. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26117. */
  26118. constructor(name: string, scene: Scene, options?: {
  26119. updatable?: boolean;
  26120. isPickable?: boolean;
  26121. enableDepthSort?: boolean;
  26122. particleIntersection?: boolean;
  26123. boundingSphereOnly?: boolean;
  26124. bSphereRadiusFactor?: number;
  26125. expandable?: boolean;
  26126. });
  26127. /**
  26128. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26129. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26130. * @returns the created mesh
  26131. */
  26132. buildMesh(): Mesh;
  26133. /**
  26134. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26135. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26136. * Thus the particles generated from `digest()` have their property `position` set yet.
  26137. * @param mesh ( Mesh ) is the mesh to be digested
  26138. * @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
  26139. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26140. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26141. * @returns the current SPS
  26142. */
  26143. digest(mesh: Mesh, options?: {
  26144. facetNb?: number;
  26145. number?: number;
  26146. delta?: number;
  26147. }): SolidParticleSystem;
  26148. private _unrotateFixedNormals;
  26149. private _resetCopy;
  26150. private _meshBuilder;
  26151. private _posToShape;
  26152. private _uvsToShapeUV;
  26153. private _addParticle;
  26154. /**
  26155. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26156. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26157. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26158. * @param nb (positive integer) the number of particles to be created from this model
  26159. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26160. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26161. * @returns the number of shapes in the system
  26162. */
  26163. addShape(mesh: Mesh, nb: number, options?: {
  26164. positionFunction?: any;
  26165. vertexFunction?: any;
  26166. }): number;
  26167. private _rebuildParticle;
  26168. /**
  26169. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26170. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  26171. * @returns the SPS.
  26172. */
  26173. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26174. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26175. * Returns an array with the removed particles.
  26176. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  26177. * The SPS can't be empty so at least one particle needs to remain in place.
  26178. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26179. * @param start index of the first particle to remove
  26180. * @param end index of the last particle to remove (included)
  26181. * @returns an array populated with the removed particles
  26182. */
  26183. removeParticles(start: number, end: number): SolidParticle[];
  26184. /**
  26185. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26186. * This method calls `updateParticle()` for each particle of the SPS.
  26187. * For an animated SPS, it is usually called within the render loop.
  26188. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  26189. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26190. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26191. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26192. * @returns the SPS.
  26193. */
  26194. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26195. /**
  26196. * Disposes the SPS.
  26197. */
  26198. dispose(): void;
  26199. /**
  26200. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26201. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26202. * @returns the SPS.
  26203. */
  26204. refreshVisibleSize(): SolidParticleSystem;
  26205. /**
  26206. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26207. * @param size the size (float) of the visibility box
  26208. * note : this doesn't lock the SPS mesh bounding box.
  26209. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26210. */
  26211. setVisibilityBox(size: number): void;
  26212. /**
  26213. * Gets whether the SPS as always visible or not
  26214. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26215. */
  26216. /**
  26217. * Sets the SPS as always visible or not
  26218. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26219. */
  26220. isAlwaysVisible: boolean;
  26221. /**
  26222. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26223. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26224. */
  26225. /**
  26226. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26227. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26228. */
  26229. isVisibilityBoxLocked: boolean;
  26230. /**
  26231. * Tells to `setParticles()` to compute the particle rotations or not.
  26232. * Default value : true. The SPS is faster when it's set to false.
  26233. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26234. */
  26235. /**
  26236. * Gets if `setParticles()` computes the particle rotations or not.
  26237. * Default value : true. The SPS is faster when it's set to false.
  26238. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26239. */
  26240. computeParticleRotation: boolean;
  26241. /**
  26242. * Tells to `setParticles()` to compute the particle colors or not.
  26243. * Default value : true. The SPS is faster when it's set to false.
  26244. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26245. */
  26246. /**
  26247. * Gets if `setParticles()` computes the particle colors or not.
  26248. * Default value : true. The SPS is faster when it's set to false.
  26249. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26250. */
  26251. computeParticleColor: boolean;
  26252. /**
  26253. * Gets if `setParticles()` computes the particle textures or not.
  26254. * Default value : true. The SPS is faster when it's set to false.
  26255. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26256. */
  26257. computeParticleTexture: boolean;
  26258. /**
  26259. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26260. * Default value : false. The SPS is faster when it's set to false.
  26261. * Note : the particle custom vertex positions aren't stored values.
  26262. */
  26263. /**
  26264. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26265. * Default value : false. The SPS is faster when it's set to false.
  26266. * Note : the particle custom vertex positions aren't stored values.
  26267. */
  26268. computeParticleVertex: boolean;
  26269. /**
  26270. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26271. */
  26272. /**
  26273. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26274. */
  26275. computeBoundingBox: boolean;
  26276. /**
  26277. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26278. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26279. * Default : `true`
  26280. */
  26281. /**
  26282. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26283. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26284. * Default : `true`
  26285. */
  26286. depthSortParticles: boolean;
  26287. /**
  26288. * Gets if the SPS is created as expandable at construction time.
  26289. * Default : `false`
  26290. */
  26291. readonly expandable: boolean;
  26292. /**
  26293. * This function does nothing. It may be overwritten to set all the particle first values.
  26294. * The SPS doesn't call this function, you may have to call it by your own.
  26295. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26296. */
  26297. initParticles(): void;
  26298. /**
  26299. * This function does nothing. It may be overwritten to recycle a particle.
  26300. * The SPS doesn't call this function, you may have to call it by your own.
  26301. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26302. * @param particle The particle to recycle
  26303. * @returns the recycled particle
  26304. */
  26305. recycleParticle(particle: SolidParticle): SolidParticle;
  26306. /**
  26307. * Updates a particle : this function should be overwritten by the user.
  26308. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26309. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26310. * @example : just set a particle position or velocity and recycle conditions
  26311. * @param particle The particle to update
  26312. * @returns the updated particle
  26313. */
  26314. updateParticle(particle: SolidParticle): SolidParticle;
  26315. /**
  26316. * Updates a vertex of a particle : it can be overwritten by the user.
  26317. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26318. * @param particle the current particle
  26319. * @param vertex the current index of the current particle
  26320. * @param pt the index of the current vertex in the particle shape
  26321. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26322. * @example : just set a vertex particle position
  26323. * @returns the updated vertex
  26324. */
  26325. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26326. /**
  26327. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26328. * This does nothing and may be overwritten by the user.
  26329. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26330. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26331. * @param update the boolean update value actually passed to setParticles()
  26332. */
  26333. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26334. /**
  26335. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26336. * This will be passed three parameters.
  26337. * This does nothing and may be overwritten by the user.
  26338. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26339. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26340. * @param update the boolean update value actually passed to setParticles()
  26341. */
  26342. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26343. }
  26344. }
  26345. declare module "babylonjs/Particles/solidParticle" {
  26346. import { Nullable } from "babylonjs/types";
  26347. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26348. import { Color4 } from "babylonjs/Maths/math.color";
  26349. import { Mesh } from "babylonjs/Meshes/mesh";
  26350. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26351. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26352. import { Plane } from "babylonjs/Maths/math.plane";
  26353. /**
  26354. * Represents one particle of a solid particle system.
  26355. */
  26356. export class SolidParticle {
  26357. /**
  26358. * particle global index
  26359. */
  26360. idx: number;
  26361. /**
  26362. * The color of the particle
  26363. */
  26364. color: Nullable<Color4>;
  26365. /**
  26366. * The world space position of the particle.
  26367. */
  26368. position: Vector3;
  26369. /**
  26370. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26371. */
  26372. rotation: Vector3;
  26373. /**
  26374. * The world space rotation quaternion of the particle.
  26375. */
  26376. rotationQuaternion: Nullable<Quaternion>;
  26377. /**
  26378. * The scaling of the particle.
  26379. */
  26380. scaling: Vector3;
  26381. /**
  26382. * The uvs of the particle.
  26383. */
  26384. uvs: Vector4;
  26385. /**
  26386. * The current speed of the particle.
  26387. */
  26388. velocity: Vector3;
  26389. /**
  26390. * The pivot point in the particle local space.
  26391. */
  26392. pivot: Vector3;
  26393. /**
  26394. * Must the particle be translated from its pivot point in its local space ?
  26395. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26396. * Default : false
  26397. */
  26398. translateFromPivot: boolean;
  26399. /**
  26400. * Is the particle active or not ?
  26401. */
  26402. alive: boolean;
  26403. /**
  26404. * Is the particle visible or not ?
  26405. */
  26406. isVisible: boolean;
  26407. /**
  26408. * Index of this particle in the global "positions" array (Internal use)
  26409. * @hidden
  26410. */
  26411. _pos: number;
  26412. /**
  26413. * @hidden Index of this particle in the global "indices" array (Internal use)
  26414. */
  26415. _ind: number;
  26416. /**
  26417. * @hidden ModelShape of this particle (Internal use)
  26418. */
  26419. _model: ModelShape;
  26420. /**
  26421. * ModelShape id of this particle
  26422. */
  26423. shapeId: number;
  26424. /**
  26425. * Index of the particle in its shape id
  26426. */
  26427. idxInShape: number;
  26428. /**
  26429. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26430. */
  26431. _modelBoundingInfo: BoundingInfo;
  26432. /**
  26433. * @hidden Particle BoundingInfo object (Internal use)
  26434. */
  26435. _boundingInfo: BoundingInfo;
  26436. /**
  26437. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26438. */
  26439. _sps: SolidParticleSystem;
  26440. /**
  26441. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26442. */
  26443. _stillInvisible: boolean;
  26444. /**
  26445. * @hidden Last computed particle rotation matrix
  26446. */
  26447. _rotationMatrix: number[];
  26448. /**
  26449. * Parent particle Id, if any.
  26450. * Default null.
  26451. */
  26452. parentId: Nullable<number>;
  26453. /**
  26454. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26455. * The possible values are :
  26456. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26457. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26458. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26459. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26460. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26461. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26462. * */
  26463. cullingStrategy: number;
  26464. /**
  26465. * @hidden Internal global position in the SPS.
  26466. */
  26467. _globalPosition: Vector3;
  26468. /**
  26469. * Creates a Solid Particle object.
  26470. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26471. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26472. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26473. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26474. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26475. * @param shapeId (integer) is the model shape identifier in the SPS.
  26476. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26477. * @param sps defines the sps it is associated to
  26478. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26479. */
  26480. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26481. /**
  26482. * Legacy support, changed scale to scaling
  26483. */
  26484. /**
  26485. * Legacy support, changed scale to scaling
  26486. */
  26487. scale: Vector3;
  26488. /**
  26489. * Legacy support, changed quaternion to rotationQuaternion
  26490. */
  26491. /**
  26492. * Legacy support, changed quaternion to rotationQuaternion
  26493. */
  26494. quaternion: Nullable<Quaternion>;
  26495. /**
  26496. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26497. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26498. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26499. * @returns true if it intersects
  26500. */
  26501. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26502. /**
  26503. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26504. * A particle is in the frustum if its bounding box intersects the frustum
  26505. * @param frustumPlanes defines the frustum to test
  26506. * @returns true if the particle is in the frustum planes
  26507. */
  26508. isInFrustum(frustumPlanes: Plane[]): boolean;
  26509. /**
  26510. * get the rotation matrix of the particle
  26511. * @hidden
  26512. */
  26513. getRotationMatrix(m: Matrix): void;
  26514. }
  26515. /**
  26516. * Represents the shape of the model used by one particle of a solid particle system.
  26517. * SPS internal tool, don't use it manually.
  26518. */
  26519. export class ModelShape {
  26520. /**
  26521. * The shape id
  26522. * @hidden
  26523. */
  26524. shapeID: number;
  26525. /**
  26526. * flat array of model positions (internal use)
  26527. * @hidden
  26528. */
  26529. _shape: Vector3[];
  26530. /**
  26531. * flat array of model UVs (internal use)
  26532. * @hidden
  26533. */
  26534. _shapeUV: number[];
  26535. /**
  26536. * color array of the model
  26537. * @hidden
  26538. */
  26539. _shapeColors: number[];
  26540. /**
  26541. * indices array of the model
  26542. * @hidden
  26543. */
  26544. _indices: number[];
  26545. /**
  26546. * normals array of the model
  26547. * @hidden
  26548. */
  26549. _normals: number[];
  26550. /**
  26551. * length of the shape in the model indices array (internal use)
  26552. * @hidden
  26553. */
  26554. _indicesLength: number;
  26555. /**
  26556. * Custom position function (internal use)
  26557. * @hidden
  26558. */
  26559. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26560. /**
  26561. * Custom vertex function (internal use)
  26562. * @hidden
  26563. */
  26564. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26565. /**
  26566. * 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.
  26567. * SPS internal tool, don't use it manually.
  26568. * @hidden
  26569. */
  26570. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26571. }
  26572. /**
  26573. * Represents a Depth Sorted Particle in the solid particle system.
  26574. */
  26575. export class DepthSortedParticle {
  26576. /**
  26577. * Index of the particle in the "indices" array
  26578. */
  26579. ind: number;
  26580. /**
  26581. * Length of the particle shape in the "indices" array
  26582. */
  26583. indicesLength: number;
  26584. /**
  26585. * Squared distance from the particle to the camera
  26586. */
  26587. sqDistance: number;
  26588. }
  26589. }
  26590. declare module "babylonjs/Collisions/meshCollisionData" {
  26591. import { Collider } from "babylonjs/Collisions/collider";
  26592. import { Vector3 } from "babylonjs/Maths/math.vector";
  26593. import { Nullable } from "babylonjs/types";
  26594. import { Observer } from "babylonjs/Misc/observable";
  26595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26596. /**
  26597. * @hidden
  26598. */
  26599. export class _MeshCollisionData {
  26600. _checkCollisions: boolean;
  26601. _collisionMask: number;
  26602. _collisionGroup: number;
  26603. _collider: Nullable<Collider>;
  26604. _oldPositionForCollisions: Vector3;
  26605. _diffPositionForCollisions: Vector3;
  26606. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26607. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26608. }
  26609. }
  26610. declare module "babylonjs/Meshes/abstractMesh" {
  26611. import { Observable } from "babylonjs/Misc/observable";
  26612. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26613. import { Camera } from "babylonjs/Cameras/camera";
  26614. import { Scene, IDisposable } from "babylonjs/scene";
  26615. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26616. import { Node } from "babylonjs/node";
  26617. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26618. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26619. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26620. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26621. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26622. import { Material } from "babylonjs/Materials/material";
  26623. import { Light } from "babylonjs/Lights/light";
  26624. import { Skeleton } from "babylonjs/Bones/skeleton";
  26625. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26626. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26627. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26628. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26629. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26630. import { Plane } from "babylonjs/Maths/math.plane";
  26631. import { Ray } from "babylonjs/Culling/ray";
  26632. import { Collider } from "babylonjs/Collisions/collider";
  26633. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26634. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26635. /** @hidden */
  26636. class _FacetDataStorage {
  26637. facetPositions: Vector3[];
  26638. facetNormals: Vector3[];
  26639. facetPartitioning: number[][];
  26640. facetNb: number;
  26641. partitioningSubdivisions: number;
  26642. partitioningBBoxRatio: number;
  26643. facetDataEnabled: boolean;
  26644. facetParameters: any;
  26645. bbSize: Vector3;
  26646. subDiv: {
  26647. max: number;
  26648. X: number;
  26649. Y: number;
  26650. Z: number;
  26651. };
  26652. facetDepthSort: boolean;
  26653. facetDepthSortEnabled: boolean;
  26654. depthSortedIndices: IndicesArray;
  26655. depthSortedFacets: {
  26656. ind: number;
  26657. sqDistance: number;
  26658. }[];
  26659. facetDepthSortFunction: (f1: {
  26660. ind: number;
  26661. sqDistance: number;
  26662. }, f2: {
  26663. ind: number;
  26664. sqDistance: number;
  26665. }) => number;
  26666. facetDepthSortFrom: Vector3;
  26667. facetDepthSortOrigin: Vector3;
  26668. invertedMatrix: Matrix;
  26669. }
  26670. /**
  26671. * @hidden
  26672. **/
  26673. class _InternalAbstractMeshDataInfo {
  26674. _hasVertexAlpha: boolean;
  26675. _useVertexColors: boolean;
  26676. _numBoneInfluencers: number;
  26677. _applyFog: boolean;
  26678. _receiveShadows: boolean;
  26679. _facetData: _FacetDataStorage;
  26680. _visibility: number;
  26681. _skeleton: Nullable<Skeleton>;
  26682. _layerMask: number;
  26683. _computeBonesUsingShaders: boolean;
  26684. _isActive: boolean;
  26685. _onlyForInstances: boolean;
  26686. _isActiveIntermediate: boolean;
  26687. _onlyForInstancesIntermediate: boolean;
  26688. _actAsRegularMesh: boolean;
  26689. }
  26690. /**
  26691. * Class used to store all common mesh properties
  26692. */
  26693. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26694. /** No occlusion */
  26695. static OCCLUSION_TYPE_NONE: number;
  26696. /** Occlusion set to optimisitic */
  26697. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26698. /** Occlusion set to strict */
  26699. static OCCLUSION_TYPE_STRICT: number;
  26700. /** Use an accurante occlusion algorithm */
  26701. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26702. /** Use a conservative occlusion algorithm */
  26703. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26704. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26705. * Test order :
  26706. * Is the bounding sphere outside the frustum ?
  26707. * If not, are the bounding box vertices outside the frustum ?
  26708. * It not, then the cullable object is in the frustum.
  26709. */
  26710. static readonly CULLINGSTRATEGY_STANDARD: number;
  26711. /** Culling strategy : Bounding Sphere Only.
  26712. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26713. * It's also less accurate than the standard because some not visible objects can still be selected.
  26714. * Test : is the bounding sphere outside the frustum ?
  26715. * If not, then the cullable object is in the frustum.
  26716. */
  26717. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26718. /** Culling strategy : Optimistic Inclusion.
  26719. * This in an inclusion test first, then the standard exclusion test.
  26720. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26721. * 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.
  26722. * Anyway, it's as accurate as the standard strategy.
  26723. * Test :
  26724. * Is the cullable object bounding sphere center in the frustum ?
  26725. * If not, apply the default culling strategy.
  26726. */
  26727. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26728. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26729. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26730. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26731. * 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.
  26732. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26733. * Test :
  26734. * Is the cullable object bounding sphere center in the frustum ?
  26735. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26736. */
  26737. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26738. /**
  26739. * No billboard
  26740. */
  26741. static readonly BILLBOARDMODE_NONE: number;
  26742. /** Billboard on X axis */
  26743. static readonly BILLBOARDMODE_X: number;
  26744. /** Billboard on Y axis */
  26745. static readonly BILLBOARDMODE_Y: number;
  26746. /** Billboard on Z axis */
  26747. static readonly BILLBOARDMODE_Z: number;
  26748. /** Billboard on all axes */
  26749. static readonly BILLBOARDMODE_ALL: number;
  26750. /** Billboard on using position instead of orientation */
  26751. static readonly BILLBOARDMODE_USE_POSITION: number;
  26752. /** @hidden */
  26753. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26754. /**
  26755. * The culling strategy to use to check whether the mesh must be rendered or not.
  26756. * This value can be changed at any time and will be used on the next render mesh selection.
  26757. * The possible values are :
  26758. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26759. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26760. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26761. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26762. * Please read each static variable documentation to get details about the culling process.
  26763. * */
  26764. cullingStrategy: number;
  26765. /**
  26766. * Gets the number of facets in the mesh
  26767. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26768. */
  26769. readonly facetNb: number;
  26770. /**
  26771. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26773. */
  26774. partitioningSubdivisions: number;
  26775. /**
  26776. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26777. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26779. */
  26780. partitioningBBoxRatio: number;
  26781. /**
  26782. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26783. * Works only for updatable meshes.
  26784. * Doesn't work with multi-materials
  26785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26786. */
  26787. mustDepthSortFacets: boolean;
  26788. /**
  26789. * The location (Vector3) where the facet depth sort must be computed from.
  26790. * By default, the active camera position.
  26791. * Used only when facet depth sort is enabled
  26792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26793. */
  26794. facetDepthSortFrom: Vector3;
  26795. /**
  26796. * gets a boolean indicating if facetData is enabled
  26797. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26798. */
  26799. readonly isFacetDataEnabled: boolean;
  26800. /** @hidden */
  26801. _updateNonUniformScalingState(value: boolean): boolean;
  26802. /**
  26803. * An event triggered when this mesh collides with another one
  26804. */
  26805. onCollideObservable: Observable<AbstractMesh>;
  26806. /** Set a function to call when this mesh collides with another one */
  26807. onCollide: () => void;
  26808. /**
  26809. * An event triggered when the collision's position changes
  26810. */
  26811. onCollisionPositionChangeObservable: Observable<Vector3>;
  26812. /** Set a function to call when the collision's position changes */
  26813. onCollisionPositionChange: () => void;
  26814. /**
  26815. * An event triggered when material is changed
  26816. */
  26817. onMaterialChangedObservable: Observable<AbstractMesh>;
  26818. /**
  26819. * Gets or sets the orientation for POV movement & rotation
  26820. */
  26821. definedFacingForward: boolean;
  26822. /** @hidden */
  26823. _occlusionQuery: Nullable<WebGLQuery>;
  26824. /** @hidden */
  26825. _renderingGroup: Nullable<RenderingGroup>;
  26826. /**
  26827. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26828. */
  26829. /**
  26830. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26831. */
  26832. visibility: number;
  26833. /** Gets or sets the alpha index used to sort transparent meshes
  26834. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26835. */
  26836. alphaIndex: number;
  26837. /**
  26838. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26839. */
  26840. isVisible: boolean;
  26841. /**
  26842. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26843. */
  26844. isPickable: boolean;
  26845. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26846. showSubMeshesBoundingBox: boolean;
  26847. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26848. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26849. */
  26850. isBlocker: boolean;
  26851. /**
  26852. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26853. */
  26854. enablePointerMoveEvents: boolean;
  26855. /**
  26856. * Specifies the rendering group id for this mesh (0 by default)
  26857. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26858. */
  26859. renderingGroupId: number;
  26860. private _material;
  26861. /** Gets or sets current material */
  26862. material: Nullable<Material>;
  26863. /**
  26864. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26865. * @see http://doc.babylonjs.com/babylon101/shadows
  26866. */
  26867. receiveShadows: boolean;
  26868. /** Defines color to use when rendering outline */
  26869. outlineColor: Color3;
  26870. /** Define width to use when rendering outline */
  26871. outlineWidth: number;
  26872. /** Defines color to use when rendering overlay */
  26873. overlayColor: Color3;
  26874. /** Defines alpha to use when rendering overlay */
  26875. overlayAlpha: number;
  26876. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26877. hasVertexAlpha: boolean;
  26878. /** 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) */
  26879. useVertexColors: boolean;
  26880. /**
  26881. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26882. */
  26883. computeBonesUsingShaders: boolean;
  26884. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26885. numBoneInfluencers: number;
  26886. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26887. applyFog: boolean;
  26888. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26889. useOctreeForRenderingSelection: boolean;
  26890. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26891. useOctreeForPicking: boolean;
  26892. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26893. useOctreeForCollisions: boolean;
  26894. /**
  26895. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26896. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26897. */
  26898. layerMask: number;
  26899. /**
  26900. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26901. */
  26902. alwaysSelectAsActiveMesh: boolean;
  26903. /**
  26904. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26905. */
  26906. doNotSyncBoundingInfo: boolean;
  26907. /**
  26908. * Gets or sets the current action manager
  26909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26910. */
  26911. actionManager: Nullable<AbstractActionManager>;
  26912. private _meshCollisionData;
  26913. /**
  26914. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26915. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26916. */
  26917. ellipsoid: Vector3;
  26918. /**
  26919. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26920. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26921. */
  26922. ellipsoidOffset: Vector3;
  26923. /**
  26924. * Gets or sets a collision mask used to mask collisions (default is -1).
  26925. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26926. */
  26927. collisionMask: number;
  26928. /**
  26929. * Gets or sets the current collision group mask (-1 by default).
  26930. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26931. */
  26932. collisionGroup: number;
  26933. /**
  26934. * Defines edge width used when edgesRenderer is enabled
  26935. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26936. */
  26937. edgesWidth: number;
  26938. /**
  26939. * Defines edge color used when edgesRenderer is enabled
  26940. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26941. */
  26942. edgesColor: Color4;
  26943. /** @hidden */
  26944. _edgesRenderer: Nullable<IEdgesRenderer>;
  26945. /** @hidden */
  26946. _masterMesh: Nullable<AbstractMesh>;
  26947. /** @hidden */
  26948. _boundingInfo: Nullable<BoundingInfo>;
  26949. /** @hidden */
  26950. _renderId: number;
  26951. /**
  26952. * Gets or sets the list of subMeshes
  26953. * @see http://doc.babylonjs.com/how_to/multi_materials
  26954. */
  26955. subMeshes: SubMesh[];
  26956. /** @hidden */
  26957. _intersectionsInProgress: AbstractMesh[];
  26958. /** @hidden */
  26959. _unIndexed: boolean;
  26960. /** @hidden */
  26961. _lightSources: Light[];
  26962. /** Gets the list of lights affecting that mesh */
  26963. readonly lightSources: Light[];
  26964. /** @hidden */
  26965. readonly _positions: Nullable<Vector3[]>;
  26966. /** @hidden */
  26967. _waitingData: {
  26968. lods: Nullable<any>;
  26969. actions: Nullable<any>;
  26970. freezeWorldMatrix: Nullable<boolean>;
  26971. };
  26972. /** @hidden */
  26973. _bonesTransformMatrices: Nullable<Float32Array>;
  26974. /** @hidden */
  26975. _transformMatrixTexture: Nullable<RawTexture>;
  26976. /**
  26977. * Gets or sets a skeleton to apply skining transformations
  26978. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26979. */
  26980. skeleton: Nullable<Skeleton>;
  26981. /**
  26982. * An event triggered when the mesh is rebuilt.
  26983. */
  26984. onRebuildObservable: Observable<AbstractMesh>;
  26985. /**
  26986. * Creates a new AbstractMesh
  26987. * @param name defines the name of the mesh
  26988. * @param scene defines the hosting scene
  26989. */
  26990. constructor(name: string, scene?: Nullable<Scene>);
  26991. /**
  26992. * Returns the string "AbstractMesh"
  26993. * @returns "AbstractMesh"
  26994. */
  26995. getClassName(): string;
  26996. /**
  26997. * Gets a string representation of the current mesh
  26998. * @param fullDetails defines a boolean indicating if full details must be included
  26999. * @returns a string representation of the current mesh
  27000. */
  27001. toString(fullDetails?: boolean): string;
  27002. /**
  27003. * @hidden
  27004. */
  27005. protected _getEffectiveParent(): Nullable<Node>;
  27006. /** @hidden */
  27007. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27008. /** @hidden */
  27009. _rebuild(): void;
  27010. /** @hidden */
  27011. _resyncLightSources(): void;
  27012. /** @hidden */
  27013. _resyncLighSource(light: Light): void;
  27014. /** @hidden */
  27015. _unBindEffect(): void;
  27016. /** @hidden */
  27017. _removeLightSource(light: Light, dispose: boolean): void;
  27018. private _markSubMeshesAsDirty;
  27019. /** @hidden */
  27020. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27021. /** @hidden */
  27022. _markSubMeshesAsAttributesDirty(): void;
  27023. /** @hidden */
  27024. _markSubMeshesAsMiscDirty(): void;
  27025. /**
  27026. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27027. */
  27028. scaling: Vector3;
  27029. /**
  27030. * Returns true if the mesh is blocked. Implemented by child classes
  27031. */
  27032. readonly isBlocked: boolean;
  27033. /**
  27034. * Returns the mesh itself by default. Implemented by child classes
  27035. * @param camera defines the camera to use to pick the right LOD level
  27036. * @returns the currentAbstractMesh
  27037. */
  27038. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27039. /**
  27040. * Returns 0 by default. Implemented by child classes
  27041. * @returns an integer
  27042. */
  27043. getTotalVertices(): number;
  27044. /**
  27045. * Returns a positive integer : the total number of indices in this mesh geometry.
  27046. * @returns the numner of indices or zero if the mesh has no geometry.
  27047. */
  27048. getTotalIndices(): number;
  27049. /**
  27050. * Returns null by default. Implemented by child classes
  27051. * @returns null
  27052. */
  27053. getIndices(): Nullable<IndicesArray>;
  27054. /**
  27055. * Returns the array of the requested vertex data kind. Implemented by child classes
  27056. * @param kind defines the vertex data kind to use
  27057. * @returns null
  27058. */
  27059. getVerticesData(kind: string): Nullable<FloatArray>;
  27060. /**
  27061. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27062. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27063. * Note that a new underlying VertexBuffer object is created each call.
  27064. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27065. * @param kind defines vertex data kind:
  27066. * * VertexBuffer.PositionKind
  27067. * * VertexBuffer.UVKind
  27068. * * VertexBuffer.UV2Kind
  27069. * * VertexBuffer.UV3Kind
  27070. * * VertexBuffer.UV4Kind
  27071. * * VertexBuffer.UV5Kind
  27072. * * VertexBuffer.UV6Kind
  27073. * * VertexBuffer.ColorKind
  27074. * * VertexBuffer.MatricesIndicesKind
  27075. * * VertexBuffer.MatricesIndicesExtraKind
  27076. * * VertexBuffer.MatricesWeightsKind
  27077. * * VertexBuffer.MatricesWeightsExtraKind
  27078. * @param data defines the data source
  27079. * @param updatable defines if the data must be flagged as updatable (or static)
  27080. * @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
  27081. * @returns the current mesh
  27082. */
  27083. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27084. /**
  27085. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27086. * If the mesh has no geometry, it is simply returned as it is.
  27087. * @param kind defines vertex data kind:
  27088. * * VertexBuffer.PositionKind
  27089. * * VertexBuffer.UVKind
  27090. * * VertexBuffer.UV2Kind
  27091. * * VertexBuffer.UV3Kind
  27092. * * VertexBuffer.UV4Kind
  27093. * * VertexBuffer.UV5Kind
  27094. * * VertexBuffer.UV6Kind
  27095. * * VertexBuffer.ColorKind
  27096. * * VertexBuffer.MatricesIndicesKind
  27097. * * VertexBuffer.MatricesIndicesExtraKind
  27098. * * VertexBuffer.MatricesWeightsKind
  27099. * * VertexBuffer.MatricesWeightsExtraKind
  27100. * @param data defines the data source
  27101. * @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
  27102. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27103. * @returns the current mesh
  27104. */
  27105. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27106. /**
  27107. * Sets the mesh indices,
  27108. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27109. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27110. * @param totalVertices Defines the total number of vertices
  27111. * @returns the current mesh
  27112. */
  27113. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27114. /**
  27115. * Gets a boolean indicating if specific vertex data is present
  27116. * @param kind defines the vertex data kind to use
  27117. * @returns true is data kind is present
  27118. */
  27119. isVerticesDataPresent(kind: string): boolean;
  27120. /**
  27121. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27122. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27123. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27124. * @returns a BoundingInfo
  27125. */
  27126. getBoundingInfo(): BoundingInfo;
  27127. /**
  27128. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27129. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27130. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27131. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27132. * @returns the current mesh
  27133. */
  27134. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27135. /**
  27136. * Overwrite the current bounding info
  27137. * @param boundingInfo defines the new bounding info
  27138. * @returns the current mesh
  27139. */
  27140. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27141. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27142. readonly useBones: boolean;
  27143. /** @hidden */
  27144. _preActivate(): void;
  27145. /** @hidden */
  27146. _preActivateForIntermediateRendering(renderId: number): void;
  27147. /** @hidden */
  27148. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27149. /** @hidden */
  27150. _postActivate(): void;
  27151. /** @hidden */
  27152. _freeze(): void;
  27153. /** @hidden */
  27154. _unFreeze(): void;
  27155. /**
  27156. * Gets the current world matrix
  27157. * @returns a Matrix
  27158. */
  27159. getWorldMatrix(): Matrix;
  27160. /** @hidden */
  27161. _getWorldMatrixDeterminant(): number;
  27162. /**
  27163. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27164. */
  27165. readonly isAnInstance: boolean;
  27166. /**
  27167. * Gets a boolean indicating if this mesh has instances
  27168. */
  27169. readonly hasInstances: boolean;
  27170. /**
  27171. * Perform relative position change from the point of view of behind the front of the mesh.
  27172. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27173. * Supports definition of mesh facing forward or backward
  27174. * @param amountRight defines the distance on the right axis
  27175. * @param amountUp defines the distance on the up axis
  27176. * @param amountForward defines the distance on the forward axis
  27177. * @returns the current mesh
  27178. */
  27179. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27180. /**
  27181. * Calculate relative position change from the point of view of behind the front of the mesh.
  27182. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27183. * Supports definition of mesh facing forward or backward
  27184. * @param amountRight defines the distance on the right axis
  27185. * @param amountUp defines the distance on the up axis
  27186. * @param amountForward defines the distance on the forward axis
  27187. * @returns the new displacement vector
  27188. */
  27189. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27190. /**
  27191. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27192. * Supports definition of mesh facing forward or backward
  27193. * @param flipBack defines the flip
  27194. * @param twirlClockwise defines the twirl
  27195. * @param tiltRight defines the tilt
  27196. * @returns the current mesh
  27197. */
  27198. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27199. /**
  27200. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27201. * Supports definition of mesh facing forward or backward.
  27202. * @param flipBack defines the flip
  27203. * @param twirlClockwise defines the twirl
  27204. * @param tiltRight defines the tilt
  27205. * @returns the new rotation vector
  27206. */
  27207. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27208. /**
  27209. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27210. * This means the mesh underlying bounding box and sphere are recomputed.
  27211. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27212. * @returns the current mesh
  27213. */
  27214. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27215. /** @hidden */
  27216. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27217. /** @hidden */
  27218. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27219. /** @hidden */
  27220. _updateBoundingInfo(): AbstractMesh;
  27221. /** @hidden */
  27222. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27223. /** @hidden */
  27224. protected _afterComputeWorldMatrix(): void;
  27225. /** @hidden */
  27226. readonly _effectiveMesh: AbstractMesh;
  27227. /**
  27228. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27229. * A mesh is in the frustum if its bounding box intersects the frustum
  27230. * @param frustumPlanes defines the frustum to test
  27231. * @returns true if the mesh is in the frustum planes
  27232. */
  27233. isInFrustum(frustumPlanes: Plane[]): boolean;
  27234. /**
  27235. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27236. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27237. * @param frustumPlanes defines the frustum to test
  27238. * @returns true if the mesh is completely in the frustum planes
  27239. */
  27240. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27241. /**
  27242. * True if the mesh intersects another mesh or a SolidParticle object
  27243. * @param mesh defines a target mesh or SolidParticle to test
  27244. * @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)
  27245. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27246. * @returns true if there is an intersection
  27247. */
  27248. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27249. /**
  27250. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27251. * @param point defines the point to test
  27252. * @returns true if there is an intersection
  27253. */
  27254. intersectsPoint(point: Vector3): boolean;
  27255. /**
  27256. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27257. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27258. */
  27259. checkCollisions: boolean;
  27260. /**
  27261. * Gets Collider object used to compute collisions (not physics)
  27262. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27263. */
  27264. readonly collider: Nullable<Collider>;
  27265. /**
  27266. * Move the mesh using collision engine
  27267. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27268. * @param displacement defines the requested displacement vector
  27269. * @returns the current mesh
  27270. */
  27271. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27272. private _onCollisionPositionChange;
  27273. /** @hidden */
  27274. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27275. /** @hidden */
  27276. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27277. /** @hidden */
  27278. _checkCollision(collider: Collider): AbstractMesh;
  27279. /** @hidden */
  27280. _generatePointsArray(): boolean;
  27281. /**
  27282. * Checks if the passed Ray intersects with the mesh
  27283. * @param ray defines the ray to use
  27284. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27285. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27286. * @returns the picking info
  27287. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27288. */
  27289. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27290. /**
  27291. * Clones the current mesh
  27292. * @param name defines the mesh name
  27293. * @param newParent defines the new mesh parent
  27294. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27295. * @returns the new mesh
  27296. */
  27297. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27298. /**
  27299. * Disposes all the submeshes of the current meshnp
  27300. * @returns the current mesh
  27301. */
  27302. releaseSubMeshes(): AbstractMesh;
  27303. /**
  27304. * Releases resources associated with this abstract mesh.
  27305. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27306. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27307. */
  27308. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27309. /**
  27310. * Adds the passed mesh as a child to the current mesh
  27311. * @param mesh defines the child mesh
  27312. * @returns the current mesh
  27313. */
  27314. addChild(mesh: AbstractMesh): AbstractMesh;
  27315. /**
  27316. * Removes the passed mesh from the current mesh children list
  27317. * @param mesh defines the child mesh
  27318. * @returns the current mesh
  27319. */
  27320. removeChild(mesh: AbstractMesh): AbstractMesh;
  27321. /** @hidden */
  27322. private _initFacetData;
  27323. /**
  27324. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27325. * This method can be called within the render loop.
  27326. * 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
  27327. * @returns the current mesh
  27328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27329. */
  27330. updateFacetData(): AbstractMesh;
  27331. /**
  27332. * Returns the facetLocalNormals array.
  27333. * The normals are expressed in the mesh local spac
  27334. * @returns an array of Vector3
  27335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27336. */
  27337. getFacetLocalNormals(): Vector3[];
  27338. /**
  27339. * Returns the facetLocalPositions array.
  27340. * The facet positions are expressed in the mesh local space
  27341. * @returns an array of Vector3
  27342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27343. */
  27344. getFacetLocalPositions(): Vector3[];
  27345. /**
  27346. * Returns the facetLocalPartioning array
  27347. * @returns an array of array of numbers
  27348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27349. */
  27350. getFacetLocalPartitioning(): number[][];
  27351. /**
  27352. * Returns the i-th facet position in the world system.
  27353. * This method allocates a new Vector3 per call
  27354. * @param i defines the facet index
  27355. * @returns a new Vector3
  27356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27357. */
  27358. getFacetPosition(i: number): Vector3;
  27359. /**
  27360. * Sets the reference Vector3 with the i-th facet position in the world system
  27361. * @param i defines the facet index
  27362. * @param ref defines the target vector
  27363. * @returns the current mesh
  27364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27365. */
  27366. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27367. /**
  27368. * Returns the i-th facet normal in the world system.
  27369. * This method allocates a new Vector3 per call
  27370. * @param i defines the facet index
  27371. * @returns a new Vector3
  27372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27373. */
  27374. getFacetNormal(i: number): Vector3;
  27375. /**
  27376. * Sets the reference Vector3 with the i-th facet normal in the world system
  27377. * @param i defines the facet index
  27378. * @param ref defines the target vector
  27379. * @returns the current mesh
  27380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27381. */
  27382. getFacetNormalToRef(i: number, ref: Vector3): this;
  27383. /**
  27384. * 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)
  27385. * @param x defines x coordinate
  27386. * @param y defines y coordinate
  27387. * @param z defines z coordinate
  27388. * @returns the array of facet indexes
  27389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27390. */
  27391. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27392. /**
  27393. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27394. * @param projected sets as the (x,y,z) world projection on the facet
  27395. * @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
  27396. * @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
  27397. * @param x defines x coordinate
  27398. * @param y defines y coordinate
  27399. * @param z defines z coordinate
  27400. * @returns the face index if found (or null instead)
  27401. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27402. */
  27403. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27404. /**
  27405. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27406. * @param projected sets as the (x,y,z) local projection on the facet
  27407. * @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
  27408. * @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
  27409. * @param x defines x coordinate
  27410. * @param y defines y coordinate
  27411. * @param z defines z coordinate
  27412. * @returns the face index if found (or null instead)
  27413. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27414. */
  27415. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27416. /**
  27417. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27418. * @returns the parameters
  27419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27420. */
  27421. getFacetDataParameters(): any;
  27422. /**
  27423. * Disables the feature FacetData and frees the related memory
  27424. * @returns the current mesh
  27425. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27426. */
  27427. disableFacetData(): AbstractMesh;
  27428. /**
  27429. * Updates the AbstractMesh indices array
  27430. * @param indices defines the data source
  27431. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27432. * @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)
  27433. * @returns the current mesh
  27434. */
  27435. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27436. /**
  27437. * Creates new normals data for the mesh
  27438. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27439. * @returns the current mesh
  27440. */
  27441. createNormals(updatable: boolean): AbstractMesh;
  27442. /**
  27443. * Align the mesh with a normal
  27444. * @param normal defines the normal to use
  27445. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27446. * @returns the current mesh
  27447. */
  27448. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27449. /** @hidden */
  27450. _checkOcclusionQuery(): boolean;
  27451. /**
  27452. * Disables the mesh edge rendering mode
  27453. * @returns the currentAbstractMesh
  27454. */
  27455. disableEdgesRendering(): AbstractMesh;
  27456. /**
  27457. * Enables the edge rendering mode on the mesh.
  27458. * This mode makes the mesh edges visible
  27459. * @param epsilon defines the maximal distance between two angles to detect a face
  27460. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27461. * @returns the currentAbstractMesh
  27462. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27463. */
  27464. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27465. }
  27466. }
  27467. declare module "babylonjs/Actions/actionEvent" {
  27468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27469. import { Nullable } from "babylonjs/types";
  27470. import { Sprite } from "babylonjs/Sprites/sprite";
  27471. import { Scene } from "babylonjs/scene";
  27472. import { Vector2 } from "babylonjs/Maths/math.vector";
  27473. /**
  27474. * Interface used to define ActionEvent
  27475. */
  27476. export interface IActionEvent {
  27477. /** The mesh or sprite that triggered the action */
  27478. source: any;
  27479. /** The X mouse cursor position at the time of the event */
  27480. pointerX: number;
  27481. /** The Y mouse cursor position at the time of the event */
  27482. pointerY: number;
  27483. /** The mesh that is currently pointed at (can be null) */
  27484. meshUnderPointer: Nullable<AbstractMesh>;
  27485. /** the original (browser) event that triggered the ActionEvent */
  27486. sourceEvent?: any;
  27487. /** additional data for the event */
  27488. additionalData?: any;
  27489. }
  27490. /**
  27491. * ActionEvent is the event being sent when an action is triggered.
  27492. */
  27493. export class ActionEvent implements IActionEvent {
  27494. /** The mesh or sprite that triggered the action */
  27495. source: any;
  27496. /** The X mouse cursor position at the time of the event */
  27497. pointerX: number;
  27498. /** The Y mouse cursor position at the time of the event */
  27499. pointerY: number;
  27500. /** The mesh that is currently pointed at (can be null) */
  27501. meshUnderPointer: Nullable<AbstractMesh>;
  27502. /** the original (browser) event that triggered the ActionEvent */
  27503. sourceEvent?: any;
  27504. /** additional data for the event */
  27505. additionalData?: any;
  27506. /**
  27507. * Creates a new ActionEvent
  27508. * @param source The mesh or sprite that triggered the action
  27509. * @param pointerX The X mouse cursor position at the time of the event
  27510. * @param pointerY The Y mouse cursor position at the time of the event
  27511. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27512. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27513. * @param additionalData additional data for the event
  27514. */
  27515. constructor(
  27516. /** The mesh or sprite that triggered the action */
  27517. source: any,
  27518. /** The X mouse cursor position at the time of the event */
  27519. pointerX: number,
  27520. /** The Y mouse cursor position at the time of the event */
  27521. pointerY: number,
  27522. /** The mesh that is currently pointed at (can be null) */
  27523. meshUnderPointer: Nullable<AbstractMesh>,
  27524. /** the original (browser) event that triggered the ActionEvent */
  27525. sourceEvent?: any,
  27526. /** additional data for the event */
  27527. additionalData?: any);
  27528. /**
  27529. * Helper function to auto-create an ActionEvent from a source mesh.
  27530. * @param source The source mesh that triggered the event
  27531. * @param evt The original (browser) event
  27532. * @param additionalData additional data for the event
  27533. * @returns the new ActionEvent
  27534. */
  27535. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27536. /**
  27537. * Helper function to auto-create an ActionEvent from a source sprite
  27538. * @param source The source sprite that triggered the event
  27539. * @param scene Scene associated with the sprite
  27540. * @param evt The original (browser) event
  27541. * @param additionalData additional data for the event
  27542. * @returns the new ActionEvent
  27543. */
  27544. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27545. /**
  27546. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27547. * @param scene the scene where the event occurred
  27548. * @param evt The original (browser) event
  27549. * @returns the new ActionEvent
  27550. */
  27551. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27552. /**
  27553. * Helper function to auto-create an ActionEvent from a primitive
  27554. * @param prim defines the target primitive
  27555. * @param pointerPos defines the pointer position
  27556. * @param evt The original (browser) event
  27557. * @param additionalData additional data for the event
  27558. * @returns the new ActionEvent
  27559. */
  27560. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27561. }
  27562. }
  27563. declare module "babylonjs/Actions/abstractActionManager" {
  27564. import { IDisposable } from "babylonjs/scene";
  27565. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27566. import { IAction } from "babylonjs/Actions/action";
  27567. import { Nullable } from "babylonjs/types";
  27568. /**
  27569. * Abstract class used to decouple action Manager from scene and meshes.
  27570. * Do not instantiate.
  27571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27572. */
  27573. export abstract class AbstractActionManager implements IDisposable {
  27574. /** Gets the list of active triggers */
  27575. static Triggers: {
  27576. [key: string]: number;
  27577. };
  27578. /** Gets the cursor to use when hovering items */
  27579. hoverCursor: string;
  27580. /** Gets the list of actions */
  27581. actions: IAction[];
  27582. /**
  27583. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27584. */
  27585. isRecursive: boolean;
  27586. /**
  27587. * Releases all associated resources
  27588. */
  27589. abstract dispose(): void;
  27590. /**
  27591. * Does this action manager has pointer triggers
  27592. */
  27593. abstract readonly hasPointerTriggers: boolean;
  27594. /**
  27595. * Does this action manager has pick triggers
  27596. */
  27597. abstract readonly hasPickTriggers: boolean;
  27598. /**
  27599. * Process a specific trigger
  27600. * @param trigger defines the trigger to process
  27601. * @param evt defines the event details to be processed
  27602. */
  27603. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27604. /**
  27605. * Does this action manager handles actions of any of the given triggers
  27606. * @param triggers defines the triggers to be tested
  27607. * @return a boolean indicating whether one (or more) of the triggers is handled
  27608. */
  27609. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27610. /**
  27611. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27612. * speed.
  27613. * @param triggerA defines the trigger to be tested
  27614. * @param triggerB defines the trigger to be tested
  27615. * @return a boolean indicating whether one (or more) of the triggers is handled
  27616. */
  27617. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27618. /**
  27619. * Does this action manager handles actions of a given trigger
  27620. * @param trigger defines the trigger to be tested
  27621. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27622. * @return whether the trigger is handled
  27623. */
  27624. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27625. /**
  27626. * Serialize this manager to a JSON object
  27627. * @param name defines the property name to store this manager
  27628. * @returns a JSON representation of this manager
  27629. */
  27630. abstract serialize(name: string): any;
  27631. /**
  27632. * Registers an action to this action manager
  27633. * @param action defines the action to be registered
  27634. * @return the action amended (prepared) after registration
  27635. */
  27636. abstract registerAction(action: IAction): Nullable<IAction>;
  27637. /**
  27638. * Unregisters an action to this action manager
  27639. * @param action defines the action to be unregistered
  27640. * @return a boolean indicating whether the action has been unregistered
  27641. */
  27642. abstract unregisterAction(action: IAction): Boolean;
  27643. /**
  27644. * Does exist one action manager with at least one trigger
  27645. **/
  27646. static readonly HasTriggers: boolean;
  27647. /**
  27648. * Does exist one action manager with at least one pick trigger
  27649. **/
  27650. static readonly HasPickTriggers: boolean;
  27651. /**
  27652. * Does exist one action manager that handles actions of a given trigger
  27653. * @param trigger defines the trigger to be tested
  27654. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27655. **/
  27656. static HasSpecificTrigger(trigger: number): boolean;
  27657. }
  27658. }
  27659. declare module "babylonjs/node" {
  27660. import { Scene } from "babylonjs/scene";
  27661. import { Nullable } from "babylonjs/types";
  27662. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27663. import { Engine } from "babylonjs/Engines/engine";
  27664. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27665. import { Observable } from "babylonjs/Misc/observable";
  27666. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27667. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27668. import { Animatable } from "babylonjs/Animations/animatable";
  27669. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27670. import { Animation } from "babylonjs/Animations/animation";
  27671. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27673. /**
  27674. * Defines how a node can be built from a string name.
  27675. */
  27676. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27677. /**
  27678. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27679. */
  27680. export class Node implements IBehaviorAware<Node> {
  27681. /** @hidden */
  27682. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27683. private static _NodeConstructors;
  27684. /**
  27685. * Add a new node constructor
  27686. * @param type defines the type name of the node to construct
  27687. * @param constructorFunc defines the constructor function
  27688. */
  27689. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27690. /**
  27691. * Returns a node constructor based on type name
  27692. * @param type defines the type name
  27693. * @param name defines the new node name
  27694. * @param scene defines the hosting scene
  27695. * @param options defines optional options to transmit to constructors
  27696. * @returns the new constructor or null
  27697. */
  27698. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27699. /**
  27700. * Gets or sets the name of the node
  27701. */
  27702. name: string;
  27703. /**
  27704. * Gets or sets the id of the node
  27705. */
  27706. id: string;
  27707. /**
  27708. * Gets or sets the unique id of the node
  27709. */
  27710. uniqueId: number;
  27711. /**
  27712. * Gets or sets a string used to store user defined state for the node
  27713. */
  27714. state: string;
  27715. /**
  27716. * Gets or sets an object used to store user defined information for the node
  27717. */
  27718. metadata: any;
  27719. /**
  27720. * For internal use only. Please do not use.
  27721. */
  27722. reservedDataStore: any;
  27723. /**
  27724. * List of inspectable custom properties (used by the Inspector)
  27725. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27726. */
  27727. inspectableCustomProperties: IInspectable[];
  27728. private _doNotSerialize;
  27729. /**
  27730. * Gets or sets a boolean used to define if the node must be serialized
  27731. */
  27732. doNotSerialize: boolean;
  27733. /** @hidden */
  27734. _isDisposed: boolean;
  27735. /**
  27736. * Gets a list of Animations associated with the node
  27737. */
  27738. animations: import("babylonjs/Animations/animation").Animation[];
  27739. protected _ranges: {
  27740. [name: string]: Nullable<AnimationRange>;
  27741. };
  27742. /**
  27743. * Callback raised when the node is ready to be used
  27744. */
  27745. onReady: Nullable<(node: Node) => void>;
  27746. private _isEnabled;
  27747. private _isParentEnabled;
  27748. private _isReady;
  27749. /** @hidden */
  27750. _currentRenderId: number;
  27751. private _parentUpdateId;
  27752. /** @hidden */
  27753. _childUpdateId: number;
  27754. /** @hidden */
  27755. _waitingParentId: Nullable<string>;
  27756. /** @hidden */
  27757. _scene: Scene;
  27758. /** @hidden */
  27759. _cache: any;
  27760. private _parentNode;
  27761. private _children;
  27762. /** @hidden */
  27763. _worldMatrix: Matrix;
  27764. /** @hidden */
  27765. _worldMatrixDeterminant: number;
  27766. /** @hidden */
  27767. _worldMatrixDeterminantIsDirty: boolean;
  27768. /** @hidden */
  27769. private _sceneRootNodesIndex;
  27770. /**
  27771. * Gets a boolean indicating if the node has been disposed
  27772. * @returns true if the node was disposed
  27773. */
  27774. isDisposed(): boolean;
  27775. /**
  27776. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27777. * @see https://doc.babylonjs.com/how_to/parenting
  27778. */
  27779. parent: Nullable<Node>;
  27780. private addToSceneRootNodes;
  27781. private removeFromSceneRootNodes;
  27782. private _animationPropertiesOverride;
  27783. /**
  27784. * Gets or sets the animation properties override
  27785. */
  27786. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27787. /**
  27788. * Gets a string idenfifying the name of the class
  27789. * @returns "Node" string
  27790. */
  27791. getClassName(): string;
  27792. /** @hidden */
  27793. readonly _isNode: boolean;
  27794. /**
  27795. * An event triggered when the mesh is disposed
  27796. */
  27797. onDisposeObservable: Observable<Node>;
  27798. private _onDisposeObserver;
  27799. /**
  27800. * Sets a callback that will be raised when the node will be disposed
  27801. */
  27802. onDispose: () => void;
  27803. /**
  27804. * Creates a new Node
  27805. * @param name the name and id to be given to this node
  27806. * @param scene the scene this node will be added to
  27807. * @param addToRootNodes the node will be added to scene.rootNodes
  27808. */
  27809. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27810. /**
  27811. * Gets the scene of the node
  27812. * @returns a scene
  27813. */
  27814. getScene(): Scene;
  27815. /**
  27816. * Gets the engine of the node
  27817. * @returns a Engine
  27818. */
  27819. getEngine(): Engine;
  27820. private _behaviors;
  27821. /**
  27822. * Attach a behavior to the node
  27823. * @see http://doc.babylonjs.com/features/behaviour
  27824. * @param behavior defines the behavior to attach
  27825. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27826. * @returns the current Node
  27827. */
  27828. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27829. /**
  27830. * Remove an attached behavior
  27831. * @see http://doc.babylonjs.com/features/behaviour
  27832. * @param behavior defines the behavior to attach
  27833. * @returns the current Node
  27834. */
  27835. removeBehavior(behavior: Behavior<Node>): Node;
  27836. /**
  27837. * Gets the list of attached behaviors
  27838. * @see http://doc.babylonjs.com/features/behaviour
  27839. */
  27840. readonly behaviors: Behavior<Node>[];
  27841. /**
  27842. * Gets an attached behavior by name
  27843. * @param name defines the name of the behavior to look for
  27844. * @see http://doc.babylonjs.com/features/behaviour
  27845. * @returns null if behavior was not found else the requested behavior
  27846. */
  27847. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27848. /**
  27849. * Returns the latest update of the World matrix
  27850. * @returns a Matrix
  27851. */
  27852. getWorldMatrix(): Matrix;
  27853. /** @hidden */
  27854. _getWorldMatrixDeterminant(): number;
  27855. /**
  27856. * Returns directly the latest state of the mesh World matrix.
  27857. * A Matrix is returned.
  27858. */
  27859. readonly worldMatrixFromCache: Matrix;
  27860. /** @hidden */
  27861. _initCache(): void;
  27862. /** @hidden */
  27863. updateCache(force?: boolean): void;
  27864. /** @hidden */
  27865. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27866. /** @hidden */
  27867. _updateCache(ignoreParentClass?: boolean): void;
  27868. /** @hidden */
  27869. _isSynchronized(): boolean;
  27870. /** @hidden */
  27871. _markSyncedWithParent(): void;
  27872. /** @hidden */
  27873. isSynchronizedWithParent(): boolean;
  27874. /** @hidden */
  27875. isSynchronized(): boolean;
  27876. /**
  27877. * Is this node ready to be used/rendered
  27878. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27879. * @return true if the node is ready
  27880. */
  27881. isReady(completeCheck?: boolean): boolean;
  27882. /**
  27883. * Is this node enabled?
  27884. * 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
  27885. * @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
  27886. * @return whether this node (and its parent) is enabled
  27887. */
  27888. isEnabled(checkAncestors?: boolean): boolean;
  27889. /** @hidden */
  27890. protected _syncParentEnabledState(): void;
  27891. /**
  27892. * Set the enabled state of this node
  27893. * @param value defines the new enabled state
  27894. */
  27895. setEnabled(value: boolean): void;
  27896. /**
  27897. * Is this node a descendant of the given node?
  27898. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27899. * @param ancestor defines the parent node to inspect
  27900. * @returns a boolean indicating if this node is a descendant of the given node
  27901. */
  27902. isDescendantOf(ancestor: Node): boolean;
  27903. /** @hidden */
  27904. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27905. /**
  27906. * Will return all nodes that have this node as ascendant
  27907. * @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
  27908. * @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
  27909. * @return all children nodes of all types
  27910. */
  27911. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27912. /**
  27913. * Get all child-meshes of this node
  27914. * @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)
  27915. * @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
  27916. * @returns an array of AbstractMesh
  27917. */
  27918. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27919. /**
  27920. * Get all direct children of this node
  27921. * @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
  27922. * @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)
  27923. * @returns an array of Node
  27924. */
  27925. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27926. /** @hidden */
  27927. _setReady(state: boolean): void;
  27928. /**
  27929. * Get an animation by name
  27930. * @param name defines the name of the animation to look for
  27931. * @returns null if not found else the requested animation
  27932. */
  27933. getAnimationByName(name: string): Nullable<Animation>;
  27934. /**
  27935. * Creates an animation range for this node
  27936. * @param name defines the name of the range
  27937. * @param from defines the starting key
  27938. * @param to defines the end key
  27939. */
  27940. createAnimationRange(name: string, from: number, to: number): void;
  27941. /**
  27942. * Delete a specific animation range
  27943. * @param name defines the name of the range to delete
  27944. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27945. */
  27946. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27947. /**
  27948. * Get an animation range by name
  27949. * @param name defines the name of the animation range to look for
  27950. * @returns null if not found else the requested animation range
  27951. */
  27952. getAnimationRange(name: string): Nullable<AnimationRange>;
  27953. /**
  27954. * Gets the list of all animation ranges defined on this node
  27955. * @returns an array
  27956. */
  27957. getAnimationRanges(): Nullable<AnimationRange>[];
  27958. /**
  27959. * Will start the animation sequence
  27960. * @param name defines the range frames for animation sequence
  27961. * @param loop defines if the animation should loop (false by default)
  27962. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27963. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27964. * @returns the object created for this animation. If range does not exist, it will return null
  27965. */
  27966. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27967. /**
  27968. * Serialize animation ranges into a JSON compatible object
  27969. * @returns serialization object
  27970. */
  27971. serializeAnimationRanges(): any;
  27972. /**
  27973. * Computes the world matrix of the node
  27974. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27975. * @returns the world matrix
  27976. */
  27977. computeWorldMatrix(force?: boolean): Matrix;
  27978. /**
  27979. * Releases resources associated with this node.
  27980. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27981. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27982. */
  27983. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27984. /**
  27985. * Parse animation range data from a serialization object and store them into a given node
  27986. * @param node defines where to store the animation ranges
  27987. * @param parsedNode defines the serialization object to read data from
  27988. * @param scene defines the hosting scene
  27989. */
  27990. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27991. /**
  27992. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27993. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27994. * @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
  27995. * @returns the new bounding vectors
  27996. */
  27997. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27998. min: Vector3;
  27999. max: Vector3;
  28000. };
  28001. }
  28002. }
  28003. declare module "babylonjs/Animations/animation" {
  28004. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28005. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28006. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28007. import { Nullable } from "babylonjs/types";
  28008. import { Scene } from "babylonjs/scene";
  28009. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28010. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28011. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28012. import { Node } from "babylonjs/node";
  28013. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28014. import { Size } from "babylonjs/Maths/math.size";
  28015. import { Animatable } from "babylonjs/Animations/animatable";
  28016. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28017. /**
  28018. * @hidden
  28019. */
  28020. export class _IAnimationState {
  28021. key: number;
  28022. repeatCount: number;
  28023. workValue?: any;
  28024. loopMode?: number;
  28025. offsetValue?: any;
  28026. highLimitValue?: any;
  28027. }
  28028. /**
  28029. * Class used to store any kind of animation
  28030. */
  28031. export class Animation {
  28032. /**Name of the animation */
  28033. name: string;
  28034. /**Property to animate */
  28035. targetProperty: string;
  28036. /**The frames per second of the animation */
  28037. framePerSecond: number;
  28038. /**The data type of the animation */
  28039. dataType: number;
  28040. /**The loop mode of the animation */
  28041. loopMode?: number | undefined;
  28042. /**Specifies if blending should be enabled */
  28043. enableBlending?: boolean | undefined;
  28044. /**
  28045. * Use matrix interpolation instead of using direct key value when animating matrices
  28046. */
  28047. static AllowMatricesInterpolation: boolean;
  28048. /**
  28049. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28050. */
  28051. static AllowMatrixDecomposeForInterpolation: boolean;
  28052. /**
  28053. * Stores the key frames of the animation
  28054. */
  28055. private _keys;
  28056. /**
  28057. * Stores the easing function of the animation
  28058. */
  28059. private _easingFunction;
  28060. /**
  28061. * @hidden Internal use only
  28062. */
  28063. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28064. /**
  28065. * The set of event that will be linked to this animation
  28066. */
  28067. private _events;
  28068. /**
  28069. * Stores an array of target property paths
  28070. */
  28071. targetPropertyPath: string[];
  28072. /**
  28073. * Stores the blending speed of the animation
  28074. */
  28075. blendingSpeed: number;
  28076. /**
  28077. * Stores the animation ranges for the animation
  28078. */
  28079. private _ranges;
  28080. /**
  28081. * @hidden Internal use
  28082. */
  28083. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28084. /**
  28085. * Sets up an animation
  28086. * @param property The property to animate
  28087. * @param animationType The animation type to apply
  28088. * @param framePerSecond The frames per second of the animation
  28089. * @param easingFunction The easing function used in the animation
  28090. * @returns The created animation
  28091. */
  28092. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28093. /**
  28094. * Create and start an animation on a node
  28095. * @param name defines the name of the global animation that will be run on all nodes
  28096. * @param node defines the root node where the animation will take place
  28097. * @param targetProperty defines property to animate
  28098. * @param framePerSecond defines the number of frame per second yo use
  28099. * @param totalFrame defines the number of frames in total
  28100. * @param from defines the initial value
  28101. * @param to defines the final value
  28102. * @param loopMode defines which loop mode you want to use (off by default)
  28103. * @param easingFunction defines the easing function to use (linear by default)
  28104. * @param onAnimationEnd defines the callback to call when animation end
  28105. * @returns the animatable created for this animation
  28106. */
  28107. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28108. /**
  28109. * Create and start an animation on a node and its descendants
  28110. * @param name defines the name of the global animation that will be run on all nodes
  28111. * @param node defines the root node where the animation will take place
  28112. * @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
  28113. * @param targetProperty defines property to animate
  28114. * @param framePerSecond defines the number of frame per second to use
  28115. * @param totalFrame defines the number of frames in total
  28116. * @param from defines the initial value
  28117. * @param to defines the final value
  28118. * @param loopMode defines which loop mode you want to use (off by default)
  28119. * @param easingFunction defines the easing function to use (linear by default)
  28120. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28121. * @returns the list of animatables created for all nodes
  28122. * @example https://www.babylonjs-playground.com/#MH0VLI
  28123. */
  28124. 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[]>;
  28125. /**
  28126. * Creates a new animation, merges it with the existing animations and starts it
  28127. * @param name Name of the animation
  28128. * @param node Node which contains the scene that begins the animations
  28129. * @param targetProperty Specifies which property to animate
  28130. * @param framePerSecond The frames per second of the animation
  28131. * @param totalFrame The total number of frames
  28132. * @param from The frame at the beginning of the animation
  28133. * @param to The frame at the end of the animation
  28134. * @param loopMode Specifies the loop mode of the animation
  28135. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28136. * @param onAnimationEnd Callback to run once the animation is complete
  28137. * @returns Nullable animation
  28138. */
  28139. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28140. /**
  28141. * Transition property of an host to the target Value
  28142. * @param property The property to transition
  28143. * @param targetValue The target Value of the property
  28144. * @param host The object where the property to animate belongs
  28145. * @param scene Scene used to run the animation
  28146. * @param frameRate Framerate (in frame/s) to use
  28147. * @param transition The transition type we want to use
  28148. * @param duration The duration of the animation, in milliseconds
  28149. * @param onAnimationEnd Callback trigger at the end of the animation
  28150. * @returns Nullable animation
  28151. */
  28152. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28153. /**
  28154. * Return the array of runtime animations currently using this animation
  28155. */
  28156. readonly runtimeAnimations: RuntimeAnimation[];
  28157. /**
  28158. * Specifies if any of the runtime animations are currently running
  28159. */
  28160. readonly hasRunningRuntimeAnimations: boolean;
  28161. /**
  28162. * Initializes the animation
  28163. * @param name Name of the animation
  28164. * @param targetProperty Property to animate
  28165. * @param framePerSecond The frames per second of the animation
  28166. * @param dataType The data type of the animation
  28167. * @param loopMode The loop mode of the animation
  28168. * @param enableBlending Specifies if blending should be enabled
  28169. */
  28170. constructor(
  28171. /**Name of the animation */
  28172. name: string,
  28173. /**Property to animate */
  28174. targetProperty: string,
  28175. /**The frames per second of the animation */
  28176. framePerSecond: number,
  28177. /**The data type of the animation */
  28178. dataType: number,
  28179. /**The loop mode of the animation */
  28180. loopMode?: number | undefined,
  28181. /**Specifies if blending should be enabled */
  28182. enableBlending?: boolean | undefined);
  28183. /**
  28184. * Converts the animation to a string
  28185. * @param fullDetails support for multiple levels of logging within scene loading
  28186. * @returns String form of the animation
  28187. */
  28188. toString(fullDetails?: boolean): string;
  28189. /**
  28190. * Add an event to this animation
  28191. * @param event Event to add
  28192. */
  28193. addEvent(event: AnimationEvent): void;
  28194. /**
  28195. * Remove all events found at the given frame
  28196. * @param frame The frame to remove events from
  28197. */
  28198. removeEvents(frame: number): void;
  28199. /**
  28200. * Retrieves all the events from the animation
  28201. * @returns Events from the animation
  28202. */
  28203. getEvents(): AnimationEvent[];
  28204. /**
  28205. * Creates an animation range
  28206. * @param name Name of the animation range
  28207. * @param from Starting frame of the animation range
  28208. * @param to Ending frame of the animation
  28209. */
  28210. createRange(name: string, from: number, to: number): void;
  28211. /**
  28212. * Deletes an animation range by name
  28213. * @param name Name of the animation range to delete
  28214. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28215. */
  28216. deleteRange(name: string, deleteFrames?: boolean): void;
  28217. /**
  28218. * Gets the animation range by name, or null if not defined
  28219. * @param name Name of the animation range
  28220. * @returns Nullable animation range
  28221. */
  28222. getRange(name: string): Nullable<AnimationRange>;
  28223. /**
  28224. * Gets the key frames from the animation
  28225. * @returns The key frames of the animation
  28226. */
  28227. getKeys(): Array<IAnimationKey>;
  28228. /**
  28229. * Gets the highest frame rate of the animation
  28230. * @returns Highest frame rate of the animation
  28231. */
  28232. getHighestFrame(): number;
  28233. /**
  28234. * Gets the easing function of the animation
  28235. * @returns Easing function of the animation
  28236. */
  28237. getEasingFunction(): IEasingFunction;
  28238. /**
  28239. * Sets the easing function of the animation
  28240. * @param easingFunction A custom mathematical formula for animation
  28241. */
  28242. setEasingFunction(easingFunction: EasingFunction): void;
  28243. /**
  28244. * Interpolates a scalar linearly
  28245. * @param startValue Start value of the animation curve
  28246. * @param endValue End value of the animation curve
  28247. * @param gradient Scalar amount to interpolate
  28248. * @returns Interpolated scalar value
  28249. */
  28250. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28251. /**
  28252. * Interpolates a scalar cubically
  28253. * @param startValue Start value of the animation curve
  28254. * @param outTangent End tangent of the animation
  28255. * @param endValue End value of the animation curve
  28256. * @param inTangent Start tangent of the animation curve
  28257. * @param gradient Scalar amount to interpolate
  28258. * @returns Interpolated scalar value
  28259. */
  28260. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28261. /**
  28262. * Interpolates a quaternion using a spherical linear interpolation
  28263. * @param startValue Start value of the animation curve
  28264. * @param endValue End value of the animation curve
  28265. * @param gradient Scalar amount to interpolate
  28266. * @returns Interpolated quaternion value
  28267. */
  28268. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28269. /**
  28270. * Interpolates a quaternion cubically
  28271. * @param startValue Start value of the animation curve
  28272. * @param outTangent End tangent of the animation curve
  28273. * @param endValue End value of the animation curve
  28274. * @param inTangent Start tangent of the animation curve
  28275. * @param gradient Scalar amount to interpolate
  28276. * @returns Interpolated quaternion value
  28277. */
  28278. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28279. /**
  28280. * Interpolates a Vector3 linearl
  28281. * @param startValue Start value of the animation curve
  28282. * @param endValue End value of the animation curve
  28283. * @param gradient Scalar amount to interpolate
  28284. * @returns Interpolated scalar value
  28285. */
  28286. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28287. /**
  28288. * Interpolates a Vector3 cubically
  28289. * @param startValue Start value of the animation curve
  28290. * @param outTangent End tangent of the animation
  28291. * @param endValue End value of the animation curve
  28292. * @param inTangent Start tangent of the animation curve
  28293. * @param gradient Scalar amount to interpolate
  28294. * @returns InterpolatedVector3 value
  28295. */
  28296. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28297. /**
  28298. * Interpolates a Vector2 linearly
  28299. * @param startValue Start value of the animation curve
  28300. * @param endValue End value of the animation curve
  28301. * @param gradient Scalar amount to interpolate
  28302. * @returns Interpolated Vector2 value
  28303. */
  28304. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28305. /**
  28306. * Interpolates a Vector2 cubically
  28307. * @param startValue Start value of the animation curve
  28308. * @param outTangent End tangent of the animation
  28309. * @param endValue End value of the animation curve
  28310. * @param inTangent Start tangent of the animation curve
  28311. * @param gradient Scalar amount to interpolate
  28312. * @returns Interpolated Vector2 value
  28313. */
  28314. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28315. /**
  28316. * Interpolates a size linearly
  28317. * @param startValue Start value of the animation curve
  28318. * @param endValue End value of the animation curve
  28319. * @param gradient Scalar amount to interpolate
  28320. * @returns Interpolated Size value
  28321. */
  28322. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28323. /**
  28324. * Interpolates a Color3 linearly
  28325. * @param startValue Start value of the animation curve
  28326. * @param endValue End value of the animation curve
  28327. * @param gradient Scalar amount to interpolate
  28328. * @returns Interpolated Color3 value
  28329. */
  28330. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28331. /**
  28332. * Interpolates a Color4 linearly
  28333. * @param startValue Start value of the animation curve
  28334. * @param endValue End value of the animation curve
  28335. * @param gradient Scalar amount to interpolate
  28336. * @returns Interpolated Color3 value
  28337. */
  28338. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28339. /**
  28340. * @hidden Internal use only
  28341. */
  28342. _getKeyValue(value: any): any;
  28343. /**
  28344. * @hidden Internal use only
  28345. */
  28346. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28347. /**
  28348. * Defines the function to use to interpolate matrices
  28349. * @param startValue defines the start matrix
  28350. * @param endValue defines the end matrix
  28351. * @param gradient defines the gradient between both matrices
  28352. * @param result defines an optional target matrix where to store the interpolation
  28353. * @returns the interpolated matrix
  28354. */
  28355. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28356. /**
  28357. * Makes a copy of the animation
  28358. * @returns Cloned animation
  28359. */
  28360. clone(): Animation;
  28361. /**
  28362. * Sets the key frames of the animation
  28363. * @param values The animation key frames to set
  28364. */
  28365. setKeys(values: Array<IAnimationKey>): void;
  28366. /**
  28367. * Serializes the animation to an object
  28368. * @returns Serialized object
  28369. */
  28370. serialize(): any;
  28371. /**
  28372. * Float animation type
  28373. */
  28374. static readonly ANIMATIONTYPE_FLOAT: number;
  28375. /**
  28376. * Vector3 animation type
  28377. */
  28378. static readonly ANIMATIONTYPE_VECTOR3: number;
  28379. /**
  28380. * Quaternion animation type
  28381. */
  28382. static readonly ANIMATIONTYPE_QUATERNION: number;
  28383. /**
  28384. * Matrix animation type
  28385. */
  28386. static readonly ANIMATIONTYPE_MATRIX: number;
  28387. /**
  28388. * Color3 animation type
  28389. */
  28390. static readonly ANIMATIONTYPE_COLOR3: number;
  28391. /**
  28392. * Color3 animation type
  28393. */
  28394. static readonly ANIMATIONTYPE_COLOR4: number;
  28395. /**
  28396. * Vector2 animation type
  28397. */
  28398. static readonly ANIMATIONTYPE_VECTOR2: number;
  28399. /**
  28400. * Size animation type
  28401. */
  28402. static readonly ANIMATIONTYPE_SIZE: number;
  28403. /**
  28404. * Relative Loop Mode
  28405. */
  28406. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28407. /**
  28408. * Cycle Loop Mode
  28409. */
  28410. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28411. /**
  28412. * Constant Loop Mode
  28413. */
  28414. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28415. /** @hidden */
  28416. static _UniversalLerp(left: any, right: any, amount: number): any;
  28417. /**
  28418. * Parses an animation object and creates an animation
  28419. * @param parsedAnimation Parsed animation object
  28420. * @returns Animation object
  28421. */
  28422. static Parse(parsedAnimation: any): Animation;
  28423. /**
  28424. * Appends the serialized animations from the source animations
  28425. * @param source Source containing the animations
  28426. * @param destination Target to store the animations
  28427. */
  28428. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28429. }
  28430. }
  28431. declare module "babylonjs/Animations/animatable.interface" {
  28432. import { Nullable } from "babylonjs/types";
  28433. import { Animation } from "babylonjs/Animations/animation";
  28434. /**
  28435. * Interface containing an array of animations
  28436. */
  28437. export interface IAnimatable {
  28438. /**
  28439. * Array of animations
  28440. */
  28441. animations: Nullable<Array<Animation>>;
  28442. }
  28443. }
  28444. declare module "babylonjs/Materials/fresnelParameters" {
  28445. import { Color3 } from "babylonjs/Maths/math.color";
  28446. /**
  28447. * This represents all the required information to add a fresnel effect on a material:
  28448. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28449. */
  28450. export class FresnelParameters {
  28451. private _isEnabled;
  28452. /**
  28453. * Define if the fresnel effect is enable or not.
  28454. */
  28455. isEnabled: boolean;
  28456. /**
  28457. * Define the color used on edges (grazing angle)
  28458. */
  28459. leftColor: Color3;
  28460. /**
  28461. * Define the color used on center
  28462. */
  28463. rightColor: Color3;
  28464. /**
  28465. * Define bias applied to computed fresnel term
  28466. */
  28467. bias: number;
  28468. /**
  28469. * Defined the power exponent applied to fresnel term
  28470. */
  28471. power: number;
  28472. /**
  28473. * Clones the current fresnel and its valuues
  28474. * @returns a clone fresnel configuration
  28475. */
  28476. clone(): FresnelParameters;
  28477. /**
  28478. * Serializes the current fresnel parameters to a JSON representation.
  28479. * @return the JSON serialization
  28480. */
  28481. serialize(): any;
  28482. /**
  28483. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28484. * @param parsedFresnelParameters Define the JSON representation
  28485. * @returns the parsed parameters
  28486. */
  28487. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28488. }
  28489. }
  28490. declare module "babylonjs/Misc/decorators" {
  28491. import { Nullable } from "babylonjs/types";
  28492. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28493. import { Scene } from "babylonjs/scene";
  28494. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28495. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28496. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28497. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28498. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28499. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28500. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28501. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28502. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28503. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28504. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28505. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28506. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28507. /**
  28508. * Decorator used to define property that can be serialized as reference to a camera
  28509. * @param sourceName defines the name of the property to decorate
  28510. */
  28511. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28512. /**
  28513. * Class used to help serialization objects
  28514. */
  28515. export class SerializationHelper {
  28516. /** @hidden */
  28517. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28518. /** @hidden */
  28519. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28520. /** @hidden */
  28521. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28522. /** @hidden */
  28523. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28524. /**
  28525. * Appends the serialized animations from the source animations
  28526. * @param source Source containing the animations
  28527. * @param destination Target to store the animations
  28528. */
  28529. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28530. /**
  28531. * Static function used to serialized a specific entity
  28532. * @param entity defines the entity to serialize
  28533. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28534. * @returns a JSON compatible object representing the serialization of the entity
  28535. */
  28536. static Serialize<T>(entity: T, serializationObject?: any): any;
  28537. /**
  28538. * Creates a new entity from a serialization data object
  28539. * @param creationFunction defines a function used to instanciated the new entity
  28540. * @param source defines the source serialization data
  28541. * @param scene defines the hosting scene
  28542. * @param rootUrl defines the root url for resources
  28543. * @returns a new entity
  28544. */
  28545. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28546. /**
  28547. * Clones an object
  28548. * @param creationFunction defines the function used to instanciate the new object
  28549. * @param source defines the source object
  28550. * @returns the cloned object
  28551. */
  28552. static Clone<T>(creationFunction: () => T, source: T): T;
  28553. /**
  28554. * Instanciates a new object based on a source one (some data will be shared between both object)
  28555. * @param creationFunction defines the function used to instanciate the new object
  28556. * @param source defines the source object
  28557. * @returns the new object
  28558. */
  28559. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28560. }
  28561. }
  28562. declare module "babylonjs/Misc/guid" {
  28563. /**
  28564. * Class used to manipulate GUIDs
  28565. */
  28566. export class GUID {
  28567. /**
  28568. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28569. * Be aware Math.random() could cause collisions, but:
  28570. * "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"
  28571. * @returns a pseudo random id
  28572. */
  28573. static RandomId(): string;
  28574. }
  28575. }
  28576. declare module "babylonjs/Materials/Textures/baseTexture" {
  28577. import { Observable } from "babylonjs/Misc/observable";
  28578. import { Nullable } from "babylonjs/types";
  28579. import { Scene } from "babylonjs/scene";
  28580. import { Matrix } from "babylonjs/Maths/math.vector";
  28581. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28582. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28583. import { ISize } from "babylonjs/Maths/math.size";
  28584. /**
  28585. * Base class of all the textures in babylon.
  28586. * It groups all the common properties the materials, post process, lights... might need
  28587. * in order to make a correct use of the texture.
  28588. */
  28589. export class BaseTexture implements IAnimatable {
  28590. /**
  28591. * Default anisotropic filtering level for the application.
  28592. * It is set to 4 as a good tradeoff between perf and quality.
  28593. */
  28594. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28595. /**
  28596. * Gets or sets the unique id of the texture
  28597. */
  28598. uniqueId: number;
  28599. /**
  28600. * Define the name of the texture.
  28601. */
  28602. name: string;
  28603. /**
  28604. * Gets or sets an object used to store user defined information.
  28605. */
  28606. metadata: any;
  28607. /**
  28608. * For internal use only. Please do not use.
  28609. */
  28610. reservedDataStore: any;
  28611. private _hasAlpha;
  28612. /**
  28613. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28614. */
  28615. hasAlpha: boolean;
  28616. /**
  28617. * Defines if the alpha value should be determined via the rgb values.
  28618. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28619. */
  28620. getAlphaFromRGB: boolean;
  28621. /**
  28622. * Intensity or strength of the texture.
  28623. * It is commonly used by materials to fine tune the intensity of the texture
  28624. */
  28625. level: number;
  28626. /**
  28627. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28628. * This is part of the texture as textures usually maps to one uv set.
  28629. */
  28630. coordinatesIndex: number;
  28631. private _coordinatesMode;
  28632. /**
  28633. * How a texture is mapped.
  28634. *
  28635. * | Value | Type | Description |
  28636. * | ----- | ----------------------------------- | ----------- |
  28637. * | 0 | EXPLICIT_MODE | |
  28638. * | 1 | SPHERICAL_MODE | |
  28639. * | 2 | PLANAR_MODE | |
  28640. * | 3 | CUBIC_MODE | |
  28641. * | 4 | PROJECTION_MODE | |
  28642. * | 5 | SKYBOX_MODE | |
  28643. * | 6 | INVCUBIC_MODE | |
  28644. * | 7 | EQUIRECTANGULAR_MODE | |
  28645. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28646. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28647. */
  28648. coordinatesMode: number;
  28649. /**
  28650. * | Value | Type | Description |
  28651. * | ----- | ------------------ | ----------- |
  28652. * | 0 | CLAMP_ADDRESSMODE | |
  28653. * | 1 | WRAP_ADDRESSMODE | |
  28654. * | 2 | MIRROR_ADDRESSMODE | |
  28655. */
  28656. wrapU: number;
  28657. /**
  28658. * | Value | Type | Description |
  28659. * | ----- | ------------------ | ----------- |
  28660. * | 0 | CLAMP_ADDRESSMODE | |
  28661. * | 1 | WRAP_ADDRESSMODE | |
  28662. * | 2 | MIRROR_ADDRESSMODE | |
  28663. */
  28664. wrapV: number;
  28665. /**
  28666. * | Value | Type | Description |
  28667. * | ----- | ------------------ | ----------- |
  28668. * | 0 | CLAMP_ADDRESSMODE | |
  28669. * | 1 | WRAP_ADDRESSMODE | |
  28670. * | 2 | MIRROR_ADDRESSMODE | |
  28671. */
  28672. wrapR: number;
  28673. /**
  28674. * With compliant hardware and browser (supporting anisotropic filtering)
  28675. * this defines the level of anisotropic filtering in the texture.
  28676. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28677. */
  28678. anisotropicFilteringLevel: number;
  28679. /**
  28680. * Define if the texture is a cube texture or if false a 2d texture.
  28681. */
  28682. isCube: boolean;
  28683. /**
  28684. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28685. */
  28686. is3D: boolean;
  28687. /**
  28688. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28689. * HDR texture are usually stored in linear space.
  28690. * This only impacts the PBR and Background materials
  28691. */
  28692. gammaSpace: boolean;
  28693. /**
  28694. * Gets or sets whether or not the texture contains RGBD data.
  28695. */
  28696. isRGBD: boolean;
  28697. /**
  28698. * Is Z inverted in the texture (useful in a cube texture).
  28699. */
  28700. invertZ: boolean;
  28701. /**
  28702. * Are mip maps generated for this texture or not.
  28703. */
  28704. readonly noMipmap: boolean;
  28705. /**
  28706. * @hidden
  28707. */
  28708. lodLevelInAlpha: boolean;
  28709. /**
  28710. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28711. */
  28712. lodGenerationOffset: number;
  28713. /**
  28714. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28715. */
  28716. lodGenerationScale: number;
  28717. /**
  28718. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28719. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28720. * average roughness values.
  28721. */
  28722. linearSpecularLOD: boolean;
  28723. /**
  28724. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28725. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28726. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28727. */
  28728. irradianceTexture: Nullable<BaseTexture>;
  28729. /**
  28730. * Define if the texture is a render target.
  28731. */
  28732. isRenderTarget: boolean;
  28733. /**
  28734. * Define the unique id of the texture in the scene.
  28735. */
  28736. readonly uid: string;
  28737. /**
  28738. * Return a string representation of the texture.
  28739. * @returns the texture as a string
  28740. */
  28741. toString(): string;
  28742. /**
  28743. * Get the class name of the texture.
  28744. * @returns "BaseTexture"
  28745. */
  28746. getClassName(): string;
  28747. /**
  28748. * Define the list of animation attached to the texture.
  28749. */
  28750. animations: import("babylonjs/Animations/animation").Animation[];
  28751. /**
  28752. * An event triggered when the texture is disposed.
  28753. */
  28754. onDisposeObservable: Observable<BaseTexture>;
  28755. private _onDisposeObserver;
  28756. /**
  28757. * Callback triggered when the texture has been disposed.
  28758. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28759. */
  28760. onDispose: () => void;
  28761. /**
  28762. * Define the current state of the loading sequence when in delayed load mode.
  28763. */
  28764. delayLoadState: number;
  28765. private _scene;
  28766. /** @hidden */
  28767. _texture: Nullable<InternalTexture>;
  28768. private _uid;
  28769. /**
  28770. * Define if the texture is preventinga material to render or not.
  28771. * If not and the texture is not ready, the engine will use a default black texture instead.
  28772. */
  28773. readonly isBlocking: boolean;
  28774. /**
  28775. * Instantiates a new BaseTexture.
  28776. * Base class of all the textures in babylon.
  28777. * It groups all the common properties the materials, post process, lights... might need
  28778. * in order to make a correct use of the texture.
  28779. * @param scene Define the scene the texture blongs to
  28780. */
  28781. constructor(scene: Nullable<Scene>);
  28782. /**
  28783. * Get the scene the texture belongs to.
  28784. * @returns the scene or null if undefined
  28785. */
  28786. getScene(): Nullable<Scene>;
  28787. /**
  28788. * Get the texture transform matrix used to offset tile the texture for istance.
  28789. * @returns the transformation matrix
  28790. */
  28791. getTextureMatrix(): Matrix;
  28792. /**
  28793. * Get the texture reflection matrix used to rotate/transform the reflection.
  28794. * @returns the reflection matrix
  28795. */
  28796. getReflectionTextureMatrix(): Matrix;
  28797. /**
  28798. * Get the underlying lower level texture from Babylon.
  28799. * @returns the insternal texture
  28800. */
  28801. getInternalTexture(): Nullable<InternalTexture>;
  28802. /**
  28803. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28804. * @returns true if ready or not blocking
  28805. */
  28806. isReadyOrNotBlocking(): boolean;
  28807. /**
  28808. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28809. * @returns true if fully ready
  28810. */
  28811. isReady(): boolean;
  28812. private _cachedSize;
  28813. /**
  28814. * Get the size of the texture.
  28815. * @returns the texture size.
  28816. */
  28817. getSize(): ISize;
  28818. /**
  28819. * Get the base size of the texture.
  28820. * It can be different from the size if the texture has been resized for POT for instance
  28821. * @returns the base size
  28822. */
  28823. getBaseSize(): ISize;
  28824. /**
  28825. * Update the sampling mode of the texture.
  28826. * Default is Trilinear mode.
  28827. *
  28828. * | Value | Type | Description |
  28829. * | ----- | ------------------ | ----------- |
  28830. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28831. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28832. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28833. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28834. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28835. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28836. * | 7 | NEAREST_LINEAR | |
  28837. * | 8 | NEAREST_NEAREST | |
  28838. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28839. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28840. * | 11 | LINEAR_LINEAR | |
  28841. * | 12 | LINEAR_NEAREST | |
  28842. *
  28843. * > _mag_: magnification filter (close to the viewer)
  28844. * > _min_: minification filter (far from the viewer)
  28845. * > _mip_: filter used between mip map levels
  28846. *@param samplingMode Define the new sampling mode of the texture
  28847. */
  28848. updateSamplingMode(samplingMode: number): void;
  28849. /**
  28850. * Scales the texture if is `canRescale()`
  28851. * @param ratio the resize factor we want to use to rescale
  28852. */
  28853. scale(ratio: number): void;
  28854. /**
  28855. * Get if the texture can rescale.
  28856. */
  28857. readonly canRescale: boolean;
  28858. /** @hidden */
  28859. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28860. /** @hidden */
  28861. _rebuild(): void;
  28862. /**
  28863. * Triggers the load sequence in delayed load mode.
  28864. */
  28865. delayLoad(): void;
  28866. /**
  28867. * Clones the texture.
  28868. * @returns the cloned texture
  28869. */
  28870. clone(): Nullable<BaseTexture>;
  28871. /**
  28872. * Get the texture underlying type (INT, FLOAT...)
  28873. */
  28874. readonly textureType: number;
  28875. /**
  28876. * Get the texture underlying format (RGB, RGBA...)
  28877. */
  28878. readonly textureFormat: number;
  28879. /**
  28880. * Indicates that textures need to be re-calculated for all materials
  28881. */
  28882. protected _markAllSubMeshesAsTexturesDirty(): void;
  28883. /**
  28884. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28885. * This will returns an RGBA array buffer containing either in values (0-255) or
  28886. * float values (0-1) depending of the underlying buffer type.
  28887. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28888. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28889. * @param buffer defines a user defined buffer to fill with data (can be null)
  28890. * @returns The Array buffer containing the pixels data.
  28891. */
  28892. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28893. /**
  28894. * Release and destroy the underlying lower level texture aka internalTexture.
  28895. */
  28896. releaseInternalTexture(): void;
  28897. /** @hidden */
  28898. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28899. /** @hidden */
  28900. readonly _lodTextureMid: Nullable<BaseTexture>;
  28901. /** @hidden */
  28902. readonly _lodTextureLow: Nullable<BaseTexture>;
  28903. /**
  28904. * Dispose the texture and release its associated resources.
  28905. */
  28906. dispose(): void;
  28907. /**
  28908. * Serialize the texture into a JSON representation that can be parsed later on.
  28909. * @returns the JSON representation of the texture
  28910. */
  28911. serialize(): any;
  28912. /**
  28913. * Helper function to be called back once a list of texture contains only ready textures.
  28914. * @param textures Define the list of textures to wait for
  28915. * @param callback Define the callback triggered once the entire list will be ready
  28916. */
  28917. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28918. }
  28919. }
  28920. declare module "babylonjs/Materials/effect" {
  28921. import { Observable } from "babylonjs/Misc/observable";
  28922. import { Nullable } from "babylonjs/types";
  28923. import { IDisposable } from "babylonjs/scene";
  28924. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28925. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28926. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28927. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28928. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28929. import { Engine } from "babylonjs/Engines/engine";
  28930. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28932. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28934. /**
  28935. * Options to be used when creating an effect.
  28936. */
  28937. export interface IEffectCreationOptions {
  28938. /**
  28939. * Atrributes that will be used in the shader.
  28940. */
  28941. attributes: string[];
  28942. /**
  28943. * Uniform varible names that will be set in the shader.
  28944. */
  28945. uniformsNames: string[];
  28946. /**
  28947. * Uniform buffer varible names that will be set in the shader.
  28948. */
  28949. uniformBuffersNames: string[];
  28950. /**
  28951. * Sampler texture variable names that will be set in the shader.
  28952. */
  28953. samplers: string[];
  28954. /**
  28955. * Define statements that will be set in the shader.
  28956. */
  28957. defines: any;
  28958. /**
  28959. * Possible fallbacks for this effect to improve performance when needed.
  28960. */
  28961. fallbacks: Nullable<IEffectFallbacks>;
  28962. /**
  28963. * Callback that will be called when the shader is compiled.
  28964. */
  28965. onCompiled: Nullable<(effect: Effect) => void>;
  28966. /**
  28967. * Callback that will be called if an error occurs during shader compilation.
  28968. */
  28969. onError: Nullable<(effect: Effect, errors: string) => void>;
  28970. /**
  28971. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28972. */
  28973. indexParameters?: any;
  28974. /**
  28975. * Max number of lights that can be used in the shader.
  28976. */
  28977. maxSimultaneousLights?: number;
  28978. /**
  28979. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28980. */
  28981. transformFeedbackVaryings?: Nullable<string[]>;
  28982. }
  28983. /**
  28984. * Effect containing vertex and fragment shader that can be executed on an object.
  28985. */
  28986. export class Effect implements IDisposable {
  28987. /**
  28988. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28989. */
  28990. static ShadersRepository: string;
  28991. /**
  28992. * Name of the effect.
  28993. */
  28994. name: any;
  28995. /**
  28996. * String container all the define statements that should be set on the shader.
  28997. */
  28998. defines: string;
  28999. /**
  29000. * Callback that will be called when the shader is compiled.
  29001. */
  29002. onCompiled: Nullable<(effect: Effect) => void>;
  29003. /**
  29004. * Callback that will be called if an error occurs during shader compilation.
  29005. */
  29006. onError: Nullable<(effect: Effect, errors: string) => void>;
  29007. /**
  29008. * Callback that will be called when effect is bound.
  29009. */
  29010. onBind: Nullable<(effect: Effect) => void>;
  29011. /**
  29012. * Unique ID of the effect.
  29013. */
  29014. uniqueId: number;
  29015. /**
  29016. * Observable that will be called when the shader is compiled.
  29017. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29018. */
  29019. onCompileObservable: Observable<Effect>;
  29020. /**
  29021. * Observable that will be called if an error occurs during shader compilation.
  29022. */
  29023. onErrorObservable: Observable<Effect>;
  29024. /** @hidden */
  29025. _onBindObservable: Nullable<Observable<Effect>>;
  29026. /**
  29027. * Observable that will be called when effect is bound.
  29028. */
  29029. readonly onBindObservable: Observable<Effect>;
  29030. /** @hidden */
  29031. _bonesComputationForcedToCPU: boolean;
  29032. private static _uniqueIdSeed;
  29033. private _engine;
  29034. private _uniformBuffersNames;
  29035. private _uniformsNames;
  29036. private _samplerList;
  29037. private _samplers;
  29038. private _isReady;
  29039. private _compilationError;
  29040. private _allFallbacksProcessed;
  29041. private _attributesNames;
  29042. private _attributes;
  29043. private _uniforms;
  29044. /**
  29045. * Key for the effect.
  29046. * @hidden
  29047. */
  29048. _key: string;
  29049. private _indexParameters;
  29050. private _fallbacks;
  29051. private _vertexSourceCode;
  29052. private _fragmentSourceCode;
  29053. private _vertexSourceCodeOverride;
  29054. private _fragmentSourceCodeOverride;
  29055. private _transformFeedbackVaryings;
  29056. /**
  29057. * Compiled shader to webGL program.
  29058. * @hidden
  29059. */
  29060. _pipelineContext: Nullable<IPipelineContext>;
  29061. private _valueCache;
  29062. private static _baseCache;
  29063. /**
  29064. * Instantiates an effect.
  29065. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29066. * @param baseName Name of the effect.
  29067. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29068. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29069. * @param samplers List of sampler variables that will be passed to the shader.
  29070. * @param engine Engine to be used to render the effect
  29071. * @param defines Define statements to be added to the shader.
  29072. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29073. * @param onCompiled Callback that will be called when the shader is compiled.
  29074. * @param onError Callback that will be called if an error occurs during shader compilation.
  29075. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29076. */
  29077. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, 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);
  29078. private _useFinalCode;
  29079. /**
  29080. * Unique key for this effect
  29081. */
  29082. readonly key: string;
  29083. /**
  29084. * If the effect has been compiled and prepared.
  29085. * @returns if the effect is compiled and prepared.
  29086. */
  29087. isReady(): boolean;
  29088. private _isReadyInternal;
  29089. /**
  29090. * The engine the effect was initialized with.
  29091. * @returns the engine.
  29092. */
  29093. getEngine(): Engine;
  29094. /**
  29095. * The pipeline context for this effect
  29096. * @returns the associated pipeline context
  29097. */
  29098. getPipelineContext(): Nullable<IPipelineContext>;
  29099. /**
  29100. * The set of names of attribute variables for the shader.
  29101. * @returns An array of attribute names.
  29102. */
  29103. getAttributesNames(): string[];
  29104. /**
  29105. * Returns the attribute at the given index.
  29106. * @param index The index of the attribute.
  29107. * @returns The location of the attribute.
  29108. */
  29109. getAttributeLocation(index: number): number;
  29110. /**
  29111. * Returns the attribute based on the name of the variable.
  29112. * @param name of the attribute to look up.
  29113. * @returns the attribute location.
  29114. */
  29115. getAttributeLocationByName(name: string): number;
  29116. /**
  29117. * The number of attributes.
  29118. * @returns the numnber of attributes.
  29119. */
  29120. getAttributesCount(): number;
  29121. /**
  29122. * Gets the index of a uniform variable.
  29123. * @param uniformName of the uniform to look up.
  29124. * @returns the index.
  29125. */
  29126. getUniformIndex(uniformName: string): number;
  29127. /**
  29128. * Returns the attribute based on the name of the variable.
  29129. * @param uniformName of the uniform to look up.
  29130. * @returns the location of the uniform.
  29131. */
  29132. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29133. /**
  29134. * Returns an array of sampler variable names
  29135. * @returns The array of sampler variable neames.
  29136. */
  29137. getSamplers(): string[];
  29138. /**
  29139. * The error from the last compilation.
  29140. * @returns the error string.
  29141. */
  29142. getCompilationError(): string;
  29143. /**
  29144. * Gets a boolean indicating that all fallbacks were used during compilation
  29145. * @returns true if all fallbacks were used
  29146. */
  29147. allFallbacksProcessed(): boolean;
  29148. /**
  29149. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29150. * @param func The callback to be used.
  29151. */
  29152. executeWhenCompiled(func: (effect: Effect) => void): void;
  29153. private _checkIsReady;
  29154. private _loadShader;
  29155. /**
  29156. * Recompiles the webGL program
  29157. * @param vertexSourceCode The source code for the vertex shader.
  29158. * @param fragmentSourceCode The source code for the fragment shader.
  29159. * @param onCompiled Callback called when completed.
  29160. * @param onError Callback called on error.
  29161. * @hidden
  29162. */
  29163. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29164. /**
  29165. * Prepares the effect
  29166. * @hidden
  29167. */
  29168. _prepareEffect(): void;
  29169. private _processCompilationErrors;
  29170. /**
  29171. * Checks if the effect is supported. (Must be called after compilation)
  29172. */
  29173. readonly isSupported: boolean;
  29174. /**
  29175. * Binds a texture to the engine to be used as output of the shader.
  29176. * @param channel Name of the output variable.
  29177. * @param texture Texture to bind.
  29178. * @hidden
  29179. */
  29180. _bindTexture(channel: string, texture: InternalTexture): void;
  29181. /**
  29182. * Sets a texture on the engine to be used in the shader.
  29183. * @param channel Name of the sampler variable.
  29184. * @param texture Texture to set.
  29185. */
  29186. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29187. /**
  29188. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29189. * @param channel Name of the sampler variable.
  29190. * @param texture Texture to set.
  29191. */
  29192. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29193. /**
  29194. * Sets an array of textures on the engine to be used in the shader.
  29195. * @param channel Name of the variable.
  29196. * @param textures Textures to set.
  29197. */
  29198. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29199. /**
  29200. * 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)
  29201. * @param channel Name of the sampler variable.
  29202. * @param postProcess Post process to get the input texture from.
  29203. */
  29204. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29205. /**
  29206. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29207. * 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)
  29208. * @param channel Name of the sampler variable.
  29209. * @param postProcess Post process to get the output texture from.
  29210. */
  29211. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29212. /** @hidden */
  29213. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29214. /** @hidden */
  29215. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29216. /** @hidden */
  29217. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29218. /** @hidden */
  29219. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29220. /**
  29221. * Binds a buffer to a uniform.
  29222. * @param buffer Buffer to bind.
  29223. * @param name Name of the uniform variable to bind to.
  29224. */
  29225. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29226. /**
  29227. * Binds block to a uniform.
  29228. * @param blockName Name of the block to bind.
  29229. * @param index Index to bind.
  29230. */
  29231. bindUniformBlock(blockName: string, index: number): void;
  29232. /**
  29233. * Sets an interger value on a uniform variable.
  29234. * @param uniformName Name of the variable.
  29235. * @param value Value to be set.
  29236. * @returns this effect.
  29237. */
  29238. setInt(uniformName: string, value: number): Effect;
  29239. /**
  29240. * Sets an int array on a uniform variable.
  29241. * @param uniformName Name of the variable.
  29242. * @param array array to be set.
  29243. * @returns this effect.
  29244. */
  29245. setIntArray(uniformName: string, array: Int32Array): Effect;
  29246. /**
  29247. * 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)
  29248. * @param uniformName Name of the variable.
  29249. * @param array array to be set.
  29250. * @returns this effect.
  29251. */
  29252. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29253. /**
  29254. * 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)
  29255. * @param uniformName Name of the variable.
  29256. * @param array array to be set.
  29257. * @returns this effect.
  29258. */
  29259. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29260. /**
  29261. * 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)
  29262. * @param uniformName Name of the variable.
  29263. * @param array array to be set.
  29264. * @returns this effect.
  29265. */
  29266. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29267. /**
  29268. * Sets an float array on a uniform variable.
  29269. * @param uniformName Name of the variable.
  29270. * @param array array to be set.
  29271. * @returns this effect.
  29272. */
  29273. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29274. /**
  29275. * 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)
  29276. * @param uniformName Name of the variable.
  29277. * @param array array to be set.
  29278. * @returns this effect.
  29279. */
  29280. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29281. /**
  29282. * 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)
  29283. * @param uniformName Name of the variable.
  29284. * @param array array to be set.
  29285. * @returns this effect.
  29286. */
  29287. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29288. /**
  29289. * 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)
  29290. * @param uniformName Name of the variable.
  29291. * @param array array to be set.
  29292. * @returns this effect.
  29293. */
  29294. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29295. /**
  29296. * Sets an array on a uniform variable.
  29297. * @param uniformName Name of the variable.
  29298. * @param array array to be set.
  29299. * @returns this effect.
  29300. */
  29301. setArray(uniformName: string, array: number[]): Effect;
  29302. /**
  29303. * 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)
  29304. * @param uniformName Name of the variable.
  29305. * @param array array to be set.
  29306. * @returns this effect.
  29307. */
  29308. setArray2(uniformName: string, array: number[]): Effect;
  29309. /**
  29310. * 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)
  29311. * @param uniformName Name of the variable.
  29312. * @param array array to be set.
  29313. * @returns this effect.
  29314. */
  29315. setArray3(uniformName: string, array: number[]): Effect;
  29316. /**
  29317. * 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)
  29318. * @param uniformName Name of the variable.
  29319. * @param array array to be set.
  29320. * @returns this effect.
  29321. */
  29322. setArray4(uniformName: string, array: number[]): Effect;
  29323. /**
  29324. * Sets matrices on a uniform variable.
  29325. * @param uniformName Name of the variable.
  29326. * @param matrices matrices to be set.
  29327. * @returns this effect.
  29328. */
  29329. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29330. /**
  29331. * Sets matrix on a uniform variable.
  29332. * @param uniformName Name of the variable.
  29333. * @param matrix matrix to be set.
  29334. * @returns this effect.
  29335. */
  29336. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29337. /**
  29338. * 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)
  29339. * @param uniformName Name of the variable.
  29340. * @param matrix matrix to be set.
  29341. * @returns this effect.
  29342. */
  29343. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29344. /**
  29345. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29346. * @param uniformName Name of the variable.
  29347. * @param matrix matrix to be set.
  29348. * @returns this effect.
  29349. */
  29350. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29351. /**
  29352. * Sets a float on a uniform variable.
  29353. * @param uniformName Name of the variable.
  29354. * @param value value to be set.
  29355. * @returns this effect.
  29356. */
  29357. setFloat(uniformName: string, value: number): Effect;
  29358. /**
  29359. * Sets a boolean on a uniform variable.
  29360. * @param uniformName Name of the variable.
  29361. * @param bool value to be set.
  29362. * @returns this effect.
  29363. */
  29364. setBool(uniformName: string, bool: boolean): Effect;
  29365. /**
  29366. * Sets a Vector2 on a uniform variable.
  29367. * @param uniformName Name of the variable.
  29368. * @param vector2 vector2 to be set.
  29369. * @returns this effect.
  29370. */
  29371. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29372. /**
  29373. * Sets a float2 on a uniform variable.
  29374. * @param uniformName Name of the variable.
  29375. * @param x First float in float2.
  29376. * @param y Second float in float2.
  29377. * @returns this effect.
  29378. */
  29379. setFloat2(uniformName: string, x: number, y: number): Effect;
  29380. /**
  29381. * Sets a Vector3 on a uniform variable.
  29382. * @param uniformName Name of the variable.
  29383. * @param vector3 Value to be set.
  29384. * @returns this effect.
  29385. */
  29386. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29387. /**
  29388. * Sets a float3 on a uniform variable.
  29389. * @param uniformName Name of the variable.
  29390. * @param x First float in float3.
  29391. * @param y Second float in float3.
  29392. * @param z Third float in float3.
  29393. * @returns this effect.
  29394. */
  29395. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29396. /**
  29397. * Sets a Vector4 on a uniform variable.
  29398. * @param uniformName Name of the variable.
  29399. * @param vector4 Value to be set.
  29400. * @returns this effect.
  29401. */
  29402. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29403. /**
  29404. * Sets a float4 on a uniform variable.
  29405. * @param uniformName Name of the variable.
  29406. * @param x First float in float4.
  29407. * @param y Second float in float4.
  29408. * @param z Third float in float4.
  29409. * @param w Fourth float in float4.
  29410. * @returns this effect.
  29411. */
  29412. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29413. /**
  29414. * Sets a Color3 on a uniform variable.
  29415. * @param uniformName Name of the variable.
  29416. * @param color3 Value to be set.
  29417. * @returns this effect.
  29418. */
  29419. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29420. /**
  29421. * Sets a Color4 on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param color3 Value to be set.
  29424. * @param alpha Alpha value to be set.
  29425. * @returns this effect.
  29426. */
  29427. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29428. /**
  29429. * Sets a Color4 on a uniform variable
  29430. * @param uniformName defines the name of the variable
  29431. * @param color4 defines the value to be set
  29432. * @returns this effect.
  29433. */
  29434. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29435. /** Release all associated resources */
  29436. dispose(): void;
  29437. /**
  29438. * This function will add a new shader to the shader store
  29439. * @param name the name of the shader
  29440. * @param pixelShader optional pixel shader content
  29441. * @param vertexShader optional vertex shader content
  29442. */
  29443. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29444. /**
  29445. * Store of each shader (The can be looked up using effect.key)
  29446. */
  29447. static ShadersStore: {
  29448. [key: string]: string;
  29449. };
  29450. /**
  29451. * Store of each included file for a shader (The can be looked up using effect.key)
  29452. */
  29453. static IncludesShadersStore: {
  29454. [key: string]: string;
  29455. };
  29456. /**
  29457. * Resets the cache of effects.
  29458. */
  29459. static ResetCache(): void;
  29460. }
  29461. }
  29462. declare module "babylonjs/Engines/engineCapabilities" {
  29463. import { Nullable } from "babylonjs/types";
  29464. /**
  29465. * Class used to describe the capabilities of the engine relatively to the current browser
  29466. */
  29467. export class EngineCapabilities {
  29468. /** Maximum textures units per fragment shader */
  29469. maxTexturesImageUnits: number;
  29470. /** Maximum texture units per vertex shader */
  29471. maxVertexTextureImageUnits: number;
  29472. /** Maximum textures units in the entire pipeline */
  29473. maxCombinedTexturesImageUnits: number;
  29474. /** Maximum texture size */
  29475. maxTextureSize: number;
  29476. /** Maximum cube texture size */
  29477. maxCubemapTextureSize: number;
  29478. /** Maximum render texture size */
  29479. maxRenderTextureSize: number;
  29480. /** Maximum number of vertex attributes */
  29481. maxVertexAttribs: number;
  29482. /** Maximum number of varyings */
  29483. maxVaryingVectors: number;
  29484. /** Maximum number of uniforms per vertex shader */
  29485. maxVertexUniformVectors: number;
  29486. /** Maximum number of uniforms per fragment shader */
  29487. maxFragmentUniformVectors: number;
  29488. /** Defines if standard derivates (dx/dy) are supported */
  29489. standardDerivatives: boolean;
  29490. /** Defines if s3tc texture compression is supported */
  29491. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29492. /** Defines if pvrtc texture compression is supported */
  29493. pvrtc: any;
  29494. /** Defines if etc1 texture compression is supported */
  29495. etc1: any;
  29496. /** Defines if etc2 texture compression is supported */
  29497. etc2: any;
  29498. /** Defines if astc texture compression is supported */
  29499. astc: any;
  29500. /** Defines if float textures are supported */
  29501. textureFloat: boolean;
  29502. /** Defines if vertex array objects are supported */
  29503. vertexArrayObject: boolean;
  29504. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29505. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29506. /** Gets the maximum level of anisotropy supported */
  29507. maxAnisotropy: number;
  29508. /** Defines if instancing is supported */
  29509. instancedArrays: boolean;
  29510. /** Defines if 32 bits indices are supported */
  29511. uintIndices: boolean;
  29512. /** Defines if high precision shaders are supported */
  29513. highPrecisionShaderSupported: boolean;
  29514. /** Defines if depth reading in the fragment shader is supported */
  29515. fragmentDepthSupported: boolean;
  29516. /** Defines if float texture linear filtering is supported*/
  29517. textureFloatLinearFiltering: boolean;
  29518. /** Defines if rendering to float textures is supported */
  29519. textureFloatRender: boolean;
  29520. /** Defines if half float textures are supported*/
  29521. textureHalfFloat: boolean;
  29522. /** Defines if half float texture linear filtering is supported*/
  29523. textureHalfFloatLinearFiltering: boolean;
  29524. /** Defines if rendering to half float textures is supported */
  29525. textureHalfFloatRender: boolean;
  29526. /** Defines if textureLOD shader command is supported */
  29527. textureLOD: boolean;
  29528. /** Defines if draw buffers extension is supported */
  29529. drawBuffersExtension: boolean;
  29530. /** Defines if depth textures are supported */
  29531. depthTextureExtension: boolean;
  29532. /** Defines if float color buffer are supported */
  29533. colorBufferFloat: boolean;
  29534. /** Gets disjoint timer query extension (null if not supported) */
  29535. timerQuery: EXT_disjoint_timer_query;
  29536. /** Defines if timestamp can be used with timer query */
  29537. canUseTimestampForTimerQuery: boolean;
  29538. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29539. multiview: any;
  29540. /** Function used to let the system compiles shaders in background */
  29541. parallelShaderCompile: {
  29542. COMPLETION_STATUS_KHR: number;
  29543. };
  29544. /** Max number of texture samples for MSAA */
  29545. maxMSAASamples: number;
  29546. /** Defines if the blend min max extension is supported */
  29547. blendMinMax: boolean;
  29548. }
  29549. }
  29550. declare module "babylonjs/States/depthCullingState" {
  29551. import { Nullable } from "babylonjs/types";
  29552. /**
  29553. * @hidden
  29554. **/
  29555. export class DepthCullingState {
  29556. private _isDepthTestDirty;
  29557. private _isDepthMaskDirty;
  29558. private _isDepthFuncDirty;
  29559. private _isCullFaceDirty;
  29560. private _isCullDirty;
  29561. private _isZOffsetDirty;
  29562. private _isFrontFaceDirty;
  29563. private _depthTest;
  29564. private _depthMask;
  29565. private _depthFunc;
  29566. private _cull;
  29567. private _cullFace;
  29568. private _zOffset;
  29569. private _frontFace;
  29570. /**
  29571. * Initializes the state.
  29572. */
  29573. constructor();
  29574. readonly isDirty: boolean;
  29575. zOffset: number;
  29576. cullFace: Nullable<number>;
  29577. cull: Nullable<boolean>;
  29578. depthFunc: Nullable<number>;
  29579. depthMask: boolean;
  29580. depthTest: boolean;
  29581. frontFace: Nullable<number>;
  29582. reset(): void;
  29583. apply(gl: WebGLRenderingContext): void;
  29584. }
  29585. }
  29586. declare module "babylonjs/States/stencilState" {
  29587. /**
  29588. * @hidden
  29589. **/
  29590. export class StencilState {
  29591. /** 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 */
  29592. static readonly ALWAYS: number;
  29593. /** Passed to stencilOperation to specify that stencil value must be kept */
  29594. static readonly KEEP: number;
  29595. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29596. static readonly REPLACE: number;
  29597. private _isStencilTestDirty;
  29598. private _isStencilMaskDirty;
  29599. private _isStencilFuncDirty;
  29600. private _isStencilOpDirty;
  29601. private _stencilTest;
  29602. private _stencilMask;
  29603. private _stencilFunc;
  29604. private _stencilFuncRef;
  29605. private _stencilFuncMask;
  29606. private _stencilOpStencilFail;
  29607. private _stencilOpDepthFail;
  29608. private _stencilOpStencilDepthPass;
  29609. readonly isDirty: boolean;
  29610. stencilFunc: number;
  29611. stencilFuncRef: number;
  29612. stencilFuncMask: number;
  29613. stencilOpStencilFail: number;
  29614. stencilOpDepthFail: number;
  29615. stencilOpStencilDepthPass: number;
  29616. stencilMask: number;
  29617. stencilTest: boolean;
  29618. constructor();
  29619. reset(): void;
  29620. apply(gl: WebGLRenderingContext): void;
  29621. }
  29622. }
  29623. declare module "babylonjs/States/alphaCullingState" {
  29624. /**
  29625. * @hidden
  29626. **/
  29627. export class AlphaState {
  29628. private _isAlphaBlendDirty;
  29629. private _isBlendFunctionParametersDirty;
  29630. private _isBlendEquationParametersDirty;
  29631. private _isBlendConstantsDirty;
  29632. private _alphaBlend;
  29633. private _blendFunctionParameters;
  29634. private _blendEquationParameters;
  29635. private _blendConstants;
  29636. /**
  29637. * Initializes the state.
  29638. */
  29639. constructor();
  29640. readonly isDirty: boolean;
  29641. alphaBlend: boolean;
  29642. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29643. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29644. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29645. reset(): void;
  29646. apply(gl: WebGLRenderingContext): void;
  29647. }
  29648. }
  29649. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29650. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29651. /** @hidden */
  29652. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29653. attributeProcessor(attribute: string): string;
  29654. varyingProcessor(varying: string, isFragment: boolean): string;
  29655. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29656. }
  29657. }
  29658. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29659. /**
  29660. * Interface for attribute information associated with buffer instanciation
  29661. */
  29662. export class InstancingAttributeInfo {
  29663. /**
  29664. * Index/offset of the attribute in the vertex shader
  29665. */
  29666. index: number;
  29667. /**
  29668. * size of the attribute, 1, 2, 3 or 4
  29669. */
  29670. attributeSize: number;
  29671. /**
  29672. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29673. * default is FLOAT
  29674. */
  29675. attribyteType: number;
  29676. /**
  29677. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29678. */
  29679. normalized: boolean;
  29680. /**
  29681. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29682. */
  29683. offset: number;
  29684. /**
  29685. * Name of the GLSL attribute, for debugging purpose only
  29686. */
  29687. attributeName: string;
  29688. }
  29689. }
  29690. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29691. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29692. import { Nullable } from "babylonjs/types";
  29693. module "babylonjs/Engines/thinEngine" {
  29694. interface ThinEngine {
  29695. /**
  29696. * Update a video texture
  29697. * @param texture defines the texture to update
  29698. * @param video defines the video element to use
  29699. * @param invertY defines if data must be stored with Y axis inverted
  29700. */
  29701. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29702. }
  29703. }
  29704. }
  29705. declare module "babylonjs/Materials/Textures/videoTexture" {
  29706. import { Observable } from "babylonjs/Misc/observable";
  29707. import { Nullable } from "babylonjs/types";
  29708. import { Scene } from "babylonjs/scene";
  29709. import { Texture } from "babylonjs/Materials/Textures/texture";
  29710. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29711. /**
  29712. * Settings for finer control over video usage
  29713. */
  29714. export interface VideoTextureSettings {
  29715. /**
  29716. * Applies `autoplay` to video, if specified
  29717. */
  29718. autoPlay?: boolean;
  29719. /**
  29720. * Applies `loop` to video, if specified
  29721. */
  29722. loop?: boolean;
  29723. /**
  29724. * Automatically updates internal texture from video at every frame in the render loop
  29725. */
  29726. autoUpdateTexture: boolean;
  29727. /**
  29728. * Image src displayed during the video loading or until the user interacts with the video.
  29729. */
  29730. poster?: string;
  29731. }
  29732. /**
  29733. * If you want to display a video in your scene, this is the special texture for that.
  29734. * This special texture works similar to other textures, with the exception of a few parameters.
  29735. * @see https://doc.babylonjs.com/how_to/video_texture
  29736. */
  29737. export class VideoTexture extends Texture {
  29738. /**
  29739. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29740. */
  29741. readonly autoUpdateTexture: boolean;
  29742. /**
  29743. * The video instance used by the texture internally
  29744. */
  29745. readonly video: HTMLVideoElement;
  29746. private _onUserActionRequestedObservable;
  29747. /**
  29748. * Event triggerd when a dom action is required by the user to play the video.
  29749. * This happens due to recent changes in browser policies preventing video to auto start.
  29750. */
  29751. readonly onUserActionRequestedObservable: Observable<Texture>;
  29752. private _generateMipMaps;
  29753. private _engine;
  29754. private _stillImageCaptured;
  29755. private _displayingPosterTexture;
  29756. private _settings;
  29757. private _createInternalTextureOnEvent;
  29758. private _frameId;
  29759. /**
  29760. * Creates a video texture.
  29761. * If you want to display a video in your scene, this is the special texture for that.
  29762. * This special texture works similar to other textures, with the exception of a few parameters.
  29763. * @see https://doc.babylonjs.com/how_to/video_texture
  29764. * @param name optional name, will detect from video source, if not defined
  29765. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29766. * @param scene is obviously the current scene.
  29767. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29768. * @param invertY is false by default but can be used to invert video on Y axis
  29769. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29770. * @param settings allows finer control over video usage
  29771. */
  29772. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29773. private _getName;
  29774. private _getVideo;
  29775. private _createInternalTexture;
  29776. private reset;
  29777. /**
  29778. * @hidden Internal method to initiate `update`.
  29779. */
  29780. _rebuild(): void;
  29781. /**
  29782. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29783. */
  29784. update(): void;
  29785. /**
  29786. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29787. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29788. */
  29789. updateTexture(isVisible: boolean): void;
  29790. protected _updateInternalTexture: () => void;
  29791. /**
  29792. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29793. * @param url New url.
  29794. */
  29795. updateURL(url: string): void;
  29796. /**
  29797. * Dispose the texture and release its associated resources.
  29798. */
  29799. dispose(): void;
  29800. /**
  29801. * Creates a video texture straight from a stream.
  29802. * @param scene Define the scene the texture should be created in
  29803. * @param stream Define the stream the texture should be created from
  29804. * @returns The created video texture as a promise
  29805. */
  29806. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29807. /**
  29808. * Creates a video texture straight from your WebCam video feed.
  29809. * @param scene Define the scene the texture should be created in
  29810. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29811. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29812. * @returns The created video texture as a promise
  29813. */
  29814. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29815. minWidth: number;
  29816. maxWidth: number;
  29817. minHeight: number;
  29818. maxHeight: number;
  29819. deviceId: string;
  29820. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29821. /**
  29822. * Creates a video texture straight from your WebCam video feed.
  29823. * @param scene Define the scene the texture should be created in
  29824. * @param onReady Define a callback to triggered once the texture will be ready
  29825. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29826. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29827. */
  29828. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29829. minWidth: number;
  29830. maxWidth: number;
  29831. minHeight: number;
  29832. maxHeight: number;
  29833. deviceId: string;
  29834. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29835. }
  29836. }
  29837. declare module "babylonjs/Engines/thinEngine" {
  29838. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29839. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29840. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29841. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29842. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29843. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29844. import { Observable } from "babylonjs/Misc/observable";
  29845. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29846. import { StencilState } from "babylonjs/States/stencilState";
  29847. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29848. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29849. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29850. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29851. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29852. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29853. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29854. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29855. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29856. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29857. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29858. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29859. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29860. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29861. /**
  29862. * Defines the interface used by objects working like Scene
  29863. * @hidden
  29864. */
  29865. interface ISceneLike {
  29866. _addPendingData(data: any): void;
  29867. _removePendingData(data: any): void;
  29868. offlineProvider: IOfflineProvider;
  29869. }
  29870. /** Interface defining initialization parameters for Engine class */
  29871. export interface EngineOptions extends WebGLContextAttributes {
  29872. /**
  29873. * Defines if the engine should no exceed a specified device ratio
  29874. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29875. */
  29876. limitDeviceRatio?: number;
  29877. /**
  29878. * Defines if webvr should be enabled automatically
  29879. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29880. */
  29881. autoEnableWebVR?: boolean;
  29882. /**
  29883. * Defines if webgl2 should be turned off even if supported
  29884. * @see http://doc.babylonjs.com/features/webgl2
  29885. */
  29886. disableWebGL2Support?: boolean;
  29887. /**
  29888. * Defines if webaudio should be initialized as well
  29889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29890. */
  29891. audioEngine?: boolean;
  29892. /**
  29893. * Defines if animations should run using a deterministic lock step
  29894. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29895. */
  29896. deterministicLockstep?: boolean;
  29897. /** Defines the maximum steps to use with deterministic lock step mode */
  29898. lockstepMaxSteps?: number;
  29899. /**
  29900. * Defines that engine should ignore context lost events
  29901. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29902. */
  29903. doNotHandleContextLost?: boolean;
  29904. /**
  29905. * Defines that engine should ignore modifying touch action attribute and style
  29906. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29907. */
  29908. doNotHandleTouchAction?: boolean;
  29909. /**
  29910. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29911. */
  29912. useHighPrecisionFloats?: boolean;
  29913. }
  29914. /**
  29915. * The base engine class (root of all engines)
  29916. */
  29917. export class ThinEngine {
  29918. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29919. static ExceptionList: ({
  29920. key: string;
  29921. capture: string;
  29922. captureConstraint: number;
  29923. targets: string[];
  29924. } | {
  29925. key: string;
  29926. capture: null;
  29927. captureConstraint: null;
  29928. targets: string[];
  29929. })[];
  29930. /** @hidden */
  29931. static _TextureLoaders: IInternalTextureLoader[];
  29932. /**
  29933. * Returns the current npm package of the sdk
  29934. */
  29935. static readonly NpmPackage: string;
  29936. /**
  29937. * Returns the current version of the framework
  29938. */
  29939. static readonly Version: string;
  29940. /**
  29941. * Returns a string describing the current engine
  29942. */
  29943. readonly description: string;
  29944. /**
  29945. * Gets or sets the epsilon value used by collision engine
  29946. */
  29947. static CollisionsEpsilon: number;
  29948. /**
  29949. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29950. */
  29951. static ShadersRepository: string;
  29952. /** @hidden */
  29953. _shaderProcessor: IShaderProcessor;
  29954. /**
  29955. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29956. */
  29957. forcePOTTextures: boolean;
  29958. /**
  29959. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29960. */
  29961. isFullscreen: boolean;
  29962. /**
  29963. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29964. */
  29965. cullBackFaces: boolean;
  29966. /**
  29967. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29968. */
  29969. renderEvenInBackground: boolean;
  29970. /**
  29971. * Gets or sets a boolean indicating that cache can be kept between frames
  29972. */
  29973. preventCacheWipeBetweenFrames: boolean;
  29974. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29975. validateShaderPrograms: boolean;
  29976. /**
  29977. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29978. */
  29979. disableUniformBuffers: boolean;
  29980. /** @hidden */
  29981. _uniformBuffers: UniformBuffer[];
  29982. /**
  29983. * Gets a boolean indicating that the engine supports uniform buffers
  29984. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29985. */
  29986. readonly supportsUniformBuffers: boolean;
  29987. /** @hidden */
  29988. _gl: WebGLRenderingContext;
  29989. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29990. protected _windowIsBackground: boolean;
  29991. protected _webGLVersion: number;
  29992. protected _highPrecisionShadersAllowed: boolean;
  29993. /** @hidden */
  29994. readonly _shouldUseHighPrecisionShader: boolean;
  29995. /**
  29996. * Gets a boolean indicating that only power of 2 textures are supported
  29997. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29998. */
  29999. readonly needPOTTextures: boolean;
  30000. /** @hidden */
  30001. _badOS: boolean;
  30002. /** @hidden */
  30003. _badDesktopOS: boolean;
  30004. private _hardwareScalingLevel;
  30005. /** @hidden */
  30006. _caps: EngineCapabilities;
  30007. private _isStencilEnable;
  30008. protected _colorWrite: boolean;
  30009. private _glVersion;
  30010. private _glRenderer;
  30011. private _glVendor;
  30012. /** @hidden */
  30013. _videoTextureSupported: boolean;
  30014. protected _renderingQueueLaunched: boolean;
  30015. protected _activeRenderLoops: (() => void)[];
  30016. /**
  30017. * Observable signaled when a context lost event is raised
  30018. */
  30019. onContextLostObservable: Observable<ThinEngine>;
  30020. /**
  30021. * Observable signaled when a context restored event is raised
  30022. */
  30023. onContextRestoredObservable: Observable<ThinEngine>;
  30024. private _onContextLost;
  30025. private _onContextRestored;
  30026. protected _contextWasLost: boolean;
  30027. /** @hidden */
  30028. _doNotHandleContextLost: boolean;
  30029. /**
  30030. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30031. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30032. */
  30033. doNotHandleContextLost: boolean;
  30034. /**
  30035. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30036. */
  30037. disableVertexArrayObjects: boolean;
  30038. /** @hidden */
  30039. protected _depthCullingState: DepthCullingState;
  30040. /** @hidden */
  30041. protected _stencilState: StencilState;
  30042. /** @hidden */
  30043. protected _alphaState: AlphaState;
  30044. /** @hidden */
  30045. _internalTexturesCache: InternalTexture[];
  30046. /** @hidden */
  30047. protected _activeChannel: number;
  30048. private _currentTextureChannel;
  30049. /** @hidden */
  30050. protected _boundTexturesCache: {
  30051. [key: string]: Nullable<InternalTexture>;
  30052. };
  30053. /** @hidden */
  30054. protected _currentEffect: Nullable<Effect>;
  30055. /** @hidden */
  30056. protected _currentProgram: Nullable<WebGLProgram>;
  30057. private _compiledEffects;
  30058. private _vertexAttribArraysEnabled;
  30059. /** @hidden */
  30060. protected _cachedViewport: Nullable<IViewportLike>;
  30061. private _cachedVertexArrayObject;
  30062. /** @hidden */
  30063. protected _cachedVertexBuffers: any;
  30064. /** @hidden */
  30065. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30066. /** @hidden */
  30067. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30068. /** @hidden */
  30069. _currentRenderTarget: Nullable<InternalTexture>;
  30070. private _uintIndicesCurrentlySet;
  30071. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30072. /** @hidden */
  30073. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30074. private _currentBufferPointers;
  30075. private _currentInstanceLocations;
  30076. private _currentInstanceBuffers;
  30077. private _textureUnits;
  30078. /** @hidden */
  30079. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30080. /** @hidden */
  30081. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30082. /** @hidden */
  30083. _bindedRenderFunction: any;
  30084. private _vaoRecordInProgress;
  30085. private _mustWipeVertexAttributes;
  30086. private _emptyTexture;
  30087. private _emptyCubeTexture;
  30088. private _emptyTexture3D;
  30089. /** @hidden */
  30090. _frameHandler: number;
  30091. private _nextFreeTextureSlots;
  30092. private _maxSimultaneousTextures;
  30093. private _activeRequests;
  30094. protected _texturesSupported: string[];
  30095. /** @hidden */
  30096. _textureFormatInUse: Nullable<string>;
  30097. protected readonly _supportsHardwareTextureRescaling: boolean;
  30098. /**
  30099. * Gets the list of texture formats supported
  30100. */
  30101. readonly texturesSupported: Array<string>;
  30102. /**
  30103. * Gets the list of texture formats in use
  30104. */
  30105. readonly textureFormatInUse: Nullable<string>;
  30106. /**
  30107. * Gets the current viewport
  30108. */
  30109. readonly currentViewport: Nullable<IViewportLike>;
  30110. /**
  30111. * Gets the default empty texture
  30112. */
  30113. readonly emptyTexture: InternalTexture;
  30114. /**
  30115. * Gets the default empty 3D texture
  30116. */
  30117. readonly emptyTexture3D: InternalTexture;
  30118. /**
  30119. * Gets the default empty cube texture
  30120. */
  30121. readonly emptyCubeTexture: InternalTexture;
  30122. /**
  30123. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30124. */
  30125. readonly premultipliedAlpha: boolean;
  30126. /**
  30127. * Observable event triggered before each texture is initialized
  30128. */
  30129. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30130. /**
  30131. * Creates a new engine
  30132. * @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
  30133. * @param antialias defines enable antialiasing (default: false)
  30134. * @param options defines further options to be sent to the getContext() function
  30135. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30136. */
  30137. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30138. private _rebuildInternalTextures;
  30139. private _rebuildEffects;
  30140. /**
  30141. * Gets a boolean indicating if all created effects are ready
  30142. * @returns true if all effects are ready
  30143. */
  30144. areAllEffectsReady(): boolean;
  30145. protected _rebuildBuffers(): void;
  30146. private _initGLContext;
  30147. /**
  30148. * Gets version of the current webGL context
  30149. */
  30150. readonly webGLVersion: number;
  30151. /**
  30152. * Gets a string idenfifying the name of the class
  30153. * @returns "Engine" string
  30154. */
  30155. getClassName(): string;
  30156. /**
  30157. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30158. */
  30159. readonly isStencilEnable: boolean;
  30160. /** @hidden */
  30161. _prepareWorkingCanvas(): void;
  30162. /**
  30163. * Reset the texture cache to empty state
  30164. */
  30165. resetTextureCache(): void;
  30166. /**
  30167. * Gets an object containing information about the current webGL context
  30168. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30169. */
  30170. getGlInfo(): {
  30171. vendor: string;
  30172. renderer: string;
  30173. version: string;
  30174. };
  30175. /**
  30176. * Defines the hardware scaling level.
  30177. * By default the hardware scaling level is computed from the window device ratio.
  30178. * 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.
  30179. * @param level defines the level to use
  30180. */
  30181. setHardwareScalingLevel(level: number): void;
  30182. /**
  30183. * Gets the current hardware scaling level.
  30184. * By default the hardware scaling level is computed from the window device ratio.
  30185. * 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.
  30186. * @returns a number indicating the current hardware scaling level
  30187. */
  30188. getHardwareScalingLevel(): number;
  30189. /**
  30190. * Gets the list of loaded textures
  30191. * @returns an array containing all loaded textures
  30192. */
  30193. getLoadedTexturesCache(): InternalTexture[];
  30194. /**
  30195. * Gets the object containing all engine capabilities
  30196. * @returns the EngineCapabilities object
  30197. */
  30198. getCaps(): EngineCapabilities;
  30199. /**
  30200. * stop executing a render loop function and remove it from the execution array
  30201. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30202. */
  30203. stopRenderLoop(renderFunction?: () => void): void;
  30204. /** @hidden */
  30205. _renderLoop(): void;
  30206. /**
  30207. * Gets the HTML canvas attached with the current webGL context
  30208. * @returns a HTML canvas
  30209. */
  30210. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30211. /**
  30212. * Gets host window
  30213. * @returns the host window object
  30214. */
  30215. getHostWindow(): Nullable<Window>;
  30216. /**
  30217. * Gets the current render width
  30218. * @param useScreen defines if screen size must be used (or the current render target if any)
  30219. * @returns a number defining the current render width
  30220. */
  30221. getRenderWidth(useScreen?: boolean): number;
  30222. /**
  30223. * Gets the current render height
  30224. * @param useScreen defines if screen size must be used (or the current render target if any)
  30225. * @returns a number defining the current render height
  30226. */
  30227. getRenderHeight(useScreen?: boolean): number;
  30228. /**
  30229. * Can be used to override the current requestAnimationFrame requester.
  30230. * @hidden
  30231. */
  30232. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30233. /**
  30234. * Register and execute a render loop. The engine can have more than one render function
  30235. * @param renderFunction defines the function to continuously execute
  30236. */
  30237. runRenderLoop(renderFunction: () => void): void;
  30238. /**
  30239. * Clear the current render buffer or the current render target (if any is set up)
  30240. * @param color defines the color to use
  30241. * @param backBuffer defines if the back buffer must be cleared
  30242. * @param depth defines if the depth buffer must be cleared
  30243. * @param stencil defines if the stencil buffer must be cleared
  30244. */
  30245. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30246. private _viewportCached;
  30247. /** @hidden */
  30248. _viewport(x: number, y: number, width: number, height: number): void;
  30249. /**
  30250. * Set the WebGL's viewport
  30251. * @param viewport defines the viewport element to be used
  30252. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30253. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30254. */
  30255. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30256. /**
  30257. * Begin a new frame
  30258. */
  30259. beginFrame(): void;
  30260. /**
  30261. * Enf the current frame
  30262. */
  30263. endFrame(): void;
  30264. /**
  30265. * Resize the view according to the canvas' size
  30266. */
  30267. resize(): void;
  30268. /**
  30269. * Force a specific size of the canvas
  30270. * @param width defines the new canvas' width
  30271. * @param height defines the new canvas' height
  30272. */
  30273. setSize(width: number, height: number): void;
  30274. /**
  30275. * Binds the frame buffer to the specified texture.
  30276. * @param texture The texture to render to or null for the default canvas
  30277. * @param faceIndex The face of the texture to render to in case of cube texture
  30278. * @param requiredWidth The width of the target to render to
  30279. * @param requiredHeight The height of the target to render to
  30280. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30281. * @param depthStencilTexture The depth stencil texture to use to render
  30282. * @param lodLevel defines le lod level to bind to the frame buffer
  30283. */
  30284. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30285. /** @hidden */
  30286. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30287. /**
  30288. * Unbind the current render target texture from the webGL context
  30289. * @param texture defines the render target texture to unbind
  30290. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30291. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30292. */
  30293. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30294. /**
  30295. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30296. */
  30297. flushFramebuffer(): void;
  30298. /**
  30299. * Unbind the current render target and bind the default framebuffer
  30300. */
  30301. restoreDefaultFramebuffer(): void;
  30302. private _resetVertexBufferBinding;
  30303. /**
  30304. * Creates a vertex buffer
  30305. * @param data the data for the vertex buffer
  30306. * @returns the new WebGL static buffer
  30307. */
  30308. createVertexBuffer(data: DataArray): DataBuffer;
  30309. private _createVertexBuffer;
  30310. /**
  30311. * Creates a dynamic vertex buffer
  30312. * @param data the data for the dynamic vertex buffer
  30313. * @returns the new WebGL dynamic buffer
  30314. */
  30315. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30316. /**
  30317. * Updates a dynamic vertex buffer.
  30318. * @param vertexBuffer the vertex buffer to update
  30319. * @param data the data used to update the vertex buffer
  30320. * @param byteOffset the byte offset of the data
  30321. * @param byteLength the byte length of the data
  30322. */
  30323. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30324. protected _resetIndexBufferBinding(): void;
  30325. /**
  30326. * Creates a new index buffer
  30327. * @param indices defines the content of the index buffer
  30328. * @param updatable defines if the index buffer must be updatable
  30329. * @returns a new webGL buffer
  30330. */
  30331. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30332. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30333. /**
  30334. * Bind a webGL buffer to the webGL context
  30335. * @param buffer defines the buffer to bind
  30336. */
  30337. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30338. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30339. private bindBuffer;
  30340. /**
  30341. * update the bound buffer with the given data
  30342. * @param data defines the data to update
  30343. */
  30344. updateArrayBuffer(data: Float32Array): void;
  30345. private _vertexAttribPointer;
  30346. private _bindIndexBufferWithCache;
  30347. private _bindVertexBuffersAttributes;
  30348. /**
  30349. * Records a vertex array object
  30350. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30351. * @param vertexBuffers defines the list of vertex buffers to store
  30352. * @param indexBuffer defines the index buffer to store
  30353. * @param effect defines the effect to store
  30354. * @returns the new vertex array object
  30355. */
  30356. recordVertexArrayObject(vertexBuffers: {
  30357. [key: string]: VertexBuffer;
  30358. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30359. /**
  30360. * Bind a specific vertex array object
  30361. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30362. * @param vertexArrayObject defines the vertex array object to bind
  30363. * @param indexBuffer defines the index buffer to bind
  30364. */
  30365. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30366. /**
  30367. * Bind webGl buffers directly to the webGL context
  30368. * @param vertexBuffer defines the vertex buffer to bind
  30369. * @param indexBuffer defines the index buffer to bind
  30370. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30371. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30372. * @param effect defines the effect associated with the vertex buffer
  30373. */
  30374. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30375. private _unbindVertexArrayObject;
  30376. /**
  30377. * Bind a list of vertex buffers to the webGL context
  30378. * @param vertexBuffers defines the list of vertex buffers to bind
  30379. * @param indexBuffer defines the index buffer to bind
  30380. * @param effect defines the effect associated with the vertex buffers
  30381. */
  30382. bindBuffers(vertexBuffers: {
  30383. [key: string]: Nullable<VertexBuffer>;
  30384. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30385. /**
  30386. * Unbind all instance attributes
  30387. */
  30388. unbindInstanceAttributes(): void;
  30389. /**
  30390. * Release and free the memory of a vertex array object
  30391. * @param vao defines the vertex array object to delete
  30392. */
  30393. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30394. /** @hidden */
  30395. _releaseBuffer(buffer: DataBuffer): boolean;
  30396. protected _deleteBuffer(buffer: DataBuffer): void;
  30397. /**
  30398. * Creates a webGL buffer to use with instanciation
  30399. * @param capacity defines the size of the buffer
  30400. * @returns the webGL buffer
  30401. */
  30402. createInstancesBuffer(capacity: number): DataBuffer;
  30403. /**
  30404. * Delete a webGL buffer used with instanciation
  30405. * @param buffer defines the webGL buffer to delete
  30406. */
  30407. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30408. /**
  30409. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30410. * @param instancesBuffer defines the webGL buffer to update and bind
  30411. * @param data defines the data to store in the buffer
  30412. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30413. */
  30414. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30415. /**
  30416. * Apply all cached states (depth, culling, stencil and alpha)
  30417. */
  30418. applyStates(): void;
  30419. /**
  30420. * Send a draw order
  30421. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30422. * @param indexStart defines the starting index
  30423. * @param indexCount defines the number of index to draw
  30424. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30425. */
  30426. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30427. /**
  30428. * Draw a list of points
  30429. * @param verticesStart defines the index of first vertex to draw
  30430. * @param verticesCount defines the count of vertices to draw
  30431. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30432. */
  30433. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30434. /**
  30435. * Draw a list of unindexed primitives
  30436. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30437. * @param verticesStart defines the index of first vertex to draw
  30438. * @param verticesCount defines the count of vertices to draw
  30439. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30440. */
  30441. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30442. /**
  30443. * Draw a list of indexed primitives
  30444. * @param fillMode defines the primitive to use
  30445. * @param indexStart defines the starting index
  30446. * @param indexCount defines the number of index to draw
  30447. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30448. */
  30449. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30450. /**
  30451. * Draw a list of unindexed primitives
  30452. * @param fillMode defines the primitive to use
  30453. * @param verticesStart defines the index of first vertex to draw
  30454. * @param verticesCount defines the count of vertices to draw
  30455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30456. */
  30457. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30458. private _drawMode;
  30459. /** @hidden */
  30460. protected _reportDrawCall(): void;
  30461. /** @hidden */
  30462. _releaseEffect(effect: Effect): void;
  30463. /** @hidden */
  30464. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30465. /**
  30466. * Create a new effect (used to store vertex/fragment shaders)
  30467. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30468. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30469. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30470. * @param samplers defines an array of string used to represent textures
  30471. * @param defines defines the string containing the defines to use to compile the shaders
  30472. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30473. * @param onCompiled defines a function to call when the effect creation is successful
  30474. * @param onError defines a function to call when the effect creation has failed
  30475. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30476. * @returns the new Effect
  30477. */
  30478. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30479. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30480. private _compileShader;
  30481. private _compileRawShader;
  30482. /**
  30483. * Directly creates a webGL program
  30484. * @param pipelineContext defines the pipeline context to attach to
  30485. * @param vertexCode defines the vertex shader code to use
  30486. * @param fragmentCode defines the fragment shader code to use
  30487. * @param context defines the webGL context to use (if not set, the current one will be used)
  30488. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30489. * @returns the new webGL program
  30490. */
  30491. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30492. /**
  30493. * Creates a webGL program
  30494. * @param pipelineContext defines the pipeline context to attach to
  30495. * @param vertexCode defines the vertex shader code to use
  30496. * @param fragmentCode defines the fragment shader code to use
  30497. * @param defines defines the string containing the defines to use to compile the shaders
  30498. * @param context defines the webGL context to use (if not set, the current one will be used)
  30499. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30500. * @returns the new webGL program
  30501. */
  30502. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30503. /**
  30504. * Creates a new pipeline context
  30505. * @returns the new pipeline
  30506. */
  30507. createPipelineContext(): IPipelineContext;
  30508. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30509. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30510. /** @hidden */
  30511. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30512. /** @hidden */
  30513. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30514. /** @hidden */
  30515. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30516. /**
  30517. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30518. * @param pipelineContext defines the pipeline context to use
  30519. * @param uniformsNames defines the list of uniform names
  30520. * @returns an array of webGL uniform locations
  30521. */
  30522. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30523. /**
  30524. * Gets the lsit of active attributes for a given webGL program
  30525. * @param pipelineContext defines the pipeline context to use
  30526. * @param attributesNames defines the list of attribute names to get
  30527. * @returns an array of indices indicating the offset of each attribute
  30528. */
  30529. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30530. /**
  30531. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30532. * @param effect defines the effect to activate
  30533. */
  30534. enableEffect(effect: Nullable<Effect>): void;
  30535. /**
  30536. * Set the value of an uniform to an array of int32
  30537. * @param uniform defines the webGL uniform location where to store the value
  30538. * @param array defines the array of int32 to store
  30539. */
  30540. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30541. /**
  30542. * Set the value of an uniform to an array of int32 (stored as vec2)
  30543. * @param uniform defines the webGL uniform location where to store the value
  30544. * @param array defines the array of int32 to store
  30545. */
  30546. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30547. /**
  30548. * Set the value of an uniform to an array of int32 (stored as vec3)
  30549. * @param uniform defines the webGL uniform location where to store the value
  30550. * @param array defines the array of int32 to store
  30551. */
  30552. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30553. /**
  30554. * Set the value of an uniform to an array of int32 (stored as vec4)
  30555. * @param uniform defines the webGL uniform location where to store the value
  30556. * @param array defines the array of int32 to store
  30557. */
  30558. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30559. /**
  30560. * Set the value of an uniform to an array of float32
  30561. * @param uniform defines the webGL uniform location where to store the value
  30562. * @param array defines the array of float32 to store
  30563. */
  30564. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30565. /**
  30566. * Set the value of an uniform to an array of float32 (stored as vec2)
  30567. * @param uniform defines the webGL uniform location where to store the value
  30568. * @param array defines the array of float32 to store
  30569. */
  30570. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30571. /**
  30572. * Set the value of an uniform to an array of float32 (stored as vec3)
  30573. * @param uniform defines the webGL uniform location where to store the value
  30574. * @param array defines the array of float32 to store
  30575. */
  30576. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30577. /**
  30578. * Set the value of an uniform to an array of float32 (stored as vec4)
  30579. * @param uniform defines the webGL uniform location where to store the value
  30580. * @param array defines the array of float32 to store
  30581. */
  30582. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30583. /**
  30584. * Set the value of an uniform to an array of number
  30585. * @param uniform defines the webGL uniform location where to store the value
  30586. * @param array defines the array of number to store
  30587. */
  30588. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30589. /**
  30590. * Set the value of an uniform to an array of number (stored as vec2)
  30591. * @param uniform defines the webGL uniform location where to store the value
  30592. * @param array defines the array of number to store
  30593. */
  30594. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30595. /**
  30596. * Set the value of an uniform to an array of number (stored as vec3)
  30597. * @param uniform defines the webGL uniform location where to store the value
  30598. * @param array defines the array of number to store
  30599. */
  30600. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30601. /**
  30602. * Set the value of an uniform to an array of number (stored as vec4)
  30603. * @param uniform defines the webGL uniform location where to store the value
  30604. * @param array defines the array of number to store
  30605. */
  30606. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30607. /**
  30608. * Set the value of an uniform to an array of float32 (stored as matrices)
  30609. * @param uniform defines the webGL uniform location where to store the value
  30610. * @param matrices defines the array of float32 to store
  30611. */
  30612. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30613. /**
  30614. * Set the value of an uniform to a matrix (3x3)
  30615. * @param uniform defines the webGL uniform location where to store the value
  30616. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30617. */
  30618. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30619. /**
  30620. * Set the value of an uniform to a matrix (2x2)
  30621. * @param uniform defines the webGL uniform location where to store the value
  30622. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30623. */
  30624. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30625. /**
  30626. * Set the value of an uniform to a number (int)
  30627. * @param uniform defines the webGL uniform location where to store the value
  30628. * @param value defines the int number to store
  30629. */
  30630. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30631. /**
  30632. * Set the value of an uniform to a number (float)
  30633. * @param uniform defines the webGL uniform location where to store the value
  30634. * @param value defines the float number to store
  30635. */
  30636. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30637. /**
  30638. * Set the value of an uniform to a vec2
  30639. * @param uniform defines the webGL uniform location where to store the value
  30640. * @param x defines the 1st component of the value
  30641. * @param y defines the 2nd component of the value
  30642. */
  30643. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30644. /**
  30645. * Set the value of an uniform to a vec3
  30646. * @param uniform defines the webGL uniform location where to store the value
  30647. * @param x defines the 1st component of the value
  30648. * @param y defines the 2nd component of the value
  30649. * @param z defines the 3rd component of the value
  30650. */
  30651. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30652. /**
  30653. * Set the value of an uniform to a boolean
  30654. * @param uniform defines the webGL uniform location where to store the value
  30655. * @param bool defines the boolean to store
  30656. */
  30657. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30658. /**
  30659. * Set the value of an uniform to a vec4
  30660. * @param uniform defines the webGL uniform location where to store the value
  30661. * @param x defines the 1st component of the value
  30662. * @param y defines the 2nd component of the value
  30663. * @param z defines the 3rd component of the value
  30664. * @param w defines the 4th component of the value
  30665. */
  30666. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30667. /**
  30668. * Sets a Color4 on a uniform variable
  30669. * @param uniform defines the uniform location
  30670. * @param color4 defines the value to be set
  30671. */
  30672. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30673. /**
  30674. * Gets the depth culling state manager
  30675. */
  30676. readonly depthCullingState: DepthCullingState;
  30677. /**
  30678. * Gets the alpha state manager
  30679. */
  30680. readonly alphaState: AlphaState;
  30681. /**
  30682. * Gets the stencil state manager
  30683. */
  30684. readonly stencilState: StencilState;
  30685. /**
  30686. * Clears the list of texture accessible through engine.
  30687. * This can help preventing texture load conflict due to name collision.
  30688. */
  30689. clearInternalTexturesCache(): void;
  30690. /**
  30691. * Force the entire cache to be cleared
  30692. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30693. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30694. */
  30695. wipeCaches(bruteForce?: boolean): void;
  30696. /** @hidden */
  30697. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30698. min: number;
  30699. mag: number;
  30700. };
  30701. /** @hidden */
  30702. _createTexture(): WebGLTexture;
  30703. /**
  30704. * Usually called from Texture.ts.
  30705. * Passed information to create a WebGLTexture
  30706. * @param urlArg defines a value which contains one of the following:
  30707. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30708. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30709. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30711. * @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)
  30712. * @param scene needed for loading to the correct scene
  30713. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30714. * @param onLoad optional callback to be called upon successful completion
  30715. * @param onError optional callback to be called upon failure
  30716. * @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
  30717. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30718. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30719. * @param forcedExtension defines the extension to use to pick the right loader
  30720. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30721. * @param mimeType defines an optional mime type
  30722. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30723. */
  30724. 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 | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  30725. /**
  30726. * @hidden
  30727. */
  30728. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30729. /**
  30730. * Creates a raw texture
  30731. * @param data defines the data to store in the texture
  30732. * @param width defines the width of the texture
  30733. * @param height defines the height of the texture
  30734. * @param format defines the format of the data
  30735. * @param generateMipMaps defines if the engine should generate the mip levels
  30736. * @param invertY defines if data must be stored with Y axis inverted
  30737. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30738. * @param compression defines the compression used (null by default)
  30739. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30740. * @returns the raw texture inside an InternalTexture
  30741. */
  30742. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30743. /**
  30744. * Creates a new raw cube texture
  30745. * @param data defines the array of data to use to create each face
  30746. * @param size defines the size of the textures
  30747. * @param format defines the format of the data
  30748. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30749. * @param generateMipMaps defines if the engine should generate the mip levels
  30750. * @param invertY defines if data must be stored with Y axis inverted
  30751. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30752. * @param compression defines the compression used (null by default)
  30753. * @returns the cube texture as an InternalTexture
  30754. */
  30755. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30756. /**
  30757. * Creates a new raw 3D texture
  30758. * @param data defines the data used to create the texture
  30759. * @param width defines the width of the texture
  30760. * @param height defines the height of the texture
  30761. * @param depth defines the depth of the texture
  30762. * @param format defines the format of the texture
  30763. * @param generateMipMaps defines if the engine must generate mip levels
  30764. * @param invertY defines if data must be stored with Y axis inverted
  30765. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30766. * @param compression defines the compressed used (can be null)
  30767. * @param textureType defines the compressed used (can be null)
  30768. * @returns a new raw 3D texture (stored in an InternalTexture)
  30769. */
  30770. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30771. private _unpackFlipYCached;
  30772. /**
  30773. * In case you are sharing the context with other applications, it might
  30774. * be interested to not cache the unpack flip y state to ensure a consistent
  30775. * value would be set.
  30776. */
  30777. enableUnpackFlipYCached: boolean;
  30778. /** @hidden */
  30779. _unpackFlipY(value: boolean): void;
  30780. /** @hidden */
  30781. _getUnpackAlignement(): number;
  30782. /**
  30783. * Update the sampling mode of a given texture
  30784. * @param samplingMode defines the required sampling mode
  30785. * @param texture defines the texture to update
  30786. */
  30787. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30788. /**
  30789. * Updates a depth texture Comparison Mode and Function.
  30790. * If the comparison Function is equal to 0, the mode will be set to none.
  30791. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30792. * @param texture The texture to set the comparison function for
  30793. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30794. */
  30795. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30796. /** @hidden */
  30797. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30798. width: number;
  30799. height: number;
  30800. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30801. /**
  30802. * Creates a depth stencil texture.
  30803. * This is only available in WebGL 2 or with the depth texture extension available.
  30804. * @param size The size of face edge in the texture.
  30805. * @param options The options defining the texture.
  30806. * @returns The texture
  30807. */
  30808. createDepthStencilTexture(size: number | {
  30809. width: number;
  30810. height: number;
  30811. }, options: DepthTextureCreationOptions): InternalTexture;
  30812. /**
  30813. * Creates a depth stencil texture.
  30814. * This is only available in WebGL 2 or with the depth texture extension available.
  30815. * @param size The size of face edge in the texture.
  30816. * @param options The options defining the texture.
  30817. * @returns The texture
  30818. */
  30819. private _createDepthStencilTexture;
  30820. /** @hidden */
  30821. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30822. /** @hidden */
  30823. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30824. /** @hidden */
  30825. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30826. /** @hidden */
  30827. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  30828. /**
  30829. * @hidden
  30830. */
  30831. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30832. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30833. private _prepareWebGLTexture;
  30834. /** @hidden */
  30835. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30836. /** @hidden */
  30837. _releaseFramebufferObjects(texture: InternalTexture): void;
  30838. /** @hidden */
  30839. _releaseTexture(texture: InternalTexture): void;
  30840. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30841. protected _setProgram(program: WebGLProgram): void;
  30842. protected _boundUniforms: {
  30843. [key: number]: WebGLUniformLocation;
  30844. };
  30845. /**
  30846. * Binds an effect to the webGL context
  30847. * @param effect defines the effect to bind
  30848. */
  30849. bindSamplers(effect: Effect): void;
  30850. private _activateCurrentTexture;
  30851. /** @hidden */
  30852. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30853. /** @hidden */
  30854. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30855. /**
  30856. * Unbind all textures from the webGL context
  30857. */
  30858. unbindAllTextures(): void;
  30859. /**
  30860. * Sets a texture to the according uniform.
  30861. * @param channel The texture channel
  30862. * @param uniform The uniform to set
  30863. * @param texture The texture to apply
  30864. */
  30865. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30866. private _bindSamplerUniformToChannel;
  30867. private _getTextureWrapMode;
  30868. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30869. /**
  30870. * Sets an array of texture to the webGL context
  30871. * @param channel defines the channel where the texture array must be set
  30872. * @param uniform defines the associated uniform location
  30873. * @param textures defines the array of textures to bind
  30874. */
  30875. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30876. /** @hidden */
  30877. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30878. private _setTextureParameterFloat;
  30879. private _setTextureParameterInteger;
  30880. /**
  30881. * Unbind all vertex attributes from the webGL context
  30882. */
  30883. unbindAllAttributes(): void;
  30884. /**
  30885. * 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
  30886. */
  30887. releaseEffects(): void;
  30888. /**
  30889. * Dispose and release all associated resources
  30890. */
  30891. dispose(): void;
  30892. /**
  30893. * Attach a new callback raised when context lost event is fired
  30894. * @param callback defines the callback to call
  30895. */
  30896. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30897. /**
  30898. * Attach a new callback raised when context restored event is fired
  30899. * @param callback defines the callback to call
  30900. */
  30901. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30902. /**
  30903. * Get the current error code of the webGL context
  30904. * @returns the error code
  30905. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30906. */
  30907. getError(): number;
  30908. private _canRenderToFloatFramebuffer;
  30909. private _canRenderToHalfFloatFramebuffer;
  30910. private _canRenderToFramebuffer;
  30911. /** @hidden */
  30912. _getWebGLTextureType(type: number): number;
  30913. /** @hidden */
  30914. _getInternalFormat(format: number): number;
  30915. /** @hidden */
  30916. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30917. /** @hidden */
  30918. _getRGBAMultiSampleBufferFormat(type: number): number;
  30919. /** @hidden */
  30920. _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;
  30921. /**
  30922. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30923. * @returns true if the engine can be created
  30924. * @ignorenaming
  30925. */
  30926. static isSupported(): boolean;
  30927. /**
  30928. * Find the next highest power of two.
  30929. * @param x Number to start search from.
  30930. * @return Next highest power of two.
  30931. */
  30932. static CeilingPOT(x: number): number;
  30933. /**
  30934. * Find the next lowest power of two.
  30935. * @param x Number to start search from.
  30936. * @return Next lowest power of two.
  30937. */
  30938. static FloorPOT(x: number): number;
  30939. /**
  30940. * Find the nearest power of two.
  30941. * @param x Number to start search from.
  30942. * @return Next nearest power of two.
  30943. */
  30944. static NearestPOT(x: number): number;
  30945. /**
  30946. * Get the closest exponent of two
  30947. * @param value defines the value to approximate
  30948. * @param max defines the maximum value to return
  30949. * @param mode defines how to define the closest value
  30950. * @returns closest exponent of two of the given value
  30951. */
  30952. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30953. /**
  30954. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30955. * @param func - the function to be called
  30956. * @param requester - the object that will request the next frame. Falls back to window.
  30957. * @returns frame number
  30958. */
  30959. static QueueNewFrame(func: () => void, requester?: any): number;
  30960. }
  30961. }
  30962. declare module "babylonjs/Maths/sphericalPolynomial" {
  30963. import { Vector3 } from "babylonjs/Maths/math.vector";
  30964. import { Color3 } from "babylonjs/Maths/math.color";
  30965. /**
  30966. * Class representing spherical harmonics coefficients to the 3rd degree
  30967. */
  30968. export class SphericalHarmonics {
  30969. /**
  30970. * Defines whether or not the harmonics have been prescaled for rendering.
  30971. */
  30972. preScaled: boolean;
  30973. /**
  30974. * The l0,0 coefficients of the spherical harmonics
  30975. */
  30976. l00: Vector3;
  30977. /**
  30978. * The l1,-1 coefficients of the spherical harmonics
  30979. */
  30980. l1_1: Vector3;
  30981. /**
  30982. * The l1,0 coefficients of the spherical harmonics
  30983. */
  30984. l10: Vector3;
  30985. /**
  30986. * The l1,1 coefficients of the spherical harmonics
  30987. */
  30988. l11: Vector3;
  30989. /**
  30990. * The l2,-2 coefficients of the spherical harmonics
  30991. */
  30992. l2_2: Vector3;
  30993. /**
  30994. * The l2,-1 coefficients of the spherical harmonics
  30995. */
  30996. l2_1: Vector3;
  30997. /**
  30998. * The l2,0 coefficients of the spherical harmonics
  30999. */
  31000. l20: Vector3;
  31001. /**
  31002. * The l2,1 coefficients of the spherical harmonics
  31003. */
  31004. l21: Vector3;
  31005. /**
  31006. * The l2,2 coefficients of the spherical harmonics
  31007. */
  31008. l22: Vector3;
  31009. /**
  31010. * Adds a light to the spherical harmonics
  31011. * @param direction the direction of the light
  31012. * @param color the color of the light
  31013. * @param deltaSolidAngle the delta solid angle of the light
  31014. */
  31015. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31016. /**
  31017. * Scales the spherical harmonics by the given amount
  31018. * @param scale the amount to scale
  31019. */
  31020. scaleInPlace(scale: number): void;
  31021. /**
  31022. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31023. *
  31024. * ```
  31025. * E_lm = A_l * L_lm
  31026. * ```
  31027. *
  31028. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31029. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31030. * the scaling factors are given in equation 9.
  31031. */
  31032. convertIncidentRadianceToIrradiance(): void;
  31033. /**
  31034. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31035. *
  31036. * ```
  31037. * L = (1/pi) * E * rho
  31038. * ```
  31039. *
  31040. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31041. */
  31042. convertIrradianceToLambertianRadiance(): void;
  31043. /**
  31044. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31045. * required operations at run time.
  31046. *
  31047. * This is simply done by scaling back the SH with Ylm constants parameter.
  31048. * The trigonometric part being applied by the shader at run time.
  31049. */
  31050. preScaleForRendering(): void;
  31051. /**
  31052. * Constructs a spherical harmonics from an array.
  31053. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31054. * @returns the spherical harmonics
  31055. */
  31056. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31057. /**
  31058. * Gets the spherical harmonics from polynomial
  31059. * @param polynomial the spherical polynomial
  31060. * @returns the spherical harmonics
  31061. */
  31062. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31063. }
  31064. /**
  31065. * Class representing spherical polynomial coefficients to the 3rd degree
  31066. */
  31067. export class SphericalPolynomial {
  31068. private _harmonics;
  31069. /**
  31070. * The spherical harmonics used to create the polynomials.
  31071. */
  31072. readonly preScaledHarmonics: SphericalHarmonics;
  31073. /**
  31074. * The x coefficients of the spherical polynomial
  31075. */
  31076. x: Vector3;
  31077. /**
  31078. * The y coefficients of the spherical polynomial
  31079. */
  31080. y: Vector3;
  31081. /**
  31082. * The z coefficients of the spherical polynomial
  31083. */
  31084. z: Vector3;
  31085. /**
  31086. * The xx coefficients of the spherical polynomial
  31087. */
  31088. xx: Vector3;
  31089. /**
  31090. * The yy coefficients of the spherical polynomial
  31091. */
  31092. yy: Vector3;
  31093. /**
  31094. * The zz coefficients of the spherical polynomial
  31095. */
  31096. zz: Vector3;
  31097. /**
  31098. * The xy coefficients of the spherical polynomial
  31099. */
  31100. xy: Vector3;
  31101. /**
  31102. * The yz coefficients of the spherical polynomial
  31103. */
  31104. yz: Vector3;
  31105. /**
  31106. * The zx coefficients of the spherical polynomial
  31107. */
  31108. zx: Vector3;
  31109. /**
  31110. * Adds an ambient color to the spherical polynomial
  31111. * @param color the color to add
  31112. */
  31113. addAmbient(color: Color3): void;
  31114. /**
  31115. * Scales the spherical polynomial by the given amount
  31116. * @param scale the amount to scale
  31117. */
  31118. scaleInPlace(scale: number): void;
  31119. /**
  31120. * Gets the spherical polynomial from harmonics
  31121. * @param harmonics the spherical harmonics
  31122. * @returns the spherical polynomial
  31123. */
  31124. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31125. /**
  31126. * Constructs a spherical polynomial from an array.
  31127. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31128. * @returns the spherical polynomial
  31129. */
  31130. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31131. }
  31132. }
  31133. declare module "babylonjs/Materials/Textures/internalTexture" {
  31134. import { Observable } from "babylonjs/Misc/observable";
  31135. import { Nullable, int } from "babylonjs/types";
  31136. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31137. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31138. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31139. /**
  31140. * Defines the source of the internal texture
  31141. */
  31142. export enum InternalTextureSource {
  31143. /**
  31144. * The source of the texture data is unknown
  31145. */
  31146. Unknown = 0,
  31147. /**
  31148. * Texture data comes from an URL
  31149. */
  31150. Url = 1,
  31151. /**
  31152. * Texture data is only used for temporary storage
  31153. */
  31154. Temp = 2,
  31155. /**
  31156. * Texture data comes from raw data (ArrayBuffer)
  31157. */
  31158. Raw = 3,
  31159. /**
  31160. * Texture content is dynamic (video or dynamic texture)
  31161. */
  31162. Dynamic = 4,
  31163. /**
  31164. * Texture content is generated by rendering to it
  31165. */
  31166. RenderTarget = 5,
  31167. /**
  31168. * Texture content is part of a multi render target process
  31169. */
  31170. MultiRenderTarget = 6,
  31171. /**
  31172. * Texture data comes from a cube data file
  31173. */
  31174. Cube = 7,
  31175. /**
  31176. * Texture data comes from a raw cube data
  31177. */
  31178. CubeRaw = 8,
  31179. /**
  31180. * Texture data come from a prefiltered cube data file
  31181. */
  31182. CubePrefiltered = 9,
  31183. /**
  31184. * Texture content is raw 3D data
  31185. */
  31186. Raw3D = 10,
  31187. /**
  31188. * Texture content is a depth texture
  31189. */
  31190. Depth = 11,
  31191. /**
  31192. * Texture data comes from a raw cube data encoded with RGBD
  31193. */
  31194. CubeRawRGBD = 12
  31195. }
  31196. /**
  31197. * Class used to store data associated with WebGL texture data for the engine
  31198. * This class should not be used directly
  31199. */
  31200. export class InternalTexture {
  31201. /** @hidden */
  31202. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31203. /**
  31204. * Defines if the texture is ready
  31205. */
  31206. isReady: boolean;
  31207. /**
  31208. * Defines if the texture is a cube texture
  31209. */
  31210. isCube: boolean;
  31211. /**
  31212. * Defines if the texture contains 3D data
  31213. */
  31214. is3D: boolean;
  31215. /**
  31216. * Defines if the texture contains multiview data
  31217. */
  31218. isMultiview: boolean;
  31219. /**
  31220. * Gets the URL used to load this texture
  31221. */
  31222. url: string;
  31223. /**
  31224. * Gets the sampling mode of the texture
  31225. */
  31226. samplingMode: number;
  31227. /**
  31228. * Gets a boolean indicating if the texture needs mipmaps generation
  31229. */
  31230. generateMipMaps: boolean;
  31231. /**
  31232. * Gets the number of samples used by the texture (WebGL2+ only)
  31233. */
  31234. samples: number;
  31235. /**
  31236. * Gets the type of the texture (int, float...)
  31237. */
  31238. type: number;
  31239. /**
  31240. * Gets the format of the texture (RGB, RGBA...)
  31241. */
  31242. format: number;
  31243. /**
  31244. * Observable called when the texture is loaded
  31245. */
  31246. onLoadedObservable: Observable<InternalTexture>;
  31247. /**
  31248. * Gets the width of the texture
  31249. */
  31250. width: number;
  31251. /**
  31252. * Gets the height of the texture
  31253. */
  31254. height: number;
  31255. /**
  31256. * Gets the depth of the texture
  31257. */
  31258. depth: number;
  31259. /**
  31260. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31261. */
  31262. baseWidth: number;
  31263. /**
  31264. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31265. */
  31266. baseHeight: number;
  31267. /**
  31268. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31269. */
  31270. baseDepth: number;
  31271. /**
  31272. * Gets a boolean indicating if the texture is inverted on Y axis
  31273. */
  31274. invertY: boolean;
  31275. /** @hidden */
  31276. _invertVScale: boolean;
  31277. /** @hidden */
  31278. _associatedChannel: number;
  31279. /** @hidden */
  31280. _source: InternalTextureSource;
  31281. /** @hidden */
  31282. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31283. /** @hidden */
  31284. _bufferView: Nullable<ArrayBufferView>;
  31285. /** @hidden */
  31286. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31287. /** @hidden */
  31288. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31289. /** @hidden */
  31290. _size: number;
  31291. /** @hidden */
  31292. _extension: string;
  31293. /** @hidden */
  31294. _files: Nullable<string[]>;
  31295. /** @hidden */
  31296. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31297. /** @hidden */
  31298. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31299. /** @hidden */
  31300. _framebuffer: Nullable<WebGLFramebuffer>;
  31301. /** @hidden */
  31302. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31303. /** @hidden */
  31304. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31305. /** @hidden */
  31306. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31307. /** @hidden */
  31308. _attachments: Nullable<number[]>;
  31309. /** @hidden */
  31310. _cachedCoordinatesMode: Nullable<number>;
  31311. /** @hidden */
  31312. _cachedWrapU: Nullable<number>;
  31313. /** @hidden */
  31314. _cachedWrapV: Nullable<number>;
  31315. /** @hidden */
  31316. _cachedWrapR: Nullable<number>;
  31317. /** @hidden */
  31318. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31319. /** @hidden */
  31320. _isDisabled: boolean;
  31321. /** @hidden */
  31322. _compression: Nullable<string>;
  31323. /** @hidden */
  31324. _generateStencilBuffer: boolean;
  31325. /** @hidden */
  31326. _generateDepthBuffer: boolean;
  31327. /** @hidden */
  31328. _comparisonFunction: number;
  31329. /** @hidden */
  31330. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31331. /** @hidden */
  31332. _lodGenerationScale: number;
  31333. /** @hidden */
  31334. _lodGenerationOffset: number;
  31335. /** @hidden */
  31336. _colorTextureArray: Nullable<WebGLTexture>;
  31337. /** @hidden */
  31338. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31339. /** @hidden */
  31340. _lodTextureHigh: Nullable<BaseTexture>;
  31341. /** @hidden */
  31342. _lodTextureMid: Nullable<BaseTexture>;
  31343. /** @hidden */
  31344. _lodTextureLow: Nullable<BaseTexture>;
  31345. /** @hidden */
  31346. _isRGBD: boolean;
  31347. /** @hidden */
  31348. _linearSpecularLOD: boolean;
  31349. /** @hidden */
  31350. _irradianceTexture: Nullable<BaseTexture>;
  31351. /** @hidden */
  31352. _webGLTexture: Nullable<WebGLTexture>;
  31353. /** @hidden */
  31354. _references: number;
  31355. private _engine;
  31356. /**
  31357. * Gets the Engine the texture belongs to.
  31358. * @returns The babylon engine
  31359. */
  31360. getEngine(): ThinEngine;
  31361. /**
  31362. * Gets the data source type of the texture
  31363. */
  31364. readonly source: InternalTextureSource;
  31365. /**
  31366. * Creates a new InternalTexture
  31367. * @param engine defines the engine to use
  31368. * @param source defines the type of data that will be used
  31369. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31370. */
  31371. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31372. /**
  31373. * Increments the number of references (ie. the number of Texture that point to it)
  31374. */
  31375. incrementReferences(): void;
  31376. /**
  31377. * Change the size of the texture (not the size of the content)
  31378. * @param width defines the new width
  31379. * @param height defines the new height
  31380. * @param depth defines the new depth (1 by default)
  31381. */
  31382. updateSize(width: int, height: int, depth?: int): void;
  31383. /** @hidden */
  31384. _rebuild(): void;
  31385. /** @hidden */
  31386. _swapAndDie(target: InternalTexture): void;
  31387. /**
  31388. * Dispose the current allocated resources
  31389. */
  31390. dispose(): void;
  31391. }
  31392. }
  31393. declare module "babylonjs/Audio/analyser" {
  31394. import { Scene } from "babylonjs/scene";
  31395. /**
  31396. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31398. */
  31399. export class Analyser {
  31400. /**
  31401. * Gets or sets the smoothing
  31402. * @ignorenaming
  31403. */
  31404. SMOOTHING: number;
  31405. /**
  31406. * Gets or sets the FFT table size
  31407. * @ignorenaming
  31408. */
  31409. FFT_SIZE: number;
  31410. /**
  31411. * Gets or sets the bar graph amplitude
  31412. * @ignorenaming
  31413. */
  31414. BARGRAPHAMPLITUDE: number;
  31415. /**
  31416. * Gets or sets the position of the debug canvas
  31417. * @ignorenaming
  31418. */
  31419. DEBUGCANVASPOS: {
  31420. x: number;
  31421. y: number;
  31422. };
  31423. /**
  31424. * Gets or sets the debug canvas size
  31425. * @ignorenaming
  31426. */
  31427. DEBUGCANVASSIZE: {
  31428. width: number;
  31429. height: number;
  31430. };
  31431. private _byteFreqs;
  31432. private _byteTime;
  31433. private _floatFreqs;
  31434. private _webAudioAnalyser;
  31435. private _debugCanvas;
  31436. private _debugCanvasContext;
  31437. private _scene;
  31438. private _registerFunc;
  31439. private _audioEngine;
  31440. /**
  31441. * Creates a new analyser
  31442. * @param scene defines hosting scene
  31443. */
  31444. constructor(scene: Scene);
  31445. /**
  31446. * Get the number of data values you will have to play with for the visualization
  31447. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31448. * @returns a number
  31449. */
  31450. getFrequencyBinCount(): number;
  31451. /**
  31452. * Gets the current frequency data as a byte array
  31453. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31454. * @returns a Uint8Array
  31455. */
  31456. getByteFrequencyData(): Uint8Array;
  31457. /**
  31458. * Gets the current waveform as a byte array
  31459. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31460. * @returns a Uint8Array
  31461. */
  31462. getByteTimeDomainData(): Uint8Array;
  31463. /**
  31464. * Gets the current frequency data as a float array
  31465. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31466. * @returns a Float32Array
  31467. */
  31468. getFloatFrequencyData(): Float32Array;
  31469. /**
  31470. * Renders the debug canvas
  31471. */
  31472. drawDebugCanvas(): void;
  31473. /**
  31474. * Stops rendering the debug canvas and removes it
  31475. */
  31476. stopDebugCanvas(): void;
  31477. /**
  31478. * Connects two audio nodes
  31479. * @param inputAudioNode defines first node to connect
  31480. * @param outputAudioNode defines second node to connect
  31481. */
  31482. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31483. /**
  31484. * Releases all associated resources
  31485. */
  31486. dispose(): void;
  31487. }
  31488. }
  31489. declare module "babylonjs/Audio/audioEngine" {
  31490. import { IDisposable } from "babylonjs/scene";
  31491. import { Analyser } from "babylonjs/Audio/analyser";
  31492. import { Nullable } from "babylonjs/types";
  31493. import { Observable } from "babylonjs/Misc/observable";
  31494. /**
  31495. * This represents an audio engine and it is responsible
  31496. * to play, synchronize and analyse sounds throughout the application.
  31497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31498. */
  31499. export interface IAudioEngine extends IDisposable {
  31500. /**
  31501. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31502. */
  31503. readonly canUseWebAudio: boolean;
  31504. /**
  31505. * Gets the current AudioContext if available.
  31506. */
  31507. readonly audioContext: Nullable<AudioContext>;
  31508. /**
  31509. * The master gain node defines the global audio volume of your audio engine.
  31510. */
  31511. readonly masterGain: GainNode;
  31512. /**
  31513. * Gets whether or not mp3 are supported by your browser.
  31514. */
  31515. readonly isMP3supported: boolean;
  31516. /**
  31517. * Gets whether or not ogg are supported by your browser.
  31518. */
  31519. readonly isOGGsupported: boolean;
  31520. /**
  31521. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31522. * @ignoreNaming
  31523. */
  31524. WarnedWebAudioUnsupported: boolean;
  31525. /**
  31526. * Defines if the audio engine relies on a custom unlocked button.
  31527. * In this case, the embedded button will not be displayed.
  31528. */
  31529. useCustomUnlockedButton: boolean;
  31530. /**
  31531. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31532. */
  31533. readonly unlocked: boolean;
  31534. /**
  31535. * Event raised when audio has been unlocked on the browser.
  31536. */
  31537. onAudioUnlockedObservable: Observable<AudioEngine>;
  31538. /**
  31539. * Event raised when audio has been locked on the browser.
  31540. */
  31541. onAudioLockedObservable: Observable<AudioEngine>;
  31542. /**
  31543. * Flags the audio engine in Locked state.
  31544. * This happens due to new browser policies preventing audio to autoplay.
  31545. */
  31546. lock(): void;
  31547. /**
  31548. * Unlocks the audio engine once a user action has been done on the dom.
  31549. * This is helpful to resume play once browser policies have been satisfied.
  31550. */
  31551. unlock(): void;
  31552. }
  31553. /**
  31554. * This represents the default audio engine used in babylon.
  31555. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31557. */
  31558. export class AudioEngine implements IAudioEngine {
  31559. private _audioContext;
  31560. private _audioContextInitialized;
  31561. private _muteButton;
  31562. private _hostElement;
  31563. /**
  31564. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31565. */
  31566. canUseWebAudio: boolean;
  31567. /**
  31568. * The master gain node defines the global audio volume of your audio engine.
  31569. */
  31570. masterGain: GainNode;
  31571. /**
  31572. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31573. * @ignoreNaming
  31574. */
  31575. WarnedWebAudioUnsupported: boolean;
  31576. /**
  31577. * Gets whether or not mp3 are supported by your browser.
  31578. */
  31579. isMP3supported: boolean;
  31580. /**
  31581. * Gets whether or not ogg are supported by your browser.
  31582. */
  31583. isOGGsupported: boolean;
  31584. /**
  31585. * Gets whether audio has been unlocked on the device.
  31586. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31587. * a user interaction has happened.
  31588. */
  31589. unlocked: boolean;
  31590. /**
  31591. * Defines if the audio engine relies on a custom unlocked button.
  31592. * In this case, the embedded button will not be displayed.
  31593. */
  31594. useCustomUnlockedButton: boolean;
  31595. /**
  31596. * Event raised when audio has been unlocked on the browser.
  31597. */
  31598. onAudioUnlockedObservable: Observable<AudioEngine>;
  31599. /**
  31600. * Event raised when audio has been locked on the browser.
  31601. */
  31602. onAudioLockedObservable: Observable<AudioEngine>;
  31603. /**
  31604. * Gets the current AudioContext if available.
  31605. */
  31606. readonly audioContext: Nullable<AudioContext>;
  31607. private _connectedAnalyser;
  31608. /**
  31609. * Instantiates a new audio engine.
  31610. *
  31611. * There should be only one per page as some browsers restrict the number
  31612. * of audio contexts you can create.
  31613. * @param hostElement defines the host element where to display the mute icon if necessary
  31614. */
  31615. constructor(hostElement?: Nullable<HTMLElement>);
  31616. /**
  31617. * Flags the audio engine in Locked state.
  31618. * This happens due to new browser policies preventing audio to autoplay.
  31619. */
  31620. lock(): void;
  31621. /**
  31622. * Unlocks the audio engine once a user action has been done on the dom.
  31623. * This is helpful to resume play once browser policies have been satisfied.
  31624. */
  31625. unlock(): void;
  31626. private _resumeAudioContext;
  31627. private _initializeAudioContext;
  31628. private _tryToRun;
  31629. private _triggerRunningState;
  31630. private _triggerSuspendedState;
  31631. private _displayMuteButton;
  31632. private _moveButtonToTopLeft;
  31633. private _onResize;
  31634. private _hideMuteButton;
  31635. /**
  31636. * Destroy and release the resources associated with the audio ccontext.
  31637. */
  31638. dispose(): void;
  31639. /**
  31640. * Gets the global volume sets on the master gain.
  31641. * @returns the global volume if set or -1 otherwise
  31642. */
  31643. getGlobalVolume(): number;
  31644. /**
  31645. * Sets the global volume of your experience (sets on the master gain).
  31646. * @param newVolume Defines the new global volume of the application
  31647. */
  31648. setGlobalVolume(newVolume: number): void;
  31649. /**
  31650. * Connect the audio engine to an audio analyser allowing some amazing
  31651. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31653. * @param analyser The analyser to connect to the engine
  31654. */
  31655. connectToAnalyser(analyser: Analyser): void;
  31656. }
  31657. }
  31658. declare module "babylonjs/Loading/loadingScreen" {
  31659. /**
  31660. * Interface used to present a loading screen while loading a scene
  31661. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31662. */
  31663. export interface ILoadingScreen {
  31664. /**
  31665. * Function called to display the loading screen
  31666. */
  31667. displayLoadingUI: () => void;
  31668. /**
  31669. * Function called to hide the loading screen
  31670. */
  31671. hideLoadingUI: () => void;
  31672. /**
  31673. * Gets or sets the color to use for the background
  31674. */
  31675. loadingUIBackgroundColor: string;
  31676. /**
  31677. * Gets or sets the text to display while loading
  31678. */
  31679. loadingUIText: string;
  31680. }
  31681. /**
  31682. * Class used for the default loading screen
  31683. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31684. */
  31685. export class DefaultLoadingScreen implements ILoadingScreen {
  31686. private _renderingCanvas;
  31687. private _loadingText;
  31688. private _loadingDivBackgroundColor;
  31689. private _loadingDiv;
  31690. private _loadingTextDiv;
  31691. /** Gets or sets the logo url to use for the default loading screen */
  31692. static DefaultLogoUrl: string;
  31693. /** Gets or sets the spinner url to use for the default loading screen */
  31694. static DefaultSpinnerUrl: string;
  31695. /**
  31696. * Creates a new default loading screen
  31697. * @param _renderingCanvas defines the canvas used to render the scene
  31698. * @param _loadingText defines the default text to display
  31699. * @param _loadingDivBackgroundColor defines the default background color
  31700. */
  31701. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31702. /**
  31703. * Function called to display the loading screen
  31704. */
  31705. displayLoadingUI(): void;
  31706. /**
  31707. * Function called to hide the loading screen
  31708. */
  31709. hideLoadingUI(): void;
  31710. /**
  31711. * Gets or sets the text to display while loading
  31712. */
  31713. loadingUIText: string;
  31714. /**
  31715. * Gets or sets the color to use for the background
  31716. */
  31717. loadingUIBackgroundColor: string;
  31718. private _resizeLoadingUI;
  31719. }
  31720. }
  31721. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31722. /**
  31723. * Interface for any object that can request an animation frame
  31724. */
  31725. export interface ICustomAnimationFrameRequester {
  31726. /**
  31727. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31728. */
  31729. renderFunction?: Function;
  31730. /**
  31731. * Called to request the next frame to render to
  31732. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31733. */
  31734. requestAnimationFrame: Function;
  31735. /**
  31736. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31737. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31738. */
  31739. requestID?: number;
  31740. }
  31741. }
  31742. declare module "babylonjs/Misc/performanceMonitor" {
  31743. /**
  31744. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31745. */
  31746. export class PerformanceMonitor {
  31747. private _enabled;
  31748. private _rollingFrameTime;
  31749. private _lastFrameTimeMs;
  31750. /**
  31751. * constructor
  31752. * @param frameSampleSize The number of samples required to saturate the sliding window
  31753. */
  31754. constructor(frameSampleSize?: number);
  31755. /**
  31756. * Samples current frame
  31757. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31758. */
  31759. sampleFrame(timeMs?: number): void;
  31760. /**
  31761. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31762. */
  31763. readonly averageFrameTime: number;
  31764. /**
  31765. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31766. */
  31767. readonly averageFrameTimeVariance: number;
  31768. /**
  31769. * Returns the frame time of the most recent frame
  31770. */
  31771. readonly instantaneousFrameTime: number;
  31772. /**
  31773. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31774. */
  31775. readonly averageFPS: number;
  31776. /**
  31777. * Returns the average framerate in frames per second using the most recent frame time
  31778. */
  31779. readonly instantaneousFPS: number;
  31780. /**
  31781. * Returns true if enough samples have been taken to completely fill the sliding window
  31782. */
  31783. readonly isSaturated: boolean;
  31784. /**
  31785. * Enables contributions to the sliding window sample set
  31786. */
  31787. enable(): void;
  31788. /**
  31789. * Disables contributions to the sliding window sample set
  31790. * Samples will not be interpolated over the disabled period
  31791. */
  31792. disable(): void;
  31793. /**
  31794. * Returns true if sampling is enabled
  31795. */
  31796. readonly isEnabled: boolean;
  31797. /**
  31798. * Resets performance monitor
  31799. */
  31800. reset(): void;
  31801. }
  31802. /**
  31803. * RollingAverage
  31804. *
  31805. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31806. */
  31807. export class RollingAverage {
  31808. /**
  31809. * Current average
  31810. */
  31811. average: number;
  31812. /**
  31813. * Current variance
  31814. */
  31815. variance: number;
  31816. protected _samples: Array<number>;
  31817. protected _sampleCount: number;
  31818. protected _pos: number;
  31819. protected _m2: number;
  31820. /**
  31821. * constructor
  31822. * @param length The number of samples required to saturate the sliding window
  31823. */
  31824. constructor(length: number);
  31825. /**
  31826. * Adds a sample to the sample set
  31827. * @param v The sample value
  31828. */
  31829. add(v: number): void;
  31830. /**
  31831. * Returns previously added values or null if outside of history or outside the sliding window domain
  31832. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31833. * @return Value previously recorded with add() or null if outside of range
  31834. */
  31835. history(i: number): number;
  31836. /**
  31837. * Returns true if enough samples have been taken to completely fill the sliding window
  31838. * @return true if sample-set saturated
  31839. */
  31840. isSaturated(): boolean;
  31841. /**
  31842. * Resets the rolling average (equivalent to 0 samples taken so far)
  31843. */
  31844. reset(): void;
  31845. /**
  31846. * Wraps a value around the sample range boundaries
  31847. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31848. * @return Wrapped position in sample range
  31849. */
  31850. protected _wrapPosition(i: number): number;
  31851. }
  31852. }
  31853. declare module "babylonjs/Misc/perfCounter" {
  31854. /**
  31855. * This class is used to track a performance counter which is number based.
  31856. * The user has access to many properties which give statistics of different nature.
  31857. *
  31858. * The implementer can track two kinds of Performance Counter: time and count.
  31859. * 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.
  31860. * 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.
  31861. */
  31862. export class PerfCounter {
  31863. /**
  31864. * Gets or sets a global boolean to turn on and off all the counters
  31865. */
  31866. static Enabled: boolean;
  31867. /**
  31868. * Returns the smallest value ever
  31869. */
  31870. readonly min: number;
  31871. /**
  31872. * Returns the biggest value ever
  31873. */
  31874. readonly max: number;
  31875. /**
  31876. * Returns the average value since the performance counter is running
  31877. */
  31878. readonly average: number;
  31879. /**
  31880. * Returns the average value of the last second the counter was monitored
  31881. */
  31882. readonly lastSecAverage: number;
  31883. /**
  31884. * Returns the current value
  31885. */
  31886. readonly current: number;
  31887. /**
  31888. * Gets the accumulated total
  31889. */
  31890. readonly total: number;
  31891. /**
  31892. * Gets the total value count
  31893. */
  31894. readonly count: number;
  31895. /**
  31896. * Creates a new counter
  31897. */
  31898. constructor();
  31899. /**
  31900. * Call this method to start monitoring a new frame.
  31901. * 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.
  31902. */
  31903. fetchNewFrame(): void;
  31904. /**
  31905. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31906. * @param newCount the count value to add to the monitored count
  31907. * @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.
  31908. */
  31909. addCount(newCount: number, fetchResult: boolean): void;
  31910. /**
  31911. * Start monitoring this performance counter
  31912. */
  31913. beginMonitoring(): void;
  31914. /**
  31915. * Compute the time lapsed since the previous beginMonitoring() call.
  31916. * @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
  31917. */
  31918. endMonitoring(newFrame?: boolean): void;
  31919. private _fetchResult;
  31920. private _startMonitoringTime;
  31921. private _min;
  31922. private _max;
  31923. private _average;
  31924. private _current;
  31925. private _totalValueCount;
  31926. private _totalAccumulated;
  31927. private _lastSecAverage;
  31928. private _lastSecAccumulated;
  31929. private _lastSecTime;
  31930. private _lastSecValueCount;
  31931. }
  31932. }
  31933. declare module "babylonjs/Engines/engine" {
  31934. import { Observable } from "babylonjs/Misc/observable";
  31935. import { Nullable, IndicesArray } from "babylonjs/types";
  31936. import { Scene } from "babylonjs/scene";
  31937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31938. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31939. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31940. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31941. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31942. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31943. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31944. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31945. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31946. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31947. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31948. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31949. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31950. import { Material } from "babylonjs/Materials/material";
  31951. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31952. /**
  31953. * Defines the interface used by display changed events
  31954. */
  31955. export interface IDisplayChangedEventArgs {
  31956. /** Gets the vrDisplay object (if any) */
  31957. vrDisplay: Nullable<any>;
  31958. /** Gets a boolean indicating if webVR is supported */
  31959. vrSupported: boolean;
  31960. }
  31961. /**
  31962. * Defines the interface used by objects containing a viewport (like a camera)
  31963. */
  31964. interface IViewportOwnerLike {
  31965. /**
  31966. * Gets or sets the viewport
  31967. */
  31968. viewport: IViewportLike;
  31969. }
  31970. /**
  31971. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31972. */
  31973. export class Engine extends ThinEngine {
  31974. /** Defines that alpha blending is disabled */
  31975. static readonly ALPHA_DISABLE: number;
  31976. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31977. static readonly ALPHA_ADD: number;
  31978. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31979. static readonly ALPHA_COMBINE: number;
  31980. /** Defines that alpha blending to DEST - SRC * DEST */
  31981. static readonly ALPHA_SUBTRACT: number;
  31982. /** Defines that alpha blending to SRC * DEST */
  31983. static readonly ALPHA_MULTIPLY: number;
  31984. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31985. static readonly ALPHA_MAXIMIZED: number;
  31986. /** Defines that alpha blending to SRC + DEST */
  31987. static readonly ALPHA_ONEONE: number;
  31988. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31989. static readonly ALPHA_PREMULTIPLIED: number;
  31990. /**
  31991. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31992. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31993. */
  31994. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31995. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31996. static readonly ALPHA_INTERPOLATE: number;
  31997. /**
  31998. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31999. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32000. */
  32001. static readonly ALPHA_SCREENMODE: number;
  32002. /** Defines that the ressource is not delayed*/
  32003. static readonly DELAYLOADSTATE_NONE: number;
  32004. /** Defines that the ressource was successfully delay loaded */
  32005. static readonly DELAYLOADSTATE_LOADED: number;
  32006. /** Defines that the ressource is currently delay loading */
  32007. static readonly DELAYLOADSTATE_LOADING: number;
  32008. /** Defines that the ressource is delayed and has not started loading */
  32009. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32010. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32011. static readonly NEVER: number;
  32012. /** 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 */
  32013. static readonly ALWAYS: number;
  32014. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32015. static readonly LESS: number;
  32016. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32017. static readonly EQUAL: number;
  32018. /** 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 */
  32019. static readonly LEQUAL: number;
  32020. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32021. static readonly GREATER: number;
  32022. /** 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 */
  32023. static readonly GEQUAL: number;
  32024. /** 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 */
  32025. static readonly NOTEQUAL: number;
  32026. /** Passed to stencilOperation to specify that stencil value must be kept */
  32027. static readonly KEEP: number;
  32028. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32029. static readonly REPLACE: number;
  32030. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32031. static readonly INCR: number;
  32032. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32033. static readonly DECR: number;
  32034. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32035. static readonly INVERT: number;
  32036. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32037. static readonly INCR_WRAP: number;
  32038. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32039. static readonly DECR_WRAP: number;
  32040. /** Texture is not repeating outside of 0..1 UVs */
  32041. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32042. /** Texture is repeating outside of 0..1 UVs */
  32043. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32044. /** Texture is repeating and mirrored */
  32045. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32046. /** ALPHA */
  32047. static readonly TEXTUREFORMAT_ALPHA: number;
  32048. /** LUMINANCE */
  32049. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32050. /** LUMINANCE_ALPHA */
  32051. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32052. /** RGB */
  32053. static readonly TEXTUREFORMAT_RGB: number;
  32054. /** RGBA */
  32055. static readonly TEXTUREFORMAT_RGBA: number;
  32056. /** RED */
  32057. static readonly TEXTUREFORMAT_RED: number;
  32058. /** RED (2nd reference) */
  32059. static readonly TEXTUREFORMAT_R: number;
  32060. /** RG */
  32061. static readonly TEXTUREFORMAT_RG: number;
  32062. /** RED_INTEGER */
  32063. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32064. /** RED_INTEGER (2nd reference) */
  32065. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32066. /** RG_INTEGER */
  32067. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32068. /** RGB_INTEGER */
  32069. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32070. /** RGBA_INTEGER */
  32071. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32072. /** UNSIGNED_BYTE */
  32073. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32074. /** UNSIGNED_BYTE (2nd reference) */
  32075. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32076. /** FLOAT */
  32077. static readonly TEXTURETYPE_FLOAT: number;
  32078. /** HALF_FLOAT */
  32079. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32080. /** BYTE */
  32081. static readonly TEXTURETYPE_BYTE: number;
  32082. /** SHORT */
  32083. static readonly TEXTURETYPE_SHORT: number;
  32084. /** UNSIGNED_SHORT */
  32085. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32086. /** INT */
  32087. static readonly TEXTURETYPE_INT: number;
  32088. /** UNSIGNED_INT */
  32089. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32090. /** UNSIGNED_SHORT_4_4_4_4 */
  32091. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32092. /** UNSIGNED_SHORT_5_5_5_1 */
  32093. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32094. /** UNSIGNED_SHORT_5_6_5 */
  32095. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32096. /** UNSIGNED_INT_2_10_10_10_REV */
  32097. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32098. /** UNSIGNED_INT_24_8 */
  32099. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32100. /** UNSIGNED_INT_10F_11F_11F_REV */
  32101. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32102. /** UNSIGNED_INT_5_9_9_9_REV */
  32103. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32104. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32105. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32106. /** nearest is mag = nearest and min = nearest and mip = linear */
  32107. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32108. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32109. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32110. /** Trilinear is mag = linear and min = linear and mip = linear */
  32111. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32112. /** nearest is mag = nearest and min = nearest and mip = linear */
  32113. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32114. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32115. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32116. /** Trilinear is mag = linear and min = linear and mip = linear */
  32117. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32118. /** mag = nearest and min = nearest and mip = nearest */
  32119. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32120. /** mag = nearest and min = linear and mip = nearest */
  32121. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32122. /** mag = nearest and min = linear and mip = linear */
  32123. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32124. /** mag = nearest and min = linear and mip = none */
  32125. static readonly TEXTURE_NEAREST_LINEAR: number;
  32126. /** mag = nearest and min = nearest and mip = none */
  32127. static readonly TEXTURE_NEAREST_NEAREST: number;
  32128. /** mag = linear and min = nearest and mip = nearest */
  32129. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32130. /** mag = linear and min = nearest and mip = linear */
  32131. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32132. /** mag = linear and min = linear and mip = none */
  32133. static readonly TEXTURE_LINEAR_LINEAR: number;
  32134. /** mag = linear and min = nearest and mip = none */
  32135. static readonly TEXTURE_LINEAR_NEAREST: number;
  32136. /** Explicit coordinates mode */
  32137. static readonly TEXTURE_EXPLICIT_MODE: number;
  32138. /** Spherical coordinates mode */
  32139. static readonly TEXTURE_SPHERICAL_MODE: number;
  32140. /** Planar coordinates mode */
  32141. static readonly TEXTURE_PLANAR_MODE: number;
  32142. /** Cubic coordinates mode */
  32143. static readonly TEXTURE_CUBIC_MODE: number;
  32144. /** Projection coordinates mode */
  32145. static readonly TEXTURE_PROJECTION_MODE: number;
  32146. /** Skybox coordinates mode */
  32147. static readonly TEXTURE_SKYBOX_MODE: number;
  32148. /** Inverse Cubic coordinates mode */
  32149. static readonly TEXTURE_INVCUBIC_MODE: number;
  32150. /** Equirectangular coordinates mode */
  32151. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32152. /** Equirectangular Fixed coordinates mode */
  32153. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32154. /** Equirectangular Fixed Mirrored coordinates mode */
  32155. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32156. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32157. static readonly SCALEMODE_FLOOR: number;
  32158. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32159. static readonly SCALEMODE_NEAREST: number;
  32160. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32161. static readonly SCALEMODE_CEILING: number;
  32162. /**
  32163. * Returns the current npm package of the sdk
  32164. */
  32165. static readonly NpmPackage: string;
  32166. /**
  32167. * Returns the current version of the framework
  32168. */
  32169. static readonly Version: string;
  32170. /** Gets the list of created engines */
  32171. static readonly Instances: Engine[];
  32172. /**
  32173. * Gets the latest created engine
  32174. */
  32175. static readonly LastCreatedEngine: Nullable<Engine>;
  32176. /**
  32177. * Gets the latest created scene
  32178. */
  32179. static readonly LastCreatedScene: Nullable<Scene>;
  32180. /**
  32181. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32182. * @param flag defines which part of the materials must be marked as dirty
  32183. * @param predicate defines a predicate used to filter which materials should be affected
  32184. */
  32185. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32186. /**
  32187. * Method called to create the default loading screen.
  32188. * This can be overriden in your own app.
  32189. * @param canvas The rendering canvas element
  32190. * @returns The loading screen
  32191. */
  32192. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32193. /**
  32194. * Method called to create the default rescale post process on each engine.
  32195. */
  32196. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32197. /**
  32198. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32199. **/
  32200. enableOfflineSupport: boolean;
  32201. /**
  32202. * 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)
  32203. **/
  32204. disableManifestCheck: boolean;
  32205. /**
  32206. * Gets the list of created scenes
  32207. */
  32208. scenes: Scene[];
  32209. /**
  32210. * Event raised when a new scene is created
  32211. */
  32212. onNewSceneAddedObservable: Observable<Scene>;
  32213. /**
  32214. * Gets the list of created postprocesses
  32215. */
  32216. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32217. /**
  32218. * Gets a boolean indicating if the pointer is currently locked
  32219. */
  32220. isPointerLock: boolean;
  32221. /**
  32222. * Observable event triggered each time the rendering canvas is resized
  32223. */
  32224. onResizeObservable: Observable<Engine>;
  32225. /**
  32226. * Observable event triggered each time the canvas loses focus
  32227. */
  32228. onCanvasBlurObservable: Observable<Engine>;
  32229. /**
  32230. * Observable event triggered each time the canvas gains focus
  32231. */
  32232. onCanvasFocusObservable: Observable<Engine>;
  32233. /**
  32234. * Observable event triggered each time the canvas receives pointerout event
  32235. */
  32236. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32237. /**
  32238. * Observable raised when the engine begins a new frame
  32239. */
  32240. onBeginFrameObservable: Observable<Engine>;
  32241. /**
  32242. * If set, will be used to request the next animation frame for the render loop
  32243. */
  32244. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32245. /**
  32246. * Observable raised when the engine ends the current frame
  32247. */
  32248. onEndFrameObservable: Observable<Engine>;
  32249. /**
  32250. * Observable raised when the engine is about to compile a shader
  32251. */
  32252. onBeforeShaderCompilationObservable: Observable<Engine>;
  32253. /**
  32254. * Observable raised when the engine has jsut compiled a shader
  32255. */
  32256. onAfterShaderCompilationObservable: Observable<Engine>;
  32257. /**
  32258. * Gets the audio engine
  32259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32260. * @ignorenaming
  32261. */
  32262. static audioEngine: IAudioEngine;
  32263. /**
  32264. * Default AudioEngine factory responsible of creating the Audio Engine.
  32265. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32266. */
  32267. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32268. /**
  32269. * Default offline support factory responsible of creating a tool used to store data locally.
  32270. * By default, this will create a Database object if the workload has been embedded.
  32271. */
  32272. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32273. private _loadingScreen;
  32274. private _pointerLockRequested;
  32275. private _dummyFramebuffer;
  32276. private _rescalePostProcess;
  32277. /** @hidden */
  32278. protected _alphaMode: number;
  32279. /** @hidden */
  32280. protected _alphaEquation: number;
  32281. private _deterministicLockstep;
  32282. private _lockstepMaxSteps;
  32283. protected readonly _supportsHardwareTextureRescaling: boolean;
  32284. private _fps;
  32285. private _deltaTime;
  32286. /** @hidden */
  32287. _drawCalls: PerfCounter;
  32288. /**
  32289. * Turn this value on if you want to pause FPS computation when in background
  32290. */
  32291. disablePerformanceMonitorInBackground: boolean;
  32292. private _performanceMonitor;
  32293. /**
  32294. * Gets the performance monitor attached to this engine
  32295. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32296. */
  32297. readonly performanceMonitor: PerformanceMonitor;
  32298. private _onFocus;
  32299. private _onBlur;
  32300. private _onCanvasPointerOut;
  32301. private _onCanvasBlur;
  32302. private _onCanvasFocus;
  32303. private _onFullscreenChange;
  32304. private _onPointerLockChange;
  32305. /**
  32306. * Creates a new engine
  32307. * @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
  32308. * @param antialias defines enable antialiasing (default: false)
  32309. * @param options defines further options to be sent to the getContext() function
  32310. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32311. */
  32312. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32313. /**
  32314. * Gets current aspect ratio
  32315. * @param viewportOwner defines the camera to use to get the aspect ratio
  32316. * @param useScreen defines if screen size must be used (or the current render target if any)
  32317. * @returns a number defining the aspect ratio
  32318. */
  32319. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32320. /**
  32321. * Gets current screen aspect ratio
  32322. * @returns a number defining the aspect ratio
  32323. */
  32324. getScreenAspectRatio(): number;
  32325. /**
  32326. * Gets host document
  32327. * @returns the host document object
  32328. */
  32329. getHostDocument(): Document;
  32330. /**
  32331. * Gets the client rect of the HTML canvas attached with the current webGL context
  32332. * @returns a client rectanglee
  32333. */
  32334. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32335. /**
  32336. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32338. * @returns true if engine is in deterministic lock step mode
  32339. */
  32340. isDeterministicLockStep(): boolean;
  32341. /**
  32342. * Gets the max steps when engine is running in deterministic lock step
  32343. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32344. * @returns the max steps
  32345. */
  32346. getLockstepMaxSteps(): number;
  32347. /**
  32348. * Force the mipmap generation for the given render target texture
  32349. * @param texture defines the render target texture to use
  32350. */
  32351. generateMipMapsForCubemap(texture: InternalTexture): void;
  32352. /** States */
  32353. /**
  32354. * Set various states to the webGL context
  32355. * @param culling defines backface culling state
  32356. * @param zOffset defines the value to apply to zOffset (0 by default)
  32357. * @param force defines if states must be applied even if cache is up to date
  32358. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32359. */
  32360. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32361. /**
  32362. * Set the z offset to apply to current rendering
  32363. * @param value defines the offset to apply
  32364. */
  32365. setZOffset(value: number): void;
  32366. /**
  32367. * Gets the current value of the zOffset
  32368. * @returns the current zOffset state
  32369. */
  32370. getZOffset(): number;
  32371. /**
  32372. * Enable or disable depth buffering
  32373. * @param enable defines the state to set
  32374. */
  32375. setDepthBuffer(enable: boolean): void;
  32376. /**
  32377. * Gets a boolean indicating if depth writing is enabled
  32378. * @returns the current depth writing state
  32379. */
  32380. getDepthWrite(): boolean;
  32381. /**
  32382. * Enable or disable depth writing
  32383. * @param enable defines the state to set
  32384. */
  32385. setDepthWrite(enable: boolean): void;
  32386. /**
  32387. * Enable or disable color writing
  32388. * @param enable defines the state to set
  32389. */
  32390. setColorWrite(enable: boolean): void;
  32391. /**
  32392. * Gets a boolean indicating if color writing is enabled
  32393. * @returns the current color writing state
  32394. */
  32395. getColorWrite(): boolean;
  32396. /**
  32397. * Sets alpha constants used by some alpha blending modes
  32398. * @param r defines the red component
  32399. * @param g defines the green component
  32400. * @param b defines the blue component
  32401. * @param a defines the alpha component
  32402. */
  32403. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32404. /**
  32405. * Sets the current alpha mode
  32406. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32407. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32408. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32409. */
  32410. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32411. /**
  32412. * Gets the current alpha mode
  32413. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32414. * @returns the current alpha mode
  32415. */
  32416. getAlphaMode(): number;
  32417. /**
  32418. * Sets the current alpha equation
  32419. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32420. */
  32421. setAlphaEquation(equation: number): void;
  32422. /**
  32423. * Gets the current alpha equation.
  32424. * @returns the current alpha equation
  32425. */
  32426. getAlphaEquation(): number;
  32427. /**
  32428. * Gets a boolean indicating if stencil buffer is enabled
  32429. * @returns the current stencil buffer state
  32430. */
  32431. getStencilBuffer(): boolean;
  32432. /**
  32433. * Enable or disable the stencil buffer
  32434. * @param enable defines if the stencil buffer must be enabled or disabled
  32435. */
  32436. setStencilBuffer(enable: boolean): void;
  32437. /**
  32438. * Gets the current stencil mask
  32439. * @returns a number defining the new stencil mask to use
  32440. */
  32441. getStencilMask(): number;
  32442. /**
  32443. * Sets the current stencil mask
  32444. * @param mask defines the new stencil mask to use
  32445. */
  32446. setStencilMask(mask: number): void;
  32447. /**
  32448. * Gets the current stencil function
  32449. * @returns a number defining the stencil function to use
  32450. */
  32451. getStencilFunction(): number;
  32452. /**
  32453. * Gets the current stencil reference value
  32454. * @returns a number defining the stencil reference value to use
  32455. */
  32456. getStencilFunctionReference(): number;
  32457. /**
  32458. * Gets the current stencil mask
  32459. * @returns a number defining the stencil mask to use
  32460. */
  32461. getStencilFunctionMask(): number;
  32462. /**
  32463. * Sets the current stencil function
  32464. * @param stencilFunc defines the new stencil function to use
  32465. */
  32466. setStencilFunction(stencilFunc: number): void;
  32467. /**
  32468. * Sets the current stencil reference
  32469. * @param reference defines the new stencil reference to use
  32470. */
  32471. setStencilFunctionReference(reference: number): void;
  32472. /**
  32473. * Sets the current stencil mask
  32474. * @param mask defines the new stencil mask to use
  32475. */
  32476. setStencilFunctionMask(mask: number): void;
  32477. /**
  32478. * Gets the current stencil operation when stencil fails
  32479. * @returns a number defining stencil operation to use when stencil fails
  32480. */
  32481. getStencilOperationFail(): number;
  32482. /**
  32483. * Gets the current stencil operation when depth fails
  32484. * @returns a number defining stencil operation to use when depth fails
  32485. */
  32486. getStencilOperationDepthFail(): number;
  32487. /**
  32488. * Gets the current stencil operation when stencil passes
  32489. * @returns a number defining stencil operation to use when stencil passes
  32490. */
  32491. getStencilOperationPass(): number;
  32492. /**
  32493. * Sets the stencil operation to use when stencil fails
  32494. * @param operation defines the stencil operation to use when stencil fails
  32495. */
  32496. setStencilOperationFail(operation: number): void;
  32497. /**
  32498. * Sets the stencil operation to use when depth fails
  32499. * @param operation defines the stencil operation to use when depth fails
  32500. */
  32501. setStencilOperationDepthFail(operation: number): void;
  32502. /**
  32503. * Sets the stencil operation to use when stencil passes
  32504. * @param operation defines the stencil operation to use when stencil passes
  32505. */
  32506. setStencilOperationPass(operation: number): void;
  32507. /**
  32508. * Sets a boolean indicating if the dithering state is enabled or disabled
  32509. * @param value defines the dithering state
  32510. */
  32511. setDitheringState(value: boolean): void;
  32512. /**
  32513. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32514. * @param value defines the rasterizer state
  32515. */
  32516. setRasterizerState(value: boolean): void;
  32517. /**
  32518. * Gets the current depth function
  32519. * @returns a number defining the depth function
  32520. */
  32521. getDepthFunction(): Nullable<number>;
  32522. /**
  32523. * Sets the current depth function
  32524. * @param depthFunc defines the function to use
  32525. */
  32526. setDepthFunction(depthFunc: number): void;
  32527. /**
  32528. * Sets the current depth function to GREATER
  32529. */
  32530. setDepthFunctionToGreater(): void;
  32531. /**
  32532. * Sets the current depth function to GEQUAL
  32533. */
  32534. setDepthFunctionToGreaterOrEqual(): void;
  32535. /**
  32536. * Sets the current depth function to LESS
  32537. */
  32538. setDepthFunctionToLess(): void;
  32539. /**
  32540. * Sets the current depth function to LEQUAL
  32541. */
  32542. setDepthFunctionToLessOrEqual(): void;
  32543. private _cachedStencilBuffer;
  32544. private _cachedStencilFunction;
  32545. private _cachedStencilMask;
  32546. private _cachedStencilOperationPass;
  32547. private _cachedStencilOperationFail;
  32548. private _cachedStencilOperationDepthFail;
  32549. private _cachedStencilReference;
  32550. /**
  32551. * Caches the the state of the stencil buffer
  32552. */
  32553. cacheStencilState(): void;
  32554. /**
  32555. * Restores the state of the stencil buffer
  32556. */
  32557. restoreStencilState(): void;
  32558. /**
  32559. * Directly set the WebGL Viewport
  32560. * @param x defines the x coordinate of the viewport (in screen space)
  32561. * @param y defines the y coordinate of the viewport (in screen space)
  32562. * @param width defines the width of the viewport (in screen space)
  32563. * @param height defines the height of the viewport (in screen space)
  32564. * @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
  32565. */
  32566. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32567. /**
  32568. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32569. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32570. * @param y defines the y-coordinate of the corner of the clear rectangle
  32571. * @param width defines the width of the clear rectangle
  32572. * @param height defines the height of the clear rectangle
  32573. * @param clearColor defines the clear color
  32574. */
  32575. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32576. /**
  32577. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32578. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32579. * @param y defines the y-coordinate of the corner of the clear rectangle
  32580. * @param width defines the width of the clear rectangle
  32581. * @param height defines the height of the clear rectangle
  32582. */
  32583. enableScissor(x: number, y: number, width: number, height: number): void;
  32584. /**
  32585. * Disable previously set scissor test rectangle
  32586. */
  32587. disableScissor(): void;
  32588. protected _reportDrawCall(): void;
  32589. /**
  32590. * Initializes a webVR display and starts listening to display change events
  32591. * The onVRDisplayChangedObservable will be notified upon these changes
  32592. * @returns The onVRDisplayChangedObservable
  32593. */
  32594. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32595. /** @hidden */
  32596. _prepareVRComponent(): void;
  32597. /** @hidden */
  32598. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32599. /** @hidden */
  32600. _submitVRFrame(): void;
  32601. /**
  32602. * Call this function to leave webVR mode
  32603. * Will do nothing if webVR is not supported or if there is no webVR device
  32604. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32605. */
  32606. disableVR(): void;
  32607. /**
  32608. * Gets a boolean indicating that the system is in VR mode and is presenting
  32609. * @returns true if VR mode is engaged
  32610. */
  32611. isVRPresenting(): boolean;
  32612. /** @hidden */
  32613. _requestVRFrame(): void;
  32614. /** @hidden */
  32615. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32616. /**
  32617. * Gets the source code of the vertex shader associated with a specific webGL program
  32618. * @param program defines the program to use
  32619. * @returns a string containing the source code of the vertex shader associated with the program
  32620. */
  32621. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32622. /**
  32623. * Gets the source code of the fragment shader associated with a specific webGL program
  32624. * @param program defines the program to use
  32625. * @returns a string containing the source code of the fragment shader associated with the program
  32626. */
  32627. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32628. /**
  32629. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32630. * @param x defines the x coordinate of the rectangle where pixels must be read
  32631. * @param y defines the y coordinate of the rectangle where pixels must be read
  32632. * @param width defines the width of the rectangle where pixels must be read
  32633. * @param height defines the height of the rectangle where pixels must be read
  32634. * @returns a Uint8Array containing RGBA colors
  32635. */
  32636. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32637. /**
  32638. * Sets a depth stencil texture from a render target to the according uniform.
  32639. * @param channel The texture channel
  32640. * @param uniform The uniform to set
  32641. * @param texture The render target texture containing the depth stencil texture to apply
  32642. */
  32643. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32644. /**
  32645. * Sets a texture to the webGL context from a postprocess
  32646. * @param channel defines the channel to use
  32647. * @param postProcess defines the source postprocess
  32648. */
  32649. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32650. /**
  32651. * Binds the output of the passed in post process to the texture channel specified
  32652. * @param channel The channel the texture should be bound to
  32653. * @param postProcess The post process which's output should be bound
  32654. */
  32655. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32656. /** @hidden */
  32657. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32658. protected _rebuildBuffers(): void;
  32659. _renderLoop(): void;
  32660. /**
  32661. * Toggle full screen mode
  32662. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32663. */
  32664. switchFullscreen(requestPointerLock: boolean): void;
  32665. /**
  32666. * Enters full screen mode
  32667. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32668. */
  32669. enterFullscreen(requestPointerLock: boolean): void;
  32670. /**
  32671. * Exits full screen mode
  32672. */
  32673. exitFullscreen(): void;
  32674. /**
  32675. * Enters Pointerlock mode
  32676. */
  32677. enterPointerlock(): void;
  32678. /**
  32679. * Exits Pointerlock mode
  32680. */
  32681. exitPointerlock(): void;
  32682. /**
  32683. * Begin a new frame
  32684. */
  32685. beginFrame(): void;
  32686. /**
  32687. * Enf the current frame
  32688. */
  32689. endFrame(): void;
  32690. resize(): void;
  32691. /**
  32692. * Set the compressed texture format to use, based on the formats you have, and the formats
  32693. * supported by the hardware / browser.
  32694. *
  32695. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32696. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32697. * to API arguments needed to compressed textures. This puts the burden on the container
  32698. * generator to house the arcane code for determining these for current & future formats.
  32699. *
  32700. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32701. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32702. *
  32703. * Note: The result of this call is not taken into account when a texture is base64.
  32704. *
  32705. * @param formatsAvailable defines the list of those format families you have created
  32706. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32707. *
  32708. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32709. * @returns The extension selected.
  32710. */
  32711. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32712. /**
  32713. * Force a specific size of the canvas
  32714. * @param width defines the new canvas' width
  32715. * @param height defines the new canvas' height
  32716. */
  32717. setSize(width: number, height: number): void;
  32718. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32719. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32720. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32721. _releaseTexture(texture: InternalTexture): void;
  32722. /**
  32723. * @hidden
  32724. * Rescales a texture
  32725. * @param source input texutre
  32726. * @param destination destination texture
  32727. * @param scene scene to use to render the resize
  32728. * @param internalFormat format to use when resizing
  32729. * @param onComplete callback to be called when resize has completed
  32730. */
  32731. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32732. /**
  32733. * Gets the current framerate
  32734. * @returns a number representing the framerate
  32735. */
  32736. getFps(): number;
  32737. /**
  32738. * Gets the time spent between current and previous frame
  32739. * @returns a number representing the delta time in ms
  32740. */
  32741. getDeltaTime(): number;
  32742. private _measureFps;
  32743. /**
  32744. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32745. * @param renderTarget The render target to set the frame buffer for
  32746. */
  32747. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32748. /**
  32749. * Update a dynamic index buffer
  32750. * @param indexBuffer defines the target index buffer
  32751. * @param indices defines the data to update
  32752. * @param offset defines the offset in the target index buffer where update should start
  32753. */
  32754. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32755. /**
  32756. * Updates the sample count of a render target texture
  32757. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32758. * @param texture defines the texture to update
  32759. * @param samples defines the sample count to set
  32760. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32761. */
  32762. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32763. /** @hidden */
  32764. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32765. dispose(): void;
  32766. private _disableTouchAction;
  32767. /**
  32768. * Display the loading screen
  32769. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32770. */
  32771. displayLoadingUI(): void;
  32772. /**
  32773. * Hide the loading screen
  32774. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32775. */
  32776. hideLoadingUI(): void;
  32777. /**
  32778. * Gets the current loading screen object
  32779. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32780. */
  32781. /**
  32782. * Sets the current loading screen object
  32783. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32784. */
  32785. loadingScreen: ILoadingScreen;
  32786. /**
  32787. * Sets the current loading screen text
  32788. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32789. */
  32790. loadingUIText: string;
  32791. /**
  32792. * Sets the current loading screen background color
  32793. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32794. */
  32795. loadingUIBackgroundColor: string;
  32796. /** Pointerlock and fullscreen */
  32797. /**
  32798. * Ask the browser to promote the current element to pointerlock mode
  32799. * @param element defines the DOM element to promote
  32800. */
  32801. static _RequestPointerlock(element: HTMLElement): void;
  32802. /**
  32803. * Asks the browser to exit pointerlock mode
  32804. */
  32805. static _ExitPointerlock(): void;
  32806. /**
  32807. * Ask the browser to promote the current element to fullscreen rendering mode
  32808. * @param element defines the DOM element to promote
  32809. */
  32810. static _RequestFullscreen(element: HTMLElement): void;
  32811. /**
  32812. * Asks the browser to exit fullscreen mode
  32813. */
  32814. static _ExitFullscreen(): void;
  32815. }
  32816. }
  32817. declare module "babylonjs/Engines/engineStore" {
  32818. import { Nullable } from "babylonjs/types";
  32819. import { Engine } from "babylonjs/Engines/engine";
  32820. import { Scene } from "babylonjs/scene";
  32821. /**
  32822. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32823. * during the life time of the application.
  32824. */
  32825. export class EngineStore {
  32826. /** Gets the list of created engines */
  32827. static Instances: import("babylonjs/Engines/engine").Engine[];
  32828. /** @hidden */
  32829. static _LastCreatedScene: Nullable<Scene>;
  32830. /**
  32831. * Gets the latest created engine
  32832. */
  32833. static readonly LastCreatedEngine: Nullable<Engine>;
  32834. /**
  32835. * Gets the latest created scene
  32836. */
  32837. static readonly LastCreatedScene: Nullable<Scene>;
  32838. /**
  32839. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32840. * @ignorenaming
  32841. */
  32842. static UseFallbackTexture: boolean;
  32843. /**
  32844. * Texture content used if a texture cannot loaded
  32845. * @ignorenaming
  32846. */
  32847. static FallbackTexture: string;
  32848. }
  32849. }
  32850. declare module "babylonjs/Misc/promise" {
  32851. /**
  32852. * Helper class that provides a small promise polyfill
  32853. */
  32854. export class PromisePolyfill {
  32855. /**
  32856. * Static function used to check if the polyfill is required
  32857. * If this is the case then the function will inject the polyfill to window.Promise
  32858. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32859. */
  32860. static Apply(force?: boolean): void;
  32861. }
  32862. }
  32863. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32864. /**
  32865. * Interface for screenshot methods with describe argument called `size` as object with options
  32866. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32867. */
  32868. export interface IScreenshotSize {
  32869. /**
  32870. * number in pixels for canvas height
  32871. */
  32872. height?: number;
  32873. /**
  32874. * multiplier allowing render at a higher or lower resolution
  32875. * If value is defined then height and width will be ignored and taken from camera
  32876. */
  32877. precision?: number;
  32878. /**
  32879. * number in pixels for canvas width
  32880. */
  32881. width?: number;
  32882. }
  32883. }
  32884. declare module "babylonjs/Misc/tools" {
  32885. import { Nullable, float } from "babylonjs/types";
  32886. import { DomManagement } from "babylonjs/Misc/domManagement";
  32887. import { WebRequest } from "babylonjs/Misc/webRequest";
  32888. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32889. import { ReadFileError } from "babylonjs/Misc/fileTools";
  32890. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32891. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32892. import { Camera } from "babylonjs/Cameras/camera";
  32893. import { Engine } from "babylonjs/Engines/engine";
  32894. interface IColor4Like {
  32895. r: float;
  32896. g: float;
  32897. b: float;
  32898. a: float;
  32899. }
  32900. /**
  32901. * Class containing a set of static utilities functions
  32902. */
  32903. export class Tools {
  32904. /**
  32905. * Gets or sets the base URL to use to load assets
  32906. */
  32907. static BaseUrl: string;
  32908. /**
  32909. * Enable/Disable Custom HTTP Request Headers globally.
  32910. * default = false
  32911. * @see CustomRequestHeaders
  32912. */
  32913. static UseCustomRequestHeaders: boolean;
  32914. /**
  32915. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32916. * i.e. when loading files, where the server/service expects an Authorization header
  32917. */
  32918. static CustomRequestHeaders: {
  32919. [key: string]: string;
  32920. };
  32921. /**
  32922. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32923. */
  32924. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32925. /**
  32926. * Default behaviour for cors in the application.
  32927. * It can be a string if the expected behavior is identical in the entire app.
  32928. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32929. */
  32930. static CorsBehavior: string | ((url: string | string[]) => string);
  32931. /**
  32932. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32933. * @ignorenaming
  32934. */
  32935. static UseFallbackTexture: boolean;
  32936. /**
  32937. * Use this object to register external classes like custom textures or material
  32938. * to allow the laoders to instantiate them
  32939. */
  32940. static RegisteredExternalClasses: {
  32941. [key: string]: Object;
  32942. };
  32943. /**
  32944. * Texture content used if a texture cannot loaded
  32945. * @ignorenaming
  32946. */
  32947. static fallbackTexture: string;
  32948. /**
  32949. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32950. * @param u defines the coordinate on X axis
  32951. * @param v defines the coordinate on Y axis
  32952. * @param width defines the width of the source data
  32953. * @param height defines the height of the source data
  32954. * @param pixels defines the source byte array
  32955. * @param color defines the output color
  32956. */
  32957. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32958. /**
  32959. * Interpolates between a and b via alpha
  32960. * @param a The lower value (returned when alpha = 0)
  32961. * @param b The upper value (returned when alpha = 1)
  32962. * @param alpha The interpolation-factor
  32963. * @return The mixed value
  32964. */
  32965. static Mix(a: number, b: number, alpha: number): number;
  32966. /**
  32967. * Tries to instantiate a new object from a given class name
  32968. * @param className defines the class name to instantiate
  32969. * @returns the new object or null if the system was not able to do the instantiation
  32970. */
  32971. static Instantiate(className: string): any;
  32972. /**
  32973. * Provides a slice function that will work even on IE
  32974. * @param data defines the array to slice
  32975. * @param start defines the start of the data (optional)
  32976. * @param end defines the end of the data (optional)
  32977. * @returns the new sliced array
  32978. */
  32979. static Slice<T>(data: T, start?: number, end?: number): T;
  32980. /**
  32981. * Polyfill for setImmediate
  32982. * @param action defines the action to execute after the current execution block
  32983. */
  32984. static SetImmediate(action: () => void): void;
  32985. /**
  32986. * Function indicating if a number is an exponent of 2
  32987. * @param value defines the value to test
  32988. * @returns true if the value is an exponent of 2
  32989. */
  32990. static IsExponentOfTwo(value: number): boolean;
  32991. private static _tmpFloatArray;
  32992. /**
  32993. * Returns the nearest 32-bit single precision float representation of a Number
  32994. * @param value A Number. If the parameter is of a different type, it will get converted
  32995. * to a number or to NaN if it cannot be converted
  32996. * @returns number
  32997. */
  32998. static FloatRound(value: number): number;
  32999. /**
  33000. * Extracts the filename from a path
  33001. * @param path defines the path to use
  33002. * @returns the filename
  33003. */
  33004. static GetFilename(path: string): string;
  33005. /**
  33006. * Extracts the "folder" part of a path (everything before the filename).
  33007. * @param uri The URI to extract the info from
  33008. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33009. * @returns The "folder" part of the path
  33010. */
  33011. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33012. /**
  33013. * Extracts text content from a DOM element hierarchy
  33014. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33015. */
  33016. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33017. /**
  33018. * Convert an angle in radians to degrees
  33019. * @param angle defines the angle to convert
  33020. * @returns the angle in degrees
  33021. */
  33022. static ToDegrees(angle: number): number;
  33023. /**
  33024. * Convert an angle in degrees to radians
  33025. * @param angle defines the angle to convert
  33026. * @returns the angle in radians
  33027. */
  33028. static ToRadians(angle: number): number;
  33029. /**
  33030. * Returns an array if obj is not an array
  33031. * @param obj defines the object to evaluate as an array
  33032. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33033. * @returns either obj directly if obj is an array or a new array containing obj
  33034. */
  33035. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33036. /**
  33037. * Gets the pointer prefix to use
  33038. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33039. */
  33040. static GetPointerPrefix(): string;
  33041. /**
  33042. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33043. * @param url define the url we are trying
  33044. * @param element define the dom element where to configure the cors policy
  33045. */
  33046. static SetCorsBehavior(url: string | string[], element: {
  33047. crossOrigin: string | null;
  33048. }): void;
  33049. /**
  33050. * Removes unwanted characters from an url
  33051. * @param url defines the url to clean
  33052. * @returns the cleaned url
  33053. */
  33054. static CleanUrl(url: string): string;
  33055. /**
  33056. * Gets or sets a function used to pre-process url before using them to load assets
  33057. */
  33058. static PreprocessUrl: (url: string) => string;
  33059. /**
  33060. * Loads an image as an HTMLImageElement.
  33061. * @param input url string, ArrayBuffer, or Blob to load
  33062. * @param onLoad callback called when the image successfully loads
  33063. * @param onError callback called when the image fails to load
  33064. * @param offlineProvider offline provider for caching
  33065. * @param mimeType optional mime type
  33066. * @returns the HTMLImageElement of the loaded image
  33067. */
  33068. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33069. /**
  33070. * Loads a file from a url
  33071. * @param url url string, ArrayBuffer, or Blob to load
  33072. * @param onSuccess callback called when the file successfully loads
  33073. * @param onProgress callback called while file is loading (if the server supports this mode)
  33074. * @param offlineProvider defines the offline provider for caching
  33075. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33076. * @param onError callback called when the file fails to load
  33077. * @returns a file request object
  33078. */
  33079. 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;
  33080. /**
  33081. * Loads a file from a url
  33082. * @param url the file url to load
  33083. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33084. */
  33085. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33086. /**
  33087. * Load a script (identified by an url). When the url returns, the
  33088. * content of this file is added into a new script element, attached to the DOM (body element)
  33089. * @param scriptUrl defines the url of the script to laod
  33090. * @param onSuccess defines the callback called when the script is loaded
  33091. * @param onError defines the callback to call if an error occurs
  33092. * @param scriptId defines the id of the script element
  33093. */
  33094. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33095. /**
  33096. * Load an asynchronous script (identified by an url). When the url returns, the
  33097. * content of this file is added into a new script element, attached to the DOM (body element)
  33098. * @param scriptUrl defines the url of the script to laod
  33099. * @param scriptId defines the id of the script element
  33100. * @returns a promise request object
  33101. */
  33102. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33103. /**
  33104. * Loads a file from a blob
  33105. * @param fileToLoad defines the blob to use
  33106. * @param callback defines the callback to call when data is loaded
  33107. * @param progressCallback defines the callback to call during loading process
  33108. * @returns a file request object
  33109. */
  33110. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33111. /**
  33112. * Reads a file from a File object
  33113. * @param file defines the file to load
  33114. * @param onSuccess defines the callback to call when data is loaded
  33115. * @param onProgress defines the callback to call during loading process
  33116. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33117. * @param onError defines the callback to call when an error occurs
  33118. * @returns a file request object
  33119. */
  33120. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33121. /**
  33122. * Creates a data url from a given string content
  33123. * @param content defines the content to convert
  33124. * @returns the new data url link
  33125. */
  33126. static FileAsURL(content: string): string;
  33127. /**
  33128. * Format the given number to a specific decimal format
  33129. * @param value defines the number to format
  33130. * @param decimals defines the number of decimals to use
  33131. * @returns the formatted string
  33132. */
  33133. static Format(value: number, decimals?: number): string;
  33134. /**
  33135. * Tries to copy an object by duplicating every property
  33136. * @param source defines the source object
  33137. * @param destination defines the target object
  33138. * @param doNotCopyList defines a list of properties to avoid
  33139. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33140. */
  33141. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33142. /**
  33143. * Gets a boolean indicating if the given object has no own property
  33144. * @param obj defines the object to test
  33145. * @returns true if object has no own property
  33146. */
  33147. static IsEmpty(obj: any): boolean;
  33148. /**
  33149. * Function used to register events at window level
  33150. * @param windowElement defines the Window object to use
  33151. * @param events defines the events to register
  33152. */
  33153. static RegisterTopRootEvents(windowElement: Window, events: {
  33154. name: string;
  33155. handler: Nullable<(e: FocusEvent) => any>;
  33156. }[]): void;
  33157. /**
  33158. * Function used to unregister events from window level
  33159. * @param windowElement defines the Window object to use
  33160. * @param events defines the events to unregister
  33161. */
  33162. static UnregisterTopRootEvents(windowElement: Window, events: {
  33163. name: string;
  33164. handler: Nullable<(e: FocusEvent) => any>;
  33165. }[]): void;
  33166. /**
  33167. * @ignore
  33168. */
  33169. static _ScreenshotCanvas: HTMLCanvasElement;
  33170. /**
  33171. * Dumps the current bound framebuffer
  33172. * @param width defines the rendering width
  33173. * @param height defines the rendering height
  33174. * @param engine defines the hosting engine
  33175. * @param successCallback defines the callback triggered once the data are available
  33176. * @param mimeType defines the mime type of the result
  33177. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33178. */
  33179. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33180. /**
  33181. * Converts the canvas data to blob.
  33182. * This acts as a polyfill for browsers not supporting the to blob function.
  33183. * @param canvas Defines the canvas to extract the data from
  33184. * @param successCallback Defines the callback triggered once the data are available
  33185. * @param mimeType Defines the mime type of the result
  33186. */
  33187. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33188. /**
  33189. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33190. * @param successCallback defines the callback triggered once the data are available
  33191. * @param mimeType defines the mime type of the result
  33192. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33193. */
  33194. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33195. /**
  33196. * Downloads a blob in the browser
  33197. * @param blob defines the blob to download
  33198. * @param fileName defines the name of the downloaded file
  33199. */
  33200. static Download(blob: Blob, fileName: string): void;
  33201. /**
  33202. * Captures a screenshot of the current rendering
  33203. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33204. * @param engine defines the rendering engine
  33205. * @param camera defines the source camera
  33206. * @param size This parameter can be set to a single number or to an object with the
  33207. * following (optional) properties: precision, width, height. If a single number is passed,
  33208. * it will be used for both width and height. If an object is passed, the screenshot size
  33209. * will be derived from the parameters. The precision property is a multiplier allowing
  33210. * rendering at a higher or lower resolution
  33211. * @param successCallback defines the callback receives a single parameter which contains the
  33212. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33213. * src parameter of an <img> to display it
  33214. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33215. * Check your browser for supported MIME types
  33216. */
  33217. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33218. /**
  33219. * Captures a screenshot of the current rendering
  33220. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33221. * @param engine defines the rendering engine
  33222. * @param camera defines the source camera
  33223. * @param size This parameter can be set to a single number or to an object with the
  33224. * following (optional) properties: precision, width, height. If a single number is passed,
  33225. * it will be used for both width and height. If an object is passed, the screenshot size
  33226. * will be derived from the parameters. The precision property is a multiplier allowing
  33227. * rendering at a higher or lower resolution
  33228. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33229. * Check your browser for supported MIME types
  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 CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33234. /**
  33235. * Generates an image screenshot from the specified camera.
  33236. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33237. * @param engine The engine to use for rendering
  33238. * @param camera The camera to use for rendering
  33239. * @param size This parameter can be set to a single number or to an object with the
  33240. * following (optional) properties: precision, width, height. If a single number is passed,
  33241. * it will be used for both width and height. If an object is passed, the screenshot size
  33242. * will be derived from the parameters. The precision property is a multiplier allowing
  33243. * rendering at a higher or lower resolution
  33244. * @param successCallback The callback receives a single parameter which contains the
  33245. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33246. * src parameter of an <img> to display it
  33247. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33248. * Check your browser for supported MIME types
  33249. * @param samples Texture samples (default: 1)
  33250. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33251. * @param fileName A name for for the downloaded file.
  33252. */
  33253. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33254. /**
  33255. * Generates an image screenshot from the specified camera.
  33256. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33257. * @param engine The engine to use for rendering
  33258. * @param camera The camera to use for rendering
  33259. * @param size This parameter can be set to a single number or to an object with the
  33260. * following (optional) properties: precision, width, height. If a single number is passed,
  33261. * it will be used for both width and height. If an object is passed, the screenshot size
  33262. * will be derived from the parameters. The precision property is a multiplier allowing
  33263. * rendering at a higher or lower resolution
  33264. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33265. * Check your browser for supported MIME types
  33266. * @param samples Texture samples (default: 1)
  33267. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33268. * @param fileName A name for for the downloaded file.
  33269. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33270. * to the src parameter of an <img> to display it
  33271. */
  33272. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33273. /**
  33274. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33275. * Be aware Math.random() could cause collisions, but:
  33276. * "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"
  33277. * @returns a pseudo random id
  33278. */
  33279. static RandomId(): string;
  33280. /**
  33281. * Test if the given uri is a base64 string
  33282. * @param uri The uri to test
  33283. * @return True if the uri is a base64 string or false otherwise
  33284. */
  33285. static IsBase64(uri: string): boolean;
  33286. /**
  33287. * Decode the given base64 uri.
  33288. * @param uri The uri to decode
  33289. * @return The decoded base64 data.
  33290. */
  33291. static DecodeBase64(uri: string): ArrayBuffer;
  33292. /**
  33293. * Gets the absolute url.
  33294. * @param url the input url
  33295. * @return the absolute url
  33296. */
  33297. static GetAbsoluteUrl(url: string): string;
  33298. /**
  33299. * No log
  33300. */
  33301. static readonly NoneLogLevel: number;
  33302. /**
  33303. * Only message logs
  33304. */
  33305. static readonly MessageLogLevel: number;
  33306. /**
  33307. * Only warning logs
  33308. */
  33309. static readonly WarningLogLevel: number;
  33310. /**
  33311. * Only error logs
  33312. */
  33313. static readonly ErrorLogLevel: number;
  33314. /**
  33315. * All logs
  33316. */
  33317. static readonly AllLogLevel: number;
  33318. /**
  33319. * Gets a value indicating the number of loading errors
  33320. * @ignorenaming
  33321. */
  33322. static readonly errorsCount: number;
  33323. /**
  33324. * Callback called when a new log is added
  33325. */
  33326. static OnNewCacheEntry: (entry: string) => void;
  33327. /**
  33328. * Log a message to the console
  33329. * @param message defines the message to log
  33330. */
  33331. static Log(message: string): void;
  33332. /**
  33333. * Write a warning message to the console
  33334. * @param message defines the message to log
  33335. */
  33336. static Warn(message: string): void;
  33337. /**
  33338. * Write an error message to the console
  33339. * @param message defines the message to log
  33340. */
  33341. static Error(message: string): void;
  33342. /**
  33343. * Gets current log cache (list of logs)
  33344. */
  33345. static readonly LogCache: string;
  33346. /**
  33347. * Clears the log cache
  33348. */
  33349. static ClearLogCache(): void;
  33350. /**
  33351. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33352. */
  33353. static LogLevels: number;
  33354. /**
  33355. * Checks if the window object exists
  33356. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33357. */
  33358. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33359. /**
  33360. * No performance log
  33361. */
  33362. static readonly PerformanceNoneLogLevel: number;
  33363. /**
  33364. * Use user marks to log performance
  33365. */
  33366. static readonly PerformanceUserMarkLogLevel: number;
  33367. /**
  33368. * Log performance to the console
  33369. */
  33370. static readonly PerformanceConsoleLogLevel: number;
  33371. private static _performance;
  33372. /**
  33373. * Sets the current performance log level
  33374. */
  33375. static PerformanceLogLevel: number;
  33376. private static _StartPerformanceCounterDisabled;
  33377. private static _EndPerformanceCounterDisabled;
  33378. private static _StartUserMark;
  33379. private static _EndUserMark;
  33380. private static _StartPerformanceConsole;
  33381. private static _EndPerformanceConsole;
  33382. /**
  33383. * Starts a performance counter
  33384. */
  33385. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33386. /**
  33387. * Ends a specific performance coutner
  33388. */
  33389. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33390. /**
  33391. * Gets either window.performance.now() if supported or Date.now() else
  33392. */
  33393. static readonly Now: number;
  33394. /**
  33395. * This method will return the name of the class used to create the instance of the given object.
  33396. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33397. * @param object the object to get the class name from
  33398. * @param isType defines if the object is actually a type
  33399. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33400. */
  33401. static GetClassName(object: any, isType?: boolean): string;
  33402. /**
  33403. * Gets the first element of an array satisfying a given predicate
  33404. * @param array defines the array to browse
  33405. * @param predicate defines the predicate to use
  33406. * @returns null if not found or the element
  33407. */
  33408. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33409. /**
  33410. * This method will return the name of the full name of the class, including its owning module (if any).
  33411. * 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).
  33412. * @param object the object to get the class name from
  33413. * @param isType defines if the object is actually a type
  33414. * @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.
  33415. * @ignorenaming
  33416. */
  33417. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33418. /**
  33419. * Returns a promise that resolves after the given amount of time.
  33420. * @param delay Number of milliseconds to delay
  33421. * @returns Promise that resolves after the given amount of time
  33422. */
  33423. static DelayAsync(delay: number): Promise<void>;
  33424. }
  33425. /**
  33426. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33427. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33428. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33429. * @param name The name of the class, case should be preserved
  33430. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33431. */
  33432. export function className(name: string, module?: string): (target: Object) => void;
  33433. /**
  33434. * An implementation of a loop for asynchronous functions.
  33435. */
  33436. export class AsyncLoop {
  33437. /**
  33438. * Defines the number of iterations for the loop
  33439. */
  33440. iterations: number;
  33441. /**
  33442. * Defines the current index of the loop.
  33443. */
  33444. index: number;
  33445. private _done;
  33446. private _fn;
  33447. private _successCallback;
  33448. /**
  33449. * Constructor.
  33450. * @param iterations the number of iterations.
  33451. * @param func the function to run each iteration
  33452. * @param successCallback the callback that will be called upon succesful execution
  33453. * @param offset starting offset.
  33454. */
  33455. constructor(
  33456. /**
  33457. * Defines the number of iterations for the loop
  33458. */
  33459. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33460. /**
  33461. * Execute the next iteration. Must be called after the last iteration was finished.
  33462. */
  33463. executeNext(): void;
  33464. /**
  33465. * Break the loop and run the success callback.
  33466. */
  33467. breakLoop(): void;
  33468. /**
  33469. * Create and run an async loop.
  33470. * @param iterations the number of iterations.
  33471. * @param fn the function to run each iteration
  33472. * @param successCallback the callback that will be called upon succesful execution
  33473. * @param offset starting offset.
  33474. * @returns the created async loop object
  33475. */
  33476. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33477. /**
  33478. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33479. * @param iterations total number of iterations
  33480. * @param syncedIterations number of synchronous iterations in each async iteration.
  33481. * @param fn the function to call each iteration.
  33482. * @param callback a success call back that will be called when iterating stops.
  33483. * @param breakFunction a break condition (optional)
  33484. * @param timeout timeout settings for the setTimeout function. default - 0.
  33485. * @returns the created async loop object
  33486. */
  33487. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33488. }
  33489. }
  33490. declare module "babylonjs/Misc/stringDictionary" {
  33491. import { Nullable } from "babylonjs/types";
  33492. /**
  33493. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33494. * The underlying implementation relies on an associative array to ensure the best performances.
  33495. * The value can be anything including 'null' but except 'undefined'
  33496. */
  33497. export class StringDictionary<T> {
  33498. /**
  33499. * This will clear this dictionary and copy the content from the 'source' one.
  33500. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33501. * @param source the dictionary to take the content from and copy to this dictionary
  33502. */
  33503. copyFrom(source: StringDictionary<T>): void;
  33504. /**
  33505. * Get a value based from its key
  33506. * @param key the given key to get the matching value from
  33507. * @return the value if found, otherwise undefined is returned
  33508. */
  33509. get(key: string): T | undefined;
  33510. /**
  33511. * Get a value from its key or add it if it doesn't exist.
  33512. * This method will ensure you that a given key/data will be present in the dictionary.
  33513. * @param key the given key to get the matching value from
  33514. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33515. * The factory will only be invoked if there's no data for the given key.
  33516. * @return the value corresponding to the key.
  33517. */
  33518. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33519. /**
  33520. * Get a value from its key if present in the dictionary otherwise add it
  33521. * @param key the key to get the value from
  33522. * @param val if there's no such key/value pair in the dictionary add it with this value
  33523. * @return the value corresponding to the key
  33524. */
  33525. getOrAdd(key: string, val: T): T;
  33526. /**
  33527. * Check if there's a given key in the dictionary
  33528. * @param key the key to check for
  33529. * @return true if the key is present, false otherwise
  33530. */
  33531. contains(key: string): boolean;
  33532. /**
  33533. * Add a new key and its corresponding value
  33534. * @param key the key to add
  33535. * @param value the value corresponding to the key
  33536. * @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
  33537. */
  33538. add(key: string, value: T): boolean;
  33539. /**
  33540. * Update a specific value associated to a key
  33541. * @param key defines the key to use
  33542. * @param value defines the value to store
  33543. * @returns true if the value was updated (or false if the key was not found)
  33544. */
  33545. set(key: string, value: T): boolean;
  33546. /**
  33547. * Get the element of the given key and remove it from the dictionary
  33548. * @param key defines the key to search
  33549. * @returns the value associated with the key or null if not found
  33550. */
  33551. getAndRemove(key: string): Nullable<T>;
  33552. /**
  33553. * Remove a key/value from the dictionary.
  33554. * @param key the key to remove
  33555. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33556. */
  33557. remove(key: string): boolean;
  33558. /**
  33559. * Clear the whole content of the dictionary
  33560. */
  33561. clear(): void;
  33562. /**
  33563. * Gets the current count
  33564. */
  33565. readonly count: number;
  33566. /**
  33567. * Execute a callback on each key/val of the dictionary.
  33568. * Note that you can remove any element in this dictionary in the callback implementation
  33569. * @param callback the callback to execute on a given key/value pair
  33570. */
  33571. forEach(callback: (key: string, val: T) => void): void;
  33572. /**
  33573. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33574. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33575. * Note that you can remove any element in this dictionary in the callback implementation
  33576. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33577. * @returns the first item
  33578. */
  33579. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33580. private _count;
  33581. private _data;
  33582. }
  33583. }
  33584. declare module "babylonjs/Collisions/collisionCoordinator" {
  33585. import { Nullable } from "babylonjs/types";
  33586. import { Scene } from "babylonjs/scene";
  33587. import { Vector3 } from "babylonjs/Maths/math.vector";
  33588. import { Collider } from "babylonjs/Collisions/collider";
  33589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33590. /** @hidden */
  33591. export interface ICollisionCoordinator {
  33592. createCollider(): Collider;
  33593. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33594. init(scene: Scene): void;
  33595. }
  33596. /** @hidden */
  33597. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33598. private _scene;
  33599. private _scaledPosition;
  33600. private _scaledVelocity;
  33601. private _finalPosition;
  33602. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33603. createCollider(): Collider;
  33604. init(scene: Scene): void;
  33605. private _collideWithWorld;
  33606. }
  33607. }
  33608. declare module "babylonjs/Inputs/scene.inputManager" {
  33609. import { Nullable } from "babylonjs/types";
  33610. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33611. import { Vector2 } from "babylonjs/Maths/math.vector";
  33612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33613. import { Scene } from "babylonjs/scene";
  33614. /**
  33615. * Class used to manage all inputs for the scene.
  33616. */
  33617. export class InputManager {
  33618. /** The distance in pixel that you have to move to prevent some events */
  33619. static DragMovementThreshold: number;
  33620. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33621. static LongPressDelay: number;
  33622. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33623. static DoubleClickDelay: number;
  33624. /** If you need to check double click without raising a single click at first click, enable this flag */
  33625. static ExclusiveDoubleClickMode: boolean;
  33626. private _wheelEventName;
  33627. private _onPointerMove;
  33628. private _onPointerDown;
  33629. private _onPointerUp;
  33630. private _initClickEvent;
  33631. private _initActionManager;
  33632. private _delayedSimpleClick;
  33633. private _delayedSimpleClickTimeout;
  33634. private _previousDelayedSimpleClickTimeout;
  33635. private _meshPickProceed;
  33636. private _previousButtonPressed;
  33637. private _currentPickResult;
  33638. private _previousPickResult;
  33639. private _totalPointersPressed;
  33640. private _doubleClickOccured;
  33641. private _pointerOverMesh;
  33642. private _pickedDownMesh;
  33643. private _pickedUpMesh;
  33644. private _pointerX;
  33645. private _pointerY;
  33646. private _unTranslatedPointerX;
  33647. private _unTranslatedPointerY;
  33648. private _startingPointerPosition;
  33649. private _previousStartingPointerPosition;
  33650. private _startingPointerTime;
  33651. private _previousStartingPointerTime;
  33652. private _pointerCaptures;
  33653. private _onKeyDown;
  33654. private _onKeyUp;
  33655. private _onCanvasFocusObserver;
  33656. private _onCanvasBlurObserver;
  33657. private _scene;
  33658. /**
  33659. * Creates a new InputManager
  33660. * @param scene defines the hosting scene
  33661. */
  33662. constructor(scene: Scene);
  33663. /**
  33664. * Gets the mesh that is currently under the pointer
  33665. */
  33666. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33667. /**
  33668. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33669. */
  33670. readonly unTranslatedPointer: Vector2;
  33671. /**
  33672. * Gets or sets the current on-screen X position of the pointer
  33673. */
  33674. pointerX: number;
  33675. /**
  33676. * Gets or sets the current on-screen Y position of the pointer
  33677. */
  33678. pointerY: number;
  33679. private _updatePointerPosition;
  33680. private _processPointerMove;
  33681. private _setRayOnPointerInfo;
  33682. private _checkPrePointerObservable;
  33683. /**
  33684. * Use this method to simulate a pointer move on a mesh
  33685. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33686. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33687. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33688. */
  33689. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33690. /**
  33691. * Use this method to simulate a pointer down on a mesh
  33692. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33693. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33694. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33695. */
  33696. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33697. private _processPointerDown;
  33698. /** @hidden */
  33699. _isPointerSwiping(): boolean;
  33700. /**
  33701. * Use this method to simulate a pointer up on a mesh
  33702. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33703. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33704. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33705. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33706. */
  33707. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33708. private _processPointerUp;
  33709. /**
  33710. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33711. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33712. * @returns true if the pointer was captured
  33713. */
  33714. isPointerCaptured(pointerId?: number): boolean;
  33715. /**
  33716. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33717. * @param attachUp defines if you want to attach events to pointerup
  33718. * @param attachDown defines if you want to attach events to pointerdown
  33719. * @param attachMove defines if you want to attach events to pointermove
  33720. */
  33721. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33722. /**
  33723. * Detaches all event handlers
  33724. */
  33725. detachControl(): void;
  33726. /**
  33727. * Force the value of meshUnderPointer
  33728. * @param mesh defines the mesh to use
  33729. */
  33730. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33731. /**
  33732. * Gets the mesh under the pointer
  33733. * @returns a Mesh or null if no mesh is under the pointer
  33734. */
  33735. getPointerOverMesh(): Nullable<AbstractMesh>;
  33736. }
  33737. }
  33738. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33739. /**
  33740. * Helper class used to generate session unique ID
  33741. */
  33742. export class UniqueIdGenerator {
  33743. private static _UniqueIdCounter;
  33744. /**
  33745. * Gets an unique (relatively to the current scene) Id
  33746. */
  33747. static readonly UniqueId: number;
  33748. }
  33749. }
  33750. declare module "babylonjs/Animations/animationGroup" {
  33751. import { Animatable } from "babylonjs/Animations/animatable";
  33752. import { Animation } from "babylonjs/Animations/animation";
  33753. import { Scene, IDisposable } from "babylonjs/scene";
  33754. import { Observable } from "babylonjs/Misc/observable";
  33755. import { Nullable } from "babylonjs/types";
  33756. import "babylonjs/Animations/animatable";
  33757. /**
  33758. * This class defines the direct association between an animation and a target
  33759. */
  33760. export class TargetedAnimation {
  33761. /**
  33762. * Animation to perform
  33763. */
  33764. animation: Animation;
  33765. /**
  33766. * Target to animate
  33767. */
  33768. target: any;
  33769. /**
  33770. * Serialize the object
  33771. * @returns the JSON object representing the current entity
  33772. */
  33773. serialize(): any;
  33774. }
  33775. /**
  33776. * Use this class to create coordinated animations on multiple targets
  33777. */
  33778. export class AnimationGroup implements IDisposable {
  33779. /** The name of the animation group */
  33780. name: string;
  33781. private _scene;
  33782. private _targetedAnimations;
  33783. private _animatables;
  33784. private _from;
  33785. private _to;
  33786. private _isStarted;
  33787. private _isPaused;
  33788. private _speedRatio;
  33789. private _loopAnimation;
  33790. /**
  33791. * Gets or sets the unique id of the node
  33792. */
  33793. uniqueId: number;
  33794. /**
  33795. * This observable will notify when one animation have ended
  33796. */
  33797. onAnimationEndObservable: Observable<TargetedAnimation>;
  33798. /**
  33799. * Observer raised when one animation loops
  33800. */
  33801. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33802. /**
  33803. * This observable will notify when all animations have ended.
  33804. */
  33805. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33806. /**
  33807. * This observable will notify when all animations have paused.
  33808. */
  33809. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33810. /**
  33811. * This observable will notify when all animations are playing.
  33812. */
  33813. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33814. /**
  33815. * Gets the first frame
  33816. */
  33817. readonly from: number;
  33818. /**
  33819. * Gets the last frame
  33820. */
  33821. readonly to: number;
  33822. /**
  33823. * Define if the animations are started
  33824. */
  33825. readonly isStarted: boolean;
  33826. /**
  33827. * Gets a value indicating that the current group is playing
  33828. */
  33829. readonly isPlaying: boolean;
  33830. /**
  33831. * Gets or sets the speed ratio to use for all animations
  33832. */
  33833. /**
  33834. * Gets or sets the speed ratio to use for all animations
  33835. */
  33836. speedRatio: number;
  33837. /**
  33838. * Gets or sets if all animations should loop or not
  33839. */
  33840. loopAnimation: boolean;
  33841. /**
  33842. * Gets the targeted animations for this animation group
  33843. */
  33844. readonly targetedAnimations: Array<TargetedAnimation>;
  33845. /**
  33846. * returning the list of animatables controlled by this animation group.
  33847. */
  33848. readonly animatables: Array<Animatable>;
  33849. /**
  33850. * Instantiates a new Animation Group.
  33851. * This helps managing several animations at once.
  33852. * @see http://doc.babylonjs.com/how_to/group
  33853. * @param name Defines the name of the group
  33854. * @param scene Defines the scene the group belongs to
  33855. */
  33856. constructor(
  33857. /** The name of the animation group */
  33858. name: string, scene?: Nullable<Scene>);
  33859. /**
  33860. * Add an animation (with its target) in the group
  33861. * @param animation defines the animation we want to add
  33862. * @param target defines the target of the animation
  33863. * @returns the TargetedAnimation object
  33864. */
  33865. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33866. /**
  33867. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33868. * It can add constant keys at begin or end
  33869. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33870. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33871. * @returns the animation group
  33872. */
  33873. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33874. /**
  33875. * Start all animations on given targets
  33876. * @param loop defines if animations must loop
  33877. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33878. * @param from defines the from key (optional)
  33879. * @param to defines the to key (optional)
  33880. * @returns the current animation group
  33881. */
  33882. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33883. /**
  33884. * Pause all animations
  33885. * @returns the animation group
  33886. */
  33887. pause(): AnimationGroup;
  33888. /**
  33889. * Play all animations to initial state
  33890. * This function will start() the animations if they were not started or will restart() them if they were paused
  33891. * @param loop defines if animations must loop
  33892. * @returns the animation group
  33893. */
  33894. play(loop?: boolean): AnimationGroup;
  33895. /**
  33896. * Reset all animations to initial state
  33897. * @returns the animation group
  33898. */
  33899. reset(): AnimationGroup;
  33900. /**
  33901. * Restart animations from key 0
  33902. * @returns the animation group
  33903. */
  33904. restart(): AnimationGroup;
  33905. /**
  33906. * Stop all animations
  33907. * @returns the animation group
  33908. */
  33909. stop(): AnimationGroup;
  33910. /**
  33911. * Set animation weight for all animatables
  33912. * @param weight defines the weight to use
  33913. * @return the animationGroup
  33914. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33915. */
  33916. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33917. /**
  33918. * Synchronize and normalize all animatables with a source animatable
  33919. * @param root defines the root animatable to synchronize with
  33920. * @return the animationGroup
  33921. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33922. */
  33923. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33924. /**
  33925. * Goes to a specific frame in this animation group
  33926. * @param frame the frame number to go to
  33927. * @return the animationGroup
  33928. */
  33929. goToFrame(frame: number): AnimationGroup;
  33930. /**
  33931. * Dispose all associated resources
  33932. */
  33933. dispose(): void;
  33934. private _checkAnimationGroupEnded;
  33935. /**
  33936. * Clone the current animation group and returns a copy
  33937. * @param newName defines the name of the new group
  33938. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33939. * @returns the new aniamtion group
  33940. */
  33941. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33942. /**
  33943. * Serializes the animationGroup to an object
  33944. * @returns Serialized object
  33945. */
  33946. serialize(): any;
  33947. /**
  33948. * Returns a new AnimationGroup object parsed from the source provided.
  33949. * @param parsedAnimationGroup defines the source
  33950. * @param scene defines the scene that will receive the animationGroup
  33951. * @returns a new AnimationGroup
  33952. */
  33953. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33954. /**
  33955. * Returns the string "AnimationGroup"
  33956. * @returns "AnimationGroup"
  33957. */
  33958. getClassName(): string;
  33959. /**
  33960. * Creates a detailled string about the object
  33961. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33962. * @returns a string representing the object
  33963. */
  33964. toString(fullDetails?: boolean): string;
  33965. }
  33966. }
  33967. declare module "babylonjs/scene" {
  33968. import { Nullable } from "babylonjs/types";
  33969. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33970. import { Observable } from "babylonjs/Misc/observable";
  33971. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33972. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33973. import { Geometry } from "babylonjs/Meshes/geometry";
  33974. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33975. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33977. import { Mesh } from "babylonjs/Meshes/mesh";
  33978. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33979. import { Bone } from "babylonjs/Bones/bone";
  33980. import { Skeleton } from "babylonjs/Bones/skeleton";
  33981. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33982. import { Camera } from "babylonjs/Cameras/camera";
  33983. import { AbstractScene } from "babylonjs/abstractScene";
  33984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33985. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33986. import { Material } from "babylonjs/Materials/material";
  33987. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33988. import { Effect } from "babylonjs/Materials/effect";
  33989. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33990. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33991. import { Light } from "babylonjs/Lights/light";
  33992. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33993. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33994. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33995. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33996. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33997. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33998. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33999. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34000. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34001. import { Engine } from "babylonjs/Engines/engine";
  34002. import { Node } from "babylonjs/node";
  34003. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34004. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34005. import { WebRequest } from "babylonjs/Misc/webRequest";
  34006. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34007. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34008. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34009. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34010. import { Plane } from "babylonjs/Maths/math.plane";
  34011. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34012. import { Ray } from "babylonjs/Culling/ray";
  34013. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34014. import { Animation } from "babylonjs/Animations/animation";
  34015. import { Animatable } from "babylonjs/Animations/animatable";
  34016. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34017. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34018. import { Collider } from "babylonjs/Collisions/collider";
  34019. /**
  34020. * Define an interface for all classes that will hold resources
  34021. */
  34022. export interface IDisposable {
  34023. /**
  34024. * Releases all held resources
  34025. */
  34026. dispose(): void;
  34027. }
  34028. /** Interface defining initialization parameters for Scene class */
  34029. export interface SceneOptions {
  34030. /**
  34031. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34032. * It will improve performance when the number of geometries becomes important.
  34033. */
  34034. useGeometryUniqueIdsMap?: boolean;
  34035. /**
  34036. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34037. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34038. */
  34039. useMaterialMeshMap?: boolean;
  34040. /**
  34041. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34042. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34043. */
  34044. useClonedMeshhMap?: boolean;
  34045. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34046. virtual?: boolean;
  34047. }
  34048. /**
  34049. * Represents a scene to be rendered by the engine.
  34050. * @see http://doc.babylonjs.com/features/scene
  34051. */
  34052. export class Scene extends AbstractScene implements IAnimatable {
  34053. /** The fog is deactivated */
  34054. static readonly FOGMODE_NONE: number;
  34055. /** The fog density is following an exponential function */
  34056. static readonly FOGMODE_EXP: number;
  34057. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34058. static readonly FOGMODE_EXP2: number;
  34059. /** The fog density is following a linear function. */
  34060. static readonly FOGMODE_LINEAR: number;
  34061. /**
  34062. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34063. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34064. */
  34065. static MinDeltaTime: number;
  34066. /**
  34067. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34068. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34069. */
  34070. static MaxDeltaTime: number;
  34071. /**
  34072. * Factory used to create the default material.
  34073. * @param name The name of the material to create
  34074. * @param scene The scene to create the material for
  34075. * @returns The default material
  34076. */
  34077. static DefaultMaterialFactory(scene: Scene): Material;
  34078. /**
  34079. * Factory used to create the a collision coordinator.
  34080. * @returns The collision coordinator
  34081. */
  34082. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34083. /** @hidden */
  34084. _inputManager: InputManager;
  34085. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34086. cameraToUseForPointers: Nullable<Camera>;
  34087. /** @hidden */
  34088. readonly _isScene: boolean;
  34089. /**
  34090. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34091. */
  34092. autoClear: boolean;
  34093. /**
  34094. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34095. */
  34096. autoClearDepthAndStencil: boolean;
  34097. /**
  34098. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34099. */
  34100. clearColor: Color4;
  34101. /**
  34102. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34103. */
  34104. ambientColor: Color3;
  34105. /**
  34106. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34107. * It should only be one of the following (if not the default embedded one):
  34108. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34109. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34110. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34111. * The material properties need to be setup according to the type of texture in use.
  34112. */
  34113. environmentBRDFTexture: BaseTexture;
  34114. /** @hidden */
  34115. protected _environmentTexture: Nullable<BaseTexture>;
  34116. /**
  34117. * Texture used in all pbr material as the reflection texture.
  34118. * As in the majority of the scene they are the same (exception for multi room and so on),
  34119. * this is easier to reference from here than from all the materials.
  34120. */
  34121. /**
  34122. * Texture used in all pbr material as the reflection texture.
  34123. * As in the majority of the scene they are the same (exception for multi room and so on),
  34124. * this is easier to set here than in all the materials.
  34125. */
  34126. environmentTexture: Nullable<BaseTexture>;
  34127. /** @hidden */
  34128. protected _environmentIntensity: number;
  34129. /**
  34130. * Intensity of the environment in all pbr material.
  34131. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34132. * As in the majority of the scene they are the same (exception for multi room and so on),
  34133. * this is easier to reference from here than from all the materials.
  34134. */
  34135. /**
  34136. * Intensity of the environment in all pbr material.
  34137. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34138. * As in the majority of the scene they are the same (exception for multi room and so on),
  34139. * this is easier to set here than in all the materials.
  34140. */
  34141. environmentIntensity: number;
  34142. /** @hidden */
  34143. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34144. /**
  34145. * Default image processing configuration used either in the rendering
  34146. * Forward main pass or through the imageProcessingPostProcess if present.
  34147. * As in the majority of the scene they are the same (exception for multi camera),
  34148. * this is easier to reference from here than from all the materials and post process.
  34149. *
  34150. * No setter as we it is a shared configuration, you can set the values instead.
  34151. */
  34152. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34153. private _forceWireframe;
  34154. /**
  34155. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34156. */
  34157. forceWireframe: boolean;
  34158. private _forcePointsCloud;
  34159. /**
  34160. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34161. */
  34162. forcePointsCloud: boolean;
  34163. /**
  34164. * Gets or sets the active clipplane 1
  34165. */
  34166. clipPlane: Nullable<Plane>;
  34167. /**
  34168. * Gets or sets the active clipplane 2
  34169. */
  34170. clipPlane2: Nullable<Plane>;
  34171. /**
  34172. * Gets or sets the active clipplane 3
  34173. */
  34174. clipPlane3: Nullable<Plane>;
  34175. /**
  34176. * Gets or sets the active clipplane 4
  34177. */
  34178. clipPlane4: Nullable<Plane>;
  34179. /**
  34180. * Gets or sets a boolean indicating if animations are enabled
  34181. */
  34182. animationsEnabled: boolean;
  34183. private _animationPropertiesOverride;
  34184. /**
  34185. * Gets or sets the animation properties override
  34186. */
  34187. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34188. /**
  34189. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34190. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34191. */
  34192. useConstantAnimationDeltaTime: boolean;
  34193. /**
  34194. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34195. * Please note that it requires to run a ray cast through the scene on every frame
  34196. */
  34197. constantlyUpdateMeshUnderPointer: boolean;
  34198. /**
  34199. * Defines the HTML cursor to use when hovering over interactive elements
  34200. */
  34201. hoverCursor: string;
  34202. /**
  34203. * Defines the HTML default cursor to use (empty by default)
  34204. */
  34205. defaultCursor: string;
  34206. /**
  34207. * Defines wether cursors are handled by the scene.
  34208. */
  34209. doNotHandleCursors: boolean;
  34210. /**
  34211. * This is used to call preventDefault() on pointer down
  34212. * in order to block unwanted artifacts like system double clicks
  34213. */
  34214. preventDefaultOnPointerDown: boolean;
  34215. /**
  34216. * This is used to call preventDefault() on pointer up
  34217. * in order to block unwanted artifacts like system double clicks
  34218. */
  34219. preventDefaultOnPointerUp: boolean;
  34220. /**
  34221. * Gets or sets user defined metadata
  34222. */
  34223. metadata: any;
  34224. /**
  34225. * For internal use only. Please do not use.
  34226. */
  34227. reservedDataStore: any;
  34228. /**
  34229. * Gets the name of the plugin used to load this scene (null by default)
  34230. */
  34231. loadingPluginName: string;
  34232. /**
  34233. * Use this array to add regular expressions used to disable offline support for specific urls
  34234. */
  34235. disableOfflineSupportExceptionRules: RegExp[];
  34236. /**
  34237. * An event triggered when the scene is disposed.
  34238. */
  34239. onDisposeObservable: Observable<Scene>;
  34240. private _onDisposeObserver;
  34241. /** Sets a function to be executed when this scene is disposed. */
  34242. onDispose: () => void;
  34243. /**
  34244. * An event triggered before rendering the scene (right after animations and physics)
  34245. */
  34246. onBeforeRenderObservable: Observable<Scene>;
  34247. private _onBeforeRenderObserver;
  34248. /** Sets a function to be executed before rendering this scene */
  34249. beforeRender: Nullable<() => void>;
  34250. /**
  34251. * An event triggered after rendering the scene
  34252. */
  34253. onAfterRenderObservable: Observable<Scene>;
  34254. /**
  34255. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34256. */
  34257. onAfterRenderCameraObservable: Observable<Camera>;
  34258. private _onAfterRenderObserver;
  34259. /** Sets a function to be executed after rendering this scene */
  34260. afterRender: Nullable<() => void>;
  34261. /**
  34262. * An event triggered before animating the scene
  34263. */
  34264. onBeforeAnimationsObservable: Observable<Scene>;
  34265. /**
  34266. * An event triggered after animations processing
  34267. */
  34268. onAfterAnimationsObservable: Observable<Scene>;
  34269. /**
  34270. * An event triggered before draw calls are ready to be sent
  34271. */
  34272. onBeforeDrawPhaseObservable: Observable<Scene>;
  34273. /**
  34274. * An event triggered after draw calls have been sent
  34275. */
  34276. onAfterDrawPhaseObservable: Observable<Scene>;
  34277. /**
  34278. * An event triggered when the scene is ready
  34279. */
  34280. onReadyObservable: Observable<Scene>;
  34281. /**
  34282. * An event triggered before rendering a camera
  34283. */
  34284. onBeforeCameraRenderObservable: Observable<Camera>;
  34285. private _onBeforeCameraRenderObserver;
  34286. /** Sets a function to be executed before rendering a camera*/
  34287. beforeCameraRender: () => void;
  34288. /**
  34289. * An event triggered after rendering a camera
  34290. */
  34291. onAfterCameraRenderObservable: Observable<Camera>;
  34292. private _onAfterCameraRenderObserver;
  34293. /** Sets a function to be executed after rendering a camera*/
  34294. afterCameraRender: () => void;
  34295. /**
  34296. * An event triggered when active meshes evaluation is about to start
  34297. */
  34298. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34299. /**
  34300. * An event triggered when active meshes evaluation is done
  34301. */
  34302. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34303. /**
  34304. * An event triggered when particles rendering is about to start
  34305. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34306. */
  34307. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34308. /**
  34309. * An event triggered when particles rendering is done
  34310. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34311. */
  34312. onAfterParticlesRenderingObservable: Observable<Scene>;
  34313. /**
  34314. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34315. */
  34316. onDataLoadedObservable: Observable<Scene>;
  34317. /**
  34318. * An event triggered when a camera is created
  34319. */
  34320. onNewCameraAddedObservable: Observable<Camera>;
  34321. /**
  34322. * An event triggered when a camera is removed
  34323. */
  34324. onCameraRemovedObservable: Observable<Camera>;
  34325. /**
  34326. * An event triggered when a light is created
  34327. */
  34328. onNewLightAddedObservable: Observable<Light>;
  34329. /**
  34330. * An event triggered when a light is removed
  34331. */
  34332. onLightRemovedObservable: Observable<Light>;
  34333. /**
  34334. * An event triggered when a geometry is created
  34335. */
  34336. onNewGeometryAddedObservable: Observable<Geometry>;
  34337. /**
  34338. * An event triggered when a geometry is removed
  34339. */
  34340. onGeometryRemovedObservable: Observable<Geometry>;
  34341. /**
  34342. * An event triggered when a transform node is created
  34343. */
  34344. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34345. /**
  34346. * An event triggered when a transform node is removed
  34347. */
  34348. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34349. /**
  34350. * An event triggered when a mesh is created
  34351. */
  34352. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34353. /**
  34354. * An event triggered when a mesh is removed
  34355. */
  34356. onMeshRemovedObservable: Observable<AbstractMesh>;
  34357. /**
  34358. * An event triggered when a skeleton is created
  34359. */
  34360. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34361. /**
  34362. * An event triggered when a skeleton is removed
  34363. */
  34364. onSkeletonRemovedObservable: Observable<Skeleton>;
  34365. /**
  34366. * An event triggered when a material is created
  34367. */
  34368. onNewMaterialAddedObservable: Observable<Material>;
  34369. /**
  34370. * An event triggered when a material is removed
  34371. */
  34372. onMaterialRemovedObservable: Observable<Material>;
  34373. /**
  34374. * An event triggered when a texture is created
  34375. */
  34376. onNewTextureAddedObservable: Observable<BaseTexture>;
  34377. /**
  34378. * An event triggered when a texture is removed
  34379. */
  34380. onTextureRemovedObservable: Observable<BaseTexture>;
  34381. /**
  34382. * An event triggered when render targets are about to be rendered
  34383. * Can happen multiple times per frame.
  34384. */
  34385. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34386. /**
  34387. * An event triggered when render targets were rendered.
  34388. * Can happen multiple times per frame.
  34389. */
  34390. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34391. /**
  34392. * An event triggered before calculating deterministic simulation step
  34393. */
  34394. onBeforeStepObservable: Observable<Scene>;
  34395. /**
  34396. * An event triggered after calculating deterministic simulation step
  34397. */
  34398. onAfterStepObservable: Observable<Scene>;
  34399. /**
  34400. * An event triggered when the activeCamera property is updated
  34401. */
  34402. onActiveCameraChanged: Observable<Scene>;
  34403. /**
  34404. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34405. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34406. * 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)
  34407. */
  34408. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34409. /**
  34410. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34411. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34412. * 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)
  34413. */
  34414. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34415. /**
  34416. * This Observable will when a mesh has been imported into the scene.
  34417. */
  34418. onMeshImportedObservable: Observable<AbstractMesh>;
  34419. /**
  34420. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34421. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34422. */
  34423. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34424. /** @hidden */
  34425. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34426. /**
  34427. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34428. */
  34429. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34430. /**
  34431. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34432. */
  34433. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34434. /**
  34435. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34436. */
  34437. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34438. /** Callback called when a pointer move is detected */
  34439. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34440. /** Callback called when a pointer down is detected */
  34441. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34442. /** Callback called when a pointer up is detected */
  34443. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34444. /** Callback called when a pointer pick is detected */
  34445. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34446. /**
  34447. * 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).
  34448. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34449. */
  34450. onPrePointerObservable: Observable<PointerInfoPre>;
  34451. /**
  34452. * Observable event triggered each time an input event is received from the rendering canvas
  34453. */
  34454. onPointerObservable: Observable<PointerInfo>;
  34455. /**
  34456. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34457. */
  34458. readonly unTranslatedPointer: Vector2;
  34459. /**
  34460. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34461. */
  34462. static DragMovementThreshold: number;
  34463. /**
  34464. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34465. */
  34466. static LongPressDelay: number;
  34467. /**
  34468. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34469. */
  34470. static DoubleClickDelay: number;
  34471. /** If you need to check double click without raising a single click at first click, enable this flag */
  34472. static ExclusiveDoubleClickMode: boolean;
  34473. /** @hidden */
  34474. _mirroredCameraPosition: Nullable<Vector3>;
  34475. /**
  34476. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34477. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34478. */
  34479. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34480. /**
  34481. * Observable event triggered each time an keyboard event is received from the hosting window
  34482. */
  34483. onKeyboardObservable: Observable<KeyboardInfo>;
  34484. private _useRightHandedSystem;
  34485. /**
  34486. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34487. */
  34488. useRightHandedSystem: boolean;
  34489. private _timeAccumulator;
  34490. private _currentStepId;
  34491. private _currentInternalStep;
  34492. /**
  34493. * Sets the step Id used by deterministic lock step
  34494. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34495. * @param newStepId defines the step Id
  34496. */
  34497. setStepId(newStepId: number): void;
  34498. /**
  34499. * Gets the step Id used by deterministic lock step
  34500. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34501. * @returns the step Id
  34502. */
  34503. getStepId(): number;
  34504. /**
  34505. * Gets the internal step used by deterministic lock step
  34506. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34507. * @returns the internal step
  34508. */
  34509. getInternalStep(): number;
  34510. private _fogEnabled;
  34511. /**
  34512. * Gets or sets a boolean indicating if fog is enabled on this scene
  34513. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34514. * (Default is true)
  34515. */
  34516. fogEnabled: boolean;
  34517. private _fogMode;
  34518. /**
  34519. * Gets or sets the fog mode to use
  34520. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34521. * | mode | value |
  34522. * | --- | --- |
  34523. * | FOGMODE_NONE | 0 |
  34524. * | FOGMODE_EXP | 1 |
  34525. * | FOGMODE_EXP2 | 2 |
  34526. * | FOGMODE_LINEAR | 3 |
  34527. */
  34528. fogMode: number;
  34529. /**
  34530. * Gets or sets the fog color to use
  34531. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34532. * (Default is Color3(0.2, 0.2, 0.3))
  34533. */
  34534. fogColor: Color3;
  34535. /**
  34536. * Gets or sets the fog density to use
  34537. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34538. * (Default is 0.1)
  34539. */
  34540. fogDensity: number;
  34541. /**
  34542. * Gets or sets the fog start distance to use
  34543. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34544. * (Default is 0)
  34545. */
  34546. fogStart: number;
  34547. /**
  34548. * Gets or sets the fog end distance to use
  34549. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34550. * (Default is 1000)
  34551. */
  34552. fogEnd: number;
  34553. private _shadowsEnabled;
  34554. /**
  34555. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34556. */
  34557. shadowsEnabled: boolean;
  34558. private _lightsEnabled;
  34559. /**
  34560. * Gets or sets a boolean indicating if lights are enabled on this scene
  34561. */
  34562. lightsEnabled: boolean;
  34563. /** All of the active cameras added to this scene. */
  34564. activeCameras: Camera[];
  34565. /** @hidden */
  34566. _activeCamera: Nullable<Camera>;
  34567. /** Gets or sets the current active camera */
  34568. activeCamera: Nullable<Camera>;
  34569. private _defaultMaterial;
  34570. /** The default material used on meshes when no material is affected */
  34571. /** The default material used on meshes when no material is affected */
  34572. defaultMaterial: Material;
  34573. private _texturesEnabled;
  34574. /**
  34575. * Gets or sets a boolean indicating if textures are enabled on this scene
  34576. */
  34577. texturesEnabled: boolean;
  34578. /**
  34579. * Gets or sets a boolean indicating if particles are enabled on this scene
  34580. */
  34581. particlesEnabled: boolean;
  34582. /**
  34583. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34584. */
  34585. spritesEnabled: boolean;
  34586. private _skeletonsEnabled;
  34587. /**
  34588. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34589. */
  34590. skeletonsEnabled: boolean;
  34591. /**
  34592. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34593. */
  34594. lensFlaresEnabled: boolean;
  34595. /**
  34596. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34597. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34598. */
  34599. collisionsEnabled: boolean;
  34600. private _collisionCoordinator;
  34601. /** @hidden */
  34602. readonly collisionCoordinator: ICollisionCoordinator;
  34603. /**
  34604. * Defines the gravity applied to this scene (used only for collisions)
  34605. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34606. */
  34607. gravity: Vector3;
  34608. /**
  34609. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34610. */
  34611. postProcessesEnabled: boolean;
  34612. /**
  34613. * The list of postprocesses added to the scene
  34614. */
  34615. postProcesses: PostProcess[];
  34616. /**
  34617. * Gets the current postprocess manager
  34618. */
  34619. postProcessManager: PostProcessManager;
  34620. /**
  34621. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34622. */
  34623. renderTargetsEnabled: boolean;
  34624. /**
  34625. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34626. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34627. */
  34628. dumpNextRenderTargets: boolean;
  34629. /**
  34630. * The list of user defined render targets added to the scene
  34631. */
  34632. customRenderTargets: RenderTargetTexture[];
  34633. /**
  34634. * Defines if texture loading must be delayed
  34635. * If true, textures will only be loaded when they need to be rendered
  34636. */
  34637. useDelayedTextureLoading: boolean;
  34638. /**
  34639. * Gets the list of meshes imported to the scene through SceneLoader
  34640. */
  34641. importedMeshesFiles: String[];
  34642. /**
  34643. * Gets or sets a boolean indicating if probes are enabled on this scene
  34644. */
  34645. probesEnabled: boolean;
  34646. /**
  34647. * Gets or sets the current offline provider to use to store scene data
  34648. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34649. */
  34650. offlineProvider: IOfflineProvider;
  34651. /**
  34652. * Gets or sets the action manager associated with the scene
  34653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34654. */
  34655. actionManager: AbstractActionManager;
  34656. private _meshesForIntersections;
  34657. /**
  34658. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34659. */
  34660. proceduralTexturesEnabled: boolean;
  34661. private _engine;
  34662. private _totalVertices;
  34663. /** @hidden */
  34664. _activeIndices: PerfCounter;
  34665. /** @hidden */
  34666. _activeParticles: PerfCounter;
  34667. /** @hidden */
  34668. _activeBones: PerfCounter;
  34669. private _animationRatio;
  34670. /** @hidden */
  34671. _animationTimeLast: number;
  34672. /** @hidden */
  34673. _animationTime: number;
  34674. /**
  34675. * Gets or sets a general scale for animation speed
  34676. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34677. */
  34678. animationTimeScale: number;
  34679. /** @hidden */
  34680. _cachedMaterial: Nullable<Material>;
  34681. /** @hidden */
  34682. _cachedEffect: Nullable<Effect>;
  34683. /** @hidden */
  34684. _cachedVisibility: Nullable<number>;
  34685. private _renderId;
  34686. private _frameId;
  34687. private _executeWhenReadyTimeoutId;
  34688. private _intermediateRendering;
  34689. private _viewUpdateFlag;
  34690. private _projectionUpdateFlag;
  34691. /** @hidden */
  34692. _toBeDisposed: Nullable<IDisposable>[];
  34693. private _activeRequests;
  34694. /** @hidden */
  34695. _pendingData: any[];
  34696. private _isDisposed;
  34697. /**
  34698. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34699. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34700. */
  34701. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34702. private _activeMeshes;
  34703. private _processedMaterials;
  34704. private _renderTargets;
  34705. /** @hidden */
  34706. _activeParticleSystems: SmartArray<IParticleSystem>;
  34707. private _activeSkeletons;
  34708. private _softwareSkinnedMeshes;
  34709. private _renderingManager;
  34710. /** @hidden */
  34711. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34712. private _transformMatrix;
  34713. private _sceneUbo;
  34714. /** @hidden */
  34715. _viewMatrix: Matrix;
  34716. private _projectionMatrix;
  34717. /** @hidden */
  34718. _forcedViewPosition: Nullable<Vector3>;
  34719. /** @hidden */
  34720. _frustumPlanes: Plane[];
  34721. /**
  34722. * Gets the list of frustum planes (built from the active camera)
  34723. */
  34724. readonly frustumPlanes: Plane[];
  34725. /**
  34726. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34727. * This is useful if there are more lights that the maximum simulteanous authorized
  34728. */
  34729. requireLightSorting: boolean;
  34730. /** @hidden */
  34731. readonly useMaterialMeshMap: boolean;
  34732. /** @hidden */
  34733. readonly useClonedMeshhMap: boolean;
  34734. private _externalData;
  34735. private _uid;
  34736. /**
  34737. * @hidden
  34738. * Backing store of defined scene components.
  34739. */
  34740. _components: ISceneComponent[];
  34741. /**
  34742. * @hidden
  34743. * Backing store of defined scene components.
  34744. */
  34745. _serializableComponents: ISceneSerializableComponent[];
  34746. /**
  34747. * List of components to register on the next registration step.
  34748. */
  34749. private _transientComponents;
  34750. /**
  34751. * Registers the transient components if needed.
  34752. */
  34753. private _registerTransientComponents;
  34754. /**
  34755. * @hidden
  34756. * Add a component to the scene.
  34757. * Note that the ccomponent could be registered on th next frame if this is called after
  34758. * the register component stage.
  34759. * @param component Defines the component to add to the scene
  34760. */
  34761. _addComponent(component: ISceneComponent): void;
  34762. /**
  34763. * @hidden
  34764. * Gets a component from the scene.
  34765. * @param name defines the name of the component to retrieve
  34766. * @returns the component or null if not present
  34767. */
  34768. _getComponent(name: string): Nullable<ISceneComponent>;
  34769. /**
  34770. * @hidden
  34771. * Defines the actions happening before camera updates.
  34772. */
  34773. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34774. /**
  34775. * @hidden
  34776. * Defines the actions happening before clear the canvas.
  34777. */
  34778. _beforeClearStage: Stage<SimpleStageAction>;
  34779. /**
  34780. * @hidden
  34781. * Defines the actions when collecting render targets for the frame.
  34782. */
  34783. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34784. /**
  34785. * @hidden
  34786. * Defines the actions happening for one camera in the frame.
  34787. */
  34788. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34789. /**
  34790. * @hidden
  34791. * Defines the actions happening during the per mesh ready checks.
  34792. */
  34793. _isReadyForMeshStage: Stage<MeshStageAction>;
  34794. /**
  34795. * @hidden
  34796. * Defines the actions happening before evaluate active mesh checks.
  34797. */
  34798. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34799. /**
  34800. * @hidden
  34801. * Defines the actions happening during the evaluate sub mesh checks.
  34802. */
  34803. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34804. /**
  34805. * @hidden
  34806. * Defines the actions happening during the active mesh stage.
  34807. */
  34808. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34809. /**
  34810. * @hidden
  34811. * Defines the actions happening during the per camera render target step.
  34812. */
  34813. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34814. /**
  34815. * @hidden
  34816. * Defines the actions happening just before the active camera is drawing.
  34817. */
  34818. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34819. /**
  34820. * @hidden
  34821. * Defines the actions happening just before a render target is drawing.
  34822. */
  34823. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34824. /**
  34825. * @hidden
  34826. * Defines the actions happening just before a rendering group is drawing.
  34827. */
  34828. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34829. /**
  34830. * @hidden
  34831. * Defines the actions happening just before a mesh is drawing.
  34832. */
  34833. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34834. /**
  34835. * @hidden
  34836. * Defines the actions happening just after a mesh has been drawn.
  34837. */
  34838. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34839. /**
  34840. * @hidden
  34841. * Defines the actions happening just after a rendering group has been drawn.
  34842. */
  34843. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34844. /**
  34845. * @hidden
  34846. * Defines the actions happening just after the active camera has been drawn.
  34847. */
  34848. _afterCameraDrawStage: Stage<CameraStageAction>;
  34849. /**
  34850. * @hidden
  34851. * Defines the actions happening just after a render target has been drawn.
  34852. */
  34853. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34854. /**
  34855. * @hidden
  34856. * Defines the actions happening just after rendering all cameras and computing intersections.
  34857. */
  34858. _afterRenderStage: Stage<SimpleStageAction>;
  34859. /**
  34860. * @hidden
  34861. * Defines the actions happening when a pointer move event happens.
  34862. */
  34863. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34864. /**
  34865. * @hidden
  34866. * Defines the actions happening when a pointer down event happens.
  34867. */
  34868. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34869. /**
  34870. * @hidden
  34871. * Defines the actions happening when a pointer up event happens.
  34872. */
  34873. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34874. /**
  34875. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34876. */
  34877. private geometriesByUniqueId;
  34878. /**
  34879. * Creates a new Scene
  34880. * @param engine defines the engine to use to render this scene
  34881. * @param options defines the scene options
  34882. */
  34883. constructor(engine: Engine, options?: SceneOptions);
  34884. /**
  34885. * Gets a string idenfifying the name of the class
  34886. * @returns "Scene" string
  34887. */
  34888. getClassName(): string;
  34889. private _defaultMeshCandidates;
  34890. /**
  34891. * @hidden
  34892. */
  34893. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34894. private _defaultSubMeshCandidates;
  34895. /**
  34896. * @hidden
  34897. */
  34898. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34899. /**
  34900. * Sets the default candidate providers for the scene.
  34901. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34902. * and getCollidingSubMeshCandidates to their default function
  34903. */
  34904. setDefaultCandidateProviders(): void;
  34905. /**
  34906. * Gets the mesh that is currently under the pointer
  34907. */
  34908. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34909. /**
  34910. * Gets or sets the current on-screen X position of the pointer
  34911. */
  34912. pointerX: number;
  34913. /**
  34914. * Gets or sets the current on-screen Y position of the pointer
  34915. */
  34916. pointerY: number;
  34917. /**
  34918. * Gets the cached material (ie. the latest rendered one)
  34919. * @returns the cached material
  34920. */
  34921. getCachedMaterial(): Nullable<Material>;
  34922. /**
  34923. * Gets the cached effect (ie. the latest rendered one)
  34924. * @returns the cached effect
  34925. */
  34926. getCachedEffect(): Nullable<Effect>;
  34927. /**
  34928. * Gets the cached visibility state (ie. the latest rendered one)
  34929. * @returns the cached visibility state
  34930. */
  34931. getCachedVisibility(): Nullable<number>;
  34932. /**
  34933. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34934. * @param material defines the current material
  34935. * @param effect defines the current effect
  34936. * @param visibility defines the current visibility state
  34937. * @returns true if one parameter is not cached
  34938. */
  34939. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34940. /**
  34941. * Gets the engine associated with the scene
  34942. * @returns an Engine
  34943. */
  34944. getEngine(): Engine;
  34945. /**
  34946. * Gets the total number of vertices rendered per frame
  34947. * @returns the total number of vertices rendered per frame
  34948. */
  34949. getTotalVertices(): number;
  34950. /**
  34951. * Gets the performance counter for total vertices
  34952. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34953. */
  34954. readonly totalVerticesPerfCounter: PerfCounter;
  34955. /**
  34956. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34957. * @returns the total number of active indices rendered per frame
  34958. */
  34959. getActiveIndices(): number;
  34960. /**
  34961. * Gets the performance counter for active indices
  34962. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34963. */
  34964. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34965. /**
  34966. * Gets the total number of active particles rendered per frame
  34967. * @returns the total number of active particles rendered per frame
  34968. */
  34969. getActiveParticles(): number;
  34970. /**
  34971. * Gets the performance counter for active particles
  34972. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34973. */
  34974. readonly activeParticlesPerfCounter: PerfCounter;
  34975. /**
  34976. * Gets the total number of active bones rendered per frame
  34977. * @returns the total number of active bones rendered per frame
  34978. */
  34979. getActiveBones(): number;
  34980. /**
  34981. * Gets the performance counter for active bones
  34982. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34983. */
  34984. readonly activeBonesPerfCounter: PerfCounter;
  34985. /**
  34986. * Gets the array of active meshes
  34987. * @returns an array of AbstractMesh
  34988. */
  34989. getActiveMeshes(): SmartArray<AbstractMesh>;
  34990. /**
  34991. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34992. * @returns a number
  34993. */
  34994. getAnimationRatio(): number;
  34995. /**
  34996. * Gets an unique Id for the current render phase
  34997. * @returns a number
  34998. */
  34999. getRenderId(): number;
  35000. /**
  35001. * Gets an unique Id for the current frame
  35002. * @returns a number
  35003. */
  35004. getFrameId(): number;
  35005. /** Call this function if you want to manually increment the render Id*/
  35006. incrementRenderId(): void;
  35007. private _createUbo;
  35008. /**
  35009. * Use this method to simulate a pointer move on a mesh
  35010. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35011. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35012. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35013. * @returns the current scene
  35014. */
  35015. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35016. /**
  35017. * Use this method to simulate a pointer down on a mesh
  35018. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35019. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35020. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35021. * @returns the current scene
  35022. */
  35023. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35024. /**
  35025. * Use this method to simulate a pointer up on a mesh
  35026. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35027. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35028. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35029. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35030. * @returns the current scene
  35031. */
  35032. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35033. /**
  35034. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35035. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35036. * @returns true if the pointer was captured
  35037. */
  35038. isPointerCaptured(pointerId?: number): boolean;
  35039. /**
  35040. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35041. * @param attachUp defines if you want to attach events to pointerup
  35042. * @param attachDown defines if you want to attach events to pointerdown
  35043. * @param attachMove defines if you want to attach events to pointermove
  35044. */
  35045. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35046. /** Detaches all event handlers*/
  35047. detachControl(): void;
  35048. /**
  35049. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35050. * Delay loaded resources are not taking in account
  35051. * @return true if all required resources are ready
  35052. */
  35053. isReady(): boolean;
  35054. /** Resets all cached information relative to material (including effect and visibility) */
  35055. resetCachedMaterial(): void;
  35056. /**
  35057. * Registers a function to be called before every frame render
  35058. * @param func defines the function to register
  35059. */
  35060. registerBeforeRender(func: () => void): void;
  35061. /**
  35062. * Unregisters a function called before every frame render
  35063. * @param func defines the function to unregister
  35064. */
  35065. unregisterBeforeRender(func: () => void): void;
  35066. /**
  35067. * Registers a function to be called after every frame render
  35068. * @param func defines the function to register
  35069. */
  35070. registerAfterRender(func: () => void): void;
  35071. /**
  35072. * Unregisters a function called after every frame render
  35073. * @param func defines the function to unregister
  35074. */
  35075. unregisterAfterRender(func: () => void): void;
  35076. private _executeOnceBeforeRender;
  35077. /**
  35078. * The provided function will run before render once and will be disposed afterwards.
  35079. * A timeout delay can be provided so that the function will be executed in N ms.
  35080. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35081. * @param func The function to be executed.
  35082. * @param timeout optional delay in ms
  35083. */
  35084. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35085. /** @hidden */
  35086. _addPendingData(data: any): void;
  35087. /** @hidden */
  35088. _removePendingData(data: any): void;
  35089. /**
  35090. * Returns the number of items waiting to be loaded
  35091. * @returns the number of items waiting to be loaded
  35092. */
  35093. getWaitingItemsCount(): number;
  35094. /**
  35095. * Returns a boolean indicating if the scene is still loading data
  35096. */
  35097. readonly isLoading: boolean;
  35098. /**
  35099. * Registers a function to be executed when the scene is ready
  35100. * @param {Function} func - the function to be executed
  35101. */
  35102. executeWhenReady(func: () => void): void;
  35103. /**
  35104. * Returns a promise that resolves when the scene is ready
  35105. * @returns A promise that resolves when the scene is ready
  35106. */
  35107. whenReadyAsync(): Promise<void>;
  35108. /** @hidden */
  35109. _checkIsReady(): void;
  35110. /**
  35111. * Gets all animatable attached to the scene
  35112. */
  35113. readonly animatables: Animatable[];
  35114. /**
  35115. * Resets the last animation time frame.
  35116. * Useful to override when animations start running when loading a scene for the first time.
  35117. */
  35118. resetLastAnimationTimeFrame(): void;
  35119. /**
  35120. * Gets the current view matrix
  35121. * @returns a Matrix
  35122. */
  35123. getViewMatrix(): Matrix;
  35124. /**
  35125. * Gets the current projection matrix
  35126. * @returns a Matrix
  35127. */
  35128. getProjectionMatrix(): Matrix;
  35129. /**
  35130. * Gets the current transform matrix
  35131. * @returns a Matrix made of View * Projection
  35132. */
  35133. getTransformMatrix(): Matrix;
  35134. /**
  35135. * Sets the current transform matrix
  35136. * @param viewL defines the View matrix to use
  35137. * @param projectionL defines the Projection matrix to use
  35138. * @param viewR defines the right View matrix to use (if provided)
  35139. * @param projectionR defines the right Projection matrix to use (if provided)
  35140. */
  35141. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35142. /**
  35143. * Gets the uniform buffer used to store scene data
  35144. * @returns a UniformBuffer
  35145. */
  35146. getSceneUniformBuffer(): UniformBuffer;
  35147. /**
  35148. * Gets an unique (relatively to the current scene) Id
  35149. * @returns an unique number for the scene
  35150. */
  35151. getUniqueId(): number;
  35152. /**
  35153. * Add a mesh to the list of scene's meshes
  35154. * @param newMesh defines the mesh to add
  35155. * @param recursive if all child meshes should also be added to the scene
  35156. */
  35157. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35158. /**
  35159. * Remove a mesh for the list of scene's meshes
  35160. * @param toRemove defines the mesh to remove
  35161. * @param recursive if all child meshes should also be removed from the scene
  35162. * @returns the index where the mesh was in the mesh list
  35163. */
  35164. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35165. /**
  35166. * Add a transform node to the list of scene's transform nodes
  35167. * @param newTransformNode defines the transform node to add
  35168. */
  35169. addTransformNode(newTransformNode: TransformNode): void;
  35170. /**
  35171. * Remove a transform node for the list of scene's transform nodes
  35172. * @param toRemove defines the transform node to remove
  35173. * @returns the index where the transform node was in the transform node list
  35174. */
  35175. removeTransformNode(toRemove: TransformNode): number;
  35176. /**
  35177. * Remove a skeleton for the list of scene's skeletons
  35178. * @param toRemove defines the skeleton to remove
  35179. * @returns the index where the skeleton was in the skeleton list
  35180. */
  35181. removeSkeleton(toRemove: Skeleton): number;
  35182. /**
  35183. * Remove a morph target for the list of scene's morph targets
  35184. * @param toRemove defines the morph target to remove
  35185. * @returns the index where the morph target was in the morph target list
  35186. */
  35187. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35188. /**
  35189. * Remove a light for the list of scene's lights
  35190. * @param toRemove defines the light to remove
  35191. * @returns the index where the light was in the light list
  35192. */
  35193. removeLight(toRemove: Light): number;
  35194. /**
  35195. * Remove a camera for the list of scene's cameras
  35196. * @param toRemove defines the camera to remove
  35197. * @returns the index where the camera was in the camera list
  35198. */
  35199. removeCamera(toRemove: Camera): number;
  35200. /**
  35201. * Remove a particle system for the list of scene's particle systems
  35202. * @param toRemove defines the particle system to remove
  35203. * @returns the index where the particle system was in the particle system list
  35204. */
  35205. removeParticleSystem(toRemove: IParticleSystem): number;
  35206. /**
  35207. * Remove a animation for the list of scene's animations
  35208. * @param toRemove defines the animation to remove
  35209. * @returns the index where the animation was in the animation list
  35210. */
  35211. removeAnimation(toRemove: Animation): number;
  35212. /**
  35213. * Will stop the animation of the given target
  35214. * @param target - the target
  35215. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35216. * @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)
  35217. */
  35218. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35219. /**
  35220. * Removes the given animation group from this scene.
  35221. * @param toRemove The animation group to remove
  35222. * @returns The index of the removed animation group
  35223. */
  35224. removeAnimationGroup(toRemove: AnimationGroup): number;
  35225. /**
  35226. * Removes the given multi-material from this scene.
  35227. * @param toRemove The multi-material to remove
  35228. * @returns The index of the removed multi-material
  35229. */
  35230. removeMultiMaterial(toRemove: MultiMaterial): number;
  35231. /**
  35232. * Removes the given material from this scene.
  35233. * @param toRemove The material to remove
  35234. * @returns The index of the removed material
  35235. */
  35236. removeMaterial(toRemove: Material): number;
  35237. /**
  35238. * Removes the given action manager from this scene.
  35239. * @param toRemove The action manager to remove
  35240. * @returns The index of the removed action manager
  35241. */
  35242. removeActionManager(toRemove: AbstractActionManager): number;
  35243. /**
  35244. * Removes the given texture from this scene.
  35245. * @param toRemove The texture to remove
  35246. * @returns The index of the removed texture
  35247. */
  35248. removeTexture(toRemove: BaseTexture): number;
  35249. /**
  35250. * Adds the given light to this scene
  35251. * @param newLight The light to add
  35252. */
  35253. addLight(newLight: Light): void;
  35254. /**
  35255. * Sorts the list list based on light priorities
  35256. */
  35257. sortLightsByPriority(): void;
  35258. /**
  35259. * Adds the given camera to this scene
  35260. * @param newCamera The camera to add
  35261. */
  35262. addCamera(newCamera: Camera): void;
  35263. /**
  35264. * Adds the given skeleton to this scene
  35265. * @param newSkeleton The skeleton to add
  35266. */
  35267. addSkeleton(newSkeleton: Skeleton): void;
  35268. /**
  35269. * Adds the given particle system to this scene
  35270. * @param newParticleSystem The particle system to add
  35271. */
  35272. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35273. /**
  35274. * Adds the given animation to this scene
  35275. * @param newAnimation The animation to add
  35276. */
  35277. addAnimation(newAnimation: Animation): void;
  35278. /**
  35279. * Adds the given animation group to this scene.
  35280. * @param newAnimationGroup The animation group to add
  35281. */
  35282. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35283. /**
  35284. * Adds the given multi-material to this scene
  35285. * @param newMultiMaterial The multi-material to add
  35286. */
  35287. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35288. /**
  35289. * Adds the given material to this scene
  35290. * @param newMaterial The material to add
  35291. */
  35292. addMaterial(newMaterial: Material): void;
  35293. /**
  35294. * Adds the given morph target to this scene
  35295. * @param newMorphTargetManager The morph target to add
  35296. */
  35297. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35298. /**
  35299. * Adds the given geometry to this scene
  35300. * @param newGeometry The geometry to add
  35301. */
  35302. addGeometry(newGeometry: Geometry): void;
  35303. /**
  35304. * Adds the given action manager to this scene
  35305. * @param newActionManager The action manager to add
  35306. */
  35307. addActionManager(newActionManager: AbstractActionManager): void;
  35308. /**
  35309. * Adds the given texture to this scene.
  35310. * @param newTexture The texture to add
  35311. */
  35312. addTexture(newTexture: BaseTexture): void;
  35313. /**
  35314. * Switch active camera
  35315. * @param newCamera defines the new active camera
  35316. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35317. */
  35318. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35319. /**
  35320. * sets the active camera of the scene using its ID
  35321. * @param id defines the camera's ID
  35322. * @return the new active camera or null if none found.
  35323. */
  35324. setActiveCameraByID(id: string): Nullable<Camera>;
  35325. /**
  35326. * sets the active camera of the scene using its name
  35327. * @param name defines the camera's name
  35328. * @returns the new active camera or null if none found.
  35329. */
  35330. setActiveCameraByName(name: string): Nullable<Camera>;
  35331. /**
  35332. * get an animation group using its name
  35333. * @param name defines the material's name
  35334. * @return the animation group or null if none found.
  35335. */
  35336. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35337. /**
  35338. * Get a material using its unique id
  35339. * @param uniqueId defines the material's unique id
  35340. * @return the material or null if none found.
  35341. */
  35342. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35343. /**
  35344. * get a material using its id
  35345. * @param id defines the material's ID
  35346. * @return the material or null if none found.
  35347. */
  35348. getMaterialByID(id: string): Nullable<Material>;
  35349. /**
  35350. * Gets a the last added material using a given id
  35351. * @param id defines the material's ID
  35352. * @return the last material with the given id or null if none found.
  35353. */
  35354. getLastMaterialByID(id: string): Nullable<Material>;
  35355. /**
  35356. * Gets a material using its name
  35357. * @param name defines the material's name
  35358. * @return the material or null if none found.
  35359. */
  35360. getMaterialByName(name: string): Nullable<Material>;
  35361. /**
  35362. * Get a texture using its unique id
  35363. * @param uniqueId defines the texture's unique id
  35364. * @return the texture or null if none found.
  35365. */
  35366. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35367. /**
  35368. * Gets a camera using its id
  35369. * @param id defines the id to look for
  35370. * @returns the camera or null if not found
  35371. */
  35372. getCameraByID(id: string): Nullable<Camera>;
  35373. /**
  35374. * Gets a camera using its unique id
  35375. * @param uniqueId defines the unique id to look for
  35376. * @returns the camera or null if not found
  35377. */
  35378. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35379. /**
  35380. * Gets a camera using its name
  35381. * @param name defines the camera's name
  35382. * @return the camera or null if none found.
  35383. */
  35384. getCameraByName(name: string): Nullable<Camera>;
  35385. /**
  35386. * Gets a bone using its id
  35387. * @param id defines the bone's id
  35388. * @return the bone or null if not found
  35389. */
  35390. getBoneByID(id: string): Nullable<Bone>;
  35391. /**
  35392. * Gets a bone using its id
  35393. * @param name defines the bone's name
  35394. * @return the bone or null if not found
  35395. */
  35396. getBoneByName(name: string): Nullable<Bone>;
  35397. /**
  35398. * Gets a light node using its name
  35399. * @param name defines the the light's name
  35400. * @return the light or null if none found.
  35401. */
  35402. getLightByName(name: string): Nullable<Light>;
  35403. /**
  35404. * Gets a light node using its id
  35405. * @param id defines the light's id
  35406. * @return the light or null if none found.
  35407. */
  35408. getLightByID(id: string): Nullable<Light>;
  35409. /**
  35410. * Gets a light node using its scene-generated unique ID
  35411. * @param uniqueId defines the light's unique id
  35412. * @return the light or null if none found.
  35413. */
  35414. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35415. /**
  35416. * Gets a particle system by id
  35417. * @param id defines the particle system id
  35418. * @return the corresponding system or null if none found
  35419. */
  35420. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35421. /**
  35422. * Gets a geometry using its ID
  35423. * @param id defines the geometry's id
  35424. * @return the geometry or null if none found.
  35425. */
  35426. getGeometryByID(id: string): Nullable<Geometry>;
  35427. private _getGeometryByUniqueID;
  35428. /**
  35429. * Add a new geometry to this scene
  35430. * @param geometry defines the geometry to be added to the scene.
  35431. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35432. * @return a boolean defining if the geometry was added or not
  35433. */
  35434. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35435. /**
  35436. * Removes an existing geometry
  35437. * @param geometry defines the geometry to be removed from the scene
  35438. * @return a boolean defining if the geometry was removed or not
  35439. */
  35440. removeGeometry(geometry: Geometry): boolean;
  35441. /**
  35442. * Gets the list of geometries attached to the scene
  35443. * @returns an array of Geometry
  35444. */
  35445. getGeometries(): Geometry[];
  35446. /**
  35447. * Gets the first added mesh found of a given ID
  35448. * @param id defines the id to search for
  35449. * @return the mesh found or null if not found at all
  35450. */
  35451. getMeshByID(id: string): Nullable<AbstractMesh>;
  35452. /**
  35453. * Gets a list of meshes using their id
  35454. * @param id defines the id to search for
  35455. * @returns a list of meshes
  35456. */
  35457. getMeshesByID(id: string): Array<AbstractMesh>;
  35458. /**
  35459. * Gets the first added transform node found of a given ID
  35460. * @param id defines the id to search for
  35461. * @return the found transform node or null if not found at all.
  35462. */
  35463. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35464. /**
  35465. * Gets a transform node with its auto-generated unique id
  35466. * @param uniqueId efines the unique id to search for
  35467. * @return the found transform node or null if not found at all.
  35468. */
  35469. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35470. /**
  35471. * Gets a list of transform nodes using their id
  35472. * @param id defines the id to search for
  35473. * @returns a list of transform nodes
  35474. */
  35475. getTransformNodesByID(id: string): Array<TransformNode>;
  35476. /**
  35477. * Gets a mesh with its auto-generated unique id
  35478. * @param uniqueId defines the unique id to search for
  35479. * @return the found mesh or null if not found at all.
  35480. */
  35481. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35482. /**
  35483. * Gets a the last added mesh using a given id
  35484. * @param id defines the id to search for
  35485. * @return the found mesh or null if not found at all.
  35486. */
  35487. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35488. /**
  35489. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35490. * @param id defines the id to search for
  35491. * @return the found node or null if not found at all
  35492. */
  35493. getLastEntryByID(id: string): Nullable<Node>;
  35494. /**
  35495. * Gets a node (Mesh, Camera, Light) using a given id
  35496. * @param id defines the id to search for
  35497. * @return the found node or null if not found at all
  35498. */
  35499. getNodeByID(id: string): Nullable<Node>;
  35500. /**
  35501. * Gets a node (Mesh, Camera, Light) using a given name
  35502. * @param name defines the name to search for
  35503. * @return the found node or null if not found at all.
  35504. */
  35505. getNodeByName(name: string): Nullable<Node>;
  35506. /**
  35507. * Gets a mesh using a given name
  35508. * @param name defines the name to search for
  35509. * @return the found mesh or null if not found at all.
  35510. */
  35511. getMeshByName(name: string): Nullable<AbstractMesh>;
  35512. /**
  35513. * Gets a transform node using a given name
  35514. * @param name defines the name to search for
  35515. * @return the found transform node or null if not found at all.
  35516. */
  35517. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35518. /**
  35519. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35520. * @param id defines the id to search for
  35521. * @return the found skeleton or null if not found at all.
  35522. */
  35523. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35524. /**
  35525. * Gets a skeleton using a given auto generated unique id
  35526. * @param uniqueId defines the unique id to search for
  35527. * @return the found skeleton or null if not found at all.
  35528. */
  35529. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35530. /**
  35531. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35532. * @param id defines the id to search for
  35533. * @return the found skeleton or null if not found at all.
  35534. */
  35535. getSkeletonById(id: string): Nullable<Skeleton>;
  35536. /**
  35537. * Gets a skeleton using a given name
  35538. * @param name defines the name to search for
  35539. * @return the found skeleton or null if not found at all.
  35540. */
  35541. getSkeletonByName(name: string): Nullable<Skeleton>;
  35542. /**
  35543. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35544. * @param id defines the id to search for
  35545. * @return the found morph target manager or null if not found at all.
  35546. */
  35547. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35548. /**
  35549. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35550. * @param id defines the id to search for
  35551. * @return the found morph target or null if not found at all.
  35552. */
  35553. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35554. /**
  35555. * Gets a boolean indicating if the given mesh is active
  35556. * @param mesh defines the mesh to look for
  35557. * @returns true if the mesh is in the active list
  35558. */
  35559. isActiveMesh(mesh: AbstractMesh): boolean;
  35560. /**
  35561. * Return a unique id as a string which can serve as an identifier for the scene
  35562. */
  35563. readonly uid: string;
  35564. /**
  35565. * Add an externaly attached data from its key.
  35566. * This method call will fail and return false, if such key already exists.
  35567. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35568. * @param key the unique key that identifies the data
  35569. * @param data the data object to associate to the key for this Engine instance
  35570. * @return true if no such key were already present and the data was added successfully, false otherwise
  35571. */
  35572. addExternalData<T>(key: string, data: T): boolean;
  35573. /**
  35574. * Get an externaly attached data from its key
  35575. * @param key the unique key that identifies the data
  35576. * @return the associated data, if present (can be null), or undefined if not present
  35577. */
  35578. getExternalData<T>(key: string): Nullable<T>;
  35579. /**
  35580. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35581. * @param key the unique key that identifies the data
  35582. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35583. * @return the associated data, can be null if the factory returned null.
  35584. */
  35585. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35586. /**
  35587. * Remove an externaly attached data from the Engine instance
  35588. * @param key the unique key that identifies the data
  35589. * @return true if the data was successfully removed, false if it doesn't exist
  35590. */
  35591. removeExternalData(key: string): boolean;
  35592. private _evaluateSubMesh;
  35593. /**
  35594. * Clear the processed materials smart array preventing retention point in material dispose.
  35595. */
  35596. freeProcessedMaterials(): void;
  35597. private _preventFreeActiveMeshesAndRenderingGroups;
  35598. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35599. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35600. * when disposing several meshes in a row or a hierarchy of meshes.
  35601. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35602. */
  35603. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35604. /**
  35605. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35606. */
  35607. freeActiveMeshes(): void;
  35608. /**
  35609. * Clear the info related to rendering groups preventing retention points during dispose.
  35610. */
  35611. freeRenderingGroups(): void;
  35612. /** @hidden */
  35613. _isInIntermediateRendering(): boolean;
  35614. /**
  35615. * Lambda returning the list of potentially active meshes.
  35616. */
  35617. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35618. /**
  35619. * Lambda returning the list of potentially active sub meshes.
  35620. */
  35621. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35622. /**
  35623. * Lambda returning the list of potentially intersecting sub meshes.
  35624. */
  35625. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35626. /**
  35627. * Lambda returning the list of potentially colliding sub meshes.
  35628. */
  35629. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35630. private _activeMeshesFrozen;
  35631. /**
  35632. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35633. * @returns the current scene
  35634. */
  35635. freezeActiveMeshes(): Scene;
  35636. /**
  35637. * Use this function to restart evaluating active meshes on every frame
  35638. * @returns the current scene
  35639. */
  35640. unfreezeActiveMeshes(): Scene;
  35641. private _evaluateActiveMeshes;
  35642. private _activeMesh;
  35643. /**
  35644. * Update the transform matrix to update from the current active camera
  35645. * @param force defines a boolean used to force the update even if cache is up to date
  35646. */
  35647. updateTransformMatrix(force?: boolean): void;
  35648. private _bindFrameBuffer;
  35649. /** @hidden */
  35650. _allowPostProcessClearColor: boolean;
  35651. /** @hidden */
  35652. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35653. private _processSubCameras;
  35654. private _checkIntersections;
  35655. /** @hidden */
  35656. _advancePhysicsEngineStep(step: number): void;
  35657. /**
  35658. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35659. */
  35660. getDeterministicFrameTime: () => number;
  35661. /** @hidden */
  35662. _animate(): void;
  35663. /** Execute all animations (for a frame) */
  35664. animate(): void;
  35665. /**
  35666. * Render the scene
  35667. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35668. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35669. */
  35670. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35671. /**
  35672. * Freeze all materials
  35673. * A frozen material will not be updatable but should be faster to render
  35674. */
  35675. freezeMaterials(): void;
  35676. /**
  35677. * Unfreeze all materials
  35678. * A frozen material will not be updatable but should be faster to render
  35679. */
  35680. unfreezeMaterials(): void;
  35681. /**
  35682. * Releases all held ressources
  35683. */
  35684. dispose(): void;
  35685. /**
  35686. * Gets if the scene is already disposed
  35687. */
  35688. readonly isDisposed: boolean;
  35689. /**
  35690. * Call this function to reduce memory footprint of the scene.
  35691. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35692. */
  35693. clearCachedVertexData(): void;
  35694. /**
  35695. * This function will remove the local cached buffer data from texture.
  35696. * It will save memory but will prevent the texture from being rebuilt
  35697. */
  35698. cleanCachedTextureBuffer(): void;
  35699. /**
  35700. * Get the world extend vectors with an optional filter
  35701. *
  35702. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35703. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35704. */
  35705. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35706. min: Vector3;
  35707. max: Vector3;
  35708. };
  35709. /**
  35710. * Creates a ray that can be used to pick in the scene
  35711. * @param x defines the x coordinate of the origin (on-screen)
  35712. * @param y defines the y coordinate of the origin (on-screen)
  35713. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35714. * @param camera defines the camera to use for the picking
  35715. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35716. * @returns a Ray
  35717. */
  35718. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35719. /**
  35720. * Creates a ray that can be used to pick in the scene
  35721. * @param x defines the x coordinate of the origin (on-screen)
  35722. * @param y defines the y coordinate of the origin (on-screen)
  35723. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35724. * @param result defines the ray where to store the picking ray
  35725. * @param camera defines the camera to use for the picking
  35726. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35727. * @returns the current scene
  35728. */
  35729. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35730. /**
  35731. * Creates a ray that can be used to pick in the scene
  35732. * @param x defines the x coordinate of the origin (on-screen)
  35733. * @param y defines the y coordinate of the origin (on-screen)
  35734. * @param camera defines the camera to use for the picking
  35735. * @returns a Ray
  35736. */
  35737. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35738. /**
  35739. * Creates a ray that can be used to pick in the scene
  35740. * @param x defines the x coordinate of the origin (on-screen)
  35741. * @param y defines the y coordinate of the origin (on-screen)
  35742. * @param result defines the ray where to store the picking ray
  35743. * @param camera defines the camera to use for the picking
  35744. * @returns the current scene
  35745. */
  35746. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35747. /** Launch a ray to try to pick a mesh in the scene
  35748. * @param x position on screen
  35749. * @param y position on screen
  35750. * @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
  35751. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35752. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35753. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35754. * @returns a PickingInfo
  35755. */
  35756. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35757. /** Use the given ray to pick a mesh in the scene
  35758. * @param ray The ray to use to pick meshes
  35759. * @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
  35760. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35761. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35762. * @returns a PickingInfo
  35763. */
  35764. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35765. /**
  35766. * Launch a ray to try to pick a mesh in the scene
  35767. * @param x X position on screen
  35768. * @param y Y position on screen
  35769. * @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
  35770. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35771. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35772. * @returns an array of PickingInfo
  35773. */
  35774. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35775. /**
  35776. * Launch a ray to try to pick a mesh in the scene
  35777. * @param ray Ray to use
  35778. * @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
  35779. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35780. * @returns an array of PickingInfo
  35781. */
  35782. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35783. /**
  35784. * Force the value of meshUnderPointer
  35785. * @param mesh defines the mesh to use
  35786. */
  35787. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35788. /**
  35789. * Gets the mesh under the pointer
  35790. * @returns a Mesh or null if no mesh is under the pointer
  35791. */
  35792. getPointerOverMesh(): Nullable<AbstractMesh>;
  35793. /** @hidden */
  35794. _rebuildGeometries(): void;
  35795. /** @hidden */
  35796. _rebuildTextures(): void;
  35797. private _getByTags;
  35798. /**
  35799. * Get a list of meshes by tags
  35800. * @param tagsQuery defines the tags query to use
  35801. * @param forEach defines a predicate used to filter results
  35802. * @returns an array of Mesh
  35803. */
  35804. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35805. /**
  35806. * Get a list of cameras by tags
  35807. * @param tagsQuery defines the tags query to use
  35808. * @param forEach defines a predicate used to filter results
  35809. * @returns an array of Camera
  35810. */
  35811. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35812. /**
  35813. * Get a list of lights by tags
  35814. * @param tagsQuery defines the tags query to use
  35815. * @param forEach defines a predicate used to filter results
  35816. * @returns an array of Light
  35817. */
  35818. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35819. /**
  35820. * Get a list of materials by tags
  35821. * @param tagsQuery defines the tags query to use
  35822. * @param forEach defines a predicate used to filter results
  35823. * @returns an array of Material
  35824. */
  35825. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35826. /**
  35827. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35828. * This allowed control for front to back rendering or reversly depending of the special needs.
  35829. *
  35830. * @param renderingGroupId The rendering group id corresponding to its index
  35831. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35832. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35833. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35834. */
  35835. 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;
  35836. /**
  35837. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35838. *
  35839. * @param renderingGroupId The rendering group id corresponding to its index
  35840. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35841. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35842. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35843. */
  35844. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35845. /**
  35846. * Gets the current auto clear configuration for one rendering group of the rendering
  35847. * manager.
  35848. * @param index the rendering group index to get the information for
  35849. * @returns The auto clear setup for the requested rendering group
  35850. */
  35851. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35852. private _blockMaterialDirtyMechanism;
  35853. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35854. blockMaterialDirtyMechanism: boolean;
  35855. /**
  35856. * Will flag all materials as dirty to trigger new shader compilation
  35857. * @param flag defines the flag used to specify which material part must be marked as dirty
  35858. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35859. */
  35860. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35861. /** @hidden */
  35862. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  35863. /** @hidden */
  35864. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35865. /** @hidden */
  35866. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  35867. /** @hidden */
  35868. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  35869. /** @hidden */
  35870. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35871. /** @hidden */
  35872. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35873. }
  35874. }
  35875. declare module "babylonjs/assetContainer" {
  35876. import { AbstractScene } from "babylonjs/abstractScene";
  35877. import { Scene } from "babylonjs/scene";
  35878. import { Mesh } from "babylonjs/Meshes/mesh";
  35879. /**
  35880. * Set of assets to keep when moving a scene into an asset container.
  35881. */
  35882. export class KeepAssets extends AbstractScene {
  35883. }
  35884. /**
  35885. * Container with a set of assets that can be added or removed from a scene.
  35886. */
  35887. export class AssetContainer extends AbstractScene {
  35888. /**
  35889. * The scene the AssetContainer belongs to.
  35890. */
  35891. scene: Scene;
  35892. /**
  35893. * Instantiates an AssetContainer.
  35894. * @param scene The scene the AssetContainer belongs to.
  35895. */
  35896. constructor(scene: Scene);
  35897. /**
  35898. * Adds all the assets from the container to the scene.
  35899. */
  35900. addAllToScene(): void;
  35901. /**
  35902. * Removes all the assets in the container from the scene
  35903. */
  35904. removeAllFromScene(): void;
  35905. /**
  35906. * Disposes all the assets in the container
  35907. */
  35908. dispose(): void;
  35909. private _moveAssets;
  35910. /**
  35911. * Removes all the assets contained in the scene and adds them to the container.
  35912. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35913. */
  35914. moveAllFromScene(keepAssets?: KeepAssets): void;
  35915. /**
  35916. * 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.
  35917. * @returns the root mesh
  35918. */
  35919. createRootMesh(): Mesh;
  35920. }
  35921. }
  35922. declare module "babylonjs/abstractScene" {
  35923. import { Scene } from "babylonjs/scene";
  35924. import { Nullable } from "babylonjs/types";
  35925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35926. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35927. import { Geometry } from "babylonjs/Meshes/geometry";
  35928. import { Skeleton } from "babylonjs/Bones/skeleton";
  35929. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35930. import { AssetContainer } from "babylonjs/assetContainer";
  35931. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35932. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35934. import { Material } from "babylonjs/Materials/material";
  35935. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35936. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35937. import { Camera } from "babylonjs/Cameras/camera";
  35938. import { Light } from "babylonjs/Lights/light";
  35939. import { Node } from "babylonjs/node";
  35940. import { Animation } from "babylonjs/Animations/animation";
  35941. /**
  35942. * Defines how the parser contract is defined.
  35943. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35944. */
  35945. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35946. /**
  35947. * Defines how the individual parser contract is defined.
  35948. * These parser can parse an individual asset
  35949. */
  35950. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35951. /**
  35952. * Base class of the scene acting as a container for the different elements composing a scene.
  35953. * This class is dynamically extended by the different components of the scene increasing
  35954. * flexibility and reducing coupling
  35955. */
  35956. export abstract class AbstractScene {
  35957. /**
  35958. * Stores the list of available parsers in the application.
  35959. */
  35960. private static _BabylonFileParsers;
  35961. /**
  35962. * Stores the list of available individual parsers in the application.
  35963. */
  35964. private static _IndividualBabylonFileParsers;
  35965. /**
  35966. * Adds a parser in the list of available ones
  35967. * @param name Defines the name of the parser
  35968. * @param parser Defines the parser to add
  35969. */
  35970. static AddParser(name: string, parser: BabylonFileParser): void;
  35971. /**
  35972. * Gets a general parser from the list of avaialble ones
  35973. * @param name Defines the name of the parser
  35974. * @returns the requested parser or null
  35975. */
  35976. static GetParser(name: string): Nullable<BabylonFileParser>;
  35977. /**
  35978. * Adds n individual parser in the list of available ones
  35979. * @param name Defines the name of the parser
  35980. * @param parser Defines the parser to add
  35981. */
  35982. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35983. /**
  35984. * Gets an individual parser from the list of avaialble ones
  35985. * @param name Defines the name of the parser
  35986. * @returns the requested parser or null
  35987. */
  35988. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35989. /**
  35990. * Parser json data and populate both a scene and its associated container object
  35991. * @param jsonData Defines the data to parse
  35992. * @param scene Defines the scene to parse the data for
  35993. * @param container Defines the container attached to the parsing sequence
  35994. * @param rootUrl Defines the root url of the data
  35995. */
  35996. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35997. /**
  35998. * Gets the list of root nodes (ie. nodes with no parent)
  35999. */
  36000. rootNodes: Node[];
  36001. /** All of the cameras added to this scene
  36002. * @see http://doc.babylonjs.com/babylon101/cameras
  36003. */
  36004. cameras: Camera[];
  36005. /**
  36006. * All of the lights added to this scene
  36007. * @see http://doc.babylonjs.com/babylon101/lights
  36008. */
  36009. lights: Light[];
  36010. /**
  36011. * All of the (abstract) meshes added to this scene
  36012. */
  36013. meshes: AbstractMesh[];
  36014. /**
  36015. * The list of skeletons added to the scene
  36016. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36017. */
  36018. skeletons: Skeleton[];
  36019. /**
  36020. * All of the particle systems added to this scene
  36021. * @see http://doc.babylonjs.com/babylon101/particles
  36022. */
  36023. particleSystems: IParticleSystem[];
  36024. /**
  36025. * Gets a list of Animations associated with the scene
  36026. */
  36027. animations: Animation[];
  36028. /**
  36029. * All of the animation groups added to this scene
  36030. * @see http://doc.babylonjs.com/how_to/group
  36031. */
  36032. animationGroups: AnimationGroup[];
  36033. /**
  36034. * All of the multi-materials added to this scene
  36035. * @see http://doc.babylonjs.com/how_to/multi_materials
  36036. */
  36037. multiMaterials: MultiMaterial[];
  36038. /**
  36039. * All of the materials added to this scene
  36040. * In the context of a Scene, it is not supposed to be modified manually.
  36041. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  36042. * Note also that the order of the Material wihin the array is not significant and might change.
  36043. * @see http://doc.babylonjs.com/babylon101/materials
  36044. */
  36045. materials: Material[];
  36046. /**
  36047. * The list of morph target managers added to the scene
  36048. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36049. */
  36050. morphTargetManagers: MorphTargetManager[];
  36051. /**
  36052. * The list of geometries used in the scene.
  36053. */
  36054. geometries: Geometry[];
  36055. /**
  36056. * All of the tranform nodes added to this scene
  36057. * In the context of a Scene, it is not supposed to be modified manually.
  36058. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36059. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36060. * @see http://doc.babylonjs.com/how_to/transformnode
  36061. */
  36062. transformNodes: TransformNode[];
  36063. /**
  36064. * ActionManagers available on the scene.
  36065. */
  36066. actionManagers: AbstractActionManager[];
  36067. /**
  36068. * Textures to keep.
  36069. */
  36070. textures: BaseTexture[];
  36071. /**
  36072. * Environment texture for the scene
  36073. */
  36074. environmentTexture: Nullable<BaseTexture>;
  36075. }
  36076. }
  36077. declare module "babylonjs/Audio/sound" {
  36078. import { Observable } from "babylonjs/Misc/observable";
  36079. import { Vector3 } from "babylonjs/Maths/math.vector";
  36080. import { Nullable } from "babylonjs/types";
  36081. import { Scene } from "babylonjs/scene";
  36082. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36083. /**
  36084. * Interface used to define options for Sound class
  36085. */
  36086. export interface ISoundOptions {
  36087. /**
  36088. * Does the sound autoplay once loaded.
  36089. */
  36090. autoplay?: boolean;
  36091. /**
  36092. * Does the sound loop after it finishes playing once.
  36093. */
  36094. loop?: boolean;
  36095. /**
  36096. * Sound's volume
  36097. */
  36098. volume?: number;
  36099. /**
  36100. * Is it a spatial sound?
  36101. */
  36102. spatialSound?: boolean;
  36103. /**
  36104. * Maximum distance to hear that sound
  36105. */
  36106. maxDistance?: number;
  36107. /**
  36108. * Uses user defined attenuation function
  36109. */
  36110. useCustomAttenuation?: boolean;
  36111. /**
  36112. * Define the roll off factor of spatial sounds.
  36113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36114. */
  36115. rolloffFactor?: number;
  36116. /**
  36117. * Define the reference distance the sound should be heard perfectly.
  36118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36119. */
  36120. refDistance?: number;
  36121. /**
  36122. * Define the distance attenuation model the sound will follow.
  36123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36124. */
  36125. distanceModel?: string;
  36126. /**
  36127. * Defines the playback speed (1 by default)
  36128. */
  36129. playbackRate?: number;
  36130. /**
  36131. * Defines if the sound is from a streaming source
  36132. */
  36133. streaming?: boolean;
  36134. /**
  36135. * Defines an optional length (in seconds) inside the sound file
  36136. */
  36137. length?: number;
  36138. /**
  36139. * Defines an optional offset (in seconds) inside the sound file
  36140. */
  36141. offset?: number;
  36142. /**
  36143. * If true, URLs will not be required to state the audio file codec to use.
  36144. */
  36145. skipCodecCheck?: boolean;
  36146. }
  36147. /**
  36148. * Defines a sound that can be played in the application.
  36149. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36151. */
  36152. export class Sound {
  36153. /**
  36154. * The name of the sound in the scene.
  36155. */
  36156. name: string;
  36157. /**
  36158. * Does the sound autoplay once loaded.
  36159. */
  36160. autoplay: boolean;
  36161. /**
  36162. * Does the sound loop after it finishes playing once.
  36163. */
  36164. loop: boolean;
  36165. /**
  36166. * Does the sound use a custom attenuation curve to simulate the falloff
  36167. * happening when the source gets further away from the camera.
  36168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36169. */
  36170. useCustomAttenuation: boolean;
  36171. /**
  36172. * The sound track id this sound belongs to.
  36173. */
  36174. soundTrackId: number;
  36175. /**
  36176. * Is this sound currently played.
  36177. */
  36178. isPlaying: boolean;
  36179. /**
  36180. * Is this sound currently paused.
  36181. */
  36182. isPaused: boolean;
  36183. /**
  36184. * Does this sound enables spatial sound.
  36185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36186. */
  36187. spatialSound: boolean;
  36188. /**
  36189. * Define the reference distance the sound should be heard perfectly.
  36190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36191. */
  36192. refDistance: number;
  36193. /**
  36194. * Define the roll off factor of spatial sounds.
  36195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36196. */
  36197. rolloffFactor: number;
  36198. /**
  36199. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36201. */
  36202. maxDistance: number;
  36203. /**
  36204. * Define the distance attenuation model the sound will follow.
  36205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36206. */
  36207. distanceModel: string;
  36208. /**
  36209. * @hidden
  36210. * Back Compat
  36211. **/
  36212. onended: () => any;
  36213. /**
  36214. * Observable event when the current playing sound finishes.
  36215. */
  36216. onEndedObservable: Observable<Sound>;
  36217. private _panningModel;
  36218. private _playbackRate;
  36219. private _streaming;
  36220. private _startTime;
  36221. private _startOffset;
  36222. private _position;
  36223. /** @hidden */
  36224. _positionInEmitterSpace: boolean;
  36225. private _localDirection;
  36226. private _volume;
  36227. private _isReadyToPlay;
  36228. private _isDirectional;
  36229. private _readyToPlayCallback;
  36230. private _audioBuffer;
  36231. private _soundSource;
  36232. private _streamingSource;
  36233. private _soundPanner;
  36234. private _soundGain;
  36235. private _inputAudioNode;
  36236. private _outputAudioNode;
  36237. private _coneInnerAngle;
  36238. private _coneOuterAngle;
  36239. private _coneOuterGain;
  36240. private _scene;
  36241. private _connectedTransformNode;
  36242. private _customAttenuationFunction;
  36243. private _registerFunc;
  36244. private _isOutputConnected;
  36245. private _htmlAudioElement;
  36246. private _urlType;
  36247. private _length?;
  36248. private _offset?;
  36249. /** @hidden */
  36250. static _SceneComponentInitialization: (scene: Scene) => void;
  36251. /**
  36252. * Create a sound and attach it to a scene
  36253. * @param name Name of your sound
  36254. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36255. * @param scene defines the scene the sound belongs to
  36256. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36257. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36258. */
  36259. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36260. /**
  36261. * Release the sound and its associated resources
  36262. */
  36263. dispose(): void;
  36264. /**
  36265. * Gets if the sounds is ready to be played or not.
  36266. * @returns true if ready, otherwise false
  36267. */
  36268. isReady(): boolean;
  36269. private _soundLoaded;
  36270. /**
  36271. * Sets the data of the sound from an audiobuffer
  36272. * @param audioBuffer The audioBuffer containing the data
  36273. */
  36274. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36275. /**
  36276. * Updates the current sounds options such as maxdistance, loop...
  36277. * @param options A JSON object containing values named as the object properties
  36278. */
  36279. updateOptions(options: ISoundOptions): void;
  36280. private _createSpatialParameters;
  36281. private _updateSpatialParameters;
  36282. /**
  36283. * Switch the panning model to HRTF:
  36284. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36286. */
  36287. switchPanningModelToHRTF(): void;
  36288. /**
  36289. * Switch the panning model to Equal Power:
  36290. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36292. */
  36293. switchPanningModelToEqualPower(): void;
  36294. private _switchPanningModel;
  36295. /**
  36296. * Connect this sound to a sound track audio node like gain...
  36297. * @param soundTrackAudioNode the sound track audio node to connect to
  36298. */
  36299. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36300. /**
  36301. * Transform this sound into a directional source
  36302. * @param coneInnerAngle Size of the inner cone in degree
  36303. * @param coneOuterAngle Size of the outer cone in degree
  36304. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36305. */
  36306. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36307. /**
  36308. * Gets or sets the inner angle for the directional cone.
  36309. */
  36310. /**
  36311. * Gets or sets the inner angle for the directional cone.
  36312. */
  36313. directionalConeInnerAngle: number;
  36314. /**
  36315. * Gets or sets the outer angle for the directional cone.
  36316. */
  36317. /**
  36318. * Gets or sets the outer angle for the directional cone.
  36319. */
  36320. directionalConeOuterAngle: number;
  36321. /**
  36322. * Sets the position of the emitter if spatial sound is enabled
  36323. * @param newPosition Defines the new posisiton
  36324. */
  36325. setPosition(newPosition: Vector3): void;
  36326. /**
  36327. * Sets the local direction of the emitter if spatial sound is enabled
  36328. * @param newLocalDirection Defines the new local direction
  36329. */
  36330. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36331. private _updateDirection;
  36332. /** @hidden */
  36333. updateDistanceFromListener(): void;
  36334. /**
  36335. * Sets a new custom attenuation function for the sound.
  36336. * @param callback Defines the function used for the attenuation
  36337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36338. */
  36339. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36340. /**
  36341. * Play the sound
  36342. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36343. * @param offset (optional) Start the sound at a specific time in seconds
  36344. * @param length (optional) Sound duration (in seconds)
  36345. */
  36346. play(time?: number, offset?: number, length?: number): void;
  36347. private _onended;
  36348. /**
  36349. * Stop the sound
  36350. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36351. */
  36352. stop(time?: number): void;
  36353. /**
  36354. * Put the sound in pause
  36355. */
  36356. pause(): void;
  36357. /**
  36358. * Sets a dedicated volume for this sounds
  36359. * @param newVolume Define the new volume of the sound
  36360. * @param time Define time for gradual change to new volume
  36361. */
  36362. setVolume(newVolume: number, time?: number): void;
  36363. /**
  36364. * Set the sound play back rate
  36365. * @param newPlaybackRate Define the playback rate the sound should be played at
  36366. */
  36367. setPlaybackRate(newPlaybackRate: number): void;
  36368. /**
  36369. * Gets the volume of the sound.
  36370. * @returns the volume of the sound
  36371. */
  36372. getVolume(): number;
  36373. /**
  36374. * Attach the sound to a dedicated mesh
  36375. * @param transformNode The transform node to connect the sound with
  36376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36377. */
  36378. attachToMesh(transformNode: TransformNode): void;
  36379. /**
  36380. * Detach the sound from the previously attached mesh
  36381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36382. */
  36383. detachFromMesh(): void;
  36384. private _onRegisterAfterWorldMatrixUpdate;
  36385. /**
  36386. * Clone the current sound in the scene.
  36387. * @returns the new sound clone
  36388. */
  36389. clone(): Nullable<Sound>;
  36390. /**
  36391. * Gets the current underlying audio buffer containing the data
  36392. * @returns the audio buffer
  36393. */
  36394. getAudioBuffer(): Nullable<AudioBuffer>;
  36395. /**
  36396. * Serializes the Sound in a JSON representation
  36397. * @returns the JSON representation of the sound
  36398. */
  36399. serialize(): any;
  36400. /**
  36401. * Parse a JSON representation of a sound to innstantiate in a given scene
  36402. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36403. * @param scene Define the scene the new parsed sound should be created in
  36404. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36405. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36406. * @returns the newly parsed sound
  36407. */
  36408. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36409. }
  36410. }
  36411. declare module "babylonjs/Actions/directAudioActions" {
  36412. import { Action } from "babylonjs/Actions/action";
  36413. import { Condition } from "babylonjs/Actions/condition";
  36414. import { Sound } from "babylonjs/Audio/sound";
  36415. /**
  36416. * This defines an action helpful to play a defined sound on a triggered action.
  36417. */
  36418. export class PlaySoundAction extends Action {
  36419. private _sound;
  36420. /**
  36421. * Instantiate the action
  36422. * @param triggerOptions defines the trigger options
  36423. * @param sound defines the sound to play
  36424. * @param condition defines the trigger related conditions
  36425. */
  36426. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36427. /** @hidden */
  36428. _prepare(): void;
  36429. /**
  36430. * Execute the action and play the sound.
  36431. */
  36432. execute(): void;
  36433. /**
  36434. * Serializes the actions and its related information.
  36435. * @param parent defines the object to serialize in
  36436. * @returns the serialized object
  36437. */
  36438. serialize(parent: any): any;
  36439. }
  36440. /**
  36441. * This defines an action helpful to stop a defined sound on a triggered action.
  36442. */
  36443. export class StopSoundAction extends Action {
  36444. private _sound;
  36445. /**
  36446. * Instantiate the action
  36447. * @param triggerOptions defines the trigger options
  36448. * @param sound defines the sound to stop
  36449. * @param condition defines the trigger related conditions
  36450. */
  36451. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36452. /** @hidden */
  36453. _prepare(): void;
  36454. /**
  36455. * Execute the action and stop the sound.
  36456. */
  36457. execute(): void;
  36458. /**
  36459. * Serializes the actions and its related information.
  36460. * @param parent defines the object to serialize in
  36461. * @returns the serialized object
  36462. */
  36463. serialize(parent: any): any;
  36464. }
  36465. }
  36466. declare module "babylonjs/Actions/interpolateValueAction" {
  36467. import { Action } from "babylonjs/Actions/action";
  36468. import { Condition } from "babylonjs/Actions/condition";
  36469. import { Observable } from "babylonjs/Misc/observable";
  36470. /**
  36471. * This defines an action responsible to change the value of a property
  36472. * by interpolating between its current value and the newly set one once triggered.
  36473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36474. */
  36475. export class InterpolateValueAction extends Action {
  36476. /**
  36477. * Defines the path of the property where the value should be interpolated
  36478. */
  36479. propertyPath: string;
  36480. /**
  36481. * Defines the target value at the end of the interpolation.
  36482. */
  36483. value: any;
  36484. /**
  36485. * Defines the time it will take for the property to interpolate to the value.
  36486. */
  36487. duration: number;
  36488. /**
  36489. * Defines if the other scene animations should be stopped when the action has been triggered
  36490. */
  36491. stopOtherAnimations?: boolean;
  36492. /**
  36493. * Defines a callback raised once the interpolation animation has been done.
  36494. */
  36495. onInterpolationDone?: () => void;
  36496. /**
  36497. * Observable triggered once the interpolation animation has been done.
  36498. */
  36499. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36500. private _target;
  36501. private _effectiveTarget;
  36502. private _property;
  36503. /**
  36504. * Instantiate the action
  36505. * @param triggerOptions defines the trigger options
  36506. * @param target defines the object containing the value to interpolate
  36507. * @param propertyPath defines the path to the property in the target object
  36508. * @param value defines the target value at the end of the interpolation
  36509. * @param duration deines the time it will take for the property to interpolate to the value.
  36510. * @param condition defines the trigger related conditions
  36511. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36512. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36513. */
  36514. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36515. /** @hidden */
  36516. _prepare(): void;
  36517. /**
  36518. * Execute the action starts the value interpolation.
  36519. */
  36520. execute(): void;
  36521. /**
  36522. * Serializes the actions and its related information.
  36523. * @param parent defines the object to serialize in
  36524. * @returns the serialized object
  36525. */
  36526. serialize(parent: any): any;
  36527. }
  36528. }
  36529. declare module "babylonjs/Actions/index" {
  36530. export * from "babylonjs/Actions/abstractActionManager";
  36531. export * from "babylonjs/Actions/action";
  36532. export * from "babylonjs/Actions/actionEvent";
  36533. export * from "babylonjs/Actions/actionManager";
  36534. export * from "babylonjs/Actions/condition";
  36535. export * from "babylonjs/Actions/directActions";
  36536. export * from "babylonjs/Actions/directAudioActions";
  36537. export * from "babylonjs/Actions/interpolateValueAction";
  36538. }
  36539. declare module "babylonjs/Animations/index" {
  36540. export * from "babylonjs/Animations/animatable";
  36541. export * from "babylonjs/Animations/animation";
  36542. export * from "babylonjs/Animations/animationGroup";
  36543. export * from "babylonjs/Animations/animationPropertiesOverride";
  36544. export * from "babylonjs/Animations/easing";
  36545. export * from "babylonjs/Animations/runtimeAnimation";
  36546. export * from "babylonjs/Animations/animationEvent";
  36547. export * from "babylonjs/Animations/animationGroup";
  36548. export * from "babylonjs/Animations/animationKey";
  36549. export * from "babylonjs/Animations/animationRange";
  36550. export * from "babylonjs/Animations/animatable.interface";
  36551. }
  36552. declare module "babylonjs/Audio/soundTrack" {
  36553. import { Sound } from "babylonjs/Audio/sound";
  36554. import { Analyser } from "babylonjs/Audio/analyser";
  36555. import { Scene } from "babylonjs/scene";
  36556. /**
  36557. * Options allowed during the creation of a sound track.
  36558. */
  36559. export interface ISoundTrackOptions {
  36560. /**
  36561. * The volume the sound track should take during creation
  36562. */
  36563. volume?: number;
  36564. /**
  36565. * Define if the sound track is the main sound track of the scene
  36566. */
  36567. mainTrack?: boolean;
  36568. }
  36569. /**
  36570. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36571. * It will be also used in a future release to apply effects on a specific track.
  36572. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36573. */
  36574. export class SoundTrack {
  36575. /**
  36576. * The unique identifier of the sound track in the scene.
  36577. */
  36578. id: number;
  36579. /**
  36580. * The list of sounds included in the sound track.
  36581. */
  36582. soundCollection: Array<Sound>;
  36583. private _outputAudioNode;
  36584. private _scene;
  36585. private _isMainTrack;
  36586. private _connectedAnalyser;
  36587. private _options;
  36588. private _isInitialized;
  36589. /**
  36590. * Creates a new sound track.
  36591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36592. * @param scene Define the scene the sound track belongs to
  36593. * @param options
  36594. */
  36595. constructor(scene: Scene, options?: ISoundTrackOptions);
  36596. private _initializeSoundTrackAudioGraph;
  36597. /**
  36598. * Release the sound track and its associated resources
  36599. */
  36600. dispose(): void;
  36601. /**
  36602. * Adds a sound to this sound track
  36603. * @param sound define the cound to add
  36604. * @ignoreNaming
  36605. */
  36606. AddSound(sound: Sound): void;
  36607. /**
  36608. * Removes a sound to this sound track
  36609. * @param sound define the cound to remove
  36610. * @ignoreNaming
  36611. */
  36612. RemoveSound(sound: Sound): void;
  36613. /**
  36614. * Set a global volume for the full sound track.
  36615. * @param newVolume Define the new volume of the sound track
  36616. */
  36617. setVolume(newVolume: number): void;
  36618. /**
  36619. * Switch the panning model to HRTF:
  36620. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36622. */
  36623. switchPanningModelToHRTF(): void;
  36624. /**
  36625. * Switch the panning model to Equal Power:
  36626. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36628. */
  36629. switchPanningModelToEqualPower(): void;
  36630. /**
  36631. * Connect the sound track to an audio analyser allowing some amazing
  36632. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36634. * @param analyser The analyser to connect to the engine
  36635. */
  36636. connectToAnalyser(analyser: Analyser): void;
  36637. }
  36638. }
  36639. declare module "babylonjs/Audio/audioSceneComponent" {
  36640. import { Sound } from "babylonjs/Audio/sound";
  36641. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36642. import { Nullable } from "babylonjs/types";
  36643. import { Vector3 } from "babylonjs/Maths/math.vector";
  36644. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36645. import { Scene } from "babylonjs/scene";
  36646. import { AbstractScene } from "babylonjs/abstractScene";
  36647. import "babylonjs/Audio/audioEngine";
  36648. module "babylonjs/abstractScene" {
  36649. interface AbstractScene {
  36650. /**
  36651. * The list of sounds used in the scene.
  36652. */
  36653. sounds: Nullable<Array<Sound>>;
  36654. }
  36655. }
  36656. module "babylonjs/scene" {
  36657. interface Scene {
  36658. /**
  36659. * @hidden
  36660. * Backing field
  36661. */
  36662. _mainSoundTrack: SoundTrack;
  36663. /**
  36664. * The main sound track played by the scene.
  36665. * It cotains your primary collection of sounds.
  36666. */
  36667. mainSoundTrack: SoundTrack;
  36668. /**
  36669. * The list of sound tracks added to the scene
  36670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36671. */
  36672. soundTracks: Nullable<Array<SoundTrack>>;
  36673. /**
  36674. * Gets a sound using a given name
  36675. * @param name defines the name to search for
  36676. * @return the found sound or null if not found at all.
  36677. */
  36678. getSoundByName(name: string): Nullable<Sound>;
  36679. /**
  36680. * Gets or sets if audio support is enabled
  36681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36682. */
  36683. audioEnabled: boolean;
  36684. /**
  36685. * Gets or sets if audio will be output to headphones
  36686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36687. */
  36688. headphone: boolean;
  36689. /**
  36690. * Gets or sets custom audio listener position provider
  36691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36692. */
  36693. audioListenerPositionProvider: Nullable<() => Vector3>;
  36694. }
  36695. }
  36696. /**
  36697. * Defines the sound scene component responsible to manage any sounds
  36698. * in a given scene.
  36699. */
  36700. export class AudioSceneComponent implements ISceneSerializableComponent {
  36701. /**
  36702. * The component name helpfull to identify the component in the list of scene components.
  36703. */
  36704. readonly name: string;
  36705. /**
  36706. * The scene the component belongs to.
  36707. */
  36708. scene: Scene;
  36709. private _audioEnabled;
  36710. /**
  36711. * Gets whether audio is enabled or not.
  36712. * Please use related enable/disable method to switch state.
  36713. */
  36714. readonly audioEnabled: boolean;
  36715. private _headphone;
  36716. /**
  36717. * Gets whether audio is outputing to headphone or not.
  36718. * Please use the according Switch methods to change output.
  36719. */
  36720. readonly headphone: boolean;
  36721. private _audioListenerPositionProvider;
  36722. /**
  36723. * Gets the current audio listener position provider
  36724. */
  36725. /**
  36726. * Sets a custom listener position for all sounds in the scene
  36727. * By default, this is the position of the first active camera
  36728. */
  36729. audioListenerPositionProvider: Nullable<() => Vector3>;
  36730. /**
  36731. * Creates a new instance of the component for the given scene
  36732. * @param scene Defines the scene to register the component in
  36733. */
  36734. constructor(scene: Scene);
  36735. /**
  36736. * Registers the component in a given scene
  36737. */
  36738. register(): void;
  36739. /**
  36740. * Rebuilds the elements related to this component in case of
  36741. * context lost for instance.
  36742. */
  36743. rebuild(): void;
  36744. /**
  36745. * Serializes the component data to the specified json object
  36746. * @param serializationObject The object to serialize to
  36747. */
  36748. serialize(serializationObject: any): void;
  36749. /**
  36750. * Adds all the elements from the container to the scene
  36751. * @param container the container holding the elements
  36752. */
  36753. addFromContainer(container: AbstractScene): void;
  36754. /**
  36755. * Removes all the elements in the container from the scene
  36756. * @param container contains the elements to remove
  36757. * @param dispose if the removed element should be disposed (default: false)
  36758. */
  36759. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36760. /**
  36761. * Disposes the component and the associated ressources.
  36762. */
  36763. dispose(): void;
  36764. /**
  36765. * Disables audio in the associated scene.
  36766. */
  36767. disableAudio(): void;
  36768. /**
  36769. * Enables audio in the associated scene.
  36770. */
  36771. enableAudio(): void;
  36772. /**
  36773. * Switch audio to headphone output.
  36774. */
  36775. switchAudioModeForHeadphones(): void;
  36776. /**
  36777. * Switch audio to normal speakers.
  36778. */
  36779. switchAudioModeForNormalSpeakers(): void;
  36780. private _afterRender;
  36781. }
  36782. }
  36783. declare module "babylonjs/Audio/weightedsound" {
  36784. import { Sound } from "babylonjs/Audio/sound";
  36785. /**
  36786. * Wraps one or more Sound objects and selects one with random weight for playback.
  36787. */
  36788. export class WeightedSound {
  36789. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36790. loop: boolean;
  36791. private _coneInnerAngle;
  36792. private _coneOuterAngle;
  36793. private _volume;
  36794. /** A Sound is currently playing. */
  36795. isPlaying: boolean;
  36796. /** A Sound is currently paused. */
  36797. isPaused: boolean;
  36798. private _sounds;
  36799. private _weights;
  36800. private _currentIndex?;
  36801. /**
  36802. * Creates a new WeightedSound from the list of sounds given.
  36803. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36804. * @param sounds Array of Sounds that will be selected from.
  36805. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36806. */
  36807. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36808. /**
  36809. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36810. */
  36811. /**
  36812. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36813. */
  36814. directionalConeInnerAngle: number;
  36815. /**
  36816. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36817. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36818. */
  36819. /**
  36820. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36821. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36822. */
  36823. directionalConeOuterAngle: number;
  36824. /**
  36825. * Playback volume.
  36826. */
  36827. /**
  36828. * Playback volume.
  36829. */
  36830. volume: number;
  36831. private _onended;
  36832. /**
  36833. * Suspend playback
  36834. */
  36835. pause(): void;
  36836. /**
  36837. * Stop playback
  36838. */
  36839. stop(): void;
  36840. /**
  36841. * Start playback.
  36842. * @param startOffset Position the clip head at a specific time in seconds.
  36843. */
  36844. play(startOffset?: number): void;
  36845. }
  36846. }
  36847. declare module "babylonjs/Audio/index" {
  36848. export * from "babylonjs/Audio/analyser";
  36849. export * from "babylonjs/Audio/audioEngine";
  36850. export * from "babylonjs/Audio/audioSceneComponent";
  36851. export * from "babylonjs/Audio/sound";
  36852. export * from "babylonjs/Audio/soundTrack";
  36853. export * from "babylonjs/Audio/weightedsound";
  36854. }
  36855. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36856. import { Behavior } from "babylonjs/Behaviors/behavior";
  36857. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36858. import { BackEase } from "babylonjs/Animations/easing";
  36859. /**
  36860. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36861. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36862. */
  36863. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36864. /**
  36865. * Gets the name of the behavior.
  36866. */
  36867. readonly name: string;
  36868. /**
  36869. * The easing function used by animations
  36870. */
  36871. static EasingFunction: BackEase;
  36872. /**
  36873. * The easing mode used by animations
  36874. */
  36875. static EasingMode: number;
  36876. /**
  36877. * The duration of the animation, in milliseconds
  36878. */
  36879. transitionDuration: number;
  36880. /**
  36881. * Length of the distance animated by the transition when lower radius is reached
  36882. */
  36883. lowerRadiusTransitionRange: number;
  36884. /**
  36885. * Length of the distance animated by the transition when upper radius is reached
  36886. */
  36887. upperRadiusTransitionRange: number;
  36888. private _autoTransitionRange;
  36889. /**
  36890. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36891. */
  36892. /**
  36893. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36894. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36895. */
  36896. autoTransitionRange: boolean;
  36897. private _attachedCamera;
  36898. private _onAfterCheckInputsObserver;
  36899. private _onMeshTargetChangedObserver;
  36900. /**
  36901. * Initializes the behavior.
  36902. */
  36903. init(): void;
  36904. /**
  36905. * Attaches the behavior to its arc rotate camera.
  36906. * @param camera Defines the camera to attach the behavior to
  36907. */
  36908. attach(camera: ArcRotateCamera): void;
  36909. /**
  36910. * Detaches the behavior from its current arc rotate camera.
  36911. */
  36912. detach(): void;
  36913. private _radiusIsAnimating;
  36914. private _radiusBounceTransition;
  36915. private _animatables;
  36916. private _cachedWheelPrecision;
  36917. /**
  36918. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36919. * @param radiusLimit The limit to check against.
  36920. * @return Bool to indicate if at limit.
  36921. */
  36922. private _isRadiusAtLimit;
  36923. /**
  36924. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36925. * @param radiusDelta The delta by which to animate to. Can be negative.
  36926. */
  36927. private _applyBoundRadiusAnimation;
  36928. /**
  36929. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36930. */
  36931. protected _clearAnimationLocks(): void;
  36932. /**
  36933. * Stops and removes all animations that have been applied to the camera
  36934. */
  36935. stopAllAnimations(): void;
  36936. }
  36937. }
  36938. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36939. import { Behavior } from "babylonjs/Behaviors/behavior";
  36940. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36941. import { ExponentialEase } from "babylonjs/Animations/easing";
  36942. import { Nullable } from "babylonjs/types";
  36943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36944. import { Vector3 } from "babylonjs/Maths/math.vector";
  36945. /**
  36946. * 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.
  36947. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36948. */
  36949. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36950. /**
  36951. * Gets the name of the behavior.
  36952. */
  36953. readonly name: string;
  36954. private _mode;
  36955. private _radiusScale;
  36956. private _positionScale;
  36957. private _defaultElevation;
  36958. private _elevationReturnTime;
  36959. private _elevationReturnWaitTime;
  36960. private _zoomStopsAnimation;
  36961. private _framingTime;
  36962. /**
  36963. * The easing function used by animations
  36964. */
  36965. static EasingFunction: ExponentialEase;
  36966. /**
  36967. * The easing mode used by animations
  36968. */
  36969. static EasingMode: number;
  36970. /**
  36971. * Sets the current mode used by the behavior
  36972. */
  36973. /**
  36974. * Gets current mode used by the behavior.
  36975. */
  36976. mode: number;
  36977. /**
  36978. * Sets the scale applied to the radius (1 by default)
  36979. */
  36980. /**
  36981. * Gets the scale applied to the radius
  36982. */
  36983. radiusScale: number;
  36984. /**
  36985. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36986. */
  36987. /**
  36988. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36989. */
  36990. positionScale: number;
  36991. /**
  36992. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36993. * behaviour is triggered, in radians.
  36994. */
  36995. /**
  36996. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36997. * behaviour is triggered, in radians.
  36998. */
  36999. defaultElevation: number;
  37000. /**
  37001. * Sets the time (in milliseconds) taken to return to the default beta position.
  37002. * Negative value indicates camera should not return to default.
  37003. */
  37004. /**
  37005. * Gets the time (in milliseconds) taken to return to the default beta position.
  37006. * Negative value indicates camera should not return to default.
  37007. */
  37008. elevationReturnTime: number;
  37009. /**
  37010. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37011. */
  37012. /**
  37013. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37014. */
  37015. elevationReturnWaitTime: number;
  37016. /**
  37017. * Sets the flag that indicates if user zooming should stop animation.
  37018. */
  37019. /**
  37020. * Gets the flag that indicates if user zooming should stop animation.
  37021. */
  37022. zoomStopsAnimation: boolean;
  37023. /**
  37024. * Sets the transition time when framing the mesh, in milliseconds
  37025. */
  37026. /**
  37027. * Gets the transition time when framing the mesh, in milliseconds
  37028. */
  37029. framingTime: number;
  37030. /**
  37031. * Define if the behavior should automatically change the configured
  37032. * camera limits and sensibilities.
  37033. */
  37034. autoCorrectCameraLimitsAndSensibility: boolean;
  37035. private _onPrePointerObservableObserver;
  37036. private _onAfterCheckInputsObserver;
  37037. private _onMeshTargetChangedObserver;
  37038. private _attachedCamera;
  37039. private _isPointerDown;
  37040. private _lastInteractionTime;
  37041. /**
  37042. * Initializes the behavior.
  37043. */
  37044. init(): void;
  37045. /**
  37046. * Attaches the behavior to its arc rotate camera.
  37047. * @param camera Defines the camera to attach the behavior to
  37048. */
  37049. attach(camera: ArcRotateCamera): void;
  37050. /**
  37051. * Detaches the behavior from its current arc rotate camera.
  37052. */
  37053. detach(): void;
  37054. private _animatables;
  37055. private _betaIsAnimating;
  37056. private _betaTransition;
  37057. private _radiusTransition;
  37058. private _vectorTransition;
  37059. /**
  37060. * Targets the given mesh and updates zoom level accordingly.
  37061. * @param mesh The mesh to target.
  37062. * @param radius Optional. If a cached radius position already exists, overrides default.
  37063. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37064. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37065. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37066. */
  37067. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37068. /**
  37069. * Targets the given mesh with its children and updates zoom level accordingly.
  37070. * @param mesh The mesh to target.
  37071. * @param radius Optional. If a cached radius position already exists, overrides default.
  37072. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37073. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37074. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37075. */
  37076. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37077. /**
  37078. * Targets the given meshes with their children and updates zoom level accordingly.
  37079. * @param meshes The mesh to target.
  37080. * @param radius Optional. If a cached radius position already exists, overrides default.
  37081. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37082. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37083. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37084. */
  37085. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37086. /**
  37087. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37088. * @param minimumWorld Determines the smaller position of the bounding box extend
  37089. * @param maximumWorld Determines the bigger position of the bounding box extend
  37090. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37091. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37092. */
  37093. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37094. /**
  37095. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37096. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37097. * frustum width.
  37098. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37099. * to fully enclose the mesh in the viewing frustum.
  37100. */
  37101. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37102. /**
  37103. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37104. * is automatically returned to its default position (expected to be above ground plane).
  37105. */
  37106. private _maintainCameraAboveGround;
  37107. /**
  37108. * Returns the frustum slope based on the canvas ratio and camera FOV
  37109. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37110. */
  37111. private _getFrustumSlope;
  37112. /**
  37113. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37114. */
  37115. private _clearAnimationLocks;
  37116. /**
  37117. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37118. */
  37119. private _applyUserInteraction;
  37120. /**
  37121. * Stops and removes all animations that have been applied to the camera
  37122. */
  37123. stopAllAnimations(): void;
  37124. /**
  37125. * Gets a value indicating if the user is moving the camera
  37126. */
  37127. readonly isUserIsMoving: boolean;
  37128. /**
  37129. * The camera can move all the way towards the mesh.
  37130. */
  37131. static IgnoreBoundsSizeMode: number;
  37132. /**
  37133. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37134. */
  37135. static FitFrustumSidesMode: number;
  37136. }
  37137. }
  37138. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37139. import { Nullable } from "babylonjs/types";
  37140. import { Camera } from "babylonjs/Cameras/camera";
  37141. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37142. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37143. /**
  37144. * Base class for Camera Pointer Inputs.
  37145. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37146. * for example usage.
  37147. */
  37148. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37149. /**
  37150. * Defines the camera the input is attached to.
  37151. */
  37152. abstract camera: Camera;
  37153. /**
  37154. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37155. */
  37156. protected _altKey: boolean;
  37157. protected _ctrlKey: boolean;
  37158. protected _metaKey: boolean;
  37159. protected _shiftKey: boolean;
  37160. /**
  37161. * Which mouse buttons were pressed at time of last mouse event.
  37162. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37163. */
  37164. protected _buttonsPressed: number;
  37165. /**
  37166. * Defines the buttons associated with the input to handle camera move.
  37167. */
  37168. buttons: number[];
  37169. /**
  37170. * Attach the input controls to a specific dom element to get the input from.
  37171. * @param element Defines the element the controls should be listened from
  37172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37173. */
  37174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37175. /**
  37176. * Detach the current controls from the specified dom element.
  37177. * @param element Defines the element to stop listening the inputs from
  37178. */
  37179. detachControl(element: Nullable<HTMLElement>): void;
  37180. /**
  37181. * Gets the class name of the current input.
  37182. * @returns the class name
  37183. */
  37184. getClassName(): string;
  37185. /**
  37186. * Get the friendly name associated with the input class.
  37187. * @returns the input friendly name
  37188. */
  37189. getSimpleName(): string;
  37190. /**
  37191. * Called on pointer POINTERDOUBLETAP event.
  37192. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37193. */
  37194. protected onDoubleTap(type: string): void;
  37195. /**
  37196. * Called on pointer POINTERMOVE event if only a single touch is active.
  37197. * Override this method to provide functionality.
  37198. */
  37199. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37200. /**
  37201. * Called on pointer POINTERMOVE event if multiple touches are active.
  37202. * Override this method to provide functionality.
  37203. */
  37204. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37205. /**
  37206. * Called on JS contextmenu event.
  37207. * Override this method to provide functionality.
  37208. */
  37209. protected onContextMenu(evt: PointerEvent): void;
  37210. /**
  37211. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37212. * press.
  37213. * Override this method to provide functionality.
  37214. */
  37215. protected onButtonDown(evt: PointerEvent): void;
  37216. /**
  37217. * Called each time a new POINTERUP event occurs. Ie, for each button
  37218. * release.
  37219. * Override this method to provide functionality.
  37220. */
  37221. protected onButtonUp(evt: PointerEvent): void;
  37222. /**
  37223. * Called when window becomes inactive.
  37224. * Override this method to provide functionality.
  37225. */
  37226. protected onLostFocus(): void;
  37227. private _pointerInput;
  37228. private _observer;
  37229. private _onLostFocus;
  37230. private pointA;
  37231. private pointB;
  37232. }
  37233. }
  37234. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37235. import { Nullable } from "babylonjs/types";
  37236. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37237. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37238. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37239. /**
  37240. * Manage the pointers inputs to control an arc rotate camera.
  37241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37242. */
  37243. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37244. /**
  37245. * Defines the camera the input is attached to.
  37246. */
  37247. camera: ArcRotateCamera;
  37248. /**
  37249. * Gets the class name of the current input.
  37250. * @returns the class name
  37251. */
  37252. getClassName(): string;
  37253. /**
  37254. * Defines the buttons associated with the input to handle camera move.
  37255. */
  37256. buttons: number[];
  37257. /**
  37258. * Defines the pointer angular sensibility along the X axis or how fast is
  37259. * the camera rotating.
  37260. */
  37261. angularSensibilityX: number;
  37262. /**
  37263. * Defines the pointer angular sensibility along the Y axis or how fast is
  37264. * the camera rotating.
  37265. */
  37266. angularSensibilityY: number;
  37267. /**
  37268. * Defines the pointer pinch precision or how fast is the camera zooming.
  37269. */
  37270. pinchPrecision: number;
  37271. /**
  37272. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37273. * from 0.
  37274. * It defines the percentage of current camera.radius to use as delta when
  37275. * pinch zoom is used.
  37276. */
  37277. pinchDeltaPercentage: number;
  37278. /**
  37279. * Defines the pointer panning sensibility or how fast is the camera moving.
  37280. */
  37281. panningSensibility: number;
  37282. /**
  37283. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37284. */
  37285. multiTouchPanning: boolean;
  37286. /**
  37287. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37288. * zoom (pinch) through multitouch.
  37289. */
  37290. multiTouchPanAndZoom: boolean;
  37291. /**
  37292. * Revers pinch action direction.
  37293. */
  37294. pinchInwards: boolean;
  37295. private _isPanClick;
  37296. private _twoFingerActivityCount;
  37297. private _isPinching;
  37298. /**
  37299. * Called on pointer POINTERMOVE event if only a single touch is active.
  37300. */
  37301. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37302. /**
  37303. * Called on pointer POINTERDOUBLETAP event.
  37304. */
  37305. protected onDoubleTap(type: string): void;
  37306. /**
  37307. * Called on pointer POINTERMOVE event if multiple touches are active.
  37308. */
  37309. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37310. /**
  37311. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37312. * press.
  37313. */
  37314. protected onButtonDown(evt: PointerEvent): void;
  37315. /**
  37316. * Called each time a new POINTERUP event occurs. Ie, for each button
  37317. * release.
  37318. */
  37319. protected onButtonUp(evt: PointerEvent): void;
  37320. /**
  37321. * Called when window becomes inactive.
  37322. */
  37323. protected onLostFocus(): void;
  37324. }
  37325. }
  37326. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37327. import { Nullable } from "babylonjs/types";
  37328. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37329. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37330. /**
  37331. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37333. */
  37334. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37335. /**
  37336. * Defines the camera the input is attached to.
  37337. */
  37338. camera: ArcRotateCamera;
  37339. /**
  37340. * Defines the list of key codes associated with the up action (increase alpha)
  37341. */
  37342. keysUp: number[];
  37343. /**
  37344. * Defines the list of key codes associated with the down action (decrease alpha)
  37345. */
  37346. keysDown: number[];
  37347. /**
  37348. * Defines the list of key codes associated with the left action (increase beta)
  37349. */
  37350. keysLeft: number[];
  37351. /**
  37352. * Defines the list of key codes associated with the right action (decrease beta)
  37353. */
  37354. keysRight: number[];
  37355. /**
  37356. * Defines the list of key codes associated with the reset action.
  37357. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37358. */
  37359. keysReset: number[];
  37360. /**
  37361. * Defines the panning sensibility of the inputs.
  37362. * (How fast is the camera paning)
  37363. */
  37364. panningSensibility: number;
  37365. /**
  37366. * Defines the zooming sensibility of the inputs.
  37367. * (How fast is the camera zooming)
  37368. */
  37369. zoomingSensibility: number;
  37370. /**
  37371. * Defines wether maintaining the alt key down switch the movement mode from
  37372. * orientation to zoom.
  37373. */
  37374. useAltToZoom: boolean;
  37375. /**
  37376. * Rotation speed of the camera
  37377. */
  37378. angularSpeed: number;
  37379. private _keys;
  37380. private _ctrlPressed;
  37381. private _altPressed;
  37382. private _onCanvasBlurObserver;
  37383. private _onKeyboardObserver;
  37384. private _engine;
  37385. private _scene;
  37386. /**
  37387. * Attach the input controls to a specific dom element to get the input from.
  37388. * @param element Defines the element the controls should be listened from
  37389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37390. */
  37391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37392. /**
  37393. * Detach the current controls from the specified dom element.
  37394. * @param element Defines the element to stop listening the inputs from
  37395. */
  37396. detachControl(element: Nullable<HTMLElement>): void;
  37397. /**
  37398. * Update the current camera state depending on the inputs that have been used this frame.
  37399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37400. */
  37401. checkInputs(): void;
  37402. /**
  37403. * Gets the class name of the current intput.
  37404. * @returns the class name
  37405. */
  37406. getClassName(): string;
  37407. /**
  37408. * Get the friendly name associated with the input class.
  37409. * @returns the input friendly name
  37410. */
  37411. getSimpleName(): string;
  37412. }
  37413. }
  37414. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37415. import { Nullable } from "babylonjs/types";
  37416. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37417. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37418. /**
  37419. * Manage the mouse wheel inputs to control an arc rotate camera.
  37420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37421. */
  37422. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37423. /**
  37424. * Defines the camera the input is attached to.
  37425. */
  37426. camera: ArcRotateCamera;
  37427. /**
  37428. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37429. */
  37430. wheelPrecision: number;
  37431. /**
  37432. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37433. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37434. */
  37435. wheelDeltaPercentage: number;
  37436. private _wheel;
  37437. private _observer;
  37438. private computeDeltaFromMouseWheelLegacyEvent;
  37439. /**
  37440. * Attach the input controls to a specific dom element to get the input from.
  37441. * @param element Defines the element the controls should be listened from
  37442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37443. */
  37444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37445. /**
  37446. * Detach the current controls from the specified dom element.
  37447. * @param element Defines the element to stop listening the inputs from
  37448. */
  37449. detachControl(element: Nullable<HTMLElement>): void;
  37450. /**
  37451. * Gets the class name of the current intput.
  37452. * @returns the class name
  37453. */
  37454. getClassName(): string;
  37455. /**
  37456. * Get the friendly name associated with the input class.
  37457. * @returns the input friendly name
  37458. */
  37459. getSimpleName(): string;
  37460. }
  37461. }
  37462. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37463. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37464. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37465. /**
  37466. * Default Inputs manager for the ArcRotateCamera.
  37467. * It groups all the default supported inputs for ease of use.
  37468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37469. */
  37470. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37471. /**
  37472. * Instantiates a new ArcRotateCameraInputsManager.
  37473. * @param camera Defines the camera the inputs belong to
  37474. */
  37475. constructor(camera: ArcRotateCamera);
  37476. /**
  37477. * Add mouse wheel input support to the input manager.
  37478. * @returns the current input manager
  37479. */
  37480. addMouseWheel(): ArcRotateCameraInputsManager;
  37481. /**
  37482. * Add pointers input support to the input manager.
  37483. * @returns the current input manager
  37484. */
  37485. addPointers(): ArcRotateCameraInputsManager;
  37486. /**
  37487. * Add keyboard input support to the input manager.
  37488. * @returns the current input manager
  37489. */
  37490. addKeyboard(): ArcRotateCameraInputsManager;
  37491. }
  37492. }
  37493. declare module "babylonjs/Cameras/arcRotateCamera" {
  37494. import { Observable } from "babylonjs/Misc/observable";
  37495. import { Nullable } from "babylonjs/types";
  37496. import { Scene } from "babylonjs/scene";
  37497. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37499. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37500. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37501. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37502. import { Camera } from "babylonjs/Cameras/camera";
  37503. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37504. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37505. import { Collider } from "babylonjs/Collisions/collider";
  37506. /**
  37507. * This represents an orbital type of camera.
  37508. *
  37509. * 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.
  37510. * 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.
  37511. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37512. */
  37513. export class ArcRotateCamera extends TargetCamera {
  37514. /**
  37515. * Defines the rotation angle of the camera along the longitudinal axis.
  37516. */
  37517. alpha: number;
  37518. /**
  37519. * Defines the rotation angle of the camera along the latitudinal axis.
  37520. */
  37521. beta: number;
  37522. /**
  37523. * Defines the radius of the camera from it s target point.
  37524. */
  37525. radius: number;
  37526. protected _target: Vector3;
  37527. protected _targetHost: Nullable<AbstractMesh>;
  37528. /**
  37529. * Defines the target point of the camera.
  37530. * The camera looks towards it form the radius distance.
  37531. */
  37532. target: Vector3;
  37533. /**
  37534. * Define the current local position of the camera in the scene
  37535. */
  37536. position: Vector3;
  37537. protected _upVector: Vector3;
  37538. protected _upToYMatrix: Matrix;
  37539. protected _YToUpMatrix: Matrix;
  37540. /**
  37541. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37542. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37543. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37544. */
  37545. upVector: Vector3;
  37546. /**
  37547. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37548. */
  37549. setMatUp(): void;
  37550. /**
  37551. * Current inertia value on the longitudinal axis.
  37552. * The bigger this number the longer it will take for the camera to stop.
  37553. */
  37554. inertialAlphaOffset: number;
  37555. /**
  37556. * Current inertia value on the latitudinal axis.
  37557. * The bigger this number the longer it will take for the camera to stop.
  37558. */
  37559. inertialBetaOffset: number;
  37560. /**
  37561. * Current inertia value on the radius axis.
  37562. * The bigger this number the longer it will take for the camera to stop.
  37563. */
  37564. inertialRadiusOffset: number;
  37565. /**
  37566. * Minimum allowed angle on the longitudinal axis.
  37567. * This can help limiting how the Camera is able to move in the scene.
  37568. */
  37569. lowerAlphaLimit: Nullable<number>;
  37570. /**
  37571. * Maximum allowed angle on the longitudinal axis.
  37572. * This can help limiting how the Camera is able to move in the scene.
  37573. */
  37574. upperAlphaLimit: Nullable<number>;
  37575. /**
  37576. * Minimum allowed angle on the latitudinal axis.
  37577. * This can help limiting how the Camera is able to move in the scene.
  37578. */
  37579. lowerBetaLimit: number;
  37580. /**
  37581. * Maximum allowed angle on the latitudinal axis.
  37582. * This can help limiting how the Camera is able to move in the scene.
  37583. */
  37584. upperBetaLimit: number;
  37585. /**
  37586. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37587. * This can help limiting how the Camera is able to move in the scene.
  37588. */
  37589. lowerRadiusLimit: Nullable<number>;
  37590. /**
  37591. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37592. * This can help limiting how the Camera is able to move in the scene.
  37593. */
  37594. upperRadiusLimit: Nullable<number>;
  37595. /**
  37596. * Defines the current inertia value used during panning of the camera along the X axis.
  37597. */
  37598. inertialPanningX: number;
  37599. /**
  37600. * Defines the current inertia value used during panning of the camera along the Y axis.
  37601. */
  37602. inertialPanningY: number;
  37603. /**
  37604. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37605. * Basically if your fingers moves away from more than this distance you will be considered
  37606. * in pinch mode.
  37607. */
  37608. pinchToPanMaxDistance: number;
  37609. /**
  37610. * Defines the maximum distance the camera can pan.
  37611. * This could help keeping the cammera always in your scene.
  37612. */
  37613. panningDistanceLimit: Nullable<number>;
  37614. /**
  37615. * Defines the target of the camera before paning.
  37616. */
  37617. panningOriginTarget: Vector3;
  37618. /**
  37619. * Defines the value of the inertia used during panning.
  37620. * 0 would mean stop inertia and one would mean no decelleration at all.
  37621. */
  37622. panningInertia: number;
  37623. /**
  37624. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37625. */
  37626. angularSensibilityX: number;
  37627. /**
  37628. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37629. */
  37630. angularSensibilityY: number;
  37631. /**
  37632. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37633. */
  37634. pinchPrecision: number;
  37635. /**
  37636. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37637. * It will be used instead of pinchDeltaPrecision if different from 0.
  37638. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37639. */
  37640. pinchDeltaPercentage: number;
  37641. /**
  37642. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37643. */
  37644. panningSensibility: number;
  37645. /**
  37646. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37647. */
  37648. keysUp: number[];
  37649. /**
  37650. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37651. */
  37652. keysDown: number[];
  37653. /**
  37654. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37655. */
  37656. keysLeft: number[];
  37657. /**
  37658. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37659. */
  37660. keysRight: number[];
  37661. /**
  37662. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37663. */
  37664. wheelPrecision: number;
  37665. /**
  37666. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37667. * It will be used instead of pinchDeltaPrecision if different from 0.
  37668. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37669. */
  37670. wheelDeltaPercentage: number;
  37671. /**
  37672. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37673. */
  37674. zoomOnFactor: number;
  37675. /**
  37676. * Defines a screen offset for the camera position.
  37677. */
  37678. targetScreenOffset: Vector2;
  37679. /**
  37680. * Allows the camera to be completely reversed.
  37681. * If false the camera can not arrive upside down.
  37682. */
  37683. allowUpsideDown: boolean;
  37684. /**
  37685. * Define if double tap/click is used to restore the previously saved state of the camera.
  37686. */
  37687. useInputToRestoreState: boolean;
  37688. /** @hidden */
  37689. _viewMatrix: Matrix;
  37690. /** @hidden */
  37691. _useCtrlForPanning: boolean;
  37692. /** @hidden */
  37693. _panningMouseButton: number;
  37694. /**
  37695. * Defines the input associated to the camera.
  37696. */
  37697. inputs: ArcRotateCameraInputsManager;
  37698. /** @hidden */
  37699. _reset: () => void;
  37700. /**
  37701. * Defines the allowed panning axis.
  37702. */
  37703. panningAxis: Vector3;
  37704. protected _localDirection: Vector3;
  37705. protected _transformedDirection: Vector3;
  37706. private _bouncingBehavior;
  37707. /**
  37708. * Gets the bouncing behavior of the camera if it has been enabled.
  37709. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37710. */
  37711. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37712. /**
  37713. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37714. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37715. */
  37716. useBouncingBehavior: boolean;
  37717. private _framingBehavior;
  37718. /**
  37719. * Gets the framing behavior of the camera if it has been enabled.
  37720. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37721. */
  37722. readonly framingBehavior: Nullable<FramingBehavior>;
  37723. /**
  37724. * Defines if the framing behavior of the camera is enabled on the camera.
  37725. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37726. */
  37727. useFramingBehavior: boolean;
  37728. private _autoRotationBehavior;
  37729. /**
  37730. * Gets the auto rotation behavior of the camera if it has been enabled.
  37731. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37732. */
  37733. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37734. /**
  37735. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37737. */
  37738. useAutoRotationBehavior: boolean;
  37739. /**
  37740. * Observable triggered when the mesh target has been changed on the camera.
  37741. */
  37742. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37743. /**
  37744. * Event raised when the camera is colliding with a mesh.
  37745. */
  37746. onCollide: (collidedMesh: AbstractMesh) => void;
  37747. /**
  37748. * Defines whether the camera should check collision with the objects oh the scene.
  37749. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37750. */
  37751. checkCollisions: boolean;
  37752. /**
  37753. * Defines the collision radius of the camera.
  37754. * This simulates a sphere around the camera.
  37755. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37756. */
  37757. collisionRadius: Vector3;
  37758. protected _collider: Collider;
  37759. protected _previousPosition: Vector3;
  37760. protected _collisionVelocity: Vector3;
  37761. protected _newPosition: Vector3;
  37762. protected _previousAlpha: number;
  37763. protected _previousBeta: number;
  37764. protected _previousRadius: number;
  37765. protected _collisionTriggered: boolean;
  37766. protected _targetBoundingCenter: Nullable<Vector3>;
  37767. private _computationVector;
  37768. /**
  37769. * Instantiates a new ArcRotateCamera in a given scene
  37770. * @param name Defines the name of the camera
  37771. * @param alpha Defines the camera rotation along the logitudinal axis
  37772. * @param beta Defines the camera rotation along the latitudinal axis
  37773. * @param radius Defines the camera distance from its target
  37774. * @param target Defines the camera target
  37775. * @param scene Defines the scene the camera belongs to
  37776. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37777. */
  37778. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37779. /** @hidden */
  37780. _initCache(): void;
  37781. /** @hidden */
  37782. _updateCache(ignoreParentClass?: boolean): void;
  37783. protected _getTargetPosition(): Vector3;
  37784. private _storedAlpha;
  37785. private _storedBeta;
  37786. private _storedRadius;
  37787. private _storedTarget;
  37788. private _storedTargetScreenOffset;
  37789. /**
  37790. * Stores the current state of the camera (alpha, beta, radius and target)
  37791. * @returns the camera itself
  37792. */
  37793. storeState(): Camera;
  37794. /**
  37795. * @hidden
  37796. * Restored camera state. You must call storeState() first
  37797. */
  37798. _restoreStateValues(): boolean;
  37799. /** @hidden */
  37800. _isSynchronizedViewMatrix(): boolean;
  37801. /**
  37802. * Attached controls to the current camera.
  37803. * @param element Defines the element the controls should be listened from
  37804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37805. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37806. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37807. */
  37808. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37809. /**
  37810. * Detach the current controls from the camera.
  37811. * The camera will stop reacting to inputs.
  37812. * @param element Defines the element to stop listening the inputs from
  37813. */
  37814. detachControl(element: HTMLElement): void;
  37815. /** @hidden */
  37816. _checkInputs(): void;
  37817. protected _checkLimits(): void;
  37818. /**
  37819. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37820. */
  37821. rebuildAnglesAndRadius(): void;
  37822. /**
  37823. * Use a position to define the current camera related information like alpha, beta and radius
  37824. * @param position Defines the position to set the camera at
  37825. */
  37826. setPosition(position: Vector3): void;
  37827. /**
  37828. * Defines the target the camera should look at.
  37829. * This will automatically adapt alpha beta and radius to fit within the new target.
  37830. * @param target Defines the new target as a Vector or a mesh
  37831. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37832. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37833. */
  37834. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37835. /** @hidden */
  37836. _getViewMatrix(): Matrix;
  37837. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37838. /**
  37839. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37840. * @param meshes Defines the mesh to zoom on
  37841. * @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)
  37842. */
  37843. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37844. /**
  37845. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37846. * The target will be changed but the radius
  37847. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37848. * @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)
  37849. */
  37850. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37851. min: Vector3;
  37852. max: Vector3;
  37853. distance: number;
  37854. }, doNotUpdateMaxZ?: boolean): void;
  37855. /**
  37856. * @override
  37857. * Override Camera.createRigCamera
  37858. */
  37859. createRigCamera(name: string, cameraIndex: number): Camera;
  37860. /**
  37861. * @hidden
  37862. * @override
  37863. * Override Camera._updateRigCameras
  37864. */
  37865. _updateRigCameras(): void;
  37866. /**
  37867. * Destroy the camera and release the current resources hold by it.
  37868. */
  37869. dispose(): void;
  37870. /**
  37871. * Gets the current object class name.
  37872. * @return the class name
  37873. */
  37874. getClassName(): string;
  37875. }
  37876. }
  37877. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37878. import { Behavior } from "babylonjs/Behaviors/behavior";
  37879. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37880. /**
  37881. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37882. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37883. */
  37884. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37885. /**
  37886. * Gets the name of the behavior.
  37887. */
  37888. readonly name: string;
  37889. private _zoomStopsAnimation;
  37890. private _idleRotationSpeed;
  37891. private _idleRotationWaitTime;
  37892. private _idleRotationSpinupTime;
  37893. /**
  37894. * Sets the flag that indicates if user zooming should stop animation.
  37895. */
  37896. /**
  37897. * Gets the flag that indicates if user zooming should stop animation.
  37898. */
  37899. zoomStopsAnimation: boolean;
  37900. /**
  37901. * Sets the default speed at which the camera rotates around the model.
  37902. */
  37903. /**
  37904. * Gets the default speed at which the camera rotates around the model.
  37905. */
  37906. idleRotationSpeed: number;
  37907. /**
  37908. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37909. */
  37910. /**
  37911. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37912. */
  37913. idleRotationWaitTime: number;
  37914. /**
  37915. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37916. */
  37917. /**
  37918. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37919. */
  37920. idleRotationSpinupTime: number;
  37921. /**
  37922. * Gets a value indicating if the camera is currently rotating because of this behavior
  37923. */
  37924. readonly rotationInProgress: boolean;
  37925. private _onPrePointerObservableObserver;
  37926. private _onAfterCheckInputsObserver;
  37927. private _attachedCamera;
  37928. private _isPointerDown;
  37929. private _lastFrameTime;
  37930. private _lastInteractionTime;
  37931. private _cameraRotationSpeed;
  37932. /**
  37933. * Initializes the behavior.
  37934. */
  37935. init(): void;
  37936. /**
  37937. * Attaches the behavior to its arc rotate camera.
  37938. * @param camera Defines the camera to attach the behavior to
  37939. */
  37940. attach(camera: ArcRotateCamera): void;
  37941. /**
  37942. * Detaches the behavior from its current arc rotate camera.
  37943. */
  37944. detach(): void;
  37945. /**
  37946. * Returns true if user is scrolling.
  37947. * @return true if user is scrolling.
  37948. */
  37949. private _userIsZooming;
  37950. private _lastFrameRadius;
  37951. private _shouldAnimationStopForInteraction;
  37952. /**
  37953. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37954. */
  37955. private _applyUserInteraction;
  37956. private _userIsMoving;
  37957. }
  37958. }
  37959. declare module "babylonjs/Behaviors/Cameras/index" {
  37960. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37961. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37962. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37963. }
  37964. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37965. import { Mesh } from "babylonjs/Meshes/mesh";
  37966. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37967. import { Behavior } from "babylonjs/Behaviors/behavior";
  37968. /**
  37969. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37970. */
  37971. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37972. private ui;
  37973. /**
  37974. * The name of the behavior
  37975. */
  37976. name: string;
  37977. /**
  37978. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37979. */
  37980. distanceAwayFromFace: number;
  37981. /**
  37982. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37983. */
  37984. distanceAwayFromBottomOfFace: number;
  37985. private _faceVectors;
  37986. private _target;
  37987. private _scene;
  37988. private _onRenderObserver;
  37989. private _tmpMatrix;
  37990. private _tmpVector;
  37991. /**
  37992. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37993. * @param ui The transform node that should be attched to the mesh
  37994. */
  37995. constructor(ui: TransformNode);
  37996. /**
  37997. * Initializes the behavior
  37998. */
  37999. init(): void;
  38000. private _closestFace;
  38001. private _zeroVector;
  38002. private _lookAtTmpMatrix;
  38003. private _lookAtToRef;
  38004. /**
  38005. * Attaches the AttachToBoxBehavior to the passed in mesh
  38006. * @param target The mesh that the specified node will be attached to
  38007. */
  38008. attach(target: Mesh): void;
  38009. /**
  38010. * Detaches the behavior from the mesh
  38011. */
  38012. detach(): void;
  38013. }
  38014. }
  38015. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38016. import { Behavior } from "babylonjs/Behaviors/behavior";
  38017. import { Mesh } from "babylonjs/Meshes/mesh";
  38018. /**
  38019. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38020. */
  38021. export class FadeInOutBehavior implements Behavior<Mesh> {
  38022. /**
  38023. * Time in milliseconds to delay before fading in (Default: 0)
  38024. */
  38025. delay: number;
  38026. /**
  38027. * Time in milliseconds for the mesh to fade in (Default: 300)
  38028. */
  38029. fadeInTime: number;
  38030. private _millisecondsPerFrame;
  38031. private _hovered;
  38032. private _hoverValue;
  38033. private _ownerNode;
  38034. /**
  38035. * Instatiates the FadeInOutBehavior
  38036. */
  38037. constructor();
  38038. /**
  38039. * The name of the behavior
  38040. */
  38041. readonly name: string;
  38042. /**
  38043. * Initializes the behavior
  38044. */
  38045. init(): void;
  38046. /**
  38047. * Attaches the fade behavior on the passed in mesh
  38048. * @param ownerNode The mesh that will be faded in/out once attached
  38049. */
  38050. attach(ownerNode: Mesh): void;
  38051. /**
  38052. * Detaches the behavior from the mesh
  38053. */
  38054. detach(): void;
  38055. /**
  38056. * Triggers the mesh to begin fading in or out
  38057. * @param value if the object should fade in or out (true to fade in)
  38058. */
  38059. fadeIn(value: boolean): void;
  38060. private _update;
  38061. private _setAllVisibility;
  38062. }
  38063. }
  38064. declare module "babylonjs/Misc/pivotTools" {
  38065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38066. /**
  38067. * Class containing a set of static utilities functions for managing Pivots
  38068. * @hidden
  38069. */
  38070. export class PivotTools {
  38071. private static _PivotCached;
  38072. private static _OldPivotPoint;
  38073. private static _PivotTranslation;
  38074. private static _PivotTmpVector;
  38075. /** @hidden */
  38076. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38077. /** @hidden */
  38078. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38079. }
  38080. }
  38081. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38082. import { Scene } from "babylonjs/scene";
  38083. import { Vector4 } from "babylonjs/Maths/math.vector";
  38084. import { Mesh } from "babylonjs/Meshes/mesh";
  38085. import { Nullable } from "babylonjs/types";
  38086. import { Plane } from "babylonjs/Maths/math.plane";
  38087. /**
  38088. * Class containing static functions to help procedurally build meshes
  38089. */
  38090. export class PlaneBuilder {
  38091. /**
  38092. * Creates a plane mesh
  38093. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38094. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38095. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38099. * @param name defines the name of the mesh
  38100. * @param options defines the options used to create the mesh
  38101. * @param scene defines the hosting scene
  38102. * @returns the plane mesh
  38103. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38104. */
  38105. static CreatePlane(name: string, options: {
  38106. size?: number;
  38107. width?: number;
  38108. height?: number;
  38109. sideOrientation?: number;
  38110. frontUVs?: Vector4;
  38111. backUVs?: Vector4;
  38112. updatable?: boolean;
  38113. sourcePlane?: Plane;
  38114. }, scene?: Nullable<Scene>): Mesh;
  38115. }
  38116. }
  38117. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38118. import { Behavior } from "babylonjs/Behaviors/behavior";
  38119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38120. import { Observable } from "babylonjs/Misc/observable";
  38121. import { Vector3 } from "babylonjs/Maths/math.vector";
  38122. import { Ray } from "babylonjs/Culling/ray";
  38123. import "babylonjs/Meshes/Builders/planeBuilder";
  38124. /**
  38125. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38126. */
  38127. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38128. private static _AnyMouseID;
  38129. /**
  38130. * Abstract mesh the behavior is set on
  38131. */
  38132. attachedNode: AbstractMesh;
  38133. private _dragPlane;
  38134. private _scene;
  38135. private _pointerObserver;
  38136. private _beforeRenderObserver;
  38137. private static _planeScene;
  38138. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38139. /**
  38140. * 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)
  38141. */
  38142. maxDragAngle: number;
  38143. /**
  38144. * @hidden
  38145. */
  38146. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38147. /**
  38148. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38149. */
  38150. currentDraggingPointerID: number;
  38151. /**
  38152. * The last position where the pointer hit the drag plane in world space
  38153. */
  38154. lastDragPosition: Vector3;
  38155. /**
  38156. * If the behavior is currently in a dragging state
  38157. */
  38158. dragging: boolean;
  38159. /**
  38160. * 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)
  38161. */
  38162. dragDeltaRatio: number;
  38163. /**
  38164. * If the drag plane orientation should be updated during the dragging (Default: true)
  38165. */
  38166. updateDragPlane: boolean;
  38167. private _debugMode;
  38168. private _moving;
  38169. /**
  38170. * Fires each time the attached mesh is dragged with the pointer
  38171. * * delta between last drag position and current drag position in world space
  38172. * * dragDistance along the drag axis
  38173. * * dragPlaneNormal normal of the current drag plane used during the drag
  38174. * * dragPlanePoint in world space where the drag intersects the drag plane
  38175. */
  38176. onDragObservable: Observable<{
  38177. delta: Vector3;
  38178. dragPlanePoint: Vector3;
  38179. dragPlaneNormal: Vector3;
  38180. dragDistance: number;
  38181. pointerId: number;
  38182. }>;
  38183. /**
  38184. * Fires each time a drag begins (eg. mouse down on mesh)
  38185. */
  38186. onDragStartObservable: Observable<{
  38187. dragPlanePoint: Vector3;
  38188. pointerId: number;
  38189. }>;
  38190. /**
  38191. * Fires each time a drag ends (eg. mouse release after drag)
  38192. */
  38193. onDragEndObservable: Observable<{
  38194. dragPlanePoint: Vector3;
  38195. pointerId: number;
  38196. }>;
  38197. /**
  38198. * If the attached mesh should be moved when dragged
  38199. */
  38200. moveAttached: boolean;
  38201. /**
  38202. * If the drag behavior will react to drag events (Default: true)
  38203. */
  38204. enabled: boolean;
  38205. /**
  38206. * If pointer events should start and release the drag (Default: true)
  38207. */
  38208. startAndReleaseDragOnPointerEvents: boolean;
  38209. /**
  38210. * If camera controls should be detached during the drag
  38211. */
  38212. detachCameraControls: boolean;
  38213. /**
  38214. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38215. */
  38216. useObjectOrienationForDragging: boolean;
  38217. private _options;
  38218. /**
  38219. * Creates a pointer drag behavior that can be attached to a mesh
  38220. * @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)
  38221. */
  38222. constructor(options?: {
  38223. dragAxis?: Vector3;
  38224. dragPlaneNormal?: Vector3;
  38225. });
  38226. /**
  38227. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38228. */
  38229. validateDrag: (targetPosition: Vector3) => boolean;
  38230. /**
  38231. * The name of the behavior
  38232. */
  38233. readonly name: string;
  38234. /**
  38235. * Initializes the behavior
  38236. */
  38237. init(): void;
  38238. private _tmpVector;
  38239. private _alternatePickedPoint;
  38240. private _worldDragAxis;
  38241. private _targetPosition;
  38242. private _attachedElement;
  38243. /**
  38244. * Attaches the drag behavior the passed in mesh
  38245. * @param ownerNode The mesh that will be dragged around once attached
  38246. * @param predicate Predicate to use for pick filtering
  38247. */
  38248. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38249. /**
  38250. * Force relase the drag action by code.
  38251. */
  38252. releaseDrag(): void;
  38253. private _startDragRay;
  38254. private _lastPointerRay;
  38255. /**
  38256. * Simulates the start of a pointer drag event on the behavior
  38257. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38258. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38259. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38260. */
  38261. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38262. private _startDrag;
  38263. private _dragDelta;
  38264. private _moveDrag;
  38265. private _pickWithRayOnDragPlane;
  38266. private _pointA;
  38267. private _pointB;
  38268. private _pointC;
  38269. private _lineA;
  38270. private _lineB;
  38271. private _localAxis;
  38272. private _lookAt;
  38273. private _updateDragPlanePosition;
  38274. /**
  38275. * Detaches the behavior from the mesh
  38276. */
  38277. detach(): void;
  38278. }
  38279. }
  38280. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38281. import { Mesh } from "babylonjs/Meshes/mesh";
  38282. import { Behavior } from "babylonjs/Behaviors/behavior";
  38283. /**
  38284. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38285. */
  38286. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38287. private _dragBehaviorA;
  38288. private _dragBehaviorB;
  38289. private _startDistance;
  38290. private _initialScale;
  38291. private _targetScale;
  38292. private _ownerNode;
  38293. private _sceneRenderObserver;
  38294. /**
  38295. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38296. */
  38297. constructor();
  38298. /**
  38299. * The name of the behavior
  38300. */
  38301. readonly name: string;
  38302. /**
  38303. * Initializes the behavior
  38304. */
  38305. init(): void;
  38306. private _getCurrentDistance;
  38307. /**
  38308. * Attaches the scale behavior the passed in mesh
  38309. * @param ownerNode The mesh that will be scaled around once attached
  38310. */
  38311. attach(ownerNode: Mesh): void;
  38312. /**
  38313. * Detaches the behavior from the mesh
  38314. */
  38315. detach(): void;
  38316. }
  38317. }
  38318. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38319. import { Behavior } from "babylonjs/Behaviors/behavior";
  38320. import { Mesh } from "babylonjs/Meshes/mesh";
  38321. import { Observable } from "babylonjs/Misc/observable";
  38322. /**
  38323. * 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
  38324. */
  38325. export class SixDofDragBehavior implements Behavior<Mesh> {
  38326. private static _virtualScene;
  38327. private _ownerNode;
  38328. private _sceneRenderObserver;
  38329. private _scene;
  38330. private _targetPosition;
  38331. private _virtualOriginMesh;
  38332. private _virtualDragMesh;
  38333. private _pointerObserver;
  38334. private _moving;
  38335. private _startingOrientation;
  38336. /**
  38337. * 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)
  38338. */
  38339. private zDragFactor;
  38340. /**
  38341. * If the object should rotate to face the drag origin
  38342. */
  38343. rotateDraggedObject: boolean;
  38344. /**
  38345. * If the behavior is currently in a dragging state
  38346. */
  38347. dragging: boolean;
  38348. /**
  38349. * 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)
  38350. */
  38351. dragDeltaRatio: number;
  38352. /**
  38353. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38354. */
  38355. currentDraggingPointerID: number;
  38356. /**
  38357. * If camera controls should be detached during the drag
  38358. */
  38359. detachCameraControls: boolean;
  38360. /**
  38361. * Fires each time a drag starts
  38362. */
  38363. onDragStartObservable: Observable<{}>;
  38364. /**
  38365. * Fires each time a drag ends (eg. mouse release after drag)
  38366. */
  38367. onDragEndObservable: Observable<{}>;
  38368. /**
  38369. * 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
  38370. */
  38371. constructor();
  38372. /**
  38373. * The name of the behavior
  38374. */
  38375. readonly name: string;
  38376. /**
  38377. * Initializes the behavior
  38378. */
  38379. init(): void;
  38380. /**
  38381. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38382. */
  38383. private readonly _pointerCamera;
  38384. /**
  38385. * Attaches the scale behavior the passed in mesh
  38386. * @param ownerNode The mesh that will be scaled around once attached
  38387. */
  38388. attach(ownerNode: Mesh): void;
  38389. /**
  38390. * Detaches the behavior from the mesh
  38391. */
  38392. detach(): void;
  38393. }
  38394. }
  38395. declare module "babylonjs/Behaviors/Meshes/index" {
  38396. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38397. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38398. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38399. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38400. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38401. }
  38402. declare module "babylonjs/Behaviors/index" {
  38403. export * from "babylonjs/Behaviors/behavior";
  38404. export * from "babylonjs/Behaviors/Cameras/index";
  38405. export * from "babylonjs/Behaviors/Meshes/index";
  38406. }
  38407. declare module "babylonjs/Bones/boneIKController" {
  38408. import { Bone } from "babylonjs/Bones/bone";
  38409. import { Vector3 } from "babylonjs/Maths/math.vector";
  38410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38411. import { Nullable } from "babylonjs/types";
  38412. /**
  38413. * Class used to apply inverse kinematics to bones
  38414. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38415. */
  38416. export class BoneIKController {
  38417. private static _tmpVecs;
  38418. private static _tmpQuat;
  38419. private static _tmpMats;
  38420. /**
  38421. * Gets or sets the target mesh
  38422. */
  38423. targetMesh: AbstractMesh;
  38424. /** Gets or sets the mesh used as pole */
  38425. poleTargetMesh: AbstractMesh;
  38426. /**
  38427. * Gets or sets the bone used as pole
  38428. */
  38429. poleTargetBone: Nullable<Bone>;
  38430. /**
  38431. * Gets or sets the target position
  38432. */
  38433. targetPosition: Vector3;
  38434. /**
  38435. * Gets or sets the pole target position
  38436. */
  38437. poleTargetPosition: Vector3;
  38438. /**
  38439. * Gets or sets the pole target local offset
  38440. */
  38441. poleTargetLocalOffset: Vector3;
  38442. /**
  38443. * Gets or sets the pole angle
  38444. */
  38445. poleAngle: number;
  38446. /**
  38447. * Gets or sets the mesh associated with the controller
  38448. */
  38449. mesh: AbstractMesh;
  38450. /**
  38451. * 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)
  38452. */
  38453. slerpAmount: number;
  38454. private _bone1Quat;
  38455. private _bone1Mat;
  38456. private _bone2Ang;
  38457. private _bone1;
  38458. private _bone2;
  38459. private _bone1Length;
  38460. private _bone2Length;
  38461. private _maxAngle;
  38462. private _maxReach;
  38463. private _rightHandedSystem;
  38464. private _bendAxis;
  38465. private _slerping;
  38466. private _adjustRoll;
  38467. /**
  38468. * Gets or sets maximum allowed angle
  38469. */
  38470. maxAngle: number;
  38471. /**
  38472. * Creates a new BoneIKController
  38473. * @param mesh defines the mesh to control
  38474. * @param bone defines the bone to control
  38475. * @param options defines options to set up the controller
  38476. */
  38477. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38478. targetMesh?: AbstractMesh;
  38479. poleTargetMesh?: AbstractMesh;
  38480. poleTargetBone?: Bone;
  38481. poleTargetLocalOffset?: Vector3;
  38482. poleAngle?: number;
  38483. bendAxis?: Vector3;
  38484. maxAngle?: number;
  38485. slerpAmount?: number;
  38486. });
  38487. private _setMaxAngle;
  38488. /**
  38489. * Force the controller to update the bones
  38490. */
  38491. update(): void;
  38492. }
  38493. }
  38494. declare module "babylonjs/Bones/boneLookController" {
  38495. import { Vector3 } from "babylonjs/Maths/math.vector";
  38496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38497. import { Bone } from "babylonjs/Bones/bone";
  38498. import { Space } from "babylonjs/Maths/math.axis";
  38499. /**
  38500. * Class used to make a bone look toward a point in space
  38501. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38502. */
  38503. export class BoneLookController {
  38504. private static _tmpVecs;
  38505. private static _tmpQuat;
  38506. private static _tmpMats;
  38507. /**
  38508. * The target Vector3 that the bone will look at
  38509. */
  38510. target: Vector3;
  38511. /**
  38512. * The mesh that the bone is attached to
  38513. */
  38514. mesh: AbstractMesh;
  38515. /**
  38516. * The bone that will be looking to the target
  38517. */
  38518. bone: Bone;
  38519. /**
  38520. * The up axis of the coordinate system that is used when the bone is rotated
  38521. */
  38522. upAxis: Vector3;
  38523. /**
  38524. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38525. */
  38526. upAxisSpace: Space;
  38527. /**
  38528. * Used to make an adjustment to the yaw of the bone
  38529. */
  38530. adjustYaw: number;
  38531. /**
  38532. * Used to make an adjustment to the pitch of the bone
  38533. */
  38534. adjustPitch: number;
  38535. /**
  38536. * Used to make an adjustment to the roll of the bone
  38537. */
  38538. adjustRoll: number;
  38539. /**
  38540. * 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)
  38541. */
  38542. slerpAmount: number;
  38543. private _minYaw;
  38544. private _maxYaw;
  38545. private _minPitch;
  38546. private _maxPitch;
  38547. private _minYawSin;
  38548. private _minYawCos;
  38549. private _maxYawSin;
  38550. private _maxYawCos;
  38551. private _midYawConstraint;
  38552. private _minPitchTan;
  38553. private _maxPitchTan;
  38554. private _boneQuat;
  38555. private _slerping;
  38556. private _transformYawPitch;
  38557. private _transformYawPitchInv;
  38558. private _firstFrameSkipped;
  38559. private _yawRange;
  38560. private _fowardAxis;
  38561. /**
  38562. * Gets or sets the minimum yaw angle that the bone can look to
  38563. */
  38564. minYaw: number;
  38565. /**
  38566. * Gets or sets the maximum yaw angle that the bone can look to
  38567. */
  38568. maxYaw: number;
  38569. /**
  38570. * Gets or sets the minimum pitch angle that the bone can look to
  38571. */
  38572. minPitch: number;
  38573. /**
  38574. * Gets or sets the maximum pitch angle that the bone can look to
  38575. */
  38576. maxPitch: number;
  38577. /**
  38578. * Create a BoneLookController
  38579. * @param mesh the mesh that the bone belongs to
  38580. * @param bone the bone that will be looking to the target
  38581. * @param target the target Vector3 to look at
  38582. * @param options optional settings:
  38583. * * maxYaw: the maximum angle the bone will yaw to
  38584. * * minYaw: the minimum angle the bone will yaw to
  38585. * * maxPitch: the maximum angle the bone will pitch to
  38586. * * minPitch: the minimum angle the bone will yaw to
  38587. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38588. * * upAxis: the up axis of the coordinate system
  38589. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38590. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38591. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38592. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38593. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38594. * * adjustRoll: used to make an adjustment to the roll of the bone
  38595. **/
  38596. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38597. maxYaw?: number;
  38598. minYaw?: number;
  38599. maxPitch?: number;
  38600. minPitch?: number;
  38601. slerpAmount?: number;
  38602. upAxis?: Vector3;
  38603. upAxisSpace?: Space;
  38604. yawAxis?: Vector3;
  38605. pitchAxis?: Vector3;
  38606. adjustYaw?: number;
  38607. adjustPitch?: number;
  38608. adjustRoll?: number;
  38609. });
  38610. /**
  38611. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38612. */
  38613. update(): void;
  38614. private _getAngleDiff;
  38615. private _getAngleBetween;
  38616. private _isAngleBetween;
  38617. }
  38618. }
  38619. declare module "babylonjs/Bones/index" {
  38620. export * from "babylonjs/Bones/bone";
  38621. export * from "babylonjs/Bones/boneIKController";
  38622. export * from "babylonjs/Bones/boneLookController";
  38623. export * from "babylonjs/Bones/skeleton";
  38624. }
  38625. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38626. import { Nullable } from "babylonjs/types";
  38627. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38628. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38629. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38630. /**
  38631. * Manage the gamepad inputs to control an arc rotate camera.
  38632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38633. */
  38634. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38635. /**
  38636. * Defines the camera the input is attached to.
  38637. */
  38638. camera: ArcRotateCamera;
  38639. /**
  38640. * Defines the gamepad the input is gathering event from.
  38641. */
  38642. gamepad: Nullable<Gamepad>;
  38643. /**
  38644. * Defines the gamepad rotation sensiblity.
  38645. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38646. */
  38647. gamepadRotationSensibility: number;
  38648. /**
  38649. * Defines the gamepad move sensiblity.
  38650. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38651. */
  38652. gamepadMoveSensibility: number;
  38653. private _yAxisScale;
  38654. /**
  38655. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38656. */
  38657. invertYAxis: boolean;
  38658. private _onGamepadConnectedObserver;
  38659. private _onGamepadDisconnectedObserver;
  38660. /**
  38661. * Attach the input controls to a specific dom element to get the input from.
  38662. * @param element Defines the element the controls should be listened from
  38663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38664. */
  38665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38666. /**
  38667. * Detach the current controls from the specified dom element.
  38668. * @param element Defines the element to stop listening the inputs from
  38669. */
  38670. detachControl(element: Nullable<HTMLElement>): void;
  38671. /**
  38672. * Update the current camera state depending on the inputs that have been used this frame.
  38673. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38674. */
  38675. checkInputs(): void;
  38676. /**
  38677. * Gets the class name of the current intput.
  38678. * @returns the class name
  38679. */
  38680. getClassName(): string;
  38681. /**
  38682. * Get the friendly name associated with the input class.
  38683. * @returns the input friendly name
  38684. */
  38685. getSimpleName(): string;
  38686. }
  38687. }
  38688. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38689. import { Nullable } from "babylonjs/types";
  38690. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38691. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38692. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38693. interface ArcRotateCameraInputsManager {
  38694. /**
  38695. * Add orientation input support to the input manager.
  38696. * @returns the current input manager
  38697. */
  38698. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38699. }
  38700. }
  38701. /**
  38702. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38704. */
  38705. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38706. /**
  38707. * Defines the camera the input is attached to.
  38708. */
  38709. camera: ArcRotateCamera;
  38710. /**
  38711. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38712. */
  38713. alphaCorrection: number;
  38714. /**
  38715. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38716. */
  38717. gammaCorrection: number;
  38718. private _alpha;
  38719. private _gamma;
  38720. private _dirty;
  38721. private _deviceOrientationHandler;
  38722. /**
  38723. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38724. */
  38725. constructor();
  38726. /**
  38727. * Attach the input controls to a specific dom element to get the input from.
  38728. * @param element Defines the element the controls should be listened from
  38729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38730. */
  38731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38732. /** @hidden */
  38733. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38734. /**
  38735. * Update the current camera state depending on the inputs that have been used this frame.
  38736. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38737. */
  38738. checkInputs(): void;
  38739. /**
  38740. * Detach the current controls from the specified dom element.
  38741. * @param element Defines the element to stop listening the inputs from
  38742. */
  38743. detachControl(element: Nullable<HTMLElement>): void;
  38744. /**
  38745. * Gets the class name of the current intput.
  38746. * @returns the class name
  38747. */
  38748. getClassName(): string;
  38749. /**
  38750. * Get the friendly name associated with the input class.
  38751. * @returns the input friendly name
  38752. */
  38753. getSimpleName(): string;
  38754. }
  38755. }
  38756. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38757. import { Nullable } from "babylonjs/types";
  38758. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38759. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38760. /**
  38761. * Listen to mouse events to control the camera.
  38762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38763. */
  38764. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38765. /**
  38766. * Defines the camera the input is attached to.
  38767. */
  38768. camera: FlyCamera;
  38769. /**
  38770. * Defines if touch is enabled. (Default is true.)
  38771. */
  38772. touchEnabled: boolean;
  38773. /**
  38774. * Defines the buttons associated with the input to handle camera rotation.
  38775. */
  38776. buttons: number[];
  38777. /**
  38778. * Assign buttons for Yaw control.
  38779. */
  38780. buttonsYaw: number[];
  38781. /**
  38782. * Assign buttons for Pitch control.
  38783. */
  38784. buttonsPitch: number[];
  38785. /**
  38786. * Assign buttons for Roll control.
  38787. */
  38788. buttonsRoll: number[];
  38789. /**
  38790. * Detect if any button is being pressed while mouse is moved.
  38791. * -1 = Mouse locked.
  38792. * 0 = Left button.
  38793. * 1 = Middle Button.
  38794. * 2 = Right Button.
  38795. */
  38796. activeButton: number;
  38797. /**
  38798. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38799. * Higher values reduce its sensitivity.
  38800. */
  38801. angularSensibility: number;
  38802. private _mousemoveCallback;
  38803. private _observer;
  38804. private _rollObserver;
  38805. private previousPosition;
  38806. private noPreventDefault;
  38807. private element;
  38808. /**
  38809. * Listen to mouse events to control the camera.
  38810. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38812. */
  38813. constructor(touchEnabled?: boolean);
  38814. /**
  38815. * Attach the mouse control to the HTML DOM element.
  38816. * @param element Defines the element that listens to the input events.
  38817. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38818. */
  38819. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38820. /**
  38821. * Detach the current controls from the specified dom element.
  38822. * @param element Defines the element to stop listening the inputs from
  38823. */
  38824. detachControl(element: Nullable<HTMLElement>): void;
  38825. /**
  38826. * Gets the class name of the current input.
  38827. * @returns the class name.
  38828. */
  38829. getClassName(): string;
  38830. /**
  38831. * Get the friendly name associated with the input class.
  38832. * @returns the input's friendly name.
  38833. */
  38834. getSimpleName(): string;
  38835. private _pointerInput;
  38836. private _onMouseMove;
  38837. /**
  38838. * Rotate camera by mouse offset.
  38839. */
  38840. private rotateCamera;
  38841. }
  38842. }
  38843. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38844. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38845. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38846. /**
  38847. * Default Inputs manager for the FlyCamera.
  38848. * It groups all the default supported inputs for ease of use.
  38849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38850. */
  38851. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38852. /**
  38853. * Instantiates a new FlyCameraInputsManager.
  38854. * @param camera Defines the camera the inputs belong to.
  38855. */
  38856. constructor(camera: FlyCamera);
  38857. /**
  38858. * Add keyboard input support to the input manager.
  38859. * @returns the new FlyCameraKeyboardMoveInput().
  38860. */
  38861. addKeyboard(): FlyCameraInputsManager;
  38862. /**
  38863. * Add mouse input support to the input manager.
  38864. * @param touchEnabled Enable touch screen support.
  38865. * @returns the new FlyCameraMouseInput().
  38866. */
  38867. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38868. }
  38869. }
  38870. declare module "babylonjs/Cameras/flyCamera" {
  38871. import { Scene } from "babylonjs/scene";
  38872. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38874. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38875. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38876. /**
  38877. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38878. * such as in a 3D Space Shooter or a Flight Simulator.
  38879. */
  38880. export class FlyCamera extends TargetCamera {
  38881. /**
  38882. * Define the collision ellipsoid of the camera.
  38883. * This is helpful for simulating a camera body, like a player's body.
  38884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38885. */
  38886. ellipsoid: Vector3;
  38887. /**
  38888. * Define an offset for the position of the ellipsoid around the camera.
  38889. * This can be helpful if the camera is attached away from the player's body center,
  38890. * such as at its head.
  38891. */
  38892. ellipsoidOffset: Vector3;
  38893. /**
  38894. * Enable or disable collisions of the camera with the rest of the scene objects.
  38895. */
  38896. checkCollisions: boolean;
  38897. /**
  38898. * Enable or disable gravity on the camera.
  38899. */
  38900. applyGravity: boolean;
  38901. /**
  38902. * Define the current direction the camera is moving to.
  38903. */
  38904. cameraDirection: Vector3;
  38905. /**
  38906. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38907. * This overrides and empties cameraRotation.
  38908. */
  38909. rotationQuaternion: Quaternion;
  38910. /**
  38911. * Track Roll to maintain the wanted Rolling when looking around.
  38912. */
  38913. _trackRoll: number;
  38914. /**
  38915. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38916. */
  38917. rollCorrect: number;
  38918. /**
  38919. * Mimic a banked turn, Rolling the camera when Yawing.
  38920. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38921. */
  38922. bankedTurn: boolean;
  38923. /**
  38924. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38925. */
  38926. bankedTurnLimit: number;
  38927. /**
  38928. * Value of 0 disables the banked Roll.
  38929. * Value of 1 is equal to the Yaw angle in radians.
  38930. */
  38931. bankedTurnMultiplier: number;
  38932. /**
  38933. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38934. */
  38935. inputs: FlyCameraInputsManager;
  38936. /**
  38937. * Gets the input sensibility for mouse input.
  38938. * Higher values reduce sensitivity.
  38939. */
  38940. /**
  38941. * Sets the input sensibility for a mouse input.
  38942. * Higher values reduce sensitivity.
  38943. */
  38944. angularSensibility: number;
  38945. /**
  38946. * Get the keys for camera movement forward.
  38947. */
  38948. /**
  38949. * Set the keys for camera movement forward.
  38950. */
  38951. keysForward: number[];
  38952. /**
  38953. * Get the keys for camera movement backward.
  38954. */
  38955. keysBackward: number[];
  38956. /**
  38957. * Get the keys for camera movement up.
  38958. */
  38959. /**
  38960. * Set the keys for camera movement up.
  38961. */
  38962. keysUp: number[];
  38963. /**
  38964. * Get the keys for camera movement down.
  38965. */
  38966. /**
  38967. * Set the keys for camera movement down.
  38968. */
  38969. keysDown: number[];
  38970. /**
  38971. * Get the keys for camera movement left.
  38972. */
  38973. /**
  38974. * Set the keys for camera movement left.
  38975. */
  38976. keysLeft: number[];
  38977. /**
  38978. * Set the keys for camera movement right.
  38979. */
  38980. /**
  38981. * Set the keys for camera movement right.
  38982. */
  38983. keysRight: number[];
  38984. /**
  38985. * Event raised when the camera collides with a mesh in the scene.
  38986. */
  38987. onCollide: (collidedMesh: AbstractMesh) => void;
  38988. private _collider;
  38989. private _needMoveForGravity;
  38990. private _oldPosition;
  38991. private _diffPosition;
  38992. private _newPosition;
  38993. /** @hidden */
  38994. _localDirection: Vector3;
  38995. /** @hidden */
  38996. _transformedDirection: Vector3;
  38997. /**
  38998. * Instantiates a FlyCamera.
  38999. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39000. * such as in a 3D Space Shooter or a Flight Simulator.
  39001. * @param name Define the name of the camera in the scene.
  39002. * @param position Define the starting position of the camera in the scene.
  39003. * @param scene Define the scene the camera belongs to.
  39004. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39005. */
  39006. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39007. /**
  39008. * Attach a control to the HTML DOM element.
  39009. * @param element Defines the element that listens to the input events.
  39010. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39011. */
  39012. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39013. /**
  39014. * Detach a control from the HTML DOM element.
  39015. * The camera will stop reacting to that input.
  39016. * @param element Defines the element that listens to the input events.
  39017. */
  39018. detachControl(element: HTMLElement): void;
  39019. private _collisionMask;
  39020. /**
  39021. * Get the mask that the camera ignores in collision events.
  39022. */
  39023. /**
  39024. * Set the mask that the camera ignores in collision events.
  39025. */
  39026. collisionMask: number;
  39027. /** @hidden */
  39028. _collideWithWorld(displacement: Vector3): void;
  39029. /** @hidden */
  39030. private _onCollisionPositionChange;
  39031. /** @hidden */
  39032. _checkInputs(): void;
  39033. /** @hidden */
  39034. _decideIfNeedsToMove(): boolean;
  39035. /** @hidden */
  39036. _updatePosition(): void;
  39037. /**
  39038. * Restore the Roll to its target value at the rate specified.
  39039. * @param rate - Higher means slower restoring.
  39040. * @hidden
  39041. */
  39042. restoreRoll(rate: number): void;
  39043. /**
  39044. * Destroy the camera and release the current resources held by it.
  39045. */
  39046. dispose(): void;
  39047. /**
  39048. * Get the current object class name.
  39049. * @returns the class name.
  39050. */
  39051. getClassName(): string;
  39052. }
  39053. }
  39054. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39055. import { Nullable } from "babylonjs/types";
  39056. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39057. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39058. /**
  39059. * Listen to keyboard events to control the camera.
  39060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39061. */
  39062. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39063. /**
  39064. * Defines the camera the input is attached to.
  39065. */
  39066. camera: FlyCamera;
  39067. /**
  39068. * The list of keyboard keys used to control the forward move of the camera.
  39069. */
  39070. keysForward: number[];
  39071. /**
  39072. * The list of keyboard keys used to control the backward move of the camera.
  39073. */
  39074. keysBackward: number[];
  39075. /**
  39076. * The list of keyboard keys used to control the forward move of the camera.
  39077. */
  39078. keysUp: number[];
  39079. /**
  39080. * The list of keyboard keys used to control the backward move of the camera.
  39081. */
  39082. keysDown: number[];
  39083. /**
  39084. * The list of keyboard keys used to control the right strafe move of the camera.
  39085. */
  39086. keysRight: number[];
  39087. /**
  39088. * The list of keyboard keys used to control the left strafe move of the camera.
  39089. */
  39090. keysLeft: number[];
  39091. private _keys;
  39092. private _onCanvasBlurObserver;
  39093. private _onKeyboardObserver;
  39094. private _engine;
  39095. private _scene;
  39096. /**
  39097. * Attach the input controls to a specific dom element to get the input from.
  39098. * @param element Defines the element the controls should be listened from
  39099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39100. */
  39101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39102. /**
  39103. * Detach the current controls from the specified dom element.
  39104. * @param element Defines the element to stop listening the inputs from
  39105. */
  39106. detachControl(element: Nullable<HTMLElement>): void;
  39107. /**
  39108. * Gets the class name of the current intput.
  39109. * @returns the class name
  39110. */
  39111. getClassName(): string;
  39112. /** @hidden */
  39113. _onLostFocus(e: FocusEvent): void;
  39114. /**
  39115. * Get the friendly name associated with the input class.
  39116. * @returns the input friendly name
  39117. */
  39118. getSimpleName(): string;
  39119. /**
  39120. * Update the current camera state depending on the inputs that have been used this frame.
  39121. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39122. */
  39123. checkInputs(): void;
  39124. }
  39125. }
  39126. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39127. import { Nullable } from "babylonjs/types";
  39128. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39129. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39130. /**
  39131. * Manage the mouse wheel inputs to control a follow camera.
  39132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39133. */
  39134. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39135. /**
  39136. * Defines the camera the input is attached to.
  39137. */
  39138. camera: FollowCamera;
  39139. /**
  39140. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39141. */
  39142. axisControlRadius: boolean;
  39143. /**
  39144. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39145. */
  39146. axisControlHeight: boolean;
  39147. /**
  39148. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39149. */
  39150. axisControlRotation: boolean;
  39151. /**
  39152. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39153. * relation to mouseWheel events.
  39154. */
  39155. wheelPrecision: number;
  39156. /**
  39157. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39158. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39159. */
  39160. wheelDeltaPercentage: number;
  39161. private _wheel;
  39162. private _observer;
  39163. /**
  39164. * Attach the input controls to a specific dom element to get the input from.
  39165. * @param element Defines the element the controls should be listened from
  39166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39167. */
  39168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39169. /**
  39170. * Detach the current controls from the specified dom element.
  39171. * @param element Defines the element to stop listening the inputs from
  39172. */
  39173. detachControl(element: Nullable<HTMLElement>): void;
  39174. /**
  39175. * Gets the class name of the current intput.
  39176. * @returns the class name
  39177. */
  39178. getClassName(): string;
  39179. /**
  39180. * Get the friendly name associated with the input class.
  39181. * @returns the input friendly name
  39182. */
  39183. getSimpleName(): string;
  39184. }
  39185. }
  39186. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39187. import { Nullable } from "babylonjs/types";
  39188. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39189. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39190. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39191. /**
  39192. * Manage the pointers inputs to control an follow camera.
  39193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39194. */
  39195. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39196. /**
  39197. * Defines the camera the input is attached to.
  39198. */
  39199. camera: FollowCamera;
  39200. /**
  39201. * Gets the class name of the current input.
  39202. * @returns the class name
  39203. */
  39204. getClassName(): string;
  39205. /**
  39206. * Defines the pointer angular sensibility along the X axis or how fast is
  39207. * the camera rotating.
  39208. * A negative number will reverse the axis direction.
  39209. */
  39210. angularSensibilityX: number;
  39211. /**
  39212. * Defines the pointer angular sensibility along the Y axis or how fast is
  39213. * the camera rotating.
  39214. * A negative number will reverse the axis direction.
  39215. */
  39216. angularSensibilityY: number;
  39217. /**
  39218. * Defines the pointer pinch precision or how fast is the camera zooming.
  39219. * A negative number will reverse the axis direction.
  39220. */
  39221. pinchPrecision: number;
  39222. /**
  39223. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39224. * from 0.
  39225. * It defines the percentage of current camera.radius to use as delta when
  39226. * pinch zoom is used.
  39227. */
  39228. pinchDeltaPercentage: number;
  39229. /**
  39230. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39231. */
  39232. axisXControlRadius: boolean;
  39233. /**
  39234. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39235. */
  39236. axisXControlHeight: boolean;
  39237. /**
  39238. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39239. */
  39240. axisXControlRotation: boolean;
  39241. /**
  39242. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39243. */
  39244. axisYControlRadius: boolean;
  39245. /**
  39246. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39247. */
  39248. axisYControlHeight: boolean;
  39249. /**
  39250. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39251. */
  39252. axisYControlRotation: boolean;
  39253. /**
  39254. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39255. */
  39256. axisPinchControlRadius: boolean;
  39257. /**
  39258. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39259. */
  39260. axisPinchControlHeight: boolean;
  39261. /**
  39262. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39263. */
  39264. axisPinchControlRotation: boolean;
  39265. /**
  39266. * Log error messages if basic misconfiguration has occurred.
  39267. */
  39268. warningEnable: boolean;
  39269. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39270. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39271. private _warningCounter;
  39272. private _warning;
  39273. }
  39274. }
  39275. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39276. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39277. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39278. /**
  39279. * Default Inputs manager for the FollowCamera.
  39280. * It groups all the default supported inputs for ease of use.
  39281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39282. */
  39283. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39284. /**
  39285. * Instantiates a new FollowCameraInputsManager.
  39286. * @param camera Defines the camera the inputs belong to
  39287. */
  39288. constructor(camera: FollowCamera);
  39289. /**
  39290. * Add keyboard input support to the input manager.
  39291. * @returns the current input manager
  39292. */
  39293. addKeyboard(): FollowCameraInputsManager;
  39294. /**
  39295. * Add mouse wheel input support to the input manager.
  39296. * @returns the current input manager
  39297. */
  39298. addMouseWheel(): FollowCameraInputsManager;
  39299. /**
  39300. * Add pointers input support to the input manager.
  39301. * @returns the current input manager
  39302. */
  39303. addPointers(): FollowCameraInputsManager;
  39304. /**
  39305. * Add orientation input support to the input manager.
  39306. * @returns the current input manager
  39307. */
  39308. addVRDeviceOrientation(): FollowCameraInputsManager;
  39309. }
  39310. }
  39311. declare module "babylonjs/Cameras/followCamera" {
  39312. import { Nullable } from "babylonjs/types";
  39313. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39314. import { Scene } from "babylonjs/scene";
  39315. import { Vector3 } from "babylonjs/Maths/math.vector";
  39316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39317. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39318. /**
  39319. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39320. * an arc rotate version arcFollowCamera are available.
  39321. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39322. */
  39323. export class FollowCamera extends TargetCamera {
  39324. /**
  39325. * Distance the follow camera should follow an object at
  39326. */
  39327. radius: number;
  39328. /**
  39329. * Minimum allowed distance of the camera to the axis of rotation
  39330. * (The camera can not get closer).
  39331. * This can help limiting how the Camera is able to move in the scene.
  39332. */
  39333. lowerRadiusLimit: Nullable<number>;
  39334. /**
  39335. * Maximum allowed distance of the camera to the axis of rotation
  39336. * (The camera can not get further).
  39337. * This can help limiting how the Camera is able to move in the scene.
  39338. */
  39339. upperRadiusLimit: Nullable<number>;
  39340. /**
  39341. * Define a rotation offset between the camera and the object it follows
  39342. */
  39343. rotationOffset: number;
  39344. /**
  39345. * Minimum allowed angle to camera position relative to target object.
  39346. * This can help limiting how the Camera is able to move in the scene.
  39347. */
  39348. lowerRotationOffsetLimit: Nullable<number>;
  39349. /**
  39350. * Maximum allowed angle to camera position relative to target object.
  39351. * This can help limiting how the Camera is able to move in the scene.
  39352. */
  39353. upperRotationOffsetLimit: Nullable<number>;
  39354. /**
  39355. * Define a height offset between the camera and the object it follows.
  39356. * It can help following an object from the top (like a car chaing a plane)
  39357. */
  39358. heightOffset: number;
  39359. /**
  39360. * Minimum allowed height of camera position relative to target object.
  39361. * This can help limiting how the Camera is able to move in the scene.
  39362. */
  39363. lowerHeightOffsetLimit: Nullable<number>;
  39364. /**
  39365. * Maximum allowed height of camera position relative to target object.
  39366. * This can help limiting how the Camera is able to move in the scene.
  39367. */
  39368. upperHeightOffsetLimit: Nullable<number>;
  39369. /**
  39370. * Define how fast the camera can accelerate to follow it s target.
  39371. */
  39372. cameraAcceleration: number;
  39373. /**
  39374. * Define the speed limit of the camera following an object.
  39375. */
  39376. maxCameraSpeed: number;
  39377. /**
  39378. * Define the target of the camera.
  39379. */
  39380. lockedTarget: Nullable<AbstractMesh>;
  39381. /**
  39382. * Defines the input associated with the camera.
  39383. */
  39384. inputs: FollowCameraInputsManager;
  39385. /**
  39386. * Instantiates the follow camera.
  39387. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39388. * @param name Define the name of the camera in the scene
  39389. * @param position Define the position of the camera
  39390. * @param scene Define the scene the camera belong to
  39391. * @param lockedTarget Define the target of the camera
  39392. */
  39393. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39394. private _follow;
  39395. /**
  39396. * Attached controls to the current camera.
  39397. * @param element Defines the element the controls should be listened from
  39398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39399. */
  39400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39401. /**
  39402. * Detach the current controls from the camera.
  39403. * The camera will stop reacting to inputs.
  39404. * @param element Defines the element to stop listening the inputs from
  39405. */
  39406. detachControl(element: HTMLElement): void;
  39407. /** @hidden */
  39408. _checkInputs(): void;
  39409. private _checkLimits;
  39410. /**
  39411. * Gets the camera class name.
  39412. * @returns the class name
  39413. */
  39414. getClassName(): string;
  39415. }
  39416. /**
  39417. * Arc Rotate version of the follow camera.
  39418. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39419. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39420. */
  39421. export class ArcFollowCamera extends TargetCamera {
  39422. /** The longitudinal angle of the camera */
  39423. alpha: number;
  39424. /** The latitudinal angle of the camera */
  39425. beta: number;
  39426. /** The radius of the camera from its target */
  39427. radius: number;
  39428. /** Define the camera target (the messh it should follow) */
  39429. target: Nullable<AbstractMesh>;
  39430. private _cartesianCoordinates;
  39431. /**
  39432. * Instantiates a new ArcFollowCamera
  39433. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39434. * @param name Define the name of the camera
  39435. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39436. * @param beta Define the rotation angle of the camera around the elevation axis
  39437. * @param radius Define the radius of the camera from its target point
  39438. * @param target Define the target of the camera
  39439. * @param scene Define the scene the camera belongs to
  39440. */
  39441. constructor(name: string,
  39442. /** The longitudinal angle of the camera */
  39443. alpha: number,
  39444. /** The latitudinal angle of the camera */
  39445. beta: number,
  39446. /** The radius of the camera from its target */
  39447. radius: number,
  39448. /** Define the camera target (the messh it should follow) */
  39449. target: Nullable<AbstractMesh>, scene: Scene);
  39450. private _follow;
  39451. /** @hidden */
  39452. _checkInputs(): void;
  39453. /**
  39454. * Returns the class name of the object.
  39455. * It is mostly used internally for serialization purposes.
  39456. */
  39457. getClassName(): string;
  39458. }
  39459. }
  39460. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39461. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39462. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39463. import { Nullable } from "babylonjs/types";
  39464. /**
  39465. * Manage the keyboard inputs to control the movement of a follow camera.
  39466. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39467. */
  39468. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39469. /**
  39470. * Defines the camera the input is attached to.
  39471. */
  39472. camera: FollowCamera;
  39473. /**
  39474. * Defines the list of key codes associated with the up action (increase heightOffset)
  39475. */
  39476. keysHeightOffsetIncr: number[];
  39477. /**
  39478. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39479. */
  39480. keysHeightOffsetDecr: number[];
  39481. /**
  39482. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39483. */
  39484. keysHeightOffsetModifierAlt: boolean;
  39485. /**
  39486. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39487. */
  39488. keysHeightOffsetModifierCtrl: boolean;
  39489. /**
  39490. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39491. */
  39492. keysHeightOffsetModifierShift: boolean;
  39493. /**
  39494. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39495. */
  39496. keysRotationOffsetIncr: number[];
  39497. /**
  39498. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39499. */
  39500. keysRotationOffsetDecr: number[];
  39501. /**
  39502. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39503. */
  39504. keysRotationOffsetModifierAlt: boolean;
  39505. /**
  39506. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39507. */
  39508. keysRotationOffsetModifierCtrl: boolean;
  39509. /**
  39510. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39511. */
  39512. keysRotationOffsetModifierShift: boolean;
  39513. /**
  39514. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39515. */
  39516. keysRadiusIncr: number[];
  39517. /**
  39518. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39519. */
  39520. keysRadiusDecr: number[];
  39521. /**
  39522. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39523. */
  39524. keysRadiusModifierAlt: boolean;
  39525. /**
  39526. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39527. */
  39528. keysRadiusModifierCtrl: boolean;
  39529. /**
  39530. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39531. */
  39532. keysRadiusModifierShift: boolean;
  39533. /**
  39534. * Defines the rate of change of heightOffset.
  39535. */
  39536. heightSensibility: number;
  39537. /**
  39538. * Defines the rate of change of rotationOffset.
  39539. */
  39540. rotationSensibility: number;
  39541. /**
  39542. * Defines the rate of change of radius.
  39543. */
  39544. radiusSensibility: number;
  39545. private _keys;
  39546. private _ctrlPressed;
  39547. private _altPressed;
  39548. private _shiftPressed;
  39549. private _onCanvasBlurObserver;
  39550. private _onKeyboardObserver;
  39551. private _engine;
  39552. private _scene;
  39553. /**
  39554. * Attach the input controls to a specific dom element to get the input from.
  39555. * @param element Defines the element the controls should be listened from
  39556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39557. */
  39558. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39559. /**
  39560. * Detach the current controls from the specified dom element.
  39561. * @param element Defines the element to stop listening the inputs from
  39562. */
  39563. detachControl(element: Nullable<HTMLElement>): void;
  39564. /**
  39565. * Update the current camera state depending on the inputs that have been used this frame.
  39566. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39567. */
  39568. checkInputs(): void;
  39569. /**
  39570. * Gets the class name of the current input.
  39571. * @returns the class name
  39572. */
  39573. getClassName(): string;
  39574. /**
  39575. * Get the friendly name associated with the input class.
  39576. * @returns the input friendly name
  39577. */
  39578. getSimpleName(): string;
  39579. /**
  39580. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39581. * allow modification of the heightOffset value.
  39582. */
  39583. private _modifierHeightOffset;
  39584. /**
  39585. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39586. * allow modification of the rotationOffset value.
  39587. */
  39588. private _modifierRotationOffset;
  39589. /**
  39590. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39591. * allow modification of the radius value.
  39592. */
  39593. private _modifierRadius;
  39594. }
  39595. }
  39596. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39597. import { Nullable } from "babylonjs/types";
  39598. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39599. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39600. import { Observable } from "babylonjs/Misc/observable";
  39601. module "babylonjs/Cameras/freeCameraInputsManager" {
  39602. interface FreeCameraInputsManager {
  39603. /**
  39604. * @hidden
  39605. */
  39606. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39607. /**
  39608. * Add orientation input support to the input manager.
  39609. * @returns the current input manager
  39610. */
  39611. addDeviceOrientation(): FreeCameraInputsManager;
  39612. }
  39613. }
  39614. /**
  39615. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39616. * Screen rotation is taken into account.
  39617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39618. */
  39619. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39620. private _camera;
  39621. private _screenOrientationAngle;
  39622. private _constantTranform;
  39623. private _screenQuaternion;
  39624. private _alpha;
  39625. private _beta;
  39626. private _gamma;
  39627. /**
  39628. * Can be used to detect if a device orientation sensor is availible on a device
  39629. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39630. * @returns a promise that will resolve on orientation change
  39631. */
  39632. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39633. /**
  39634. * @hidden
  39635. */
  39636. _onDeviceOrientationChangedObservable: Observable<void>;
  39637. /**
  39638. * Instantiates a new input
  39639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39640. */
  39641. constructor();
  39642. /**
  39643. * Define the camera controlled by the input.
  39644. */
  39645. camera: FreeCamera;
  39646. /**
  39647. * Attach the input controls to a specific dom element to get the input from.
  39648. * @param element Defines the element the controls should be listened from
  39649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39650. */
  39651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39652. private _orientationChanged;
  39653. private _deviceOrientation;
  39654. /**
  39655. * Detach the current controls from the specified dom element.
  39656. * @param element Defines the element to stop listening the inputs from
  39657. */
  39658. detachControl(element: Nullable<HTMLElement>): void;
  39659. /**
  39660. * Update the current camera state depending on the inputs that have been used this frame.
  39661. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39662. */
  39663. checkInputs(): void;
  39664. /**
  39665. * Gets the class name of the current intput.
  39666. * @returns the class name
  39667. */
  39668. getClassName(): string;
  39669. /**
  39670. * Get the friendly name associated with the input class.
  39671. * @returns the input friendly name
  39672. */
  39673. getSimpleName(): string;
  39674. }
  39675. }
  39676. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39677. import { Nullable } from "babylonjs/types";
  39678. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39679. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39680. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39681. /**
  39682. * Manage the gamepad inputs to control a free camera.
  39683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39684. */
  39685. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39686. /**
  39687. * Define the camera the input is attached to.
  39688. */
  39689. camera: FreeCamera;
  39690. /**
  39691. * Define the Gamepad controlling the input
  39692. */
  39693. gamepad: Nullable<Gamepad>;
  39694. /**
  39695. * Defines the gamepad rotation sensiblity.
  39696. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39697. */
  39698. gamepadAngularSensibility: number;
  39699. /**
  39700. * Defines the gamepad move sensiblity.
  39701. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39702. */
  39703. gamepadMoveSensibility: number;
  39704. private _yAxisScale;
  39705. /**
  39706. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39707. */
  39708. invertYAxis: boolean;
  39709. private _onGamepadConnectedObserver;
  39710. private _onGamepadDisconnectedObserver;
  39711. private _cameraTransform;
  39712. private _deltaTransform;
  39713. private _vector3;
  39714. private _vector2;
  39715. /**
  39716. * Attach the input controls to a specific dom element to get the input from.
  39717. * @param element Defines the element the controls should be listened from
  39718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39719. */
  39720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39721. /**
  39722. * Detach the current controls from the specified dom element.
  39723. * @param element Defines the element to stop listening the inputs from
  39724. */
  39725. detachControl(element: Nullable<HTMLElement>): void;
  39726. /**
  39727. * Update the current camera state depending on the inputs that have been used this frame.
  39728. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39729. */
  39730. checkInputs(): void;
  39731. /**
  39732. * Gets the class name of the current intput.
  39733. * @returns the class name
  39734. */
  39735. getClassName(): string;
  39736. /**
  39737. * Get the friendly name associated with the input class.
  39738. * @returns the input friendly name
  39739. */
  39740. getSimpleName(): string;
  39741. }
  39742. }
  39743. declare module "babylonjs/Misc/virtualJoystick" {
  39744. import { Nullable } from "babylonjs/types";
  39745. import { Vector3 } from "babylonjs/Maths/math.vector";
  39746. /**
  39747. * Defines the potential axis of a Joystick
  39748. */
  39749. export enum JoystickAxis {
  39750. /** X axis */
  39751. X = 0,
  39752. /** Y axis */
  39753. Y = 1,
  39754. /** Z axis */
  39755. Z = 2
  39756. }
  39757. /**
  39758. * Class used to define virtual joystick (used in touch mode)
  39759. */
  39760. export class VirtualJoystick {
  39761. /**
  39762. * Gets or sets a boolean indicating that left and right values must be inverted
  39763. */
  39764. reverseLeftRight: boolean;
  39765. /**
  39766. * Gets or sets a boolean indicating that up and down values must be inverted
  39767. */
  39768. reverseUpDown: boolean;
  39769. /**
  39770. * Gets the offset value for the position (ie. the change of the position value)
  39771. */
  39772. deltaPosition: Vector3;
  39773. /**
  39774. * Gets a boolean indicating if the virtual joystick was pressed
  39775. */
  39776. pressed: boolean;
  39777. /**
  39778. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39779. */
  39780. static Canvas: Nullable<HTMLCanvasElement>;
  39781. private static _globalJoystickIndex;
  39782. private static vjCanvasContext;
  39783. private static vjCanvasWidth;
  39784. private static vjCanvasHeight;
  39785. private static halfWidth;
  39786. private _action;
  39787. private _axisTargetedByLeftAndRight;
  39788. private _axisTargetedByUpAndDown;
  39789. private _joystickSensibility;
  39790. private _inversedSensibility;
  39791. private _joystickPointerID;
  39792. private _joystickColor;
  39793. private _joystickPointerPos;
  39794. private _joystickPreviousPointerPos;
  39795. private _joystickPointerStartPos;
  39796. private _deltaJoystickVector;
  39797. private _leftJoystick;
  39798. private _touches;
  39799. private _onPointerDownHandlerRef;
  39800. private _onPointerMoveHandlerRef;
  39801. private _onPointerUpHandlerRef;
  39802. private _onResize;
  39803. /**
  39804. * Creates a new virtual joystick
  39805. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39806. */
  39807. constructor(leftJoystick?: boolean);
  39808. /**
  39809. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39810. * @param newJoystickSensibility defines the new sensibility
  39811. */
  39812. setJoystickSensibility(newJoystickSensibility: number): void;
  39813. private _onPointerDown;
  39814. private _onPointerMove;
  39815. private _onPointerUp;
  39816. /**
  39817. * Change the color of the virtual joystick
  39818. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39819. */
  39820. setJoystickColor(newColor: string): void;
  39821. /**
  39822. * Defines a callback to call when the joystick is touched
  39823. * @param action defines the callback
  39824. */
  39825. setActionOnTouch(action: () => any): void;
  39826. /**
  39827. * Defines which axis you'd like to control for left & right
  39828. * @param axis defines the axis to use
  39829. */
  39830. setAxisForLeftRight(axis: JoystickAxis): void;
  39831. /**
  39832. * Defines which axis you'd like to control for up & down
  39833. * @param axis defines the axis to use
  39834. */
  39835. setAxisForUpDown(axis: JoystickAxis): void;
  39836. private _drawVirtualJoystick;
  39837. /**
  39838. * Release internal HTML canvas
  39839. */
  39840. releaseCanvas(): void;
  39841. }
  39842. }
  39843. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39844. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39845. import { Nullable } from "babylonjs/types";
  39846. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39847. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39848. module "babylonjs/Cameras/freeCameraInputsManager" {
  39849. interface FreeCameraInputsManager {
  39850. /**
  39851. * Add virtual joystick input support to the input manager.
  39852. * @returns the current input manager
  39853. */
  39854. addVirtualJoystick(): FreeCameraInputsManager;
  39855. }
  39856. }
  39857. /**
  39858. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39860. */
  39861. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39862. /**
  39863. * Defines the camera the input is attached to.
  39864. */
  39865. camera: FreeCamera;
  39866. private _leftjoystick;
  39867. private _rightjoystick;
  39868. /**
  39869. * Gets the left stick of the virtual joystick.
  39870. * @returns The virtual Joystick
  39871. */
  39872. getLeftJoystick(): VirtualJoystick;
  39873. /**
  39874. * Gets the right stick of the virtual joystick.
  39875. * @returns The virtual Joystick
  39876. */
  39877. getRightJoystick(): VirtualJoystick;
  39878. /**
  39879. * Update the current camera state depending on the inputs that have been used this frame.
  39880. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39881. */
  39882. checkInputs(): void;
  39883. /**
  39884. * Attach the input controls to a specific dom element to get the input from.
  39885. * @param element Defines the element the controls should be listened from
  39886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39887. */
  39888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39889. /**
  39890. * Detach the current controls from the specified dom element.
  39891. * @param element Defines the element to stop listening the inputs from
  39892. */
  39893. detachControl(element: Nullable<HTMLElement>): void;
  39894. /**
  39895. * Gets the class name of the current intput.
  39896. * @returns the class name
  39897. */
  39898. getClassName(): string;
  39899. /**
  39900. * Get the friendly name associated with the input class.
  39901. * @returns the input friendly name
  39902. */
  39903. getSimpleName(): string;
  39904. }
  39905. }
  39906. declare module "babylonjs/Cameras/Inputs/index" {
  39907. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39908. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39909. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39910. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39911. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39912. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39913. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39914. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39915. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39916. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39917. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39918. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39919. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39920. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39921. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39922. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39923. }
  39924. declare module "babylonjs/Cameras/touchCamera" {
  39925. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39926. import { Scene } from "babylonjs/scene";
  39927. import { Vector3 } from "babylonjs/Maths/math.vector";
  39928. /**
  39929. * This represents a FPS type of camera controlled by touch.
  39930. * This is like a universal camera minus the Gamepad controls.
  39931. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39932. */
  39933. export class TouchCamera extends FreeCamera {
  39934. /**
  39935. * Defines the touch sensibility for rotation.
  39936. * The higher the faster.
  39937. */
  39938. touchAngularSensibility: number;
  39939. /**
  39940. * Defines the touch sensibility for move.
  39941. * The higher the faster.
  39942. */
  39943. touchMoveSensibility: number;
  39944. /**
  39945. * Instantiates a new touch camera.
  39946. * This represents a FPS type of camera controlled by touch.
  39947. * This is like a universal camera minus the Gamepad controls.
  39948. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39949. * @param name Define the name of the camera in the scene
  39950. * @param position Define the start position of the camera in the scene
  39951. * @param scene Define the scene the camera belongs to
  39952. */
  39953. constructor(name: string, position: Vector3, scene: Scene);
  39954. /**
  39955. * Gets the current object class name.
  39956. * @return the class name
  39957. */
  39958. getClassName(): string;
  39959. /** @hidden */
  39960. _setupInputs(): void;
  39961. }
  39962. }
  39963. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39964. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39965. import { Scene } from "babylonjs/scene";
  39966. import { Vector3 } from "babylonjs/Maths/math.vector";
  39967. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39968. import { Axis } from "babylonjs/Maths/math.axis";
  39969. /**
  39970. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39971. * being tilted forward or back and left or right.
  39972. */
  39973. export class DeviceOrientationCamera extends FreeCamera {
  39974. private _initialQuaternion;
  39975. private _quaternionCache;
  39976. private _tmpDragQuaternion;
  39977. private _disablePointerInputWhenUsingDeviceOrientation;
  39978. /**
  39979. * Creates a new device orientation camera
  39980. * @param name The name of the camera
  39981. * @param position The start position camera
  39982. * @param scene The scene the camera belongs to
  39983. */
  39984. constructor(name: string, position: Vector3, scene: Scene);
  39985. /**
  39986. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39987. */
  39988. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39989. private _dragFactor;
  39990. /**
  39991. * Enabled turning on the y axis when the orientation sensor is active
  39992. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39993. */
  39994. enableHorizontalDragging(dragFactor?: number): void;
  39995. /**
  39996. * Gets the current instance class name ("DeviceOrientationCamera").
  39997. * This helps avoiding instanceof at run time.
  39998. * @returns the class name
  39999. */
  40000. getClassName(): string;
  40001. /**
  40002. * @hidden
  40003. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40004. */
  40005. _checkInputs(): void;
  40006. /**
  40007. * Reset the camera to its default orientation on the specified axis only.
  40008. * @param axis The axis to reset
  40009. */
  40010. resetToCurrentRotation(axis?: Axis): void;
  40011. }
  40012. }
  40013. declare module "babylonjs/Gamepads/xboxGamepad" {
  40014. import { Observable } from "babylonjs/Misc/observable";
  40015. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40016. /**
  40017. * Defines supported buttons for XBox360 compatible gamepads
  40018. */
  40019. export enum Xbox360Button {
  40020. /** A */
  40021. A = 0,
  40022. /** B */
  40023. B = 1,
  40024. /** X */
  40025. X = 2,
  40026. /** Y */
  40027. Y = 3,
  40028. /** Start */
  40029. Start = 4,
  40030. /** Back */
  40031. Back = 5,
  40032. /** Left button */
  40033. LB = 6,
  40034. /** Right button */
  40035. RB = 7,
  40036. /** Left stick */
  40037. LeftStick = 8,
  40038. /** Right stick */
  40039. RightStick = 9
  40040. }
  40041. /** Defines values for XBox360 DPad */
  40042. export enum Xbox360Dpad {
  40043. /** Up */
  40044. Up = 0,
  40045. /** Down */
  40046. Down = 1,
  40047. /** Left */
  40048. Left = 2,
  40049. /** Right */
  40050. Right = 3
  40051. }
  40052. /**
  40053. * Defines a XBox360 gamepad
  40054. */
  40055. export class Xbox360Pad extends Gamepad {
  40056. private _leftTrigger;
  40057. private _rightTrigger;
  40058. private _onlefttriggerchanged;
  40059. private _onrighttriggerchanged;
  40060. private _onbuttondown;
  40061. private _onbuttonup;
  40062. private _ondpaddown;
  40063. private _ondpadup;
  40064. /** Observable raised when a button is pressed */
  40065. onButtonDownObservable: Observable<Xbox360Button>;
  40066. /** Observable raised when a button is released */
  40067. onButtonUpObservable: Observable<Xbox360Button>;
  40068. /** Observable raised when a pad is pressed */
  40069. onPadDownObservable: Observable<Xbox360Dpad>;
  40070. /** Observable raised when a pad is released */
  40071. onPadUpObservable: Observable<Xbox360Dpad>;
  40072. private _buttonA;
  40073. private _buttonB;
  40074. private _buttonX;
  40075. private _buttonY;
  40076. private _buttonBack;
  40077. private _buttonStart;
  40078. private _buttonLB;
  40079. private _buttonRB;
  40080. private _buttonLeftStick;
  40081. private _buttonRightStick;
  40082. private _dPadUp;
  40083. private _dPadDown;
  40084. private _dPadLeft;
  40085. private _dPadRight;
  40086. private _isXboxOnePad;
  40087. /**
  40088. * Creates a new XBox360 gamepad object
  40089. * @param id defines the id of this gamepad
  40090. * @param index defines its index
  40091. * @param gamepad defines the internal HTML gamepad object
  40092. * @param xboxOne defines if it is a XBox One gamepad
  40093. */
  40094. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40095. /**
  40096. * Defines the callback to call when left trigger is pressed
  40097. * @param callback defines the callback to use
  40098. */
  40099. onlefttriggerchanged(callback: (value: number) => void): void;
  40100. /**
  40101. * Defines the callback to call when right trigger is pressed
  40102. * @param callback defines the callback to use
  40103. */
  40104. onrighttriggerchanged(callback: (value: number) => void): void;
  40105. /**
  40106. * Gets the left trigger value
  40107. */
  40108. /**
  40109. * Sets the left trigger value
  40110. */
  40111. leftTrigger: number;
  40112. /**
  40113. * Gets the right trigger value
  40114. */
  40115. /**
  40116. * Sets the right trigger value
  40117. */
  40118. rightTrigger: number;
  40119. /**
  40120. * Defines the callback to call when a button is pressed
  40121. * @param callback defines the callback to use
  40122. */
  40123. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40124. /**
  40125. * Defines the callback to call when a button is released
  40126. * @param callback defines the callback to use
  40127. */
  40128. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40129. /**
  40130. * Defines the callback to call when a pad is pressed
  40131. * @param callback defines the callback to use
  40132. */
  40133. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40134. /**
  40135. * Defines the callback to call when a pad is released
  40136. * @param callback defines the callback to use
  40137. */
  40138. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40139. private _setButtonValue;
  40140. private _setDPadValue;
  40141. /**
  40142. * Gets the value of the `A` button
  40143. */
  40144. /**
  40145. * Sets the value of the `A` button
  40146. */
  40147. buttonA: number;
  40148. /**
  40149. * Gets the value of the `B` button
  40150. */
  40151. /**
  40152. * Sets the value of the `B` button
  40153. */
  40154. buttonB: number;
  40155. /**
  40156. * Gets the value of the `X` button
  40157. */
  40158. /**
  40159. * Sets the value of the `X` button
  40160. */
  40161. buttonX: number;
  40162. /**
  40163. * Gets the value of the `Y` button
  40164. */
  40165. /**
  40166. * Sets the value of the `Y` button
  40167. */
  40168. buttonY: number;
  40169. /**
  40170. * Gets the value of the `Start` button
  40171. */
  40172. /**
  40173. * Sets the value of the `Start` button
  40174. */
  40175. buttonStart: number;
  40176. /**
  40177. * Gets the value of the `Back` button
  40178. */
  40179. /**
  40180. * Sets the value of the `Back` button
  40181. */
  40182. buttonBack: number;
  40183. /**
  40184. * Gets the value of the `Left` button
  40185. */
  40186. /**
  40187. * Sets the value of the `Left` button
  40188. */
  40189. buttonLB: number;
  40190. /**
  40191. * Gets the value of the `Right` button
  40192. */
  40193. /**
  40194. * Sets the value of the `Right` button
  40195. */
  40196. buttonRB: number;
  40197. /**
  40198. * Gets the value of the Left joystick
  40199. */
  40200. /**
  40201. * Sets the value of the Left joystick
  40202. */
  40203. buttonLeftStick: number;
  40204. /**
  40205. * Gets the value of the Right joystick
  40206. */
  40207. /**
  40208. * Sets the value of the Right joystick
  40209. */
  40210. buttonRightStick: number;
  40211. /**
  40212. * Gets the value of D-pad up
  40213. */
  40214. /**
  40215. * Sets the value of D-pad up
  40216. */
  40217. dPadUp: number;
  40218. /**
  40219. * Gets the value of D-pad down
  40220. */
  40221. /**
  40222. * Sets the value of D-pad down
  40223. */
  40224. dPadDown: number;
  40225. /**
  40226. * Gets the value of D-pad left
  40227. */
  40228. /**
  40229. * Sets the value of D-pad left
  40230. */
  40231. dPadLeft: number;
  40232. /**
  40233. * Gets the value of D-pad right
  40234. */
  40235. /**
  40236. * Sets the value of D-pad right
  40237. */
  40238. dPadRight: number;
  40239. /**
  40240. * Force the gamepad to synchronize with device values
  40241. */
  40242. update(): void;
  40243. /**
  40244. * Disposes the gamepad
  40245. */
  40246. dispose(): void;
  40247. }
  40248. }
  40249. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40250. import { Observable } from "babylonjs/Misc/observable";
  40251. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40252. /**
  40253. * Defines supported buttons for DualShock compatible gamepads
  40254. */
  40255. export enum DualShockButton {
  40256. /** Cross */
  40257. Cross = 0,
  40258. /** Circle */
  40259. Circle = 1,
  40260. /** Square */
  40261. Square = 2,
  40262. /** Triangle */
  40263. Triangle = 3,
  40264. /** Options */
  40265. Options = 4,
  40266. /** Share */
  40267. Share = 5,
  40268. /** L1 */
  40269. L1 = 6,
  40270. /** R1 */
  40271. R1 = 7,
  40272. /** Left stick */
  40273. LeftStick = 8,
  40274. /** Right stick */
  40275. RightStick = 9
  40276. }
  40277. /** Defines values for DualShock DPad */
  40278. export enum DualShockDpad {
  40279. /** Up */
  40280. Up = 0,
  40281. /** Down */
  40282. Down = 1,
  40283. /** Left */
  40284. Left = 2,
  40285. /** Right */
  40286. Right = 3
  40287. }
  40288. /**
  40289. * Defines a DualShock gamepad
  40290. */
  40291. export class DualShockPad extends Gamepad {
  40292. private _leftTrigger;
  40293. private _rightTrigger;
  40294. private _onlefttriggerchanged;
  40295. private _onrighttriggerchanged;
  40296. private _onbuttondown;
  40297. private _onbuttonup;
  40298. private _ondpaddown;
  40299. private _ondpadup;
  40300. /** Observable raised when a button is pressed */
  40301. onButtonDownObservable: Observable<DualShockButton>;
  40302. /** Observable raised when a button is released */
  40303. onButtonUpObservable: Observable<DualShockButton>;
  40304. /** Observable raised when a pad is pressed */
  40305. onPadDownObservable: Observable<DualShockDpad>;
  40306. /** Observable raised when a pad is released */
  40307. onPadUpObservable: Observable<DualShockDpad>;
  40308. private _buttonCross;
  40309. private _buttonCircle;
  40310. private _buttonSquare;
  40311. private _buttonTriangle;
  40312. private _buttonShare;
  40313. private _buttonOptions;
  40314. private _buttonL1;
  40315. private _buttonR1;
  40316. private _buttonLeftStick;
  40317. private _buttonRightStick;
  40318. private _dPadUp;
  40319. private _dPadDown;
  40320. private _dPadLeft;
  40321. private _dPadRight;
  40322. /**
  40323. * Creates a new DualShock gamepad object
  40324. * @param id defines the id of this gamepad
  40325. * @param index defines its index
  40326. * @param gamepad defines the internal HTML gamepad object
  40327. */
  40328. constructor(id: string, index: number, gamepad: any);
  40329. /**
  40330. * Defines the callback to call when left trigger is pressed
  40331. * @param callback defines the callback to use
  40332. */
  40333. onlefttriggerchanged(callback: (value: number) => void): void;
  40334. /**
  40335. * Defines the callback to call when right trigger is pressed
  40336. * @param callback defines the callback to use
  40337. */
  40338. onrighttriggerchanged(callback: (value: number) => void): void;
  40339. /**
  40340. * Gets the left trigger value
  40341. */
  40342. /**
  40343. * Sets the left trigger value
  40344. */
  40345. leftTrigger: number;
  40346. /**
  40347. * Gets the right trigger value
  40348. */
  40349. /**
  40350. * Sets the right trigger value
  40351. */
  40352. rightTrigger: number;
  40353. /**
  40354. * Defines the callback to call when a button is pressed
  40355. * @param callback defines the callback to use
  40356. */
  40357. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40358. /**
  40359. * Defines the callback to call when a button is released
  40360. * @param callback defines the callback to use
  40361. */
  40362. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40363. /**
  40364. * Defines the callback to call when a pad is pressed
  40365. * @param callback defines the callback to use
  40366. */
  40367. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40368. /**
  40369. * Defines the callback to call when a pad is released
  40370. * @param callback defines the callback to use
  40371. */
  40372. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40373. private _setButtonValue;
  40374. private _setDPadValue;
  40375. /**
  40376. * Gets the value of the `Cross` button
  40377. */
  40378. /**
  40379. * Sets the value of the `Cross` button
  40380. */
  40381. buttonCross: number;
  40382. /**
  40383. * Gets the value of the `Circle` button
  40384. */
  40385. /**
  40386. * Sets the value of the `Circle` button
  40387. */
  40388. buttonCircle: number;
  40389. /**
  40390. * Gets the value of the `Square` button
  40391. */
  40392. /**
  40393. * Sets the value of the `Square` button
  40394. */
  40395. buttonSquare: number;
  40396. /**
  40397. * Gets the value of the `Triangle` button
  40398. */
  40399. /**
  40400. * Sets the value of the `Triangle` button
  40401. */
  40402. buttonTriangle: number;
  40403. /**
  40404. * Gets the value of the `Options` button
  40405. */
  40406. /**
  40407. * Sets the value of the `Options` button
  40408. */
  40409. buttonOptions: number;
  40410. /**
  40411. * Gets the value of the `Share` button
  40412. */
  40413. /**
  40414. * Sets the value of the `Share` button
  40415. */
  40416. buttonShare: number;
  40417. /**
  40418. * Gets the value of the `L1` button
  40419. */
  40420. /**
  40421. * Sets the value of the `L1` button
  40422. */
  40423. buttonL1: number;
  40424. /**
  40425. * Gets the value of the `R1` button
  40426. */
  40427. /**
  40428. * Sets the value of the `R1` button
  40429. */
  40430. buttonR1: number;
  40431. /**
  40432. * Gets the value of the Left joystick
  40433. */
  40434. /**
  40435. * Sets the value of the Left joystick
  40436. */
  40437. buttonLeftStick: number;
  40438. /**
  40439. * Gets the value of the Right joystick
  40440. */
  40441. /**
  40442. * Sets the value of the Right joystick
  40443. */
  40444. buttonRightStick: number;
  40445. /**
  40446. * Gets the value of D-pad up
  40447. */
  40448. /**
  40449. * Sets the value of D-pad up
  40450. */
  40451. dPadUp: number;
  40452. /**
  40453. * Gets the value of D-pad down
  40454. */
  40455. /**
  40456. * Sets the value of D-pad down
  40457. */
  40458. dPadDown: number;
  40459. /**
  40460. * Gets the value of D-pad left
  40461. */
  40462. /**
  40463. * Sets the value of D-pad left
  40464. */
  40465. dPadLeft: number;
  40466. /**
  40467. * Gets the value of D-pad right
  40468. */
  40469. /**
  40470. * Sets the value of D-pad right
  40471. */
  40472. dPadRight: number;
  40473. /**
  40474. * Force the gamepad to synchronize with device values
  40475. */
  40476. update(): void;
  40477. /**
  40478. * Disposes the gamepad
  40479. */
  40480. dispose(): void;
  40481. }
  40482. }
  40483. declare module "babylonjs/Gamepads/gamepadManager" {
  40484. import { Observable } from "babylonjs/Misc/observable";
  40485. import { Nullable } from "babylonjs/types";
  40486. import { Scene } from "babylonjs/scene";
  40487. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40488. /**
  40489. * Manager for handling gamepads
  40490. */
  40491. export class GamepadManager {
  40492. private _scene?;
  40493. private _babylonGamepads;
  40494. private _oneGamepadConnected;
  40495. /** @hidden */
  40496. _isMonitoring: boolean;
  40497. private _gamepadEventSupported;
  40498. private _gamepadSupport;
  40499. /**
  40500. * observable to be triggered when the gamepad controller has been connected
  40501. */
  40502. onGamepadConnectedObservable: Observable<Gamepad>;
  40503. /**
  40504. * observable to be triggered when the gamepad controller has been disconnected
  40505. */
  40506. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40507. private _onGamepadConnectedEvent;
  40508. private _onGamepadDisconnectedEvent;
  40509. /**
  40510. * Initializes the gamepad manager
  40511. * @param _scene BabylonJS scene
  40512. */
  40513. constructor(_scene?: Scene | undefined);
  40514. /**
  40515. * The gamepads in the game pad manager
  40516. */
  40517. readonly gamepads: Gamepad[];
  40518. /**
  40519. * Get the gamepad controllers based on type
  40520. * @param type The type of gamepad controller
  40521. * @returns Nullable gamepad
  40522. */
  40523. getGamepadByType(type?: number): Nullable<Gamepad>;
  40524. /**
  40525. * Disposes the gamepad manager
  40526. */
  40527. dispose(): void;
  40528. private _addNewGamepad;
  40529. private _startMonitoringGamepads;
  40530. private _stopMonitoringGamepads;
  40531. /** @hidden */
  40532. _checkGamepadsStatus(): void;
  40533. private _updateGamepadObjects;
  40534. }
  40535. }
  40536. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40537. import { Nullable } from "babylonjs/types";
  40538. import { Scene } from "babylonjs/scene";
  40539. import { ISceneComponent } from "babylonjs/sceneComponent";
  40540. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40541. module "babylonjs/scene" {
  40542. interface Scene {
  40543. /** @hidden */
  40544. _gamepadManager: Nullable<GamepadManager>;
  40545. /**
  40546. * Gets the gamepad manager associated with the scene
  40547. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40548. */
  40549. gamepadManager: GamepadManager;
  40550. }
  40551. }
  40552. module "babylonjs/Cameras/freeCameraInputsManager" {
  40553. /**
  40554. * Interface representing a free camera inputs manager
  40555. */
  40556. interface FreeCameraInputsManager {
  40557. /**
  40558. * Adds gamepad input support to the FreeCameraInputsManager.
  40559. * @returns the FreeCameraInputsManager
  40560. */
  40561. addGamepad(): FreeCameraInputsManager;
  40562. }
  40563. }
  40564. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40565. /**
  40566. * Interface representing an arc rotate camera inputs manager
  40567. */
  40568. interface ArcRotateCameraInputsManager {
  40569. /**
  40570. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40571. * @returns the camera inputs manager
  40572. */
  40573. addGamepad(): ArcRotateCameraInputsManager;
  40574. }
  40575. }
  40576. /**
  40577. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40578. */
  40579. export class GamepadSystemSceneComponent implements ISceneComponent {
  40580. /**
  40581. * The component name helpfull to identify the component in the list of scene components.
  40582. */
  40583. readonly name: string;
  40584. /**
  40585. * The scene the component belongs to.
  40586. */
  40587. scene: Scene;
  40588. /**
  40589. * Creates a new instance of the component for the given scene
  40590. * @param scene Defines the scene to register the component in
  40591. */
  40592. constructor(scene: Scene);
  40593. /**
  40594. * Registers the component in a given scene
  40595. */
  40596. register(): void;
  40597. /**
  40598. * Rebuilds the elements related to this component in case of
  40599. * context lost for instance.
  40600. */
  40601. rebuild(): void;
  40602. /**
  40603. * Disposes the component and the associated ressources
  40604. */
  40605. dispose(): void;
  40606. private _beforeCameraUpdate;
  40607. }
  40608. }
  40609. declare module "babylonjs/Cameras/universalCamera" {
  40610. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40611. import { Scene } from "babylonjs/scene";
  40612. import { Vector3 } from "babylonjs/Maths/math.vector";
  40613. import "babylonjs/Gamepads/gamepadSceneComponent";
  40614. /**
  40615. * 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,
  40616. * which still works and will still be found in many Playgrounds.
  40617. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40618. */
  40619. export class UniversalCamera extends TouchCamera {
  40620. /**
  40621. * Defines the gamepad rotation sensiblity.
  40622. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40623. */
  40624. gamepadAngularSensibility: number;
  40625. /**
  40626. * Defines the gamepad move sensiblity.
  40627. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40628. */
  40629. gamepadMoveSensibility: number;
  40630. /**
  40631. * 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,
  40632. * which still works and will still be found in many Playgrounds.
  40633. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40634. * @param name Define the name of the camera in the scene
  40635. * @param position Define the start position of the camera in the scene
  40636. * @param scene Define the scene the camera belongs to
  40637. */
  40638. constructor(name: string, position: Vector3, scene: Scene);
  40639. /**
  40640. * Gets the current object class name.
  40641. * @return the class name
  40642. */
  40643. getClassName(): string;
  40644. }
  40645. }
  40646. declare module "babylonjs/Cameras/gamepadCamera" {
  40647. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40648. import { Scene } from "babylonjs/scene";
  40649. import { Vector3 } from "babylonjs/Maths/math.vector";
  40650. /**
  40651. * This represents a FPS type of camera. This is only here for back compat purpose.
  40652. * Please use the UniversalCamera instead as both are identical.
  40653. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40654. */
  40655. export class GamepadCamera extends UniversalCamera {
  40656. /**
  40657. * Instantiates a new Gamepad Camera
  40658. * This represents a FPS type of camera. This is only here for back compat purpose.
  40659. * Please use the UniversalCamera instead as both are identical.
  40660. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40661. * @param name Define the name of the camera in the scene
  40662. * @param position Define the start position of the camera in the scene
  40663. * @param scene Define the scene the camera belongs to
  40664. */
  40665. constructor(name: string, position: Vector3, scene: Scene);
  40666. /**
  40667. * Gets the current object class name.
  40668. * @return the class name
  40669. */
  40670. getClassName(): string;
  40671. }
  40672. }
  40673. declare module "babylonjs/Shaders/pass.fragment" {
  40674. /** @hidden */
  40675. export var passPixelShader: {
  40676. name: string;
  40677. shader: string;
  40678. };
  40679. }
  40680. declare module "babylonjs/Shaders/passCube.fragment" {
  40681. /** @hidden */
  40682. export var passCubePixelShader: {
  40683. name: string;
  40684. shader: string;
  40685. };
  40686. }
  40687. declare module "babylonjs/PostProcesses/passPostProcess" {
  40688. import { Nullable } from "babylonjs/types";
  40689. import { Camera } from "babylonjs/Cameras/camera";
  40690. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40691. import { Engine } from "babylonjs/Engines/engine";
  40692. import "babylonjs/Shaders/pass.fragment";
  40693. import "babylonjs/Shaders/passCube.fragment";
  40694. /**
  40695. * PassPostProcess which produces an output the same as it's input
  40696. */
  40697. export class PassPostProcess extends PostProcess {
  40698. /**
  40699. * Creates the PassPostProcess
  40700. * @param name The name of the effect.
  40701. * @param options The required width/height ratio to downsize to before computing the render pass.
  40702. * @param camera The camera to apply the render pass to.
  40703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40704. * @param engine The engine which the post process will be applied. (default: current engine)
  40705. * @param reusable If the post process can be reused on the same frame. (default: false)
  40706. * @param textureType The type of texture to be used when performing the post processing.
  40707. * @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)
  40708. */
  40709. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40710. }
  40711. /**
  40712. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40713. */
  40714. export class PassCubePostProcess extends PostProcess {
  40715. private _face;
  40716. /**
  40717. * Gets or sets the cube face to display.
  40718. * * 0 is +X
  40719. * * 1 is -X
  40720. * * 2 is +Y
  40721. * * 3 is -Y
  40722. * * 4 is +Z
  40723. * * 5 is -Z
  40724. */
  40725. face: number;
  40726. /**
  40727. * Creates the PassCubePostProcess
  40728. * @param name The name of the effect.
  40729. * @param options The required width/height ratio to downsize to before computing the render pass.
  40730. * @param camera The camera to apply the render pass to.
  40731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40732. * @param engine The engine which the post process will be applied. (default: current engine)
  40733. * @param reusable If the post process can be reused on the same frame. (default: false)
  40734. * @param textureType The type of texture to be used when performing the post processing.
  40735. * @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)
  40736. */
  40737. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40738. }
  40739. }
  40740. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40741. /** @hidden */
  40742. export var anaglyphPixelShader: {
  40743. name: string;
  40744. shader: string;
  40745. };
  40746. }
  40747. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40748. import { Engine } from "babylonjs/Engines/engine";
  40749. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40750. import { Camera } from "babylonjs/Cameras/camera";
  40751. import "babylonjs/Shaders/anaglyph.fragment";
  40752. /**
  40753. * Postprocess used to generate anaglyphic rendering
  40754. */
  40755. export class AnaglyphPostProcess extends PostProcess {
  40756. private _passedProcess;
  40757. /**
  40758. * Creates a new AnaglyphPostProcess
  40759. * @param name defines postprocess name
  40760. * @param options defines creation options or target ratio scale
  40761. * @param rigCameras defines cameras using this postprocess
  40762. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40763. * @param engine defines hosting engine
  40764. * @param reusable defines if the postprocess will be reused multiple times per frame
  40765. */
  40766. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40767. }
  40768. }
  40769. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40770. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40771. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40772. import { Scene } from "babylonjs/scene";
  40773. import { Vector3 } from "babylonjs/Maths/math.vector";
  40774. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40775. /**
  40776. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40777. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40778. */
  40779. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40780. /**
  40781. * Creates a new AnaglyphArcRotateCamera
  40782. * @param name defines camera name
  40783. * @param alpha defines alpha angle (in radians)
  40784. * @param beta defines beta angle (in radians)
  40785. * @param radius defines radius
  40786. * @param target defines camera target
  40787. * @param interaxialDistance defines distance between each color axis
  40788. * @param scene defines the hosting scene
  40789. */
  40790. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40791. /**
  40792. * Gets camera class name
  40793. * @returns AnaglyphArcRotateCamera
  40794. */
  40795. getClassName(): string;
  40796. }
  40797. }
  40798. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40799. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40800. import { Scene } from "babylonjs/scene";
  40801. import { Vector3 } from "babylonjs/Maths/math.vector";
  40802. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40803. /**
  40804. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40805. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40806. */
  40807. export class AnaglyphFreeCamera extends FreeCamera {
  40808. /**
  40809. * Creates a new AnaglyphFreeCamera
  40810. * @param name defines camera name
  40811. * @param position defines initial position
  40812. * @param interaxialDistance defines distance between each color axis
  40813. * @param scene defines the hosting scene
  40814. */
  40815. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40816. /**
  40817. * Gets camera class name
  40818. * @returns AnaglyphFreeCamera
  40819. */
  40820. getClassName(): string;
  40821. }
  40822. }
  40823. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40824. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40825. import { Scene } from "babylonjs/scene";
  40826. import { Vector3 } from "babylonjs/Maths/math.vector";
  40827. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40828. /**
  40829. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40830. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40831. */
  40832. export class AnaglyphGamepadCamera extends GamepadCamera {
  40833. /**
  40834. * Creates a new AnaglyphGamepadCamera
  40835. * @param name defines camera name
  40836. * @param position defines initial position
  40837. * @param interaxialDistance defines distance between each color axis
  40838. * @param scene defines the hosting scene
  40839. */
  40840. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40841. /**
  40842. * Gets camera class name
  40843. * @returns AnaglyphGamepadCamera
  40844. */
  40845. getClassName(): string;
  40846. }
  40847. }
  40848. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40849. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40850. import { Scene } from "babylonjs/scene";
  40851. import { Vector3 } from "babylonjs/Maths/math.vector";
  40852. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40853. /**
  40854. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40855. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40856. */
  40857. export class AnaglyphUniversalCamera extends UniversalCamera {
  40858. /**
  40859. * Creates a new AnaglyphUniversalCamera
  40860. * @param name defines camera name
  40861. * @param position defines initial position
  40862. * @param interaxialDistance defines distance between each color axis
  40863. * @param scene defines the hosting scene
  40864. */
  40865. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40866. /**
  40867. * Gets camera class name
  40868. * @returns AnaglyphUniversalCamera
  40869. */
  40870. getClassName(): string;
  40871. }
  40872. }
  40873. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40874. /** @hidden */
  40875. export var stereoscopicInterlacePixelShader: {
  40876. name: string;
  40877. shader: string;
  40878. };
  40879. }
  40880. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40881. import { Camera } from "babylonjs/Cameras/camera";
  40882. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40883. import { Engine } from "babylonjs/Engines/engine";
  40884. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40885. /**
  40886. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40887. */
  40888. export class StereoscopicInterlacePostProcess extends PostProcess {
  40889. private _stepSize;
  40890. private _passedProcess;
  40891. /**
  40892. * Initializes a StereoscopicInterlacePostProcess
  40893. * @param name The name of the effect.
  40894. * @param rigCameras The rig cameras to be appled to the post process
  40895. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40897. * @param engine The engine which the post process will be applied. (default: current engine)
  40898. * @param reusable If the post process can be reused on the same frame. (default: false)
  40899. */
  40900. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40901. }
  40902. }
  40903. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40904. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40905. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40906. import { Scene } from "babylonjs/scene";
  40907. import { Vector3 } from "babylonjs/Maths/math.vector";
  40908. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40909. /**
  40910. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40911. * @see http://doc.babylonjs.com/features/cameras
  40912. */
  40913. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40914. /**
  40915. * Creates a new StereoscopicArcRotateCamera
  40916. * @param name defines camera name
  40917. * @param alpha defines alpha angle (in radians)
  40918. * @param beta defines beta angle (in radians)
  40919. * @param radius defines radius
  40920. * @param target defines camera target
  40921. * @param interaxialDistance defines distance between each color axis
  40922. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40923. * @param scene defines the hosting scene
  40924. */
  40925. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40926. /**
  40927. * Gets camera class name
  40928. * @returns StereoscopicArcRotateCamera
  40929. */
  40930. getClassName(): string;
  40931. }
  40932. }
  40933. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40934. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40935. import { Scene } from "babylonjs/scene";
  40936. import { Vector3 } from "babylonjs/Maths/math.vector";
  40937. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40938. /**
  40939. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40940. * @see http://doc.babylonjs.com/features/cameras
  40941. */
  40942. export class StereoscopicFreeCamera extends FreeCamera {
  40943. /**
  40944. * Creates a new StereoscopicFreeCamera
  40945. * @param name defines camera name
  40946. * @param position defines initial position
  40947. * @param interaxialDistance defines distance between each color axis
  40948. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40949. * @param scene defines the hosting scene
  40950. */
  40951. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40952. /**
  40953. * Gets camera class name
  40954. * @returns StereoscopicFreeCamera
  40955. */
  40956. getClassName(): string;
  40957. }
  40958. }
  40959. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40960. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40961. import { Scene } from "babylonjs/scene";
  40962. import { Vector3 } from "babylonjs/Maths/math.vector";
  40963. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40964. /**
  40965. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40966. * @see http://doc.babylonjs.com/features/cameras
  40967. */
  40968. export class StereoscopicGamepadCamera extends GamepadCamera {
  40969. /**
  40970. * Creates a new StereoscopicGamepadCamera
  40971. * @param name defines camera name
  40972. * @param position defines initial position
  40973. * @param interaxialDistance defines distance between each color axis
  40974. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40975. * @param scene defines the hosting scene
  40976. */
  40977. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40978. /**
  40979. * Gets camera class name
  40980. * @returns StereoscopicGamepadCamera
  40981. */
  40982. getClassName(): string;
  40983. }
  40984. }
  40985. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40986. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40987. import { Scene } from "babylonjs/scene";
  40988. import { Vector3 } from "babylonjs/Maths/math.vector";
  40989. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40990. /**
  40991. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40992. * @see http://doc.babylonjs.com/features/cameras
  40993. */
  40994. export class StereoscopicUniversalCamera extends UniversalCamera {
  40995. /**
  40996. * Creates a new StereoscopicUniversalCamera
  40997. * @param name defines camera name
  40998. * @param position defines initial position
  40999. * @param interaxialDistance defines distance between each color axis
  41000. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41001. * @param scene defines the hosting scene
  41002. */
  41003. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41004. /**
  41005. * Gets camera class name
  41006. * @returns StereoscopicUniversalCamera
  41007. */
  41008. getClassName(): string;
  41009. }
  41010. }
  41011. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41012. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41013. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41014. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41015. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41016. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41017. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41018. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41019. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41020. }
  41021. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41022. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41023. import { Scene } from "babylonjs/scene";
  41024. import { Vector3 } from "babylonjs/Maths/math.vector";
  41025. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41026. /**
  41027. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41028. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41029. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41030. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41031. */
  41032. export class VirtualJoysticksCamera extends FreeCamera {
  41033. /**
  41034. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41035. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41036. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41037. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41038. * @param name Define the name of the camera in the scene
  41039. * @param position Define the start position of the camera in the scene
  41040. * @param scene Define the scene the camera belongs to
  41041. */
  41042. constructor(name: string, position: Vector3, scene: Scene);
  41043. /**
  41044. * Gets the current object class name.
  41045. * @return the class name
  41046. */
  41047. getClassName(): string;
  41048. }
  41049. }
  41050. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41051. import { Matrix } from "babylonjs/Maths/math.vector";
  41052. /**
  41053. * This represents all the required metrics to create a VR camera.
  41054. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41055. */
  41056. export class VRCameraMetrics {
  41057. /**
  41058. * Define the horizontal resolution off the screen.
  41059. */
  41060. hResolution: number;
  41061. /**
  41062. * Define the vertical resolution off the screen.
  41063. */
  41064. vResolution: number;
  41065. /**
  41066. * Define the horizontal screen size.
  41067. */
  41068. hScreenSize: number;
  41069. /**
  41070. * Define the vertical screen size.
  41071. */
  41072. vScreenSize: number;
  41073. /**
  41074. * Define the vertical screen center position.
  41075. */
  41076. vScreenCenter: number;
  41077. /**
  41078. * Define the distance of the eyes to the screen.
  41079. */
  41080. eyeToScreenDistance: number;
  41081. /**
  41082. * Define the distance between both lenses
  41083. */
  41084. lensSeparationDistance: number;
  41085. /**
  41086. * Define the distance between both viewer's eyes.
  41087. */
  41088. interpupillaryDistance: number;
  41089. /**
  41090. * Define the distortion factor of the VR postprocess.
  41091. * Please, touch with care.
  41092. */
  41093. distortionK: number[];
  41094. /**
  41095. * Define the chromatic aberration correction factors for the VR post process.
  41096. */
  41097. chromaAbCorrection: number[];
  41098. /**
  41099. * Define the scale factor of the post process.
  41100. * The smaller the better but the slower.
  41101. */
  41102. postProcessScaleFactor: number;
  41103. /**
  41104. * Define an offset for the lens center.
  41105. */
  41106. lensCenterOffset: number;
  41107. /**
  41108. * Define if the current vr camera should compensate the distortion of the lense or not.
  41109. */
  41110. compensateDistortion: boolean;
  41111. /**
  41112. * Defines if multiview should be enabled when rendering (Default: false)
  41113. */
  41114. multiviewEnabled: boolean;
  41115. /**
  41116. * Gets the rendering aspect ratio based on the provided resolutions.
  41117. */
  41118. readonly aspectRatio: number;
  41119. /**
  41120. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41121. */
  41122. readonly aspectRatioFov: number;
  41123. /**
  41124. * @hidden
  41125. */
  41126. readonly leftHMatrix: Matrix;
  41127. /**
  41128. * @hidden
  41129. */
  41130. readonly rightHMatrix: Matrix;
  41131. /**
  41132. * @hidden
  41133. */
  41134. readonly leftPreViewMatrix: Matrix;
  41135. /**
  41136. * @hidden
  41137. */
  41138. readonly rightPreViewMatrix: Matrix;
  41139. /**
  41140. * Get the default VRMetrics based on the most generic setup.
  41141. * @returns the default vr metrics
  41142. */
  41143. static GetDefault(): VRCameraMetrics;
  41144. }
  41145. }
  41146. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41147. /** @hidden */
  41148. export var vrDistortionCorrectionPixelShader: {
  41149. name: string;
  41150. shader: string;
  41151. };
  41152. }
  41153. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41154. import { Camera } from "babylonjs/Cameras/camera";
  41155. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41156. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41157. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41158. /**
  41159. * VRDistortionCorrectionPostProcess used for mobile VR
  41160. */
  41161. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41162. private _isRightEye;
  41163. private _distortionFactors;
  41164. private _postProcessScaleFactor;
  41165. private _lensCenterOffset;
  41166. private _scaleIn;
  41167. private _scaleFactor;
  41168. private _lensCenter;
  41169. /**
  41170. * Initializes the VRDistortionCorrectionPostProcess
  41171. * @param name The name of the effect.
  41172. * @param camera The camera to apply the render pass to.
  41173. * @param isRightEye If this is for the right eye distortion
  41174. * @param vrMetrics All the required metrics for the VR camera
  41175. */
  41176. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41177. }
  41178. }
  41179. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41180. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41181. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41182. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41183. import { Scene } from "babylonjs/scene";
  41184. import { Vector3 } from "babylonjs/Maths/math.vector";
  41185. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41186. import "babylonjs/Cameras/RigModes/vrRigMode";
  41187. /**
  41188. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41189. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41190. */
  41191. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41192. /**
  41193. * Creates a new VRDeviceOrientationArcRotateCamera
  41194. * @param name defines camera name
  41195. * @param alpha defines the camera rotation along the logitudinal axis
  41196. * @param beta defines the camera rotation along the latitudinal axis
  41197. * @param radius defines the camera distance from its target
  41198. * @param target defines the camera target
  41199. * @param scene defines the scene the camera belongs to
  41200. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41201. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41202. */
  41203. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41204. /**
  41205. * Gets camera class name
  41206. * @returns VRDeviceOrientationArcRotateCamera
  41207. */
  41208. getClassName(): string;
  41209. }
  41210. }
  41211. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41212. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41213. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41214. import { Scene } from "babylonjs/scene";
  41215. import { Vector3 } from "babylonjs/Maths/math.vector";
  41216. import "babylonjs/Cameras/RigModes/vrRigMode";
  41217. /**
  41218. * Camera used to simulate VR rendering (based on FreeCamera)
  41219. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41220. */
  41221. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41222. /**
  41223. * Creates a new VRDeviceOrientationFreeCamera
  41224. * @param name defines camera name
  41225. * @param position defines the start position of the camera
  41226. * @param scene defines the scene the camera belongs to
  41227. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41228. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41229. */
  41230. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41231. /**
  41232. * Gets camera class name
  41233. * @returns VRDeviceOrientationFreeCamera
  41234. */
  41235. getClassName(): string;
  41236. }
  41237. }
  41238. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41239. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41240. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41241. import { Scene } from "babylonjs/scene";
  41242. import { Vector3 } from "babylonjs/Maths/math.vector";
  41243. import "babylonjs/Gamepads/gamepadSceneComponent";
  41244. /**
  41245. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41246. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41247. */
  41248. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41249. /**
  41250. * Creates a new VRDeviceOrientationGamepadCamera
  41251. * @param name defines camera name
  41252. * @param position defines the start position of the camera
  41253. * @param scene defines the scene the camera belongs to
  41254. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41255. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41256. */
  41257. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41258. /**
  41259. * Gets camera class name
  41260. * @returns VRDeviceOrientationGamepadCamera
  41261. */
  41262. getClassName(): string;
  41263. }
  41264. }
  41265. declare module "babylonjs/Materials/pushMaterial" {
  41266. import { Nullable } from "babylonjs/types";
  41267. import { Scene } from "babylonjs/scene";
  41268. import { Matrix } from "babylonjs/Maths/math.vector";
  41269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41270. import { Mesh } from "babylonjs/Meshes/mesh";
  41271. import { Material } from "babylonjs/Materials/material";
  41272. import { Effect } from "babylonjs/Materials/effect";
  41273. /**
  41274. * Base class of materials working in push mode in babylon JS
  41275. * @hidden
  41276. */
  41277. export class PushMaterial extends Material {
  41278. protected _activeEffect: Effect;
  41279. protected _normalMatrix: Matrix;
  41280. /**
  41281. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41282. * This means that the material can keep using a previous shader while a new one is being compiled.
  41283. * This is mostly used when shader parallel compilation is supported (true by default)
  41284. */
  41285. allowShaderHotSwapping: boolean;
  41286. constructor(name: string, scene: Scene);
  41287. getEffect(): Effect;
  41288. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41289. /**
  41290. * Binds the given world matrix to the active effect
  41291. *
  41292. * @param world the matrix to bind
  41293. */
  41294. bindOnlyWorldMatrix(world: Matrix): void;
  41295. /**
  41296. * Binds the given normal matrix to the active effect
  41297. *
  41298. * @param normalMatrix the matrix to bind
  41299. */
  41300. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41301. bind(world: Matrix, mesh?: Mesh): void;
  41302. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41303. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41304. }
  41305. }
  41306. declare module "babylonjs/Materials/materialFlags" {
  41307. /**
  41308. * This groups all the flags used to control the materials channel.
  41309. */
  41310. export class MaterialFlags {
  41311. private static _DiffuseTextureEnabled;
  41312. /**
  41313. * Are diffuse textures enabled in the application.
  41314. */
  41315. static DiffuseTextureEnabled: boolean;
  41316. private static _AmbientTextureEnabled;
  41317. /**
  41318. * Are ambient textures enabled in the application.
  41319. */
  41320. static AmbientTextureEnabled: boolean;
  41321. private static _OpacityTextureEnabled;
  41322. /**
  41323. * Are opacity textures enabled in the application.
  41324. */
  41325. static OpacityTextureEnabled: boolean;
  41326. private static _ReflectionTextureEnabled;
  41327. /**
  41328. * Are reflection textures enabled in the application.
  41329. */
  41330. static ReflectionTextureEnabled: boolean;
  41331. private static _EmissiveTextureEnabled;
  41332. /**
  41333. * Are emissive textures enabled in the application.
  41334. */
  41335. static EmissiveTextureEnabled: boolean;
  41336. private static _SpecularTextureEnabled;
  41337. /**
  41338. * Are specular textures enabled in the application.
  41339. */
  41340. static SpecularTextureEnabled: boolean;
  41341. private static _BumpTextureEnabled;
  41342. /**
  41343. * Are bump textures enabled in the application.
  41344. */
  41345. static BumpTextureEnabled: boolean;
  41346. private static _LightmapTextureEnabled;
  41347. /**
  41348. * Are lightmap textures enabled in the application.
  41349. */
  41350. static LightmapTextureEnabled: boolean;
  41351. private static _RefractionTextureEnabled;
  41352. /**
  41353. * Are refraction textures enabled in the application.
  41354. */
  41355. static RefractionTextureEnabled: boolean;
  41356. private static _ColorGradingTextureEnabled;
  41357. /**
  41358. * Are color grading textures enabled in the application.
  41359. */
  41360. static ColorGradingTextureEnabled: boolean;
  41361. private static _FresnelEnabled;
  41362. /**
  41363. * Are fresnels enabled in the application.
  41364. */
  41365. static FresnelEnabled: boolean;
  41366. private static _ClearCoatTextureEnabled;
  41367. /**
  41368. * Are clear coat textures enabled in the application.
  41369. */
  41370. static ClearCoatTextureEnabled: boolean;
  41371. private static _ClearCoatBumpTextureEnabled;
  41372. /**
  41373. * Are clear coat bump textures enabled in the application.
  41374. */
  41375. static ClearCoatBumpTextureEnabled: boolean;
  41376. private static _ClearCoatTintTextureEnabled;
  41377. /**
  41378. * Are clear coat tint textures enabled in the application.
  41379. */
  41380. static ClearCoatTintTextureEnabled: boolean;
  41381. private static _SheenTextureEnabled;
  41382. /**
  41383. * Are sheen textures enabled in the application.
  41384. */
  41385. static SheenTextureEnabled: boolean;
  41386. private static _AnisotropicTextureEnabled;
  41387. /**
  41388. * Are anisotropic textures enabled in the application.
  41389. */
  41390. static AnisotropicTextureEnabled: boolean;
  41391. private static _ThicknessTextureEnabled;
  41392. /**
  41393. * Are thickness textures enabled in the application.
  41394. */
  41395. static ThicknessTextureEnabled: boolean;
  41396. }
  41397. }
  41398. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41399. /** @hidden */
  41400. export var defaultFragmentDeclaration: {
  41401. name: string;
  41402. shader: string;
  41403. };
  41404. }
  41405. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41406. /** @hidden */
  41407. export var defaultUboDeclaration: {
  41408. name: string;
  41409. shader: string;
  41410. };
  41411. }
  41412. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41413. /** @hidden */
  41414. export var lightFragmentDeclaration: {
  41415. name: string;
  41416. shader: string;
  41417. };
  41418. }
  41419. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41420. /** @hidden */
  41421. export var lightUboDeclaration: {
  41422. name: string;
  41423. shader: string;
  41424. };
  41425. }
  41426. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41427. /** @hidden */
  41428. export var lightsFragmentFunctions: {
  41429. name: string;
  41430. shader: string;
  41431. };
  41432. }
  41433. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41434. /** @hidden */
  41435. export var shadowsFragmentFunctions: {
  41436. name: string;
  41437. shader: string;
  41438. };
  41439. }
  41440. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41441. /** @hidden */
  41442. export var fresnelFunction: {
  41443. name: string;
  41444. shader: string;
  41445. };
  41446. }
  41447. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41448. /** @hidden */
  41449. export var reflectionFunction: {
  41450. name: string;
  41451. shader: string;
  41452. };
  41453. }
  41454. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41455. /** @hidden */
  41456. export var bumpFragmentFunctions: {
  41457. name: string;
  41458. shader: string;
  41459. };
  41460. }
  41461. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41462. /** @hidden */
  41463. export var logDepthDeclaration: {
  41464. name: string;
  41465. shader: string;
  41466. };
  41467. }
  41468. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41469. /** @hidden */
  41470. export var bumpFragment: {
  41471. name: string;
  41472. shader: string;
  41473. };
  41474. }
  41475. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41476. /** @hidden */
  41477. export var depthPrePass: {
  41478. name: string;
  41479. shader: string;
  41480. };
  41481. }
  41482. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41483. /** @hidden */
  41484. export var lightFragment: {
  41485. name: string;
  41486. shader: string;
  41487. };
  41488. }
  41489. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41490. /** @hidden */
  41491. export var logDepthFragment: {
  41492. name: string;
  41493. shader: string;
  41494. };
  41495. }
  41496. declare module "babylonjs/Shaders/default.fragment" {
  41497. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41498. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41499. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41500. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41501. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41502. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41503. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41504. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41505. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41506. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41507. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41508. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41509. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41510. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41511. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41512. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41513. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41514. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41515. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41516. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41517. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41518. /** @hidden */
  41519. export var defaultPixelShader: {
  41520. name: string;
  41521. shader: string;
  41522. };
  41523. }
  41524. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41525. /** @hidden */
  41526. export var defaultVertexDeclaration: {
  41527. name: string;
  41528. shader: string;
  41529. };
  41530. }
  41531. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41532. /** @hidden */
  41533. export var bumpVertexDeclaration: {
  41534. name: string;
  41535. shader: string;
  41536. };
  41537. }
  41538. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41539. /** @hidden */
  41540. export var bumpVertex: {
  41541. name: string;
  41542. shader: string;
  41543. };
  41544. }
  41545. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41546. /** @hidden */
  41547. export var fogVertex: {
  41548. name: string;
  41549. shader: string;
  41550. };
  41551. }
  41552. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41553. /** @hidden */
  41554. export var shadowsVertex: {
  41555. name: string;
  41556. shader: string;
  41557. };
  41558. }
  41559. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41560. /** @hidden */
  41561. export var pointCloudVertex: {
  41562. name: string;
  41563. shader: string;
  41564. };
  41565. }
  41566. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41567. /** @hidden */
  41568. export var logDepthVertex: {
  41569. name: string;
  41570. shader: string;
  41571. };
  41572. }
  41573. declare module "babylonjs/Shaders/default.vertex" {
  41574. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41575. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41576. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41577. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41578. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41579. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41580. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41581. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41582. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41583. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41584. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41585. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41586. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41587. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41588. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41589. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41590. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41591. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41592. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41593. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41594. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41595. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41596. /** @hidden */
  41597. export var defaultVertexShader: {
  41598. name: string;
  41599. shader: string;
  41600. };
  41601. }
  41602. declare module "babylonjs/Materials/standardMaterial" {
  41603. import { SmartArray } from "babylonjs/Misc/smartArray";
  41604. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41605. import { Nullable } from "babylonjs/types";
  41606. import { Scene } from "babylonjs/scene";
  41607. import { Matrix } from "babylonjs/Maths/math.vector";
  41608. import { Color3 } from "babylonjs/Maths/math.color";
  41609. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41611. import { Mesh } from "babylonjs/Meshes/mesh";
  41612. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41613. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41614. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41615. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41616. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41619. import "babylonjs/Shaders/default.fragment";
  41620. import "babylonjs/Shaders/default.vertex";
  41621. /** @hidden */
  41622. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41623. MAINUV1: boolean;
  41624. MAINUV2: boolean;
  41625. DIFFUSE: boolean;
  41626. DIFFUSEDIRECTUV: number;
  41627. AMBIENT: boolean;
  41628. AMBIENTDIRECTUV: number;
  41629. OPACITY: boolean;
  41630. OPACITYDIRECTUV: number;
  41631. OPACITYRGB: boolean;
  41632. REFLECTION: boolean;
  41633. EMISSIVE: boolean;
  41634. EMISSIVEDIRECTUV: number;
  41635. SPECULAR: boolean;
  41636. SPECULARDIRECTUV: number;
  41637. BUMP: boolean;
  41638. BUMPDIRECTUV: number;
  41639. PARALLAX: boolean;
  41640. PARALLAXOCCLUSION: boolean;
  41641. SPECULAROVERALPHA: boolean;
  41642. CLIPPLANE: boolean;
  41643. CLIPPLANE2: boolean;
  41644. CLIPPLANE3: boolean;
  41645. CLIPPLANE4: boolean;
  41646. ALPHATEST: boolean;
  41647. DEPTHPREPASS: boolean;
  41648. ALPHAFROMDIFFUSE: boolean;
  41649. POINTSIZE: boolean;
  41650. FOG: boolean;
  41651. SPECULARTERM: boolean;
  41652. DIFFUSEFRESNEL: boolean;
  41653. OPACITYFRESNEL: boolean;
  41654. REFLECTIONFRESNEL: boolean;
  41655. REFRACTIONFRESNEL: boolean;
  41656. EMISSIVEFRESNEL: boolean;
  41657. FRESNEL: boolean;
  41658. NORMAL: boolean;
  41659. UV1: boolean;
  41660. UV2: boolean;
  41661. VERTEXCOLOR: boolean;
  41662. VERTEXALPHA: boolean;
  41663. NUM_BONE_INFLUENCERS: number;
  41664. BonesPerMesh: number;
  41665. BONETEXTURE: boolean;
  41666. INSTANCES: boolean;
  41667. GLOSSINESS: boolean;
  41668. ROUGHNESS: boolean;
  41669. EMISSIVEASILLUMINATION: boolean;
  41670. LINKEMISSIVEWITHDIFFUSE: boolean;
  41671. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41672. LIGHTMAP: boolean;
  41673. LIGHTMAPDIRECTUV: number;
  41674. OBJECTSPACE_NORMALMAP: boolean;
  41675. USELIGHTMAPASSHADOWMAP: boolean;
  41676. REFLECTIONMAP_3D: boolean;
  41677. REFLECTIONMAP_SPHERICAL: boolean;
  41678. REFLECTIONMAP_PLANAR: boolean;
  41679. REFLECTIONMAP_CUBIC: boolean;
  41680. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41681. REFLECTIONMAP_PROJECTION: boolean;
  41682. REFLECTIONMAP_SKYBOX: boolean;
  41683. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41684. REFLECTIONMAP_EXPLICIT: boolean;
  41685. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41686. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41687. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41688. INVERTCUBICMAP: boolean;
  41689. LOGARITHMICDEPTH: boolean;
  41690. REFRACTION: boolean;
  41691. REFRACTIONMAP_3D: boolean;
  41692. REFLECTIONOVERALPHA: boolean;
  41693. TWOSIDEDLIGHTING: boolean;
  41694. SHADOWFLOAT: boolean;
  41695. MORPHTARGETS: boolean;
  41696. MORPHTARGETS_NORMAL: boolean;
  41697. MORPHTARGETS_TANGENT: boolean;
  41698. MORPHTARGETS_UV: boolean;
  41699. NUM_MORPH_INFLUENCERS: number;
  41700. NONUNIFORMSCALING: boolean;
  41701. PREMULTIPLYALPHA: boolean;
  41702. IMAGEPROCESSING: boolean;
  41703. VIGNETTE: boolean;
  41704. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41705. VIGNETTEBLENDMODEOPAQUE: boolean;
  41706. TONEMAPPING: boolean;
  41707. TONEMAPPING_ACES: boolean;
  41708. CONTRAST: boolean;
  41709. COLORCURVES: boolean;
  41710. COLORGRADING: boolean;
  41711. COLORGRADING3D: boolean;
  41712. SAMPLER3DGREENDEPTH: boolean;
  41713. SAMPLER3DBGRMAP: boolean;
  41714. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41715. MULTIVIEW: boolean;
  41716. /**
  41717. * If the reflection texture on this material is in linear color space
  41718. * @hidden
  41719. */
  41720. IS_REFLECTION_LINEAR: boolean;
  41721. /**
  41722. * If the refraction texture on this material is in linear color space
  41723. * @hidden
  41724. */
  41725. IS_REFRACTION_LINEAR: boolean;
  41726. EXPOSURE: boolean;
  41727. constructor();
  41728. setReflectionMode(modeToEnable: string): void;
  41729. }
  41730. /**
  41731. * This is the default material used in Babylon. It is the best trade off between quality
  41732. * and performances.
  41733. * @see http://doc.babylonjs.com/babylon101/materials
  41734. */
  41735. export class StandardMaterial extends PushMaterial {
  41736. private _diffuseTexture;
  41737. /**
  41738. * The basic texture of the material as viewed under a light.
  41739. */
  41740. diffuseTexture: Nullable<BaseTexture>;
  41741. private _ambientTexture;
  41742. /**
  41743. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41744. */
  41745. ambientTexture: Nullable<BaseTexture>;
  41746. private _opacityTexture;
  41747. /**
  41748. * Define the transparency of the material from a texture.
  41749. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41750. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41751. */
  41752. opacityTexture: Nullable<BaseTexture>;
  41753. private _reflectionTexture;
  41754. /**
  41755. * Define the texture used to display the reflection.
  41756. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41757. */
  41758. reflectionTexture: Nullable<BaseTexture>;
  41759. private _emissiveTexture;
  41760. /**
  41761. * Define texture of the material as if self lit.
  41762. * This will be mixed in the final result even in the absence of light.
  41763. */
  41764. emissiveTexture: Nullable<BaseTexture>;
  41765. private _specularTexture;
  41766. /**
  41767. * Define how the color and intensity of the highlight given by the light in the material.
  41768. */
  41769. specularTexture: Nullable<BaseTexture>;
  41770. private _bumpTexture;
  41771. /**
  41772. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41773. * 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.
  41774. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41775. */
  41776. bumpTexture: Nullable<BaseTexture>;
  41777. private _lightmapTexture;
  41778. /**
  41779. * Complex lighting can be computationally expensive to compute at runtime.
  41780. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41781. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41782. */
  41783. lightmapTexture: Nullable<BaseTexture>;
  41784. private _refractionTexture;
  41785. /**
  41786. * Define the texture used to display the refraction.
  41787. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41788. */
  41789. refractionTexture: Nullable<BaseTexture>;
  41790. /**
  41791. * The color of the material lit by the environmental background lighting.
  41792. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41793. */
  41794. ambientColor: Color3;
  41795. /**
  41796. * The basic color of the material as viewed under a light.
  41797. */
  41798. diffuseColor: Color3;
  41799. /**
  41800. * Define how the color and intensity of the highlight given by the light in the material.
  41801. */
  41802. specularColor: Color3;
  41803. /**
  41804. * Define the color of the material as if self lit.
  41805. * This will be mixed in the final result even in the absence of light.
  41806. */
  41807. emissiveColor: Color3;
  41808. /**
  41809. * Defines how sharp are the highlights in the material.
  41810. * The bigger the value the sharper giving a more glossy feeling to the result.
  41811. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41812. */
  41813. specularPower: number;
  41814. private _useAlphaFromDiffuseTexture;
  41815. /**
  41816. * Does the transparency come from the diffuse texture alpha channel.
  41817. */
  41818. useAlphaFromDiffuseTexture: boolean;
  41819. private _useEmissiveAsIllumination;
  41820. /**
  41821. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41822. */
  41823. useEmissiveAsIllumination: boolean;
  41824. private _linkEmissiveWithDiffuse;
  41825. /**
  41826. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41827. * the emissive level when the final color is close to one.
  41828. */
  41829. linkEmissiveWithDiffuse: boolean;
  41830. private _useSpecularOverAlpha;
  41831. /**
  41832. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41833. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41834. */
  41835. useSpecularOverAlpha: boolean;
  41836. private _useReflectionOverAlpha;
  41837. /**
  41838. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41839. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41840. */
  41841. useReflectionOverAlpha: boolean;
  41842. private _disableLighting;
  41843. /**
  41844. * Does lights from the scene impacts this material.
  41845. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41846. */
  41847. disableLighting: boolean;
  41848. private _useObjectSpaceNormalMap;
  41849. /**
  41850. * Allows using an object space normal map (instead of tangent space).
  41851. */
  41852. useObjectSpaceNormalMap: boolean;
  41853. private _useParallax;
  41854. /**
  41855. * Is parallax enabled or not.
  41856. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41857. */
  41858. useParallax: boolean;
  41859. private _useParallaxOcclusion;
  41860. /**
  41861. * Is parallax occlusion enabled or not.
  41862. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41863. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41864. */
  41865. useParallaxOcclusion: boolean;
  41866. /**
  41867. * 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.
  41868. */
  41869. parallaxScaleBias: number;
  41870. private _roughness;
  41871. /**
  41872. * Helps to define how blurry the reflections should appears in the material.
  41873. */
  41874. roughness: number;
  41875. /**
  41876. * In case of refraction, define the value of the index of refraction.
  41877. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41878. */
  41879. indexOfRefraction: number;
  41880. /**
  41881. * Invert the refraction texture alongside the y axis.
  41882. * It can be useful with procedural textures or probe for instance.
  41883. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41884. */
  41885. invertRefractionY: boolean;
  41886. /**
  41887. * Defines the alpha limits in alpha test mode.
  41888. */
  41889. alphaCutOff: number;
  41890. private _useLightmapAsShadowmap;
  41891. /**
  41892. * In case of light mapping, define whether the map contains light or shadow informations.
  41893. */
  41894. useLightmapAsShadowmap: boolean;
  41895. private _diffuseFresnelParameters;
  41896. /**
  41897. * Define the diffuse fresnel parameters of the material.
  41898. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41899. */
  41900. diffuseFresnelParameters: FresnelParameters;
  41901. private _opacityFresnelParameters;
  41902. /**
  41903. * Define the opacity fresnel parameters of the material.
  41904. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41905. */
  41906. opacityFresnelParameters: FresnelParameters;
  41907. private _reflectionFresnelParameters;
  41908. /**
  41909. * Define the reflection fresnel parameters of the material.
  41910. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41911. */
  41912. reflectionFresnelParameters: FresnelParameters;
  41913. private _refractionFresnelParameters;
  41914. /**
  41915. * Define the refraction fresnel parameters of the material.
  41916. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41917. */
  41918. refractionFresnelParameters: FresnelParameters;
  41919. private _emissiveFresnelParameters;
  41920. /**
  41921. * Define the emissive fresnel parameters of the material.
  41922. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41923. */
  41924. emissiveFresnelParameters: FresnelParameters;
  41925. private _useReflectionFresnelFromSpecular;
  41926. /**
  41927. * If true automatically deducts the fresnels values from the material specularity.
  41928. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41929. */
  41930. useReflectionFresnelFromSpecular: boolean;
  41931. private _useGlossinessFromSpecularMapAlpha;
  41932. /**
  41933. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41934. */
  41935. useGlossinessFromSpecularMapAlpha: boolean;
  41936. private _maxSimultaneousLights;
  41937. /**
  41938. * Defines the maximum number of lights that can be used in the material
  41939. */
  41940. maxSimultaneousLights: number;
  41941. private _invertNormalMapX;
  41942. /**
  41943. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41944. */
  41945. invertNormalMapX: boolean;
  41946. private _invertNormalMapY;
  41947. /**
  41948. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41949. */
  41950. invertNormalMapY: boolean;
  41951. private _twoSidedLighting;
  41952. /**
  41953. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41954. */
  41955. twoSidedLighting: boolean;
  41956. /**
  41957. * Default configuration related to image processing available in the standard Material.
  41958. */
  41959. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41960. /**
  41961. * Gets the image processing configuration used either in this material.
  41962. */
  41963. /**
  41964. * Sets the Default image processing configuration used either in the this material.
  41965. *
  41966. * If sets to null, the scene one is in use.
  41967. */
  41968. imageProcessingConfiguration: ImageProcessingConfiguration;
  41969. /**
  41970. * Keep track of the image processing observer to allow dispose and replace.
  41971. */
  41972. private _imageProcessingObserver;
  41973. /**
  41974. * Attaches a new image processing configuration to the Standard Material.
  41975. * @param configuration
  41976. */
  41977. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41978. /**
  41979. * Gets wether the color curves effect is enabled.
  41980. */
  41981. /**
  41982. * Sets wether the color curves effect is enabled.
  41983. */
  41984. cameraColorCurvesEnabled: boolean;
  41985. /**
  41986. * Gets wether the color grading effect is enabled.
  41987. */
  41988. /**
  41989. * Gets wether the color grading effect is enabled.
  41990. */
  41991. cameraColorGradingEnabled: boolean;
  41992. /**
  41993. * Gets wether tonemapping is enabled or not.
  41994. */
  41995. /**
  41996. * Sets wether tonemapping is enabled or not
  41997. */
  41998. cameraToneMappingEnabled: boolean;
  41999. /**
  42000. * The camera exposure used on this material.
  42001. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42002. * This corresponds to a photographic exposure.
  42003. */
  42004. /**
  42005. * The camera exposure used on this material.
  42006. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42007. * This corresponds to a photographic exposure.
  42008. */
  42009. cameraExposure: number;
  42010. /**
  42011. * Gets The camera contrast used on this material.
  42012. */
  42013. /**
  42014. * Sets The camera contrast used on this material.
  42015. */
  42016. cameraContrast: number;
  42017. /**
  42018. * Gets the Color Grading 2D Lookup Texture.
  42019. */
  42020. /**
  42021. * Sets the Color Grading 2D Lookup Texture.
  42022. */
  42023. cameraColorGradingTexture: Nullable<BaseTexture>;
  42024. /**
  42025. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42026. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42027. * 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;
  42028. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42029. */
  42030. /**
  42031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42033. * 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;
  42034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42035. */
  42036. cameraColorCurves: Nullable<ColorCurves>;
  42037. /**
  42038. * Custom callback helping to override the default shader used in the material.
  42039. */
  42040. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42041. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42042. protected _worldViewProjectionMatrix: Matrix;
  42043. protected _globalAmbientColor: Color3;
  42044. protected _useLogarithmicDepth: boolean;
  42045. protected _rebuildInParallel: boolean;
  42046. /**
  42047. * Instantiates a new standard material.
  42048. * This is the default material used in Babylon. It is the best trade off between quality
  42049. * and performances.
  42050. * @see http://doc.babylonjs.com/babylon101/materials
  42051. * @param name Define the name of the material in the scene
  42052. * @param scene Define the scene the material belong to
  42053. */
  42054. constructor(name: string, scene: Scene);
  42055. /**
  42056. * Gets a boolean indicating that current material needs to register RTT
  42057. */
  42058. readonly hasRenderTargetTextures: boolean;
  42059. /**
  42060. * Gets the current class name of the material e.g. "StandardMaterial"
  42061. * Mainly use in serialization.
  42062. * @returns the class name
  42063. */
  42064. getClassName(): string;
  42065. /**
  42066. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42067. * You can try switching to logarithmic depth.
  42068. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42069. */
  42070. useLogarithmicDepth: boolean;
  42071. /**
  42072. * Specifies if the material will require alpha blending
  42073. * @returns a boolean specifying if alpha blending is needed
  42074. */
  42075. needAlphaBlending(): boolean;
  42076. /**
  42077. * Specifies if this material should be rendered in alpha test mode
  42078. * @returns a boolean specifying if an alpha test is needed.
  42079. */
  42080. needAlphaTesting(): boolean;
  42081. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42082. /**
  42083. * Get the texture used for alpha test purpose.
  42084. * @returns the diffuse texture in case of the standard material.
  42085. */
  42086. getAlphaTestTexture(): Nullable<BaseTexture>;
  42087. /**
  42088. * Get if the submesh is ready to be used and all its information available.
  42089. * Child classes can use it to update shaders
  42090. * @param mesh defines the mesh to check
  42091. * @param subMesh defines which submesh to check
  42092. * @param useInstances specifies that instances should be used
  42093. * @returns a boolean indicating that the submesh is ready or not
  42094. */
  42095. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42096. /**
  42097. * Builds the material UBO layouts.
  42098. * Used internally during the effect preparation.
  42099. */
  42100. buildUniformLayout(): void;
  42101. /**
  42102. * Unbinds the material from the mesh
  42103. */
  42104. unbind(): void;
  42105. /**
  42106. * Binds the submesh to this material by preparing the effect and shader to draw
  42107. * @param world defines the world transformation matrix
  42108. * @param mesh defines the mesh containing the submesh
  42109. * @param subMesh defines the submesh to bind the material to
  42110. */
  42111. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42112. /**
  42113. * Get the list of animatables in the material.
  42114. * @returns the list of animatables object used in the material
  42115. */
  42116. getAnimatables(): IAnimatable[];
  42117. /**
  42118. * Gets the active textures from the material
  42119. * @returns an array of textures
  42120. */
  42121. getActiveTextures(): BaseTexture[];
  42122. /**
  42123. * Specifies if the material uses a texture
  42124. * @param texture defines the texture to check against the material
  42125. * @returns a boolean specifying if the material uses the texture
  42126. */
  42127. hasTexture(texture: BaseTexture): boolean;
  42128. /**
  42129. * Disposes the material
  42130. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42131. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42132. */
  42133. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42134. /**
  42135. * Makes a duplicate of the material, and gives it a new name
  42136. * @param name defines the new name for the duplicated material
  42137. * @returns the cloned material
  42138. */
  42139. clone(name: string): StandardMaterial;
  42140. /**
  42141. * Serializes this material in a JSON representation
  42142. * @returns the serialized material object
  42143. */
  42144. serialize(): any;
  42145. /**
  42146. * Creates a standard material from parsed material data
  42147. * @param source defines the JSON representation of the material
  42148. * @param scene defines the hosting scene
  42149. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42150. * @returns a new standard material
  42151. */
  42152. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42153. /**
  42154. * Are diffuse textures enabled in the application.
  42155. */
  42156. static DiffuseTextureEnabled: boolean;
  42157. /**
  42158. * Are ambient textures enabled in the application.
  42159. */
  42160. static AmbientTextureEnabled: boolean;
  42161. /**
  42162. * Are opacity textures enabled in the application.
  42163. */
  42164. static OpacityTextureEnabled: boolean;
  42165. /**
  42166. * Are reflection textures enabled in the application.
  42167. */
  42168. static ReflectionTextureEnabled: boolean;
  42169. /**
  42170. * Are emissive textures enabled in the application.
  42171. */
  42172. static EmissiveTextureEnabled: boolean;
  42173. /**
  42174. * Are specular textures enabled in the application.
  42175. */
  42176. static SpecularTextureEnabled: boolean;
  42177. /**
  42178. * Are bump textures enabled in the application.
  42179. */
  42180. static BumpTextureEnabled: boolean;
  42181. /**
  42182. * Are lightmap textures enabled in the application.
  42183. */
  42184. static LightmapTextureEnabled: boolean;
  42185. /**
  42186. * Are refraction textures enabled in the application.
  42187. */
  42188. static RefractionTextureEnabled: boolean;
  42189. /**
  42190. * Are color grading textures enabled in the application.
  42191. */
  42192. static ColorGradingTextureEnabled: boolean;
  42193. /**
  42194. * Are fresnels enabled in the application.
  42195. */
  42196. static FresnelEnabled: boolean;
  42197. }
  42198. }
  42199. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42200. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42201. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42202. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42203. /** @hidden */
  42204. export var imageProcessingPixelShader: {
  42205. name: string;
  42206. shader: string;
  42207. };
  42208. }
  42209. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42210. import { Nullable } from "babylonjs/types";
  42211. import { Color4 } from "babylonjs/Maths/math.color";
  42212. import { Camera } from "babylonjs/Cameras/camera";
  42213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42214. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42215. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42216. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42217. import { Engine } from "babylonjs/Engines/engine";
  42218. import "babylonjs/Shaders/imageProcessing.fragment";
  42219. import "babylonjs/Shaders/postprocess.vertex";
  42220. /**
  42221. * ImageProcessingPostProcess
  42222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42223. */
  42224. export class ImageProcessingPostProcess extends PostProcess {
  42225. /**
  42226. * Default configuration related to image processing available in the PBR Material.
  42227. */
  42228. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42229. /**
  42230. * Gets the image processing configuration used either in this material.
  42231. */
  42232. /**
  42233. * Sets the Default image processing configuration used either in the this material.
  42234. *
  42235. * If sets to null, the scene one is in use.
  42236. */
  42237. imageProcessingConfiguration: ImageProcessingConfiguration;
  42238. /**
  42239. * Keep track of the image processing observer to allow dispose and replace.
  42240. */
  42241. private _imageProcessingObserver;
  42242. /**
  42243. * Attaches a new image processing configuration to the PBR Material.
  42244. * @param configuration
  42245. */
  42246. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42247. /**
  42248. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42249. */
  42250. /**
  42251. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42252. */
  42253. colorCurves: Nullable<ColorCurves>;
  42254. /**
  42255. * Gets wether the color curves effect is enabled.
  42256. */
  42257. /**
  42258. * Sets wether the color curves effect is enabled.
  42259. */
  42260. colorCurvesEnabled: boolean;
  42261. /**
  42262. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42263. */
  42264. /**
  42265. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42266. */
  42267. colorGradingTexture: Nullable<BaseTexture>;
  42268. /**
  42269. * Gets wether the color grading effect is enabled.
  42270. */
  42271. /**
  42272. * Gets wether the color grading effect is enabled.
  42273. */
  42274. colorGradingEnabled: boolean;
  42275. /**
  42276. * Gets exposure used in the effect.
  42277. */
  42278. /**
  42279. * Sets exposure used in the effect.
  42280. */
  42281. exposure: number;
  42282. /**
  42283. * Gets wether tonemapping is enabled or not.
  42284. */
  42285. /**
  42286. * Sets wether tonemapping is enabled or not
  42287. */
  42288. toneMappingEnabled: boolean;
  42289. /**
  42290. * Gets the type of tone mapping effect.
  42291. */
  42292. /**
  42293. * Sets the type of tone mapping effect.
  42294. */
  42295. toneMappingType: number;
  42296. /**
  42297. * Gets contrast used in the effect.
  42298. */
  42299. /**
  42300. * Sets contrast used in the effect.
  42301. */
  42302. contrast: number;
  42303. /**
  42304. * Gets Vignette stretch size.
  42305. */
  42306. /**
  42307. * Sets Vignette stretch size.
  42308. */
  42309. vignetteStretch: number;
  42310. /**
  42311. * Gets Vignette centre X Offset.
  42312. */
  42313. /**
  42314. * Sets Vignette centre X Offset.
  42315. */
  42316. vignetteCentreX: number;
  42317. /**
  42318. * Gets Vignette centre Y Offset.
  42319. */
  42320. /**
  42321. * Sets Vignette centre Y Offset.
  42322. */
  42323. vignetteCentreY: number;
  42324. /**
  42325. * Gets Vignette weight or intensity of the vignette effect.
  42326. */
  42327. /**
  42328. * Sets Vignette weight or intensity of the vignette effect.
  42329. */
  42330. vignetteWeight: number;
  42331. /**
  42332. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42333. * if vignetteEnabled is set to true.
  42334. */
  42335. /**
  42336. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42337. * if vignetteEnabled is set to true.
  42338. */
  42339. vignetteColor: Color4;
  42340. /**
  42341. * Gets Camera field of view used by the Vignette effect.
  42342. */
  42343. /**
  42344. * Sets Camera field of view used by the Vignette effect.
  42345. */
  42346. vignetteCameraFov: number;
  42347. /**
  42348. * Gets the vignette blend mode allowing different kind of effect.
  42349. */
  42350. /**
  42351. * Sets the vignette blend mode allowing different kind of effect.
  42352. */
  42353. vignetteBlendMode: number;
  42354. /**
  42355. * Gets wether the vignette effect is enabled.
  42356. */
  42357. /**
  42358. * Sets wether the vignette effect is enabled.
  42359. */
  42360. vignetteEnabled: boolean;
  42361. private _fromLinearSpace;
  42362. /**
  42363. * Gets wether the input of the processing is in Gamma or Linear Space.
  42364. */
  42365. /**
  42366. * Sets wether the input of the processing is in Gamma or Linear Space.
  42367. */
  42368. fromLinearSpace: boolean;
  42369. /**
  42370. * Defines cache preventing GC.
  42371. */
  42372. private _defines;
  42373. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42374. /**
  42375. * "ImageProcessingPostProcess"
  42376. * @returns "ImageProcessingPostProcess"
  42377. */
  42378. getClassName(): string;
  42379. protected _updateParameters(): void;
  42380. dispose(camera?: Camera): void;
  42381. }
  42382. }
  42383. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42384. import { Scene } from "babylonjs/scene";
  42385. import { Color3 } from "babylonjs/Maths/math.color";
  42386. import { Mesh } from "babylonjs/Meshes/mesh";
  42387. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42388. import { Nullable } from "babylonjs/types";
  42389. /**
  42390. * Class containing static functions to help procedurally build meshes
  42391. */
  42392. export class GroundBuilder {
  42393. /**
  42394. * Creates a ground mesh
  42395. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42396. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42398. * @param name defines the name of the mesh
  42399. * @param options defines the options used to create the mesh
  42400. * @param scene defines the hosting scene
  42401. * @returns the ground mesh
  42402. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42403. */
  42404. static CreateGround(name: string, options: {
  42405. width?: number;
  42406. height?: number;
  42407. subdivisions?: number;
  42408. subdivisionsX?: number;
  42409. subdivisionsY?: number;
  42410. updatable?: boolean;
  42411. }, scene: any): Mesh;
  42412. /**
  42413. * Creates a tiled ground mesh
  42414. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42415. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42416. * * 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
  42417. * * 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
  42418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42419. * @param name defines the name of the mesh
  42420. * @param options defines the options used to create the mesh
  42421. * @param scene defines the hosting scene
  42422. * @returns the tiled ground mesh
  42423. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42424. */
  42425. static CreateTiledGround(name: string, options: {
  42426. xmin: number;
  42427. zmin: number;
  42428. xmax: number;
  42429. zmax: number;
  42430. subdivisions?: {
  42431. w: number;
  42432. h: number;
  42433. };
  42434. precision?: {
  42435. w: number;
  42436. h: number;
  42437. };
  42438. updatable?: boolean;
  42439. }, scene?: Nullable<Scene>): Mesh;
  42440. /**
  42441. * Creates a ground mesh from a height map
  42442. * * The parameter `url` sets the URL of the height map image resource.
  42443. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42444. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42445. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42446. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42447. * * 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.
  42448. * * 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).
  42449. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42451. * @param name defines the name of the mesh
  42452. * @param url defines the url to the height map
  42453. * @param options defines the options used to create the mesh
  42454. * @param scene defines the hosting scene
  42455. * @returns the ground mesh
  42456. * @see https://doc.babylonjs.com/babylon101/height_map
  42457. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42458. */
  42459. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42460. width?: number;
  42461. height?: number;
  42462. subdivisions?: number;
  42463. minHeight?: number;
  42464. maxHeight?: number;
  42465. colorFilter?: Color3;
  42466. alphaFilter?: number;
  42467. updatable?: boolean;
  42468. onReady?: (mesh: GroundMesh) => void;
  42469. }, scene?: Nullable<Scene>): GroundMesh;
  42470. }
  42471. }
  42472. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42473. import { Vector4 } from "babylonjs/Maths/math.vector";
  42474. import { Mesh } from "babylonjs/Meshes/mesh";
  42475. /**
  42476. * Class containing static functions to help procedurally build meshes
  42477. */
  42478. export class TorusBuilder {
  42479. /**
  42480. * Creates a torus mesh
  42481. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42482. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42483. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42487. * @param name defines the name of the mesh
  42488. * @param options defines the options used to create the mesh
  42489. * @param scene defines the hosting scene
  42490. * @returns the torus mesh
  42491. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42492. */
  42493. static CreateTorus(name: string, options: {
  42494. diameter?: number;
  42495. thickness?: number;
  42496. tessellation?: number;
  42497. updatable?: boolean;
  42498. sideOrientation?: number;
  42499. frontUVs?: Vector4;
  42500. backUVs?: Vector4;
  42501. }, scene: any): Mesh;
  42502. }
  42503. }
  42504. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42505. import { Vector4 } from "babylonjs/Maths/math.vector";
  42506. import { Color4 } from "babylonjs/Maths/math.color";
  42507. import { Mesh } from "babylonjs/Meshes/mesh";
  42508. /**
  42509. * Class containing static functions to help procedurally build meshes
  42510. */
  42511. export class CylinderBuilder {
  42512. /**
  42513. * Creates a cylinder or a cone mesh
  42514. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42515. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42516. * * 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.
  42517. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42518. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42519. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42520. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42521. * * 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).
  42522. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42523. * * 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).
  42524. * * 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
  42525. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42526. * * 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
  42527. * * 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.
  42528. * * If `enclose` is false, a ring surface is one element.
  42529. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42530. * * 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
  42531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42534. * @param name defines the name of the mesh
  42535. * @param options defines the options used to create the mesh
  42536. * @param scene defines the hosting scene
  42537. * @returns the cylinder mesh
  42538. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42539. */
  42540. static CreateCylinder(name: string, options: {
  42541. height?: number;
  42542. diameterTop?: number;
  42543. diameterBottom?: number;
  42544. diameter?: number;
  42545. tessellation?: number;
  42546. subdivisions?: number;
  42547. arc?: number;
  42548. faceColors?: Color4[];
  42549. faceUV?: Vector4[];
  42550. updatable?: boolean;
  42551. hasRings?: boolean;
  42552. enclose?: boolean;
  42553. cap?: number;
  42554. sideOrientation?: number;
  42555. frontUVs?: Vector4;
  42556. backUVs?: Vector4;
  42557. }, scene: any): Mesh;
  42558. }
  42559. }
  42560. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42561. import { Observable } from "babylonjs/Misc/observable";
  42562. import { Nullable } from "babylonjs/types";
  42563. import { Camera } from "babylonjs/Cameras/camera";
  42564. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42565. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42566. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42567. import { Scene } from "babylonjs/scene";
  42568. import { Vector3 } from "babylonjs/Maths/math.vector";
  42569. import { Color3 } from "babylonjs/Maths/math.color";
  42570. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42572. import { Mesh } from "babylonjs/Meshes/mesh";
  42573. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42574. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42575. import "babylonjs/Meshes/Builders/groundBuilder";
  42576. import "babylonjs/Meshes/Builders/torusBuilder";
  42577. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42578. import "babylonjs/Gamepads/gamepadSceneComponent";
  42579. import "babylonjs/Animations/animatable";
  42580. /**
  42581. * Options to modify the vr teleportation behavior.
  42582. */
  42583. export interface VRTeleportationOptions {
  42584. /**
  42585. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42586. */
  42587. floorMeshName?: string;
  42588. /**
  42589. * A list of meshes to be used as the teleportation floor. (default: empty)
  42590. */
  42591. floorMeshes?: Mesh[];
  42592. }
  42593. /**
  42594. * Options to modify the vr experience helper's behavior.
  42595. */
  42596. export interface VRExperienceHelperOptions extends WebVROptions {
  42597. /**
  42598. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42599. */
  42600. createDeviceOrientationCamera?: boolean;
  42601. /**
  42602. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42603. */
  42604. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42605. /**
  42606. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42607. */
  42608. laserToggle?: boolean;
  42609. /**
  42610. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42611. */
  42612. floorMeshes?: Mesh[];
  42613. /**
  42614. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42615. */
  42616. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42617. }
  42618. /**
  42619. * Event containing information after VR has been entered
  42620. */
  42621. export class OnAfterEnteringVRObservableEvent {
  42622. /**
  42623. * If entering vr was successful
  42624. */
  42625. success: boolean;
  42626. }
  42627. /**
  42628. * Helps to quickly add VR support to an existing scene.
  42629. * See http://doc.babylonjs.com/how_to/webvr_helper
  42630. */
  42631. export class VRExperienceHelper {
  42632. /** Options to modify the vr experience helper's behavior. */
  42633. webVROptions: VRExperienceHelperOptions;
  42634. private _scene;
  42635. private _position;
  42636. private _btnVR;
  42637. private _btnVRDisplayed;
  42638. private _webVRsupported;
  42639. private _webVRready;
  42640. private _webVRrequesting;
  42641. private _webVRpresenting;
  42642. private _hasEnteredVR;
  42643. private _fullscreenVRpresenting;
  42644. private _canvas;
  42645. private _webVRCamera;
  42646. private _vrDeviceOrientationCamera;
  42647. private _deviceOrientationCamera;
  42648. private _existingCamera;
  42649. private _onKeyDown;
  42650. private _onVrDisplayPresentChange;
  42651. private _onVRDisplayChanged;
  42652. private _onVRRequestPresentStart;
  42653. private _onVRRequestPresentComplete;
  42654. /**
  42655. * 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)
  42656. */
  42657. enableGazeEvenWhenNoPointerLock: boolean;
  42658. /**
  42659. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42660. */
  42661. exitVROnDoubleTap: boolean;
  42662. /**
  42663. * Observable raised right before entering VR.
  42664. */
  42665. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42666. /**
  42667. * Observable raised when entering VR has completed.
  42668. */
  42669. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42670. /**
  42671. * Observable raised when exiting VR.
  42672. */
  42673. onExitingVRObservable: Observable<VRExperienceHelper>;
  42674. /**
  42675. * Observable raised when controller mesh is loaded.
  42676. */
  42677. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42678. /** Return this.onEnteringVRObservable
  42679. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42680. */
  42681. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42682. /** Return this.onExitingVRObservable
  42683. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42684. */
  42685. readonly onExitingVR: Observable<VRExperienceHelper>;
  42686. /** Return this.onControllerMeshLoadedObservable
  42687. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42688. */
  42689. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42690. private _rayLength;
  42691. private _useCustomVRButton;
  42692. private _teleportationRequested;
  42693. private _teleportActive;
  42694. private _floorMeshName;
  42695. private _floorMeshesCollection;
  42696. private _rotationAllowed;
  42697. private _teleportBackwardsVector;
  42698. private _teleportationTarget;
  42699. private _isDefaultTeleportationTarget;
  42700. private _postProcessMove;
  42701. private _teleportationFillColor;
  42702. private _teleportationBorderColor;
  42703. private _rotationAngle;
  42704. private _haloCenter;
  42705. private _cameraGazer;
  42706. private _padSensibilityUp;
  42707. private _padSensibilityDown;
  42708. private _leftController;
  42709. private _rightController;
  42710. /**
  42711. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42712. */
  42713. onNewMeshSelected: Observable<AbstractMesh>;
  42714. /**
  42715. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42716. * This observable will provide the mesh and the controller used to select the mesh
  42717. */
  42718. onMeshSelectedWithController: Observable<{
  42719. mesh: AbstractMesh;
  42720. controller: WebVRController;
  42721. }>;
  42722. /**
  42723. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42724. */
  42725. onNewMeshPicked: Observable<PickingInfo>;
  42726. private _circleEase;
  42727. /**
  42728. * Observable raised before camera teleportation
  42729. */
  42730. onBeforeCameraTeleport: Observable<Vector3>;
  42731. /**
  42732. * Observable raised after camera teleportation
  42733. */
  42734. onAfterCameraTeleport: Observable<Vector3>;
  42735. /**
  42736. * Observable raised when current selected mesh gets unselected
  42737. */
  42738. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42739. private _raySelectionPredicate;
  42740. /**
  42741. * To be optionaly changed by user to define custom ray selection
  42742. */
  42743. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42744. /**
  42745. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42746. */
  42747. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42748. /**
  42749. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42750. */
  42751. teleportationEnabled: boolean;
  42752. private _defaultHeight;
  42753. private _teleportationInitialized;
  42754. private _interactionsEnabled;
  42755. private _interactionsRequested;
  42756. private _displayGaze;
  42757. private _displayLaserPointer;
  42758. /**
  42759. * The mesh used to display where the user is going to teleport.
  42760. */
  42761. /**
  42762. * Sets the mesh to be used to display where the user is going to teleport.
  42763. */
  42764. teleportationTarget: Mesh;
  42765. /**
  42766. * 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
  42767. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42768. * See http://doc.babylonjs.com/resources/baking_transformations
  42769. */
  42770. gazeTrackerMesh: Mesh;
  42771. /**
  42772. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42773. */
  42774. updateGazeTrackerScale: boolean;
  42775. /**
  42776. * If the gaze trackers color should be updated when selecting meshes
  42777. */
  42778. updateGazeTrackerColor: boolean;
  42779. /**
  42780. * If the controller laser color should be updated when selecting meshes
  42781. */
  42782. updateControllerLaserColor: boolean;
  42783. /**
  42784. * The gaze tracking mesh corresponding to the left controller
  42785. */
  42786. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42787. /**
  42788. * The gaze tracking mesh corresponding to the right controller
  42789. */
  42790. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42791. /**
  42792. * If the ray of the gaze should be displayed.
  42793. */
  42794. /**
  42795. * Sets if the ray of the gaze should be displayed.
  42796. */
  42797. displayGaze: boolean;
  42798. /**
  42799. * If the ray of the LaserPointer should be displayed.
  42800. */
  42801. /**
  42802. * Sets if the ray of the LaserPointer should be displayed.
  42803. */
  42804. displayLaserPointer: boolean;
  42805. /**
  42806. * The deviceOrientationCamera used as the camera when not in VR.
  42807. */
  42808. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42809. /**
  42810. * Based on the current WebVR support, returns the current VR camera used.
  42811. */
  42812. readonly currentVRCamera: Nullable<Camera>;
  42813. /**
  42814. * The webVRCamera which is used when in VR.
  42815. */
  42816. readonly webVRCamera: WebVRFreeCamera;
  42817. /**
  42818. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42819. */
  42820. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42821. /**
  42822. * The html button that is used to trigger entering into VR.
  42823. */
  42824. readonly vrButton: Nullable<HTMLButtonElement>;
  42825. private readonly _teleportationRequestInitiated;
  42826. /**
  42827. * Defines wether or not Pointer lock should be requested when switching to
  42828. * full screen.
  42829. */
  42830. requestPointerLockOnFullScreen: boolean;
  42831. /**
  42832. * Instantiates a VRExperienceHelper.
  42833. * Helps to quickly add VR support to an existing scene.
  42834. * @param scene The scene the VRExperienceHelper belongs to.
  42835. * @param webVROptions Options to modify the vr experience helper's behavior.
  42836. */
  42837. constructor(scene: Scene,
  42838. /** Options to modify the vr experience helper's behavior. */
  42839. webVROptions?: VRExperienceHelperOptions);
  42840. private _onDefaultMeshLoaded;
  42841. private _onResize;
  42842. private _onFullscreenChange;
  42843. /**
  42844. * Gets a value indicating if we are currently in VR mode.
  42845. */
  42846. readonly isInVRMode: boolean;
  42847. private onVrDisplayPresentChange;
  42848. private onVRDisplayChanged;
  42849. private moveButtonToBottomRight;
  42850. private displayVRButton;
  42851. private updateButtonVisibility;
  42852. private _cachedAngularSensibility;
  42853. /**
  42854. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42855. * Otherwise, will use the fullscreen API.
  42856. */
  42857. enterVR(): void;
  42858. /**
  42859. * Attempt to exit VR, or fullscreen.
  42860. */
  42861. exitVR(): void;
  42862. /**
  42863. * The position of the vr experience helper.
  42864. */
  42865. /**
  42866. * Sets the position of the vr experience helper.
  42867. */
  42868. position: Vector3;
  42869. /**
  42870. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42871. */
  42872. enableInteractions(): void;
  42873. private readonly _noControllerIsActive;
  42874. private beforeRender;
  42875. private _isTeleportationFloor;
  42876. /**
  42877. * Adds a floor mesh to be used for teleportation.
  42878. * @param floorMesh the mesh to be used for teleportation.
  42879. */
  42880. addFloorMesh(floorMesh: Mesh): void;
  42881. /**
  42882. * Removes a floor mesh from being used for teleportation.
  42883. * @param floorMesh the mesh to be removed.
  42884. */
  42885. removeFloorMesh(floorMesh: Mesh): void;
  42886. /**
  42887. * Enables interactions and teleportation using the VR controllers and gaze.
  42888. * @param vrTeleportationOptions options to modify teleportation behavior.
  42889. */
  42890. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42891. private _onNewGamepadConnected;
  42892. private _tryEnableInteractionOnController;
  42893. private _onNewGamepadDisconnected;
  42894. private _enableInteractionOnController;
  42895. private _checkTeleportWithRay;
  42896. private _checkRotate;
  42897. private _checkTeleportBackwards;
  42898. private _enableTeleportationOnController;
  42899. private _createTeleportationCircles;
  42900. private _displayTeleportationTarget;
  42901. private _hideTeleportationTarget;
  42902. private _rotateCamera;
  42903. private _moveTeleportationSelectorTo;
  42904. private _workingVector;
  42905. private _workingQuaternion;
  42906. private _workingMatrix;
  42907. /**
  42908. * Teleports the users feet to the desired location
  42909. * @param location The location where the user's feet should be placed
  42910. */
  42911. teleportCamera(location: Vector3): void;
  42912. private _convertNormalToDirectionOfRay;
  42913. private _castRayAndSelectObject;
  42914. private _notifySelectedMeshUnselected;
  42915. /**
  42916. * Sets the color of the laser ray from the vr controllers.
  42917. * @param color new color for the ray.
  42918. */
  42919. changeLaserColor(color: Color3): void;
  42920. /**
  42921. * Sets the color of the ray from the vr headsets gaze.
  42922. * @param color new color for the ray.
  42923. */
  42924. changeGazeColor(color: Color3): void;
  42925. /**
  42926. * Exits VR and disposes of the vr experience helper
  42927. */
  42928. dispose(): void;
  42929. /**
  42930. * Gets the name of the VRExperienceHelper class
  42931. * @returns "VRExperienceHelper"
  42932. */
  42933. getClassName(): string;
  42934. }
  42935. }
  42936. declare module "babylonjs/Cameras/VR/index" {
  42937. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42938. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42939. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42940. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42941. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42942. export * from "babylonjs/Cameras/VR/webVRCamera";
  42943. }
  42944. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42945. import { Observable } from "babylonjs/Misc/observable";
  42946. import { Nullable } from "babylonjs/types";
  42947. import { IDisposable, Scene } from "babylonjs/scene";
  42948. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42949. /**
  42950. * Manages an XRSession to work with Babylon's engine
  42951. * @see https://doc.babylonjs.com/how_to/webxr
  42952. */
  42953. export class WebXRSessionManager implements IDisposable {
  42954. private scene;
  42955. /**
  42956. * Fires every time a new xrFrame arrives which can be used to update the camera
  42957. */
  42958. onXRFrameObservable: Observable<any>;
  42959. /**
  42960. * Fires when the xr session is ended either by the device or manually done
  42961. */
  42962. onXRSessionEnded: Observable<any>;
  42963. /**
  42964. * Underlying xr session
  42965. */
  42966. session: XRSession;
  42967. /**
  42968. * Type of reference space used when creating the session
  42969. */
  42970. referenceSpace: XRReferenceSpace;
  42971. /** @hidden */
  42972. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42973. /**
  42974. * Current XR frame
  42975. */
  42976. currentFrame: Nullable<XRFrame>;
  42977. private _xrNavigator;
  42978. private baseLayer;
  42979. /**
  42980. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42981. * @param scene The scene which the session should be created for
  42982. */
  42983. constructor(scene: Scene);
  42984. /**
  42985. * Initializes the manager
  42986. * After initialization enterXR can be called to start an XR session
  42987. * @returns Promise which resolves after it is initialized
  42988. */
  42989. initializeAsync(): Promise<void>;
  42990. /**
  42991. * Initializes an xr session
  42992. * @param xrSessionMode mode to initialize
  42993. * @returns a promise which will resolve once the session has been initialized
  42994. */
  42995. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42996. /**
  42997. * Sets the reference space on the xr session
  42998. * @param referenceSpace space to set
  42999. * @returns a promise that will resolve once the reference space has been set
  43000. */
  43001. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43002. /**
  43003. * Updates the render state of the session
  43004. * @param state state to set
  43005. * @returns a promise that resolves once the render state has been updated
  43006. */
  43007. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43008. /**
  43009. * Starts rendering to the xr layer
  43010. * @returns a promise that will resolve once rendering has started
  43011. */
  43012. startRenderingToXRAsync(): Promise<void>;
  43013. /**
  43014. * Stops the xrSession and restores the renderloop
  43015. * @returns Promise which resolves after it exits XR
  43016. */
  43017. exitXRAsync(): Promise<unknown>;
  43018. /**
  43019. * Checks if a session would be supported for the creation options specified
  43020. * @param sessionMode session mode to check if supported eg. immersive-vr
  43021. * @returns true if supported
  43022. */
  43023. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43024. /**
  43025. * @hidden
  43026. * Converts the render layer of xrSession to a render target
  43027. * @param session session to create render target for
  43028. * @param scene scene the new render target should be created for
  43029. */
  43030. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43031. /**
  43032. * Disposes of the session manager
  43033. */
  43034. dispose(): void;
  43035. }
  43036. }
  43037. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43038. import { Scene } from "babylonjs/scene";
  43039. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43040. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43041. /**
  43042. * WebXR Camera which holds the views for the xrSession
  43043. * @see https://doc.babylonjs.com/how_to/webxr
  43044. */
  43045. export class WebXRCamera extends FreeCamera {
  43046. private static _TmpMatrix;
  43047. /**
  43048. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43049. * @param name the name of the camera
  43050. * @param scene the scene to add the camera to
  43051. */
  43052. constructor(name: string, scene: Scene);
  43053. private _updateNumberOfRigCameras;
  43054. /** @hidden */
  43055. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43056. /**
  43057. * Updates the cameras position from the current pose information of the XR session
  43058. * @param xrSessionManager the session containing pose information
  43059. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43060. */
  43061. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43062. }
  43063. }
  43064. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43065. import { Nullable } from "babylonjs/types";
  43066. import { IDisposable } from "babylonjs/scene";
  43067. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43068. /**
  43069. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43070. */
  43071. export class WebXRManagedOutputCanvas implements IDisposable {
  43072. private helper;
  43073. private _canvas;
  43074. /**
  43075. * xrpresent context of the canvas which can be used to display/mirror xr content
  43076. */
  43077. canvasContext: WebGLRenderingContext;
  43078. /**
  43079. * xr layer for the canvas
  43080. */
  43081. xrLayer: Nullable<XRWebGLLayer>;
  43082. /**
  43083. * Initializes the xr layer for the session
  43084. * @param xrSession xr session
  43085. * @returns a promise that will resolve once the XR Layer has been created
  43086. */
  43087. initializeXRLayerAsync(xrSession: any): any;
  43088. /**
  43089. * Initializes the canvas to be added/removed upon entering/exiting xr
  43090. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43091. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43092. */
  43093. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43094. /**
  43095. * Disposes of the object
  43096. */
  43097. dispose(): void;
  43098. private _setManagedOutputCanvas;
  43099. private _addCanvas;
  43100. private _removeCanvas;
  43101. }
  43102. }
  43103. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43104. import { Observable } from "babylonjs/Misc/observable";
  43105. import { IDisposable, Scene } from "babylonjs/scene";
  43106. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43108. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43109. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43110. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43111. /**
  43112. * States of the webXR experience
  43113. */
  43114. export enum WebXRState {
  43115. /**
  43116. * Transitioning to being in XR mode
  43117. */
  43118. ENTERING_XR = 0,
  43119. /**
  43120. * Transitioning to non XR mode
  43121. */
  43122. EXITING_XR = 1,
  43123. /**
  43124. * In XR mode and presenting
  43125. */
  43126. IN_XR = 2,
  43127. /**
  43128. * Not entered XR mode
  43129. */
  43130. NOT_IN_XR = 3
  43131. }
  43132. /**
  43133. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43134. * @see https://doc.babylonjs.com/how_to/webxr
  43135. */
  43136. export class WebXRExperienceHelper implements IDisposable {
  43137. private scene;
  43138. /**
  43139. * 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
  43140. */
  43141. container: AbstractMesh;
  43142. /**
  43143. * Camera used to render xr content
  43144. */
  43145. camera: WebXRCamera;
  43146. /**
  43147. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43148. */
  43149. state: WebXRState;
  43150. private _setState;
  43151. private static _TmpVector;
  43152. /**
  43153. * Fires when the state of the experience helper has changed
  43154. */
  43155. onStateChangedObservable: Observable<WebXRState>;
  43156. /** Session manager used to keep track of xr session */
  43157. sessionManager: WebXRSessionManager;
  43158. private _nonVRCamera;
  43159. private _originalSceneAutoClear;
  43160. private _supported;
  43161. /**
  43162. * Creates the experience helper
  43163. * @param scene the scene to attach the experience helper to
  43164. * @returns a promise for the experience helper
  43165. */
  43166. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43167. /**
  43168. * Creates a WebXRExperienceHelper
  43169. * @param scene The scene the helper should be created in
  43170. */
  43171. private constructor();
  43172. /**
  43173. * Exits XR mode and returns the scene to its original state
  43174. * @returns promise that resolves after xr mode has exited
  43175. */
  43176. exitXRAsync(): Promise<unknown>;
  43177. /**
  43178. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43179. * @param sessionCreationOptions options for the XR session
  43180. * @param referenceSpaceType frame of reference of the XR session
  43181. * @param outputCanvas the output canvas that will be used to enter XR mode
  43182. * @returns promise that resolves after xr mode has entered
  43183. */
  43184. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43185. /**
  43186. * Updates the global position of the camera by moving the camera's container
  43187. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43188. * @param position The desired global position of the camera
  43189. */
  43190. setPositionOfCameraUsingContainer(position: Vector3): void;
  43191. /**
  43192. * Rotates the xr camera by rotating the camera's container around the camera's position
  43193. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43194. * @param rotation the desired quaternion rotation to apply to the camera
  43195. */
  43196. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43197. /**
  43198. * Disposes of the experience helper
  43199. */
  43200. dispose(): void;
  43201. }
  43202. }
  43203. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43204. import { Nullable } from "babylonjs/types";
  43205. import { Observable } from "babylonjs/Misc/observable";
  43206. import { IDisposable, Scene } from "babylonjs/scene";
  43207. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43208. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43209. /**
  43210. * Button which can be used to enter a different mode of XR
  43211. */
  43212. export class WebXREnterExitUIButton {
  43213. /** button element */
  43214. element: HTMLElement;
  43215. /** XR initialization options for the button */
  43216. sessionMode: XRSessionMode;
  43217. /** Reference space type */
  43218. referenceSpaceType: XRReferenceSpaceType;
  43219. /**
  43220. * Creates a WebXREnterExitUIButton
  43221. * @param element button element
  43222. * @param sessionMode XR initialization session mode
  43223. * @param referenceSpaceType the type of reference space to be used
  43224. */
  43225. constructor(
  43226. /** button element */
  43227. element: HTMLElement,
  43228. /** XR initialization options for the button */
  43229. sessionMode: XRSessionMode,
  43230. /** Reference space type */
  43231. referenceSpaceType: XRReferenceSpaceType);
  43232. /**
  43233. * Overwritable function which can be used to update the button's visuals when the state changes
  43234. * @param activeButton the current active button in the UI
  43235. */
  43236. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43237. }
  43238. /**
  43239. * Options to create the webXR UI
  43240. */
  43241. export class WebXREnterExitUIOptions {
  43242. /**
  43243. * Context to enter xr with
  43244. */
  43245. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43246. /**
  43247. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43248. */
  43249. customButtons?: Array<WebXREnterExitUIButton>;
  43250. }
  43251. /**
  43252. * UI to allow the user to enter/exit XR mode
  43253. */
  43254. export class WebXREnterExitUI implements IDisposable {
  43255. private scene;
  43256. private _overlay;
  43257. private _buttons;
  43258. private _activeButton;
  43259. /**
  43260. * Fired every time the active button is changed.
  43261. *
  43262. * When xr is entered via a button that launches xr that button will be the callback parameter
  43263. *
  43264. * When exiting xr the callback parameter will be null)
  43265. */
  43266. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43267. /**
  43268. * Creates UI to allow the user to enter/exit XR mode
  43269. * @param scene the scene to add the ui to
  43270. * @param helper the xr experience helper to enter/exit xr with
  43271. * @param options options to configure the UI
  43272. * @returns the created ui
  43273. */
  43274. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43275. private constructor();
  43276. private _updateButtons;
  43277. /**
  43278. * Disposes of the object
  43279. */
  43280. dispose(): void;
  43281. }
  43282. }
  43283. declare module "babylonjs/Cameras/XR/webXRController" {
  43284. import { Nullable } from "babylonjs/types";
  43285. import { Observable } from "babylonjs/Misc/observable";
  43286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43287. import { Ray } from "babylonjs/Culling/ray";
  43288. import { Scene } from "babylonjs/scene";
  43289. /**
  43290. * Represents an XR input
  43291. */
  43292. export class WebXRController {
  43293. private scene;
  43294. /** The underlying input source for the controller */
  43295. inputSource: XRInputSource;
  43296. private parentContainer;
  43297. /**
  43298. * 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
  43299. */
  43300. grip?: AbstractMesh;
  43301. /**
  43302. * Pointer which can be used to select objects or attach a visible laser to
  43303. */
  43304. pointer: AbstractMesh;
  43305. /**
  43306. * Event that fires when the controller is removed/disposed
  43307. */
  43308. onDisposeObservable: Observable<{}>;
  43309. private _tmpMatrix;
  43310. private _tmpQuaternion;
  43311. private _tmpVector;
  43312. /**
  43313. * Creates the controller
  43314. * @see https://doc.babylonjs.com/how_to/webxr
  43315. * @param scene the scene which the controller should be associated to
  43316. * @param inputSource the underlying input source for the controller
  43317. * @param parentContainer parent that the controller meshes should be children of
  43318. */
  43319. constructor(scene: Scene,
  43320. /** The underlying input source for the controller */
  43321. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43322. /**
  43323. * Updates the controller pose based on the given XRFrame
  43324. * @param xrFrame xr frame to update the pose with
  43325. * @param referenceSpace reference space to use
  43326. */
  43327. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43328. /**
  43329. * Gets a world space ray coming from the controller
  43330. * @param result the resulting ray
  43331. */
  43332. getWorldPointerRayToRef(result: Ray): void;
  43333. /**
  43334. * Disposes of the object
  43335. */
  43336. dispose(): void;
  43337. }
  43338. }
  43339. declare module "babylonjs/Cameras/XR/webXRInput" {
  43340. import { Observable } from "babylonjs/Misc/observable";
  43341. import { IDisposable } from "babylonjs/scene";
  43342. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43343. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43344. /**
  43345. * XR input used to track XR inputs such as controllers/rays
  43346. */
  43347. export class WebXRInput implements IDisposable {
  43348. /**
  43349. * Base experience the input listens to
  43350. */
  43351. baseExperience: WebXRExperienceHelper;
  43352. /**
  43353. * XR controllers being tracked
  43354. */
  43355. controllers: Array<WebXRController>;
  43356. private _frameObserver;
  43357. private _stateObserver;
  43358. /**
  43359. * Event when a controller has been connected/added
  43360. */
  43361. onControllerAddedObservable: Observable<WebXRController>;
  43362. /**
  43363. * Event when a controller has been removed/disconnected
  43364. */
  43365. onControllerRemovedObservable: Observable<WebXRController>;
  43366. /**
  43367. * Initializes the WebXRInput
  43368. * @param baseExperience experience helper which the input should be created for
  43369. */
  43370. constructor(
  43371. /**
  43372. * Base experience the input listens to
  43373. */
  43374. baseExperience: WebXRExperienceHelper);
  43375. private _onInputSourcesChange;
  43376. private _addAndRemoveControllers;
  43377. /**
  43378. * Disposes of the object
  43379. */
  43380. dispose(): void;
  43381. }
  43382. }
  43383. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43385. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43386. /**
  43387. * Enables teleportation
  43388. */
  43389. export class WebXRControllerTeleportation {
  43390. private _teleportationFillColor;
  43391. private _teleportationBorderColor;
  43392. private _tmpRay;
  43393. private _tmpVector;
  43394. /**
  43395. * Creates a WebXRControllerTeleportation
  43396. * @param input input manager to add teleportation to
  43397. * @param floorMeshes floormeshes which can be teleported to
  43398. */
  43399. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43400. }
  43401. }
  43402. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43403. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43404. /**
  43405. * Handles pointer input automatically for the pointer of XR controllers
  43406. */
  43407. export class WebXRControllerPointerSelection {
  43408. private static _idCounter;
  43409. private _tmpRay;
  43410. /**
  43411. * Creates a WebXRControllerPointerSelection
  43412. * @param input input manager to setup pointer selection
  43413. */
  43414. constructor(input: WebXRInput);
  43415. private _convertNormalToDirectionOfRay;
  43416. private _updatePointerDistance;
  43417. }
  43418. }
  43419. declare module "babylonjs/Loading/sceneLoader" {
  43420. import { Observable } from "babylonjs/Misc/observable";
  43421. import { Nullable } from "babylonjs/types";
  43422. import { Scene } from "babylonjs/scene";
  43423. import { Engine } from "babylonjs/Engines/engine";
  43424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43425. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43426. import { AssetContainer } from "babylonjs/assetContainer";
  43427. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43428. import { Skeleton } from "babylonjs/Bones/skeleton";
  43429. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43430. import { WebRequest } from "babylonjs/Misc/webRequest";
  43431. /**
  43432. * Class used to represent data loading progression
  43433. */
  43434. export class SceneLoaderProgressEvent {
  43435. /** defines if data length to load can be evaluated */
  43436. readonly lengthComputable: boolean;
  43437. /** defines the loaded data length */
  43438. readonly loaded: number;
  43439. /** defines the data length to load */
  43440. readonly total: number;
  43441. /**
  43442. * Create a new progress event
  43443. * @param lengthComputable defines if data length to load can be evaluated
  43444. * @param loaded defines the loaded data length
  43445. * @param total defines the data length to load
  43446. */
  43447. constructor(
  43448. /** defines if data length to load can be evaluated */
  43449. lengthComputable: boolean,
  43450. /** defines the loaded data length */
  43451. loaded: number,
  43452. /** defines the data length to load */
  43453. total: number);
  43454. /**
  43455. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43456. * @param event defines the source event
  43457. * @returns a new SceneLoaderProgressEvent
  43458. */
  43459. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43460. }
  43461. /**
  43462. * Interface used by SceneLoader plugins to define supported file extensions
  43463. */
  43464. export interface ISceneLoaderPluginExtensions {
  43465. /**
  43466. * Defines the list of supported extensions
  43467. */
  43468. [extension: string]: {
  43469. isBinary: boolean;
  43470. };
  43471. }
  43472. /**
  43473. * Interface used by SceneLoader plugin factory
  43474. */
  43475. export interface ISceneLoaderPluginFactory {
  43476. /**
  43477. * Defines the name of the factory
  43478. */
  43479. name: string;
  43480. /**
  43481. * Function called to create a new plugin
  43482. * @return the new plugin
  43483. */
  43484. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43485. /**
  43486. * The callback that returns true if the data can be directly loaded.
  43487. * @param data string containing the file data
  43488. * @returns if the data can be loaded directly
  43489. */
  43490. canDirectLoad?(data: string): boolean;
  43491. }
  43492. /**
  43493. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43494. */
  43495. export interface ISceneLoaderPluginBase {
  43496. /**
  43497. * The friendly name of this plugin.
  43498. */
  43499. name: string;
  43500. /**
  43501. * The file extensions supported by this plugin.
  43502. */
  43503. extensions: string | ISceneLoaderPluginExtensions;
  43504. /**
  43505. * The callback called when loading from a url.
  43506. * @param scene scene loading this url
  43507. * @param url url to load
  43508. * @param onSuccess callback called when the file successfully loads
  43509. * @param onProgress callback called while file is loading (if the server supports this mode)
  43510. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43511. * @param onError callback called when the file fails to load
  43512. * @returns a file request object
  43513. */
  43514. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43515. /**
  43516. * The callback called when loading from a file object.
  43517. * @param scene scene loading this file
  43518. * @param file defines the file to load
  43519. * @param onSuccess defines the callback to call when data is loaded
  43520. * @param onProgress defines the callback to call during loading process
  43521. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43522. * @param onError defines the callback to call when an error occurs
  43523. * @returns a file request object
  43524. */
  43525. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43526. /**
  43527. * The callback that returns true if the data can be directly loaded.
  43528. * @param data string containing the file data
  43529. * @returns if the data can be loaded directly
  43530. */
  43531. canDirectLoad?(data: string): boolean;
  43532. /**
  43533. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43534. * @param scene scene loading this data
  43535. * @param data string containing the data
  43536. * @returns data to pass to the plugin
  43537. */
  43538. directLoad?(scene: Scene, data: string): any;
  43539. /**
  43540. * The callback that allows custom handling of the root url based on the response url.
  43541. * @param rootUrl the original root url
  43542. * @param responseURL the response url if available
  43543. * @returns the new root url
  43544. */
  43545. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43546. }
  43547. /**
  43548. * Interface used to define a SceneLoader plugin
  43549. */
  43550. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43551. /**
  43552. * Import meshes into a scene.
  43553. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43554. * @param scene The scene to import into
  43555. * @param data The data to import
  43556. * @param rootUrl The root url for scene and resources
  43557. * @param meshes The meshes array to import into
  43558. * @param particleSystems The particle systems array to import into
  43559. * @param skeletons The skeletons array to import into
  43560. * @param onError The callback when import fails
  43561. * @returns True if successful or false otherwise
  43562. */
  43563. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43564. /**
  43565. * Load into a scene.
  43566. * @param scene The scene to load into
  43567. * @param data The data to import
  43568. * @param rootUrl The root url for scene and resources
  43569. * @param onError The callback when import fails
  43570. * @returns True if successful or false otherwise
  43571. */
  43572. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43573. /**
  43574. * Load into an asset container.
  43575. * @param scene The scene to load into
  43576. * @param data The data to import
  43577. * @param rootUrl The root url for scene and resources
  43578. * @param onError The callback when import fails
  43579. * @returns The loaded asset container
  43580. */
  43581. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43582. }
  43583. /**
  43584. * Interface used to define an async SceneLoader plugin
  43585. */
  43586. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43587. /**
  43588. * Import meshes into a scene.
  43589. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43590. * @param scene The scene to import into
  43591. * @param data The data to import
  43592. * @param rootUrl The root url for scene and resources
  43593. * @param onProgress The callback when the load progresses
  43594. * @param fileName Defines the name of the file to load
  43595. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43596. */
  43597. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43598. meshes: AbstractMesh[];
  43599. particleSystems: IParticleSystem[];
  43600. skeletons: Skeleton[];
  43601. animationGroups: AnimationGroup[];
  43602. }>;
  43603. /**
  43604. * Load into a scene.
  43605. * @param scene The scene to load into
  43606. * @param data The data to import
  43607. * @param rootUrl The root url for scene and resources
  43608. * @param onProgress The callback when the load progresses
  43609. * @param fileName Defines the name of the file to load
  43610. * @returns Nothing
  43611. */
  43612. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43613. /**
  43614. * Load into an asset container.
  43615. * @param scene The scene to load into
  43616. * @param data The data to import
  43617. * @param rootUrl The root url for scene and resources
  43618. * @param onProgress The callback when the load progresses
  43619. * @param fileName Defines the name of the file to load
  43620. * @returns The loaded asset container
  43621. */
  43622. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43623. }
  43624. /**
  43625. * Class used to load scene from various file formats using registered plugins
  43626. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43627. */
  43628. export class SceneLoader {
  43629. /**
  43630. * No logging while loading
  43631. */
  43632. static readonly NO_LOGGING: number;
  43633. /**
  43634. * Minimal logging while loading
  43635. */
  43636. static readonly MINIMAL_LOGGING: number;
  43637. /**
  43638. * Summary logging while loading
  43639. */
  43640. static readonly SUMMARY_LOGGING: number;
  43641. /**
  43642. * Detailled logging while loading
  43643. */
  43644. static readonly DETAILED_LOGGING: number;
  43645. /**
  43646. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43647. */
  43648. static ForceFullSceneLoadingForIncremental: boolean;
  43649. /**
  43650. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43651. */
  43652. static ShowLoadingScreen: boolean;
  43653. /**
  43654. * Defines the current logging level (while loading the scene)
  43655. * @ignorenaming
  43656. */
  43657. static loggingLevel: number;
  43658. /**
  43659. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43660. */
  43661. static CleanBoneMatrixWeights: boolean;
  43662. /**
  43663. * Event raised when a plugin is used to load a scene
  43664. */
  43665. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43666. private static _registeredPlugins;
  43667. private static _getDefaultPlugin;
  43668. private static _getPluginForExtension;
  43669. private static _getPluginForDirectLoad;
  43670. private static _getPluginForFilename;
  43671. private static _getDirectLoad;
  43672. private static _loadData;
  43673. private static _getFileInfo;
  43674. /**
  43675. * Gets a plugin that can load the given extension
  43676. * @param extension defines the extension to load
  43677. * @returns a plugin or null if none works
  43678. */
  43679. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43680. /**
  43681. * Gets a boolean indicating that the given extension can be loaded
  43682. * @param extension defines the extension to load
  43683. * @returns true if the extension is supported
  43684. */
  43685. static IsPluginForExtensionAvailable(extension: string): boolean;
  43686. /**
  43687. * Adds a new plugin to the list of registered plugins
  43688. * @param plugin defines the plugin to add
  43689. */
  43690. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43691. /**
  43692. * Import meshes into a scene
  43693. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43694. * @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)
  43695. * @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)
  43696. * @param scene the instance of BABYLON.Scene to append to
  43697. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43698. * @param onProgress a callback with a progress event for each file being loaded
  43699. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43700. * @param pluginExtension the extension used to determine the plugin
  43701. * @returns The loaded plugin
  43702. */
  43703. 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>;
  43704. /**
  43705. * Import meshes into a scene
  43706. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43707. * @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)
  43708. * @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)
  43709. * @param scene the instance of BABYLON.Scene to append to
  43710. * @param onProgress a callback with a progress event for each file being loaded
  43711. * @param pluginExtension the extension used to determine the plugin
  43712. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43713. */
  43714. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43715. meshes: AbstractMesh[];
  43716. particleSystems: IParticleSystem[];
  43717. skeletons: Skeleton[];
  43718. animationGroups: AnimationGroup[];
  43719. }>;
  43720. /**
  43721. * Load a scene
  43722. * @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)
  43723. * @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)
  43724. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43725. * @param onSuccess a callback with the scene when import succeeds
  43726. * @param onProgress a callback with a progress event for each file being loaded
  43727. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43728. * @param pluginExtension the extension used to determine the plugin
  43729. * @returns The loaded plugin
  43730. */
  43731. 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>;
  43732. /**
  43733. * Load a scene
  43734. * @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)
  43735. * @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)
  43736. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43737. * @param onProgress a callback with a progress event for each file being loaded
  43738. * @param pluginExtension the extension used to determine the plugin
  43739. * @returns The loaded scene
  43740. */
  43741. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43742. /**
  43743. * Append a scene
  43744. * @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)
  43745. * @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)
  43746. * @param scene is the instance of BABYLON.Scene to append to
  43747. * @param onSuccess a callback with the scene when import succeeds
  43748. * @param onProgress a callback with a progress event for each file being loaded
  43749. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43750. * @param pluginExtension the extension used to determine the plugin
  43751. * @returns The loaded plugin
  43752. */
  43753. 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>;
  43754. /**
  43755. * Append a scene
  43756. * @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)
  43757. * @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)
  43758. * @param scene is the instance of BABYLON.Scene to append to
  43759. * @param onProgress a callback with a progress event for each file being loaded
  43760. * @param pluginExtension the extension used to determine the plugin
  43761. * @returns The given scene
  43762. */
  43763. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43764. /**
  43765. * Load a scene into an asset container
  43766. * @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)
  43767. * @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)
  43768. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43769. * @param onSuccess a callback with the scene when import succeeds
  43770. * @param onProgress a callback with a progress event for each file being loaded
  43771. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43772. * @param pluginExtension the extension used to determine the plugin
  43773. * @returns The loaded plugin
  43774. */
  43775. 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>;
  43776. /**
  43777. * Load a scene into an asset container
  43778. * @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)
  43779. * @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)
  43780. * @param scene is the instance of Scene to append to
  43781. * @param onProgress a callback with a progress event for each file being loaded
  43782. * @param pluginExtension the extension used to determine the plugin
  43783. * @returns The loaded asset container
  43784. */
  43785. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43786. }
  43787. }
  43788. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43789. import { Scene } from "babylonjs/scene";
  43790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43791. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43792. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43793. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43794. /**
  43795. * Generic Controller
  43796. */
  43797. export class GenericController extends WebVRController {
  43798. /**
  43799. * Base Url for the controller model.
  43800. */
  43801. static readonly MODEL_BASE_URL: string;
  43802. /**
  43803. * File name for the controller model.
  43804. */
  43805. static readonly MODEL_FILENAME: string;
  43806. /**
  43807. * Creates a new GenericController from a gamepad
  43808. * @param vrGamepad the gamepad that the controller should be created from
  43809. */
  43810. constructor(vrGamepad: any);
  43811. /**
  43812. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43813. * @param scene scene in which to add meshes
  43814. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43815. */
  43816. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): 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. }
  43826. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43827. import { Observable } from "babylonjs/Misc/observable";
  43828. import { Scene } from "babylonjs/scene";
  43829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43830. import { Ray } from "babylonjs/Culling/ray";
  43831. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43832. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43833. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43834. /**
  43835. * Defines the WindowsMotionController object that the state of the windows motion controller
  43836. */
  43837. export class WindowsMotionController extends WebVRController {
  43838. /**
  43839. * The base url used to load the left and right controller models
  43840. */
  43841. static MODEL_BASE_URL: string;
  43842. /**
  43843. * The name of the left controller model file
  43844. */
  43845. static MODEL_LEFT_FILENAME: string;
  43846. /**
  43847. * The name of the right controller model file
  43848. */
  43849. static MODEL_RIGHT_FILENAME: string;
  43850. /**
  43851. * The controller name prefix for this controller type
  43852. */
  43853. static readonly GAMEPAD_ID_PREFIX: string;
  43854. /**
  43855. * The controller id pattern for this controller type
  43856. */
  43857. private static readonly GAMEPAD_ID_PATTERN;
  43858. private _loadedMeshInfo;
  43859. private readonly _mapping;
  43860. /**
  43861. * Fired when the trackpad on this controller is clicked
  43862. */
  43863. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43864. /**
  43865. * Fired when the trackpad on this controller is modified
  43866. */
  43867. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43868. /**
  43869. * The current x and y values of this controller's trackpad
  43870. */
  43871. trackpad: StickValues;
  43872. /**
  43873. * Creates a new WindowsMotionController from a gamepad
  43874. * @param vrGamepad the gamepad that the controller should be created from
  43875. */
  43876. constructor(vrGamepad: any);
  43877. /**
  43878. * Fired when the trigger on this controller is modified
  43879. */
  43880. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43881. /**
  43882. * Fired when the menu button on this controller is modified
  43883. */
  43884. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43885. /**
  43886. * Fired when the grip button on this controller is modified
  43887. */
  43888. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43889. /**
  43890. * Fired when the thumbstick button on this controller is modified
  43891. */
  43892. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43893. /**
  43894. * Fired when the touchpad button on this controller is modified
  43895. */
  43896. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43897. /**
  43898. * Fired when the touchpad values on this controller are modified
  43899. */
  43900. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43901. private _updateTrackpad;
  43902. /**
  43903. * Called once per frame by the engine.
  43904. */
  43905. update(): void;
  43906. /**
  43907. * Called once for each button that changed state since the last frame
  43908. * @param buttonIdx Which button index changed
  43909. * @param state New state of the button
  43910. * @param changes Which properties on the state changed since last frame
  43911. */
  43912. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43913. /**
  43914. * Moves the buttons on the controller mesh based on their current state
  43915. * @param buttonName the name of the button to move
  43916. * @param buttonValue the value of the button which determines the buttons new position
  43917. */
  43918. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43919. /**
  43920. * Moves the axis on the controller mesh based on its current state
  43921. * @param axis the index of the axis
  43922. * @param axisValue the value of the axis which determines the meshes new position
  43923. * @hidden
  43924. */
  43925. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43926. /**
  43927. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43928. * @param scene scene in which to add meshes
  43929. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43930. */
  43931. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43932. /**
  43933. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43934. * can be transformed by button presses and axes values, based on this._mapping.
  43935. *
  43936. * @param scene scene in which the meshes exist
  43937. * @param meshes list of meshes that make up the controller model to process
  43938. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43939. */
  43940. private processModel;
  43941. private createMeshInfo;
  43942. /**
  43943. * Gets the ray of the controller in the direction the controller is pointing
  43944. * @param length the length the resulting ray should be
  43945. * @returns a ray in the direction the controller is pointing
  43946. */
  43947. getForwardRay(length?: number): Ray;
  43948. /**
  43949. * Disposes of the controller
  43950. */
  43951. dispose(): void;
  43952. }
  43953. }
  43954. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43955. import { Observable } from "babylonjs/Misc/observable";
  43956. import { Scene } from "babylonjs/scene";
  43957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43958. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43959. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43960. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43961. /**
  43962. * Oculus Touch Controller
  43963. */
  43964. export class OculusTouchController extends WebVRController {
  43965. /**
  43966. * Base Url for the controller model.
  43967. */
  43968. static MODEL_BASE_URL: string;
  43969. /**
  43970. * File name for the left controller model.
  43971. */
  43972. static MODEL_LEFT_FILENAME: string;
  43973. /**
  43974. * File name for the right controller model.
  43975. */
  43976. static MODEL_RIGHT_FILENAME: string;
  43977. /**
  43978. * Base Url for the Quest controller model.
  43979. */
  43980. static QUEST_MODEL_BASE_URL: string;
  43981. /**
  43982. * @hidden
  43983. * If the controllers are running on a device that needs the updated Quest controller models
  43984. */
  43985. static _IsQuest: boolean;
  43986. /**
  43987. * Fired when the secondary trigger on this controller is modified
  43988. */
  43989. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43990. /**
  43991. * Fired when the thumb rest on this controller is modified
  43992. */
  43993. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43994. /**
  43995. * Creates a new OculusTouchController from a gamepad
  43996. * @param vrGamepad the gamepad that the controller should be created from
  43997. */
  43998. constructor(vrGamepad: any);
  43999. /**
  44000. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44001. * @param scene scene in which to add meshes
  44002. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44003. */
  44004. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44005. /**
  44006. * Fired when the A button on this controller is modified
  44007. */
  44008. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44009. /**
  44010. * Fired when the B button on this controller is modified
  44011. */
  44012. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44013. /**
  44014. * Fired when the X button on this controller is modified
  44015. */
  44016. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44017. /**
  44018. * Fired when the Y button on this controller is modified
  44019. */
  44020. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44021. /**
  44022. * Called once for each button that changed state since the last frame
  44023. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44024. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44025. * 2) secondary trigger (same)
  44026. * 3) A (right) X (left), touch, pressed = value
  44027. * 4) B / Y
  44028. * 5) thumb rest
  44029. * @param buttonIdx Which button index changed
  44030. * @param state New state of the button
  44031. * @param changes Which properties on the state changed since last frame
  44032. */
  44033. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44034. }
  44035. }
  44036. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44037. import { Scene } from "babylonjs/scene";
  44038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44039. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44040. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44041. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44042. import { Observable } from "babylonjs/Misc/observable";
  44043. /**
  44044. * Vive Controller
  44045. */
  44046. export class ViveController extends WebVRController {
  44047. /**
  44048. * Base Url for the controller model.
  44049. */
  44050. static MODEL_BASE_URL: string;
  44051. /**
  44052. * File name for the controller model.
  44053. */
  44054. static MODEL_FILENAME: string;
  44055. /**
  44056. * Creates a new ViveController from a gamepad
  44057. * @param vrGamepad the gamepad that the controller should be created from
  44058. */
  44059. constructor(vrGamepad: any);
  44060. /**
  44061. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44062. * @param scene scene in which to add meshes
  44063. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44064. */
  44065. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44066. /**
  44067. * Fired when the left button on this controller is modified
  44068. */
  44069. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44070. /**
  44071. * Fired when the right button on this controller is modified
  44072. */
  44073. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44074. /**
  44075. * Fired when the menu button on this controller is modified
  44076. */
  44077. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44078. /**
  44079. * Called once for each button that changed state since the last frame
  44080. * Vive mapping:
  44081. * 0: touchpad
  44082. * 1: trigger
  44083. * 2: left AND right buttons
  44084. * 3: menu button
  44085. * @param buttonIdx Which button index changed
  44086. * @param state New state of the button
  44087. * @param changes Which properties on the state changed since last frame
  44088. */
  44089. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44090. }
  44091. }
  44092. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44093. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44094. /**
  44095. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44096. */
  44097. export class WebXRControllerModelLoader {
  44098. /**
  44099. * Creates the WebXRControllerModelLoader
  44100. * @param input xr input that creates the controllers
  44101. */
  44102. constructor(input: WebXRInput);
  44103. }
  44104. }
  44105. declare module "babylonjs/Cameras/XR/index" {
  44106. export * from "babylonjs/Cameras/XR/webXRCamera";
  44107. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44108. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44109. export * from "babylonjs/Cameras/XR/webXRInput";
  44110. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44111. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44112. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44113. export * from "babylonjs/Cameras/XR/webXRController";
  44114. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44115. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44116. }
  44117. declare module "babylonjs/Cameras/RigModes/index" {
  44118. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44119. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44120. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44121. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44122. }
  44123. declare module "babylonjs/Cameras/index" {
  44124. export * from "babylonjs/Cameras/Inputs/index";
  44125. export * from "babylonjs/Cameras/cameraInputsManager";
  44126. export * from "babylonjs/Cameras/camera";
  44127. export * from "babylonjs/Cameras/targetCamera";
  44128. export * from "babylonjs/Cameras/freeCamera";
  44129. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44130. export * from "babylonjs/Cameras/touchCamera";
  44131. export * from "babylonjs/Cameras/arcRotateCamera";
  44132. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44133. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44134. export * from "babylonjs/Cameras/flyCamera";
  44135. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44136. export * from "babylonjs/Cameras/followCamera";
  44137. export * from "babylonjs/Cameras/followCameraInputsManager";
  44138. export * from "babylonjs/Cameras/gamepadCamera";
  44139. export * from "babylonjs/Cameras/Stereoscopic/index";
  44140. export * from "babylonjs/Cameras/universalCamera";
  44141. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44142. export * from "babylonjs/Cameras/VR/index";
  44143. export * from "babylonjs/Cameras/XR/index";
  44144. export * from "babylonjs/Cameras/RigModes/index";
  44145. }
  44146. declare module "babylonjs/Collisions/index" {
  44147. export * from "babylonjs/Collisions/collider";
  44148. export * from "babylonjs/Collisions/collisionCoordinator";
  44149. export * from "babylonjs/Collisions/pickingInfo";
  44150. export * from "babylonjs/Collisions/intersectionInfo";
  44151. export * from "babylonjs/Collisions/meshCollisionData";
  44152. }
  44153. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44154. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44155. import { Vector3 } from "babylonjs/Maths/math.vector";
  44156. import { Ray } from "babylonjs/Culling/ray";
  44157. import { Plane } from "babylonjs/Maths/math.plane";
  44158. /**
  44159. * Contains an array of blocks representing the octree
  44160. */
  44161. export interface IOctreeContainer<T> {
  44162. /**
  44163. * Blocks within the octree
  44164. */
  44165. blocks: Array<OctreeBlock<T>>;
  44166. }
  44167. /**
  44168. * Class used to store a cell in an octree
  44169. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44170. */
  44171. export class OctreeBlock<T> {
  44172. /**
  44173. * Gets the content of the current block
  44174. */
  44175. entries: T[];
  44176. /**
  44177. * Gets the list of block children
  44178. */
  44179. blocks: Array<OctreeBlock<T>>;
  44180. private _depth;
  44181. private _maxDepth;
  44182. private _capacity;
  44183. private _minPoint;
  44184. private _maxPoint;
  44185. private _boundingVectors;
  44186. private _creationFunc;
  44187. /**
  44188. * Creates a new block
  44189. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44190. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44191. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44192. * @param depth defines the current depth of this block in the octree
  44193. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44194. * @param creationFunc defines a callback to call when an element is added to the block
  44195. */
  44196. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44197. /**
  44198. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44199. */
  44200. readonly capacity: number;
  44201. /**
  44202. * Gets the minimum vector (in world space) of the block's bounding box
  44203. */
  44204. readonly minPoint: Vector3;
  44205. /**
  44206. * Gets the maximum vector (in world space) of the block's bounding box
  44207. */
  44208. readonly maxPoint: Vector3;
  44209. /**
  44210. * Add a new element to this block
  44211. * @param entry defines the element to add
  44212. */
  44213. addEntry(entry: T): void;
  44214. /**
  44215. * Remove an element from this block
  44216. * @param entry defines the element to remove
  44217. */
  44218. removeEntry(entry: T): void;
  44219. /**
  44220. * Add an array of elements to this block
  44221. * @param entries defines the array of elements to add
  44222. */
  44223. addEntries(entries: T[]): void;
  44224. /**
  44225. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44226. * @param frustumPlanes defines the frustum planes to test
  44227. * @param selection defines the array to store current content if selection is positive
  44228. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44229. */
  44230. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44231. /**
  44232. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44233. * @param sphereCenter defines the bounding sphere center
  44234. * @param sphereRadius defines the bounding sphere radius
  44235. * @param selection defines the array to store current content if selection is positive
  44236. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44237. */
  44238. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44239. /**
  44240. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44241. * @param ray defines the ray to test with
  44242. * @param selection defines the array to store current content if selection is positive
  44243. */
  44244. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44245. /**
  44246. * Subdivide the content into child blocks (this block will then be empty)
  44247. */
  44248. createInnerBlocks(): void;
  44249. /**
  44250. * @hidden
  44251. */
  44252. 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;
  44253. }
  44254. }
  44255. declare module "babylonjs/Culling/Octrees/octree" {
  44256. import { SmartArray } from "babylonjs/Misc/smartArray";
  44257. import { Vector3 } from "babylonjs/Maths/math.vector";
  44258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44260. import { Ray } from "babylonjs/Culling/ray";
  44261. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44262. import { Plane } from "babylonjs/Maths/math.plane";
  44263. /**
  44264. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44265. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44266. */
  44267. export class Octree<T> {
  44268. /** 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.) */
  44269. maxDepth: number;
  44270. /**
  44271. * Blocks within the octree containing objects
  44272. */
  44273. blocks: Array<OctreeBlock<T>>;
  44274. /**
  44275. * Content stored in the octree
  44276. */
  44277. dynamicContent: T[];
  44278. private _maxBlockCapacity;
  44279. private _selectionContent;
  44280. private _creationFunc;
  44281. /**
  44282. * Creates a octree
  44283. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44284. * @param creationFunc function to be used to instatiate the octree
  44285. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44286. * @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.)
  44287. */
  44288. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44289. /** 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.) */
  44290. maxDepth?: number);
  44291. /**
  44292. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44293. * @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);
  44294. * @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);
  44295. * @param entries meshes to be added to the octree blocks
  44296. */
  44297. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44298. /**
  44299. * Adds a mesh to the octree
  44300. * @param entry Mesh to add to the octree
  44301. */
  44302. addMesh(entry: T): void;
  44303. /**
  44304. * Remove an element from the octree
  44305. * @param entry defines the element to remove
  44306. */
  44307. removeMesh(entry: T): void;
  44308. /**
  44309. * Selects an array of meshes within the frustum
  44310. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44311. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44312. * @returns array of meshes within the frustum
  44313. */
  44314. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44315. /**
  44316. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44317. * @param sphereCenter defines the bounding sphere center
  44318. * @param sphereRadius defines the bounding sphere radius
  44319. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44320. * @returns an array of objects that intersect the sphere
  44321. */
  44322. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44323. /**
  44324. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44325. * @param ray defines the ray to test with
  44326. * @returns array of intersected objects
  44327. */
  44328. intersectsRay(ray: Ray): SmartArray<T>;
  44329. /**
  44330. * Adds a mesh into the octree block if it intersects the block
  44331. */
  44332. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44333. /**
  44334. * Adds a submesh into the octree block if it intersects the block
  44335. */
  44336. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44337. }
  44338. }
  44339. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44340. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44341. import { Scene } from "babylonjs/scene";
  44342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44344. import { Ray } from "babylonjs/Culling/ray";
  44345. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44346. import { Collider } from "babylonjs/Collisions/collider";
  44347. module "babylonjs/scene" {
  44348. interface Scene {
  44349. /**
  44350. * @hidden
  44351. * Backing Filed
  44352. */
  44353. _selectionOctree: Octree<AbstractMesh>;
  44354. /**
  44355. * Gets the octree used to boost mesh selection (picking)
  44356. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44357. */
  44358. selectionOctree: Octree<AbstractMesh>;
  44359. /**
  44360. * Creates or updates the octree used to boost selection (picking)
  44361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44362. * @param maxCapacity defines the maximum capacity per leaf
  44363. * @param maxDepth defines the maximum depth of the octree
  44364. * @returns an octree of AbstractMesh
  44365. */
  44366. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44367. }
  44368. }
  44369. module "babylonjs/Meshes/abstractMesh" {
  44370. interface AbstractMesh {
  44371. /**
  44372. * @hidden
  44373. * Backing Field
  44374. */
  44375. _submeshesOctree: Octree<SubMesh>;
  44376. /**
  44377. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44378. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44379. * @param maxCapacity defines the maximum size of each block (64 by default)
  44380. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44381. * @returns the new octree
  44382. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44383. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44384. */
  44385. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44386. }
  44387. }
  44388. /**
  44389. * Defines the octree scene component responsible to manage any octrees
  44390. * in a given scene.
  44391. */
  44392. export class OctreeSceneComponent {
  44393. /**
  44394. * The component name help to identify the component in the list of scene components.
  44395. */
  44396. readonly name: string;
  44397. /**
  44398. * The scene the component belongs to.
  44399. */
  44400. scene: Scene;
  44401. /**
  44402. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44403. */
  44404. readonly checksIsEnabled: boolean;
  44405. /**
  44406. * Creates a new instance of the component for the given scene
  44407. * @param scene Defines the scene to register the component in
  44408. */
  44409. constructor(scene: Scene);
  44410. /**
  44411. * Registers the component in a given scene
  44412. */
  44413. register(): void;
  44414. /**
  44415. * Return the list of active meshes
  44416. * @returns the list of active meshes
  44417. */
  44418. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44419. /**
  44420. * Return the list of active sub meshes
  44421. * @param mesh The mesh to get the candidates sub meshes from
  44422. * @returns the list of active sub meshes
  44423. */
  44424. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44425. private _tempRay;
  44426. /**
  44427. * Return the list of sub meshes intersecting with a given local ray
  44428. * @param mesh defines the mesh to find the submesh for
  44429. * @param localRay defines the ray in local space
  44430. * @returns the list of intersecting sub meshes
  44431. */
  44432. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44433. /**
  44434. * Return the list of sub meshes colliding with a collider
  44435. * @param mesh defines the mesh to find the submesh for
  44436. * @param collider defines the collider to evaluate the collision against
  44437. * @returns the list of colliding sub meshes
  44438. */
  44439. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44440. /**
  44441. * Rebuilds the elements related to this component in case of
  44442. * context lost for instance.
  44443. */
  44444. rebuild(): void;
  44445. /**
  44446. * Disposes the component and the associated ressources.
  44447. */
  44448. dispose(): void;
  44449. }
  44450. }
  44451. declare module "babylonjs/Culling/Octrees/index" {
  44452. export * from "babylonjs/Culling/Octrees/octree";
  44453. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44454. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44455. }
  44456. declare module "babylonjs/Culling/index" {
  44457. export * from "babylonjs/Culling/boundingBox";
  44458. export * from "babylonjs/Culling/boundingInfo";
  44459. export * from "babylonjs/Culling/boundingSphere";
  44460. export * from "babylonjs/Culling/Octrees/index";
  44461. export * from "babylonjs/Culling/ray";
  44462. }
  44463. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44464. import { IDisposable, Scene } from "babylonjs/scene";
  44465. import { Nullable } from "babylonjs/types";
  44466. import { Observable } from "babylonjs/Misc/observable";
  44467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44468. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44469. import { Camera } from "babylonjs/Cameras/camera";
  44470. /**
  44471. * Renders a layer on top of an existing scene
  44472. */
  44473. export class UtilityLayerRenderer implements IDisposable {
  44474. /** the original scene that will be rendered on top of */
  44475. originalScene: Scene;
  44476. private _pointerCaptures;
  44477. private _lastPointerEvents;
  44478. private static _DefaultUtilityLayer;
  44479. private static _DefaultKeepDepthUtilityLayer;
  44480. private _sharedGizmoLight;
  44481. private _renderCamera;
  44482. /**
  44483. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44484. * @returns the camera that is used when rendering the utility layer
  44485. */
  44486. getRenderCamera(): Nullable<Camera>;
  44487. /**
  44488. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44489. * @param cam the camera that should be used when rendering the utility layer
  44490. */
  44491. setRenderCamera(cam: Nullable<Camera>): void;
  44492. /**
  44493. * @hidden
  44494. * Light which used by gizmos to get light shading
  44495. */
  44496. _getSharedGizmoLight(): HemisphericLight;
  44497. /**
  44498. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44499. */
  44500. pickUtilitySceneFirst: boolean;
  44501. /**
  44502. * 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)
  44503. */
  44504. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44505. /**
  44506. * 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)
  44507. */
  44508. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44509. /**
  44510. * The scene that is rendered on top of the original scene
  44511. */
  44512. utilityLayerScene: Scene;
  44513. /**
  44514. * If the utility layer should automatically be rendered on top of existing scene
  44515. */
  44516. shouldRender: boolean;
  44517. /**
  44518. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44519. */
  44520. onlyCheckPointerDownEvents: boolean;
  44521. /**
  44522. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44523. */
  44524. processAllEvents: boolean;
  44525. /**
  44526. * Observable raised when the pointer move from the utility layer scene to the main scene
  44527. */
  44528. onPointerOutObservable: Observable<number>;
  44529. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44530. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44531. private _afterRenderObserver;
  44532. private _sceneDisposeObserver;
  44533. private _originalPointerObserver;
  44534. /**
  44535. * Instantiates a UtilityLayerRenderer
  44536. * @param originalScene the original scene that will be rendered on top of
  44537. * @param handleEvents boolean indicating if the utility layer should handle events
  44538. */
  44539. constructor(
  44540. /** the original scene that will be rendered on top of */
  44541. originalScene: Scene, handleEvents?: boolean);
  44542. private _notifyObservers;
  44543. /**
  44544. * Renders the utility layers scene on top of the original scene
  44545. */
  44546. render(): void;
  44547. /**
  44548. * Disposes of the renderer
  44549. */
  44550. dispose(): void;
  44551. private _updateCamera;
  44552. }
  44553. }
  44554. declare module "babylonjs/Gizmos/gizmo" {
  44555. import { Nullable } from "babylonjs/types";
  44556. import { IDisposable } from "babylonjs/scene";
  44557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44558. import { Mesh } from "babylonjs/Meshes/mesh";
  44559. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44560. /**
  44561. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44562. */
  44563. export class Gizmo implements IDisposable {
  44564. /** The utility layer the gizmo will be added to */
  44565. gizmoLayer: UtilityLayerRenderer;
  44566. /**
  44567. * The root mesh of the gizmo
  44568. */
  44569. _rootMesh: Mesh;
  44570. private _attachedMesh;
  44571. /**
  44572. * Ratio for the scale of the gizmo (Default: 1)
  44573. */
  44574. scaleRatio: number;
  44575. /**
  44576. * If a custom mesh has been set (Default: false)
  44577. */
  44578. protected _customMeshSet: boolean;
  44579. /**
  44580. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44581. * * When set, interactions will be enabled
  44582. */
  44583. attachedMesh: Nullable<AbstractMesh>;
  44584. /**
  44585. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44586. * @param mesh The mesh to replace the default mesh of the gizmo
  44587. */
  44588. setCustomMesh(mesh: Mesh): void;
  44589. /**
  44590. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44591. */
  44592. updateGizmoRotationToMatchAttachedMesh: boolean;
  44593. /**
  44594. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44595. */
  44596. updateGizmoPositionToMatchAttachedMesh: boolean;
  44597. /**
  44598. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44599. */
  44600. updateScale: boolean;
  44601. protected _interactionsEnabled: boolean;
  44602. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44603. private _beforeRenderObserver;
  44604. private _tempVector;
  44605. /**
  44606. * Creates a gizmo
  44607. * @param gizmoLayer The utility layer the gizmo will be added to
  44608. */
  44609. constructor(
  44610. /** The utility layer the gizmo will be added to */
  44611. gizmoLayer?: UtilityLayerRenderer);
  44612. /**
  44613. * Updates the gizmo to match the attached mesh's position/rotation
  44614. */
  44615. protected _update(): void;
  44616. /**
  44617. * Disposes of the gizmo
  44618. */
  44619. dispose(): void;
  44620. }
  44621. }
  44622. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44623. import { Observable } from "babylonjs/Misc/observable";
  44624. import { Nullable } from "babylonjs/types";
  44625. import { Vector3 } from "babylonjs/Maths/math.vector";
  44626. import { Color3 } from "babylonjs/Maths/math.color";
  44627. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44629. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44630. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44631. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44632. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44633. import { Scene } from "babylonjs/scene";
  44634. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44635. /**
  44636. * Single plane drag gizmo
  44637. */
  44638. export class PlaneDragGizmo extends Gizmo {
  44639. /**
  44640. * Drag behavior responsible for the gizmos dragging interactions
  44641. */
  44642. dragBehavior: PointerDragBehavior;
  44643. private _pointerObserver;
  44644. /**
  44645. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44646. */
  44647. snapDistance: number;
  44648. /**
  44649. * Event that fires each time the gizmo snaps to a new location.
  44650. * * snapDistance is the the change in distance
  44651. */
  44652. onSnapObservable: Observable<{
  44653. snapDistance: number;
  44654. }>;
  44655. private _plane;
  44656. private _coloredMaterial;
  44657. private _hoverMaterial;
  44658. private _isEnabled;
  44659. private _parent;
  44660. /** @hidden */
  44661. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44662. /** @hidden */
  44663. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44664. /**
  44665. * Creates a PlaneDragGizmo
  44666. * @param gizmoLayer The utility layer the gizmo will be added to
  44667. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44668. * @param color The color of the gizmo
  44669. */
  44670. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44671. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44672. /**
  44673. * If the gizmo is enabled
  44674. */
  44675. isEnabled: boolean;
  44676. /**
  44677. * Disposes of the gizmo
  44678. */
  44679. dispose(): void;
  44680. }
  44681. }
  44682. declare module "babylonjs/Gizmos/positionGizmo" {
  44683. import { Observable } from "babylonjs/Misc/observable";
  44684. import { Nullable } from "babylonjs/types";
  44685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44686. import { Mesh } from "babylonjs/Meshes/mesh";
  44687. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44688. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44689. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44690. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44691. /**
  44692. * Gizmo that enables dragging a mesh along 3 axis
  44693. */
  44694. export class PositionGizmo extends Gizmo {
  44695. /**
  44696. * Internal gizmo used for interactions on the x axis
  44697. */
  44698. xGizmo: AxisDragGizmo;
  44699. /**
  44700. * Internal gizmo used for interactions on the y axis
  44701. */
  44702. yGizmo: AxisDragGizmo;
  44703. /**
  44704. * Internal gizmo used for interactions on the z axis
  44705. */
  44706. zGizmo: AxisDragGizmo;
  44707. /**
  44708. * Internal gizmo used for interactions on the yz plane
  44709. */
  44710. xPlaneGizmo: PlaneDragGizmo;
  44711. /**
  44712. * Internal gizmo used for interactions on the xz plane
  44713. */
  44714. yPlaneGizmo: PlaneDragGizmo;
  44715. /**
  44716. * Internal gizmo used for interactions on the xy plane
  44717. */
  44718. zPlaneGizmo: PlaneDragGizmo;
  44719. /**
  44720. * private variables
  44721. */
  44722. private _meshAttached;
  44723. private _updateGizmoRotationToMatchAttachedMesh;
  44724. private _snapDistance;
  44725. private _scaleRatio;
  44726. /** Fires an event when any of it's sub gizmos are dragged */
  44727. onDragStartObservable: Observable<unknown>;
  44728. /** Fires an event when any of it's sub gizmos are released from dragging */
  44729. onDragEndObservable: Observable<unknown>;
  44730. /**
  44731. * If set to true, planar drag is enabled
  44732. */
  44733. private _planarGizmoEnabled;
  44734. attachedMesh: Nullable<AbstractMesh>;
  44735. /**
  44736. * Creates a PositionGizmo
  44737. * @param gizmoLayer The utility layer the gizmo will be added to
  44738. */
  44739. constructor(gizmoLayer?: UtilityLayerRenderer);
  44740. /**
  44741. * If the planar drag gizmo is enabled
  44742. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44743. */
  44744. planarGizmoEnabled: boolean;
  44745. updateGizmoRotationToMatchAttachedMesh: boolean;
  44746. /**
  44747. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44748. */
  44749. snapDistance: number;
  44750. /**
  44751. * Ratio for the scale of the gizmo (Default: 1)
  44752. */
  44753. scaleRatio: number;
  44754. /**
  44755. * Disposes of the gizmo
  44756. */
  44757. dispose(): void;
  44758. /**
  44759. * CustomMeshes are not supported by this gizmo
  44760. * @param mesh The mesh to replace the default mesh of the gizmo
  44761. */
  44762. setCustomMesh(mesh: Mesh): void;
  44763. }
  44764. }
  44765. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44766. import { Observable } from "babylonjs/Misc/observable";
  44767. import { Nullable } from "babylonjs/types";
  44768. import { Vector3 } from "babylonjs/Maths/math.vector";
  44769. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44771. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44772. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44773. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44774. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44775. import { Scene } from "babylonjs/scene";
  44776. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44777. import { Color3 } from "babylonjs/Maths/math.color";
  44778. /**
  44779. * Single axis drag gizmo
  44780. */
  44781. export class AxisDragGizmo extends Gizmo {
  44782. /**
  44783. * Drag behavior responsible for the gizmos dragging interactions
  44784. */
  44785. dragBehavior: PointerDragBehavior;
  44786. private _pointerObserver;
  44787. /**
  44788. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44789. */
  44790. snapDistance: number;
  44791. /**
  44792. * Event that fires each time the gizmo snaps to a new location.
  44793. * * snapDistance is the the change in distance
  44794. */
  44795. onSnapObservable: Observable<{
  44796. snapDistance: number;
  44797. }>;
  44798. private _isEnabled;
  44799. private _parent;
  44800. private _arrow;
  44801. private _coloredMaterial;
  44802. private _hoverMaterial;
  44803. /** @hidden */
  44804. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44805. /** @hidden */
  44806. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44807. /**
  44808. * Creates an AxisDragGizmo
  44809. * @param gizmoLayer The utility layer the gizmo will be added to
  44810. * @param dragAxis The axis which the gizmo will be able to drag on
  44811. * @param color The color of the gizmo
  44812. */
  44813. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44814. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44815. /**
  44816. * If the gizmo is enabled
  44817. */
  44818. isEnabled: boolean;
  44819. /**
  44820. * Disposes of the gizmo
  44821. */
  44822. dispose(): void;
  44823. }
  44824. }
  44825. declare module "babylonjs/Debug/axesViewer" {
  44826. import { Vector3 } from "babylonjs/Maths/math.vector";
  44827. import { Nullable } from "babylonjs/types";
  44828. import { Scene } from "babylonjs/scene";
  44829. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44830. /**
  44831. * The Axes viewer will show 3 axes in a specific point in space
  44832. */
  44833. export class AxesViewer {
  44834. private _xAxis;
  44835. private _yAxis;
  44836. private _zAxis;
  44837. private _scaleLinesFactor;
  44838. private _instanced;
  44839. /**
  44840. * Gets the hosting scene
  44841. */
  44842. scene: Scene;
  44843. /**
  44844. * Gets or sets a number used to scale line length
  44845. */
  44846. scaleLines: number;
  44847. /** Gets the node hierarchy used to render x-axis */
  44848. readonly xAxis: TransformNode;
  44849. /** Gets the node hierarchy used to render y-axis */
  44850. readonly yAxis: TransformNode;
  44851. /** Gets the node hierarchy used to render z-axis */
  44852. readonly zAxis: TransformNode;
  44853. /**
  44854. * Creates a new AxesViewer
  44855. * @param scene defines the hosting scene
  44856. * @param scaleLines defines a number used to scale line length (1 by default)
  44857. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44858. * @param xAxis defines the node hierarchy used to render the x-axis
  44859. * @param yAxis defines the node hierarchy used to render the y-axis
  44860. * @param zAxis defines the node hierarchy used to render the z-axis
  44861. */
  44862. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44863. /**
  44864. * Force the viewer to update
  44865. * @param position defines the position of the viewer
  44866. * @param xaxis defines the x axis of the viewer
  44867. * @param yaxis defines the y axis of the viewer
  44868. * @param zaxis defines the z axis of the viewer
  44869. */
  44870. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44871. /**
  44872. * Creates an instance of this axes viewer.
  44873. * @returns a new axes viewer with instanced meshes
  44874. */
  44875. createInstance(): AxesViewer;
  44876. /** Releases resources */
  44877. dispose(): void;
  44878. private static _SetRenderingGroupId;
  44879. }
  44880. }
  44881. declare module "babylonjs/Debug/boneAxesViewer" {
  44882. import { Nullable } from "babylonjs/types";
  44883. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44884. import { Vector3 } from "babylonjs/Maths/math.vector";
  44885. import { Mesh } from "babylonjs/Meshes/mesh";
  44886. import { Bone } from "babylonjs/Bones/bone";
  44887. import { Scene } from "babylonjs/scene";
  44888. /**
  44889. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44890. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44891. */
  44892. export class BoneAxesViewer extends AxesViewer {
  44893. /**
  44894. * Gets or sets the target mesh where to display the axes viewer
  44895. */
  44896. mesh: Nullable<Mesh>;
  44897. /**
  44898. * Gets or sets the target bone where to display the axes viewer
  44899. */
  44900. bone: Nullable<Bone>;
  44901. /** Gets current position */
  44902. pos: Vector3;
  44903. /** Gets direction of X axis */
  44904. xaxis: Vector3;
  44905. /** Gets direction of Y axis */
  44906. yaxis: Vector3;
  44907. /** Gets direction of Z axis */
  44908. zaxis: Vector3;
  44909. /**
  44910. * Creates a new BoneAxesViewer
  44911. * @param scene defines the hosting scene
  44912. * @param bone defines the target bone
  44913. * @param mesh defines the target mesh
  44914. * @param scaleLines defines a scaling factor for line length (1 by default)
  44915. */
  44916. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44917. /**
  44918. * Force the viewer to update
  44919. */
  44920. update(): void;
  44921. /** Releases resources */
  44922. dispose(): void;
  44923. }
  44924. }
  44925. declare module "babylonjs/Debug/debugLayer" {
  44926. import { Scene } from "babylonjs/scene";
  44927. /**
  44928. * Interface used to define scene explorer extensibility option
  44929. */
  44930. export interface IExplorerExtensibilityOption {
  44931. /**
  44932. * Define the option label
  44933. */
  44934. label: string;
  44935. /**
  44936. * Defines the action to execute on click
  44937. */
  44938. action: (entity: any) => void;
  44939. }
  44940. /**
  44941. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44942. */
  44943. export interface IExplorerExtensibilityGroup {
  44944. /**
  44945. * Defines a predicate to test if a given type mut be extended
  44946. */
  44947. predicate: (entity: any) => boolean;
  44948. /**
  44949. * Gets the list of options added to a type
  44950. */
  44951. entries: IExplorerExtensibilityOption[];
  44952. }
  44953. /**
  44954. * Interface used to define the options to use to create the Inspector
  44955. */
  44956. export interface IInspectorOptions {
  44957. /**
  44958. * Display in overlay mode (default: false)
  44959. */
  44960. overlay?: boolean;
  44961. /**
  44962. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44963. */
  44964. globalRoot?: HTMLElement;
  44965. /**
  44966. * Display the Scene explorer
  44967. */
  44968. showExplorer?: boolean;
  44969. /**
  44970. * Display the property inspector
  44971. */
  44972. showInspector?: boolean;
  44973. /**
  44974. * Display in embed mode (both panes on the right)
  44975. */
  44976. embedMode?: boolean;
  44977. /**
  44978. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44979. */
  44980. handleResize?: boolean;
  44981. /**
  44982. * Allow the panes to popup (default: true)
  44983. */
  44984. enablePopup?: boolean;
  44985. /**
  44986. * Allow the panes to be closed by users (default: true)
  44987. */
  44988. enableClose?: boolean;
  44989. /**
  44990. * Optional list of extensibility entries
  44991. */
  44992. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44993. /**
  44994. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44995. */
  44996. inspectorURL?: string;
  44997. }
  44998. module "babylonjs/scene" {
  44999. interface Scene {
  45000. /**
  45001. * @hidden
  45002. * Backing field
  45003. */
  45004. _debugLayer: DebugLayer;
  45005. /**
  45006. * Gets the debug layer (aka Inspector) associated with the scene
  45007. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45008. */
  45009. debugLayer: DebugLayer;
  45010. }
  45011. }
  45012. /**
  45013. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45014. * what is happening in your scene
  45015. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45016. */
  45017. export class DebugLayer {
  45018. /**
  45019. * Define the url to get the inspector script from.
  45020. * By default it uses the babylonjs CDN.
  45021. * @ignoreNaming
  45022. */
  45023. static InspectorURL: string;
  45024. private _scene;
  45025. private BJSINSPECTOR;
  45026. private _onPropertyChangedObservable?;
  45027. /**
  45028. * Observable triggered when a property is changed through the inspector.
  45029. */
  45030. readonly onPropertyChangedObservable: any;
  45031. /**
  45032. * Instantiates a new debug layer.
  45033. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45034. * what is happening in your scene
  45035. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45036. * @param scene Defines the scene to inspect
  45037. */
  45038. constructor(scene: Scene);
  45039. /** Creates the inspector window. */
  45040. private _createInspector;
  45041. /**
  45042. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45043. * @param entity defines the entity to select
  45044. * @param lineContainerTitle defines the specific block to highlight
  45045. */
  45046. select(entity: any, lineContainerTitle?: string): void;
  45047. /** Get the inspector from bundle or global */
  45048. private _getGlobalInspector;
  45049. /**
  45050. * Get if the inspector is visible or not.
  45051. * @returns true if visible otherwise, false
  45052. */
  45053. isVisible(): boolean;
  45054. /**
  45055. * Hide the inspector and close its window.
  45056. */
  45057. hide(): void;
  45058. /**
  45059. * Launch the debugLayer.
  45060. * @param config Define the configuration of the inspector
  45061. * @return a promise fulfilled when the debug layer is visible
  45062. */
  45063. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45064. }
  45065. }
  45066. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45067. import { Nullable } from "babylonjs/types";
  45068. import { Scene } from "babylonjs/scene";
  45069. import { Vector4 } from "babylonjs/Maths/math.vector";
  45070. import { Color4 } from "babylonjs/Maths/math.color";
  45071. import { Mesh } from "babylonjs/Meshes/mesh";
  45072. /**
  45073. * Class containing static functions to help procedurally build meshes
  45074. */
  45075. export class BoxBuilder {
  45076. /**
  45077. * Creates a box mesh
  45078. * * The parameter `size` sets the size (float) of each box side (default 1)
  45079. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45080. * * 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)
  45081. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45085. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45086. * @param name defines the name of the mesh
  45087. * @param options defines the options used to create the mesh
  45088. * @param scene defines the hosting scene
  45089. * @returns the box mesh
  45090. */
  45091. static CreateBox(name: string, options: {
  45092. size?: number;
  45093. width?: number;
  45094. height?: number;
  45095. depth?: number;
  45096. faceUV?: Vector4[];
  45097. faceColors?: Color4[];
  45098. sideOrientation?: number;
  45099. frontUVs?: Vector4;
  45100. backUVs?: Vector4;
  45101. wrap?: boolean;
  45102. topBaseAt?: number;
  45103. bottomBaseAt?: number;
  45104. updatable?: boolean;
  45105. }, scene?: Nullable<Scene>): Mesh;
  45106. }
  45107. }
  45108. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45109. import { Vector4 } from "babylonjs/Maths/math.vector";
  45110. import { Mesh } from "babylonjs/Meshes/mesh";
  45111. import { Scene } from "babylonjs/scene";
  45112. import { Nullable } from "babylonjs/types";
  45113. /**
  45114. * Class containing static functions to help procedurally build meshes
  45115. */
  45116. export class SphereBuilder {
  45117. /**
  45118. * Creates a sphere mesh
  45119. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45120. * * 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`)
  45121. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45122. * * 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
  45123. * * 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)
  45124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45127. * @param name defines the name of the mesh
  45128. * @param options defines the options used to create the mesh
  45129. * @param scene defines the hosting scene
  45130. * @returns the sphere mesh
  45131. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45132. */
  45133. static CreateSphere(name: string, options: {
  45134. segments?: number;
  45135. diameter?: number;
  45136. diameterX?: number;
  45137. diameterY?: number;
  45138. diameterZ?: number;
  45139. arc?: number;
  45140. slice?: number;
  45141. sideOrientation?: number;
  45142. frontUVs?: Vector4;
  45143. backUVs?: Vector4;
  45144. updatable?: boolean;
  45145. }, scene?: Nullable<Scene>): Mesh;
  45146. }
  45147. }
  45148. declare module "babylonjs/Debug/physicsViewer" {
  45149. import { Nullable } from "babylonjs/types";
  45150. import { Scene } from "babylonjs/scene";
  45151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45152. import { Mesh } from "babylonjs/Meshes/mesh";
  45153. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45154. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45155. /**
  45156. * Used to show the physics impostor around the specific mesh
  45157. */
  45158. export class PhysicsViewer {
  45159. /** @hidden */
  45160. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45161. /** @hidden */
  45162. protected _meshes: Array<Nullable<AbstractMesh>>;
  45163. /** @hidden */
  45164. protected _scene: Nullable<Scene>;
  45165. /** @hidden */
  45166. protected _numMeshes: number;
  45167. /** @hidden */
  45168. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45169. private _renderFunction;
  45170. private _utilityLayer;
  45171. private _debugBoxMesh;
  45172. private _debugSphereMesh;
  45173. private _debugCylinderMesh;
  45174. private _debugMaterial;
  45175. private _debugMeshMeshes;
  45176. /**
  45177. * Creates a new PhysicsViewer
  45178. * @param scene defines the hosting scene
  45179. */
  45180. constructor(scene: Scene);
  45181. /** @hidden */
  45182. protected _updateDebugMeshes(): void;
  45183. /**
  45184. * Renders a specified physic impostor
  45185. * @param impostor defines the impostor to render
  45186. * @param targetMesh defines the mesh represented by the impostor
  45187. * @returns the new debug mesh used to render the impostor
  45188. */
  45189. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45190. /**
  45191. * Hides a specified physic impostor
  45192. * @param impostor defines the impostor to hide
  45193. */
  45194. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45195. private _getDebugMaterial;
  45196. private _getDebugBoxMesh;
  45197. private _getDebugSphereMesh;
  45198. private _getDebugCylinderMesh;
  45199. private _getDebugMeshMesh;
  45200. private _getDebugMesh;
  45201. /** Releases all resources */
  45202. dispose(): void;
  45203. }
  45204. }
  45205. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45206. import { Vector3 } from "babylonjs/Maths/math.vector";
  45207. import { Color4 } from "babylonjs/Maths/math.color";
  45208. import { Nullable } from "babylonjs/types";
  45209. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45210. import { Scene } from "babylonjs/scene";
  45211. /**
  45212. * Class containing static functions to help procedurally build meshes
  45213. */
  45214. export class LinesBuilder {
  45215. /**
  45216. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45217. * * 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
  45218. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45219. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45220. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45221. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45222. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45223. * * 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
  45224. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45226. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45227. * @param name defines the name of the new line system
  45228. * @param options defines the options used to create the line system
  45229. * @param scene defines the hosting scene
  45230. * @returns a new line system mesh
  45231. */
  45232. static CreateLineSystem(name: string, options: {
  45233. lines: Vector3[][];
  45234. updatable?: boolean;
  45235. instance?: Nullable<LinesMesh>;
  45236. colors?: Nullable<Color4[][]>;
  45237. useVertexAlpha?: boolean;
  45238. }, scene: Nullable<Scene>): LinesMesh;
  45239. /**
  45240. * Creates a line mesh
  45241. * 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
  45242. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45243. * * The parameter `points` is an array successive Vector3
  45244. * * 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
  45245. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45246. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45247. * * When updating an instance, remember that only point positions can change, not the number of points
  45248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45250. * @param name defines the name of the new line system
  45251. * @param options defines the options used to create the line system
  45252. * @param scene defines the hosting scene
  45253. * @returns a new line mesh
  45254. */
  45255. static CreateLines(name: string, options: {
  45256. points: Vector3[];
  45257. updatable?: boolean;
  45258. instance?: Nullable<LinesMesh>;
  45259. colors?: Color4[];
  45260. useVertexAlpha?: boolean;
  45261. }, scene?: Nullable<Scene>): LinesMesh;
  45262. /**
  45263. * Creates a dashed line mesh
  45264. * * 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
  45265. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45266. * * The parameter `points` is an array successive Vector3
  45267. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45268. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45269. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45270. * * 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
  45271. * * When updating an instance, remember that only point positions can change, not the number of points
  45272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45273. * @param name defines the name of the mesh
  45274. * @param options defines the options used to create the mesh
  45275. * @param scene defines the hosting scene
  45276. * @returns the dashed line mesh
  45277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45278. */
  45279. static CreateDashedLines(name: string, options: {
  45280. points: Vector3[];
  45281. dashSize?: number;
  45282. gapSize?: number;
  45283. dashNb?: number;
  45284. updatable?: boolean;
  45285. instance?: LinesMesh;
  45286. }, scene?: Nullable<Scene>): LinesMesh;
  45287. }
  45288. }
  45289. declare module "babylonjs/Debug/rayHelper" {
  45290. import { Nullable } from "babylonjs/types";
  45291. import { Ray } from "babylonjs/Culling/ray";
  45292. import { Vector3 } from "babylonjs/Maths/math.vector";
  45293. import { Color3 } from "babylonjs/Maths/math.color";
  45294. import { Scene } from "babylonjs/scene";
  45295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45296. import "babylonjs/Meshes/Builders/linesBuilder";
  45297. /**
  45298. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45299. * in order to better appreciate the issue one might have.
  45300. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45301. */
  45302. export class RayHelper {
  45303. /**
  45304. * Defines the ray we are currently tryin to visualize.
  45305. */
  45306. ray: Nullable<Ray>;
  45307. private _renderPoints;
  45308. private _renderLine;
  45309. private _renderFunction;
  45310. private _scene;
  45311. private _updateToMeshFunction;
  45312. private _attachedToMesh;
  45313. private _meshSpaceDirection;
  45314. private _meshSpaceOrigin;
  45315. /**
  45316. * Helper function to create a colored helper in a scene in one line.
  45317. * @param ray Defines the ray we are currently tryin to visualize
  45318. * @param scene Defines the scene the ray is used in
  45319. * @param color Defines the color we want to see the ray in
  45320. * @returns The newly created ray helper.
  45321. */
  45322. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45323. /**
  45324. * Instantiate a new ray helper.
  45325. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45326. * in order to better appreciate the issue one might have.
  45327. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45328. * @param ray Defines the ray we are currently tryin to visualize
  45329. */
  45330. constructor(ray: Ray);
  45331. /**
  45332. * Shows the ray we are willing to debug.
  45333. * @param scene Defines the scene the ray needs to be rendered in
  45334. * @param color Defines the color the ray needs to be rendered in
  45335. */
  45336. show(scene: Scene, color?: Color3): void;
  45337. /**
  45338. * Hides the ray we are debugging.
  45339. */
  45340. hide(): void;
  45341. private _render;
  45342. /**
  45343. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45344. * @param mesh Defines the mesh we want the helper attached to
  45345. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45346. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45347. * @param length Defines the length of the ray
  45348. */
  45349. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45350. /**
  45351. * Detach the ray helper from the mesh it has previously been attached to.
  45352. */
  45353. detachFromMesh(): void;
  45354. private _updateToMesh;
  45355. /**
  45356. * Dispose the helper and release its associated resources.
  45357. */
  45358. dispose(): void;
  45359. }
  45360. }
  45361. declare module "babylonjs/Debug/skeletonViewer" {
  45362. import { Color3 } from "babylonjs/Maths/math.color";
  45363. import { Scene } from "babylonjs/scene";
  45364. import { Nullable } from "babylonjs/types";
  45365. import { Skeleton } from "babylonjs/Bones/skeleton";
  45366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45367. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45368. /**
  45369. * Class used to render a debug view of a given skeleton
  45370. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45371. */
  45372. export class SkeletonViewer {
  45373. /** defines the skeleton to render */
  45374. skeleton: Skeleton;
  45375. /** defines the mesh attached to the skeleton */
  45376. mesh: AbstractMesh;
  45377. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45378. autoUpdateBonesMatrices: boolean;
  45379. /** defines the rendering group id to use with the viewer */
  45380. renderingGroupId: number;
  45381. /** Gets or sets the color used to render the skeleton */
  45382. color: Color3;
  45383. private _scene;
  45384. private _debugLines;
  45385. private _debugMesh;
  45386. private _isEnabled;
  45387. private _renderFunction;
  45388. private _utilityLayer;
  45389. /**
  45390. * Returns the mesh used to render the bones
  45391. */
  45392. readonly debugMesh: Nullable<LinesMesh>;
  45393. /**
  45394. * Creates a new SkeletonViewer
  45395. * @param skeleton defines the skeleton to render
  45396. * @param mesh defines the mesh attached to the skeleton
  45397. * @param scene defines the hosting scene
  45398. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45399. * @param renderingGroupId defines the rendering group id to use with the viewer
  45400. */
  45401. constructor(
  45402. /** defines the skeleton to render */
  45403. skeleton: Skeleton,
  45404. /** defines the mesh attached to the skeleton */
  45405. mesh: AbstractMesh, scene: Scene,
  45406. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45407. autoUpdateBonesMatrices?: boolean,
  45408. /** defines the rendering group id to use with the viewer */
  45409. renderingGroupId?: number);
  45410. /** Gets or sets a boolean indicating if the viewer is enabled */
  45411. isEnabled: boolean;
  45412. private _getBonePosition;
  45413. private _getLinesForBonesWithLength;
  45414. private _getLinesForBonesNoLength;
  45415. /** Update the viewer to sync with current skeleton state */
  45416. update(): void;
  45417. /** Release associated resources */
  45418. dispose(): void;
  45419. }
  45420. }
  45421. declare module "babylonjs/Debug/index" {
  45422. export * from "babylonjs/Debug/axesViewer";
  45423. export * from "babylonjs/Debug/boneAxesViewer";
  45424. export * from "babylonjs/Debug/debugLayer";
  45425. export * from "babylonjs/Debug/physicsViewer";
  45426. export * from "babylonjs/Debug/rayHelper";
  45427. export * from "babylonjs/Debug/skeletonViewer";
  45428. }
  45429. declare module "babylonjs/Engines/nullEngine" {
  45430. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45431. import { Scene } from "babylonjs/scene";
  45432. import { Engine } from "babylonjs/Engines/engine";
  45433. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45434. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45435. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45436. import { Effect } from "babylonjs/Materials/effect";
  45437. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45438. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45439. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45440. /**
  45441. * Options to create the null engine
  45442. */
  45443. export class NullEngineOptions {
  45444. /**
  45445. * Render width (Default: 512)
  45446. */
  45447. renderWidth: number;
  45448. /**
  45449. * Render height (Default: 256)
  45450. */
  45451. renderHeight: number;
  45452. /**
  45453. * Texture size (Default: 512)
  45454. */
  45455. textureSize: number;
  45456. /**
  45457. * If delta time between frames should be constant
  45458. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45459. */
  45460. deterministicLockstep: boolean;
  45461. /**
  45462. * Maximum about of steps between frames (Default: 4)
  45463. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45464. */
  45465. lockstepMaxSteps: number;
  45466. }
  45467. /**
  45468. * The null engine class provides support for headless version of babylon.js.
  45469. * This can be used in server side scenario or for testing purposes
  45470. */
  45471. export class NullEngine extends Engine {
  45472. private _options;
  45473. /**
  45474. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45475. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45476. * @returns true if engine is in deterministic lock step mode
  45477. */
  45478. isDeterministicLockStep(): boolean;
  45479. /**
  45480. * Gets the max steps when engine is running in deterministic lock step
  45481. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45482. * @returns the max steps
  45483. */
  45484. getLockstepMaxSteps(): number;
  45485. /**
  45486. * Gets the current hardware scaling level.
  45487. * By default the hardware scaling level is computed from the window device ratio.
  45488. * 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.
  45489. * @returns a number indicating the current hardware scaling level
  45490. */
  45491. getHardwareScalingLevel(): number;
  45492. constructor(options?: NullEngineOptions);
  45493. /**
  45494. * Creates a vertex buffer
  45495. * @param vertices the data for the vertex buffer
  45496. * @returns the new WebGL static buffer
  45497. */
  45498. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45499. /**
  45500. * Creates a new index buffer
  45501. * @param indices defines the content of the index buffer
  45502. * @param updatable defines if the index buffer must be updatable
  45503. * @returns a new webGL buffer
  45504. */
  45505. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45506. /**
  45507. * Clear the current render buffer or the current render target (if any is set up)
  45508. * @param color defines the color to use
  45509. * @param backBuffer defines if the back buffer must be cleared
  45510. * @param depth defines if the depth buffer must be cleared
  45511. * @param stencil defines if the stencil buffer must be cleared
  45512. */
  45513. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45514. /**
  45515. * Gets the current render width
  45516. * @param useScreen defines if screen size must be used (or the current render target if any)
  45517. * @returns a number defining the current render width
  45518. */
  45519. getRenderWidth(useScreen?: boolean): number;
  45520. /**
  45521. * Gets the current render height
  45522. * @param useScreen defines if screen size must be used (or the current render target if any)
  45523. * @returns a number defining the current render height
  45524. */
  45525. getRenderHeight(useScreen?: boolean): number;
  45526. /**
  45527. * Set the WebGL's viewport
  45528. * @param viewport defines the viewport element to be used
  45529. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45530. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45531. */
  45532. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45533. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45534. /**
  45535. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45536. * @param pipelineContext defines the pipeline context to use
  45537. * @param uniformsNames defines the list of uniform names
  45538. * @returns an array of webGL uniform locations
  45539. */
  45540. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45541. /**
  45542. * Gets the lsit of active attributes for a given webGL program
  45543. * @param pipelineContext defines the pipeline context to use
  45544. * @param attributesNames defines the list of attribute names to get
  45545. * @returns an array of indices indicating the offset of each attribute
  45546. */
  45547. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45548. /**
  45549. * Binds an effect to the webGL context
  45550. * @param effect defines the effect to bind
  45551. */
  45552. bindSamplers(effect: Effect): void;
  45553. /**
  45554. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45555. * @param effect defines the effect to activate
  45556. */
  45557. enableEffect(effect: Effect): void;
  45558. /**
  45559. * Set various states to the webGL context
  45560. * @param culling defines backface culling state
  45561. * @param zOffset defines the value to apply to zOffset (0 by default)
  45562. * @param force defines if states must be applied even if cache is up to date
  45563. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45564. */
  45565. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45566. /**
  45567. * Set the value of an uniform to an array of int32
  45568. * @param uniform defines the webGL uniform location where to store the value
  45569. * @param array defines the array of int32 to store
  45570. */
  45571. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45572. /**
  45573. * Set the value of an uniform to an array of int32 (stored as vec2)
  45574. * @param uniform defines the webGL uniform location where to store the value
  45575. * @param array defines the array of int32 to store
  45576. */
  45577. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45578. /**
  45579. * Set the value of an uniform to an array of int32 (stored as vec3)
  45580. * @param uniform defines the webGL uniform location where to store the value
  45581. * @param array defines the array of int32 to store
  45582. */
  45583. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45584. /**
  45585. * Set the value of an uniform to an array of int32 (stored as vec4)
  45586. * @param uniform defines the webGL uniform location where to store the value
  45587. * @param array defines the array of int32 to store
  45588. */
  45589. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45590. /**
  45591. * Set the value of an uniform to an array of float32
  45592. * @param uniform defines the webGL uniform location where to store the value
  45593. * @param array defines the array of float32 to store
  45594. */
  45595. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45596. /**
  45597. * Set the value of an uniform to an array of float32 (stored as vec2)
  45598. * @param uniform defines the webGL uniform location where to store the value
  45599. * @param array defines the array of float32 to store
  45600. */
  45601. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45602. /**
  45603. * Set the value of an uniform to an array of float32 (stored as vec3)
  45604. * @param uniform defines the webGL uniform location where to store the value
  45605. * @param array defines the array of float32 to store
  45606. */
  45607. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45608. /**
  45609. * Set the value of an uniform to an array of float32 (stored as vec4)
  45610. * @param uniform defines the webGL uniform location where to store the value
  45611. * @param array defines the array of float32 to store
  45612. */
  45613. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45614. /**
  45615. * Set the value of an uniform to an array of number
  45616. * @param uniform defines the webGL uniform location where to store the value
  45617. * @param array defines the array of number to store
  45618. */
  45619. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45620. /**
  45621. * Set the value of an uniform to an array of number (stored as vec2)
  45622. * @param uniform defines the webGL uniform location where to store the value
  45623. * @param array defines the array of number to store
  45624. */
  45625. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45626. /**
  45627. * Set the value of an uniform to an array of number (stored as vec3)
  45628. * @param uniform defines the webGL uniform location where to store the value
  45629. * @param array defines the array of number to store
  45630. */
  45631. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45632. /**
  45633. * Set the value of an uniform to an array of number (stored as vec4)
  45634. * @param uniform defines the webGL uniform location where to store the value
  45635. * @param array defines the array of number to store
  45636. */
  45637. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45638. /**
  45639. * Set the value of an uniform to an array of float32 (stored as matrices)
  45640. * @param uniform defines the webGL uniform location where to store the value
  45641. * @param matrices defines the array of float32 to store
  45642. */
  45643. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45644. /**
  45645. * Set the value of an uniform to a matrix (3x3)
  45646. * @param uniform defines the webGL uniform location where to store the value
  45647. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45648. */
  45649. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45650. /**
  45651. * Set the value of an uniform to a matrix (2x2)
  45652. * @param uniform defines the webGL uniform location where to store the value
  45653. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45654. */
  45655. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45656. /**
  45657. * Set the value of an uniform to a number (float)
  45658. * @param uniform defines the webGL uniform location where to store the value
  45659. * @param value defines the float number to store
  45660. */
  45661. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45662. /**
  45663. * Set the value of an uniform to a vec2
  45664. * @param uniform defines the webGL uniform location where to store the value
  45665. * @param x defines the 1st component of the value
  45666. * @param y defines the 2nd component of the value
  45667. */
  45668. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45669. /**
  45670. * Set the value of an uniform to a vec3
  45671. * @param uniform defines the webGL uniform location where to store the value
  45672. * @param x defines the 1st component of the value
  45673. * @param y defines the 2nd component of the value
  45674. * @param z defines the 3rd component of the value
  45675. */
  45676. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45677. /**
  45678. * Set the value of an uniform to a boolean
  45679. * @param uniform defines the webGL uniform location where to store the value
  45680. * @param bool defines the boolean to store
  45681. */
  45682. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45683. /**
  45684. * Set the value of an uniform to a vec4
  45685. * @param uniform defines the webGL uniform location where to store the value
  45686. * @param x defines the 1st component of the value
  45687. * @param y defines the 2nd component of the value
  45688. * @param z defines the 3rd component of the value
  45689. * @param w defines the 4th component of the value
  45690. */
  45691. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45692. /**
  45693. * Sets the current alpha mode
  45694. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45695. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45696. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45697. */
  45698. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45699. /**
  45700. * Bind webGl buffers directly to the webGL context
  45701. * @param vertexBuffers defines the vertex buffer to bind
  45702. * @param indexBuffer defines the index buffer to bind
  45703. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45704. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45705. * @param effect defines the effect associated with the vertex buffer
  45706. */
  45707. bindBuffers(vertexBuffers: {
  45708. [key: string]: VertexBuffer;
  45709. }, indexBuffer: DataBuffer, effect: Effect): void;
  45710. /**
  45711. * Force the entire cache to be cleared
  45712. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45713. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45714. */
  45715. wipeCaches(bruteForce?: boolean): void;
  45716. /**
  45717. * Send a draw order
  45718. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45719. * @param indexStart defines the starting index
  45720. * @param indexCount defines the number of index to draw
  45721. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45722. */
  45723. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45724. /**
  45725. * Draw a list of indexed primitives
  45726. * @param fillMode defines the primitive to use
  45727. * @param indexStart defines the starting index
  45728. * @param indexCount defines the number of index to draw
  45729. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45730. */
  45731. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45732. /**
  45733. * Draw a list of unindexed primitives
  45734. * @param fillMode defines the primitive to use
  45735. * @param verticesStart defines the index of first vertex to draw
  45736. * @param verticesCount defines the count of vertices to draw
  45737. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45738. */
  45739. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45740. /** @hidden */
  45741. _createTexture(): WebGLTexture;
  45742. /** @hidden */
  45743. _releaseTexture(texture: InternalTexture): void;
  45744. /**
  45745. * Usually called from Texture.ts.
  45746. * Passed information to create a WebGLTexture
  45747. * @param urlArg defines a value which contains one of the following:
  45748. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45749. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45750. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45751. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45752. * @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)
  45753. * @param scene needed for loading to the correct scene
  45754. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45755. * @param onLoad optional callback to be called upon successful completion
  45756. * @param onError optional callback to be called upon failure
  45757. * @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
  45758. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45759. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45760. * @param forcedExtension defines the extension to use to pick the right loader
  45761. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45762. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45763. */
  45764. 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;
  45765. /**
  45766. * Creates a new render target texture
  45767. * @param size defines the size of the texture
  45768. * @param options defines the options used to create the texture
  45769. * @returns a new render target texture stored in an InternalTexture
  45770. */
  45771. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45772. /**
  45773. * Update the sampling mode of a given texture
  45774. * @param samplingMode defines the required sampling mode
  45775. * @param texture defines the texture to update
  45776. */
  45777. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45778. /**
  45779. * Binds the frame buffer to the specified texture.
  45780. * @param texture The texture to render to or null for the default canvas
  45781. * @param faceIndex The face of the texture to render to in case of cube texture
  45782. * @param requiredWidth The width of the target to render to
  45783. * @param requiredHeight The height of the target to render to
  45784. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45785. * @param depthStencilTexture The depth stencil texture to use to render
  45786. * @param lodLevel defines le lod level to bind to the frame buffer
  45787. */
  45788. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45789. /**
  45790. * Unbind the current render target texture from the webGL context
  45791. * @param texture defines the render target texture to unbind
  45792. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45793. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45794. */
  45795. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45796. /**
  45797. * Creates a dynamic vertex buffer
  45798. * @param vertices the data for the dynamic vertex buffer
  45799. * @returns the new WebGL dynamic buffer
  45800. */
  45801. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45802. /**
  45803. * Update the content of a dynamic texture
  45804. * @param texture defines the texture to update
  45805. * @param canvas defines the canvas containing the source
  45806. * @param invertY defines if data must be stored with Y axis inverted
  45807. * @param premulAlpha defines if alpha is stored as premultiplied
  45808. * @param format defines the format of the data
  45809. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45810. */
  45811. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45812. /**
  45813. * Gets a boolean indicating if all created effects are ready
  45814. * @returns true if all effects are ready
  45815. */
  45816. areAllEffectsReady(): boolean;
  45817. /**
  45818. * @hidden
  45819. * Get the current error code of the webGL context
  45820. * @returns the error code
  45821. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45822. */
  45823. getError(): number;
  45824. /** @hidden */
  45825. _getUnpackAlignement(): number;
  45826. /** @hidden */
  45827. _unpackFlipY(value: boolean): void;
  45828. /**
  45829. * Update a dynamic index buffer
  45830. * @param indexBuffer defines the target index buffer
  45831. * @param indices defines the data to update
  45832. * @param offset defines the offset in the target index buffer where update should start
  45833. */
  45834. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45835. /**
  45836. * Updates a dynamic vertex buffer.
  45837. * @param vertexBuffer the vertex buffer to update
  45838. * @param vertices the data used to update the vertex buffer
  45839. * @param byteOffset the byte offset of the data (optional)
  45840. * @param byteLength the byte length of the data (optional)
  45841. */
  45842. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45843. /** @hidden */
  45844. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45845. /** @hidden */
  45846. _bindTexture(channel: number, texture: InternalTexture): void;
  45847. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45848. /**
  45849. * 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
  45850. */
  45851. releaseEffects(): void;
  45852. displayLoadingUI(): void;
  45853. hideLoadingUI(): void;
  45854. /** @hidden */
  45855. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45856. /** @hidden */
  45857. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45858. /** @hidden */
  45859. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45860. /** @hidden */
  45861. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45862. }
  45863. }
  45864. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45865. import { Nullable, int } from "babylonjs/types";
  45866. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45867. /** @hidden */
  45868. export class _OcclusionDataStorage {
  45869. /** @hidden */
  45870. occlusionInternalRetryCounter: number;
  45871. /** @hidden */
  45872. isOcclusionQueryInProgress: boolean;
  45873. /** @hidden */
  45874. isOccluded: boolean;
  45875. /** @hidden */
  45876. occlusionRetryCount: number;
  45877. /** @hidden */
  45878. occlusionType: number;
  45879. /** @hidden */
  45880. occlusionQueryAlgorithmType: number;
  45881. }
  45882. module "babylonjs/Engines/engine" {
  45883. interface Engine {
  45884. /**
  45885. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45886. * @return the new query
  45887. */
  45888. createQuery(): WebGLQuery;
  45889. /**
  45890. * Delete and release a webGL query
  45891. * @param query defines the query to delete
  45892. * @return the current engine
  45893. */
  45894. deleteQuery(query: WebGLQuery): Engine;
  45895. /**
  45896. * Check if a given query has resolved and got its value
  45897. * @param query defines the query to check
  45898. * @returns true if the query got its value
  45899. */
  45900. isQueryResultAvailable(query: WebGLQuery): boolean;
  45901. /**
  45902. * Gets the value of a given query
  45903. * @param query defines the query to check
  45904. * @returns the value of the query
  45905. */
  45906. getQueryResult(query: WebGLQuery): number;
  45907. /**
  45908. * Initiates an occlusion query
  45909. * @param algorithmType defines the algorithm to use
  45910. * @param query defines the query to use
  45911. * @returns the current engine
  45912. * @see http://doc.babylonjs.com/features/occlusionquery
  45913. */
  45914. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45915. /**
  45916. * Ends an occlusion query
  45917. * @see http://doc.babylonjs.com/features/occlusionquery
  45918. * @param algorithmType defines the algorithm to use
  45919. * @returns the current engine
  45920. */
  45921. endOcclusionQuery(algorithmType: number): Engine;
  45922. /**
  45923. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45924. * Please note that only one query can be issued at a time
  45925. * @returns a time token used to track the time span
  45926. */
  45927. startTimeQuery(): Nullable<_TimeToken>;
  45928. /**
  45929. * Ends a time query
  45930. * @param token defines the token used to measure the time span
  45931. * @returns the time spent (in ns)
  45932. */
  45933. endTimeQuery(token: _TimeToken): int;
  45934. /** @hidden */
  45935. _currentNonTimestampToken: Nullable<_TimeToken>;
  45936. /** @hidden */
  45937. _createTimeQuery(): WebGLQuery;
  45938. /** @hidden */
  45939. _deleteTimeQuery(query: WebGLQuery): void;
  45940. /** @hidden */
  45941. _getGlAlgorithmType(algorithmType: number): number;
  45942. /** @hidden */
  45943. _getTimeQueryResult(query: WebGLQuery): any;
  45944. /** @hidden */
  45945. _getTimeQueryAvailability(query: WebGLQuery): any;
  45946. }
  45947. }
  45948. module "babylonjs/Meshes/abstractMesh" {
  45949. interface AbstractMesh {
  45950. /**
  45951. * Backing filed
  45952. * @hidden
  45953. */
  45954. __occlusionDataStorage: _OcclusionDataStorage;
  45955. /**
  45956. * Access property
  45957. * @hidden
  45958. */
  45959. _occlusionDataStorage: _OcclusionDataStorage;
  45960. /**
  45961. * 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.
  45962. * The default value is -1 which means don't break the query and wait till the result
  45963. * @see http://doc.babylonjs.com/features/occlusionquery
  45964. */
  45965. occlusionRetryCount: number;
  45966. /**
  45967. * 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:
  45968. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45969. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45970. * * 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.
  45971. * @see http://doc.babylonjs.com/features/occlusionquery
  45972. */
  45973. occlusionType: number;
  45974. /**
  45975. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45976. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45977. * * 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.
  45978. * @see http://doc.babylonjs.com/features/occlusionquery
  45979. */
  45980. occlusionQueryAlgorithmType: number;
  45981. /**
  45982. * 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
  45983. * @see http://doc.babylonjs.com/features/occlusionquery
  45984. */
  45985. isOccluded: boolean;
  45986. /**
  45987. * Flag to check the progress status of the query
  45988. * @see http://doc.babylonjs.com/features/occlusionquery
  45989. */
  45990. isOcclusionQueryInProgress: boolean;
  45991. }
  45992. }
  45993. }
  45994. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45995. import { Nullable } from "babylonjs/types";
  45996. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45997. /** @hidden */
  45998. export var _forceTransformFeedbackToBundle: boolean;
  45999. module "babylonjs/Engines/engine" {
  46000. interface Engine {
  46001. /**
  46002. * Creates a webGL transform feedback object
  46003. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46004. * @returns the webGL transform feedback object
  46005. */
  46006. createTransformFeedback(): WebGLTransformFeedback;
  46007. /**
  46008. * Delete a webGL transform feedback object
  46009. * @param value defines the webGL transform feedback object to delete
  46010. */
  46011. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46012. /**
  46013. * Bind a webGL transform feedback object to the webgl context
  46014. * @param value defines the webGL transform feedback object to bind
  46015. */
  46016. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46017. /**
  46018. * Begins a transform feedback operation
  46019. * @param usePoints defines if points or triangles must be used
  46020. */
  46021. beginTransformFeedback(usePoints: boolean): void;
  46022. /**
  46023. * Ends a transform feedback operation
  46024. */
  46025. endTransformFeedback(): void;
  46026. /**
  46027. * Specify the varyings to use with transform feedback
  46028. * @param program defines the associated webGL program
  46029. * @param value defines the list of strings representing the varying names
  46030. */
  46031. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46032. /**
  46033. * Bind a webGL buffer for a transform feedback operation
  46034. * @param value defines the webGL buffer to bind
  46035. */
  46036. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46037. }
  46038. }
  46039. }
  46040. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46041. import { Scene } from "babylonjs/scene";
  46042. import { Engine } from "babylonjs/Engines/engine";
  46043. import { Texture } from "babylonjs/Materials/Textures/texture";
  46044. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46045. import "babylonjs/Engines/Extensions/engine.multiRender";
  46046. /**
  46047. * Creation options of the multi render target texture.
  46048. */
  46049. export interface IMultiRenderTargetOptions {
  46050. /**
  46051. * Define if the texture needs to create mip maps after render.
  46052. */
  46053. generateMipMaps?: boolean;
  46054. /**
  46055. * Define the types of all the draw buffers we want to create
  46056. */
  46057. types?: number[];
  46058. /**
  46059. * Define the sampling modes of all the draw buffers we want to create
  46060. */
  46061. samplingModes?: number[];
  46062. /**
  46063. * Define if a depth buffer is required
  46064. */
  46065. generateDepthBuffer?: boolean;
  46066. /**
  46067. * Define if a stencil buffer is required
  46068. */
  46069. generateStencilBuffer?: boolean;
  46070. /**
  46071. * Define if a depth texture is required instead of a depth buffer
  46072. */
  46073. generateDepthTexture?: boolean;
  46074. /**
  46075. * Define the number of desired draw buffers
  46076. */
  46077. textureCount?: number;
  46078. /**
  46079. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46080. */
  46081. doNotChangeAspectRatio?: boolean;
  46082. /**
  46083. * Define the default type of the buffers we are creating
  46084. */
  46085. defaultType?: number;
  46086. }
  46087. /**
  46088. * A multi render target, like a render target provides the ability to render to a texture.
  46089. * Unlike the render target, it can render to several draw buffers in one draw.
  46090. * This is specially interesting in deferred rendering or for any effects requiring more than
  46091. * just one color from a single pass.
  46092. */
  46093. export class MultiRenderTarget extends RenderTargetTexture {
  46094. private _internalTextures;
  46095. private _textures;
  46096. private _multiRenderTargetOptions;
  46097. /**
  46098. * Get if draw buffers are currently supported by the used hardware and browser.
  46099. */
  46100. readonly isSupported: boolean;
  46101. /**
  46102. * Get the list of textures generated by the multi render target.
  46103. */
  46104. readonly textures: Texture[];
  46105. /**
  46106. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46107. */
  46108. readonly depthTexture: Texture;
  46109. /**
  46110. * Set the wrapping mode on U of all the textures we are rendering to.
  46111. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46112. */
  46113. wrapU: number;
  46114. /**
  46115. * Set the wrapping mode on V of all the textures we are rendering to.
  46116. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46117. */
  46118. wrapV: number;
  46119. /**
  46120. * Instantiate a new multi render target texture.
  46121. * A multi render target, like a render target provides the ability to render to a texture.
  46122. * Unlike the render target, it can render to several draw buffers in one draw.
  46123. * This is specially interesting in deferred rendering or for any effects requiring more than
  46124. * just one color from a single pass.
  46125. * @param name Define the name of the texture
  46126. * @param size Define the size of the buffers to render to
  46127. * @param count Define the number of target we are rendering into
  46128. * @param scene Define the scene the texture belongs to
  46129. * @param options Define the options used to create the multi render target
  46130. */
  46131. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46132. /** @hidden */
  46133. _rebuild(): void;
  46134. private _createInternalTextures;
  46135. private _createTextures;
  46136. /**
  46137. * Define the number of samples used if MSAA is enabled.
  46138. */
  46139. samples: number;
  46140. /**
  46141. * Resize all the textures in the multi render target.
  46142. * Be carrefull as it will recreate all the data in the new texture.
  46143. * @param size Define the new size
  46144. */
  46145. resize(size: any): void;
  46146. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46147. /**
  46148. * Dispose the render targets and their associated resources
  46149. */
  46150. dispose(): void;
  46151. /**
  46152. * Release all the underlying texture used as draw buffers.
  46153. */
  46154. releaseInternalTextures(): void;
  46155. }
  46156. }
  46157. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46159. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46160. import { Nullable } from "babylonjs/types";
  46161. module "babylonjs/Engines/thinEngine" {
  46162. interface ThinEngine {
  46163. /**
  46164. * Unbind a list of render target textures from the webGL context
  46165. * This is used only when drawBuffer extension or webGL2 are active
  46166. * @param textures defines the render target textures to unbind
  46167. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46168. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46169. */
  46170. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46171. /**
  46172. * Create a multi render target texture
  46173. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46174. * @param size defines the size of the texture
  46175. * @param options defines the creation options
  46176. * @returns the cube texture as an InternalTexture
  46177. */
  46178. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46179. /**
  46180. * Update the sample count for a given multiple render target texture
  46181. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46182. * @param textures defines the textures to update
  46183. * @param samples defines the sample count to set
  46184. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46185. */
  46186. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46187. }
  46188. }
  46189. }
  46190. declare module "babylonjs/Engines/Extensions/index" {
  46191. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46192. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46193. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46194. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46195. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46196. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46197. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46198. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46199. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46200. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46201. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46202. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46203. }
  46204. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46205. import { Nullable } from "babylonjs/types";
  46206. /**
  46207. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46208. */
  46209. export interface CubeMapInfo {
  46210. /**
  46211. * The pixel array for the front face.
  46212. * This is stored in format, left to right, up to down format.
  46213. */
  46214. front: Nullable<ArrayBufferView>;
  46215. /**
  46216. * The pixel array for the back face.
  46217. * This is stored in format, left to right, up to down format.
  46218. */
  46219. back: Nullable<ArrayBufferView>;
  46220. /**
  46221. * The pixel array for the left face.
  46222. * This is stored in format, left to right, up to down format.
  46223. */
  46224. left: Nullable<ArrayBufferView>;
  46225. /**
  46226. * The pixel array for the right face.
  46227. * This is stored in format, left to right, up to down format.
  46228. */
  46229. right: Nullable<ArrayBufferView>;
  46230. /**
  46231. * The pixel array for the up face.
  46232. * This is stored in format, left to right, up to down format.
  46233. */
  46234. up: Nullable<ArrayBufferView>;
  46235. /**
  46236. * The pixel array for the down face.
  46237. * This is stored in format, left to right, up to down format.
  46238. */
  46239. down: Nullable<ArrayBufferView>;
  46240. /**
  46241. * The size of the cubemap stored.
  46242. *
  46243. * Each faces will be size * size pixels.
  46244. */
  46245. size: number;
  46246. /**
  46247. * The format of the texture.
  46248. *
  46249. * RGBA, RGB.
  46250. */
  46251. format: number;
  46252. /**
  46253. * The type of the texture data.
  46254. *
  46255. * UNSIGNED_INT, FLOAT.
  46256. */
  46257. type: number;
  46258. /**
  46259. * Specifies whether the texture is in gamma space.
  46260. */
  46261. gammaSpace: boolean;
  46262. }
  46263. /**
  46264. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46265. */
  46266. export class PanoramaToCubeMapTools {
  46267. private static FACE_FRONT;
  46268. private static FACE_BACK;
  46269. private static FACE_RIGHT;
  46270. private static FACE_LEFT;
  46271. private static FACE_DOWN;
  46272. private static FACE_UP;
  46273. /**
  46274. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46275. *
  46276. * @param float32Array The source data.
  46277. * @param inputWidth The width of the input panorama.
  46278. * @param inputHeight The height of the input panorama.
  46279. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46280. * @return The cubemap data
  46281. */
  46282. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46283. private static CreateCubemapTexture;
  46284. private static CalcProjectionSpherical;
  46285. }
  46286. }
  46287. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46288. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46289. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46290. import { Nullable } from "babylonjs/types";
  46291. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46292. /**
  46293. * Helper class dealing with the extraction of spherical polynomial dataArray
  46294. * from a cube map.
  46295. */
  46296. export class CubeMapToSphericalPolynomialTools {
  46297. private static FileFaces;
  46298. /**
  46299. * Converts a texture to the according Spherical Polynomial data.
  46300. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46301. *
  46302. * @param texture The texture to extract the information from.
  46303. * @return The Spherical Polynomial data.
  46304. */
  46305. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46306. /**
  46307. * Converts a cubemap to the according Spherical Polynomial data.
  46308. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46309. *
  46310. * @param cubeInfo The Cube map to extract the information from.
  46311. * @return The Spherical Polynomial data.
  46312. */
  46313. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46314. }
  46315. }
  46316. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46317. import { Nullable } from "babylonjs/types";
  46318. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46319. module "babylonjs/Materials/Textures/baseTexture" {
  46320. interface BaseTexture {
  46321. /**
  46322. * Get the polynomial representation of the texture data.
  46323. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46324. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46325. */
  46326. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46327. }
  46328. }
  46329. }
  46330. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46331. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46332. /** @hidden */
  46333. export var rgbdEncodePixelShader: {
  46334. name: string;
  46335. shader: string;
  46336. };
  46337. }
  46338. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46339. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46340. /** @hidden */
  46341. export var rgbdDecodePixelShader: {
  46342. name: string;
  46343. shader: string;
  46344. };
  46345. }
  46346. declare module "babylonjs/Misc/environmentTextureTools" {
  46347. import { Nullable } from "babylonjs/types";
  46348. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46350. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46351. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46352. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46353. import "babylonjs/Shaders/rgbdEncode.fragment";
  46354. import "babylonjs/Shaders/rgbdDecode.fragment";
  46355. /**
  46356. * Raw texture data and descriptor sufficient for WebGL texture upload
  46357. */
  46358. export interface EnvironmentTextureInfo {
  46359. /**
  46360. * Version of the environment map
  46361. */
  46362. version: number;
  46363. /**
  46364. * Width of image
  46365. */
  46366. width: number;
  46367. /**
  46368. * Irradiance information stored in the file.
  46369. */
  46370. irradiance: any;
  46371. /**
  46372. * Specular information stored in the file.
  46373. */
  46374. specular: any;
  46375. }
  46376. /**
  46377. * Defines One Image in the file. It requires only the position in the file
  46378. * as well as the length.
  46379. */
  46380. interface BufferImageData {
  46381. /**
  46382. * Length of the image data.
  46383. */
  46384. length: number;
  46385. /**
  46386. * Position of the data from the null terminator delimiting the end of the JSON.
  46387. */
  46388. position: number;
  46389. }
  46390. /**
  46391. * Defines the specular data enclosed in the file.
  46392. * This corresponds to the version 1 of the data.
  46393. */
  46394. export interface EnvironmentTextureSpecularInfoV1 {
  46395. /**
  46396. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46397. */
  46398. specularDataPosition?: number;
  46399. /**
  46400. * This contains all the images data needed to reconstruct the cubemap.
  46401. */
  46402. mipmaps: Array<BufferImageData>;
  46403. /**
  46404. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46405. */
  46406. lodGenerationScale: number;
  46407. }
  46408. /**
  46409. * Sets of helpers addressing the serialization and deserialization of environment texture
  46410. * stored in a BabylonJS env file.
  46411. * Those files are usually stored as .env files.
  46412. */
  46413. export class EnvironmentTextureTools {
  46414. /**
  46415. * Magic number identifying the env file.
  46416. */
  46417. private static _MagicBytes;
  46418. /**
  46419. * Gets the environment info from an env file.
  46420. * @param data The array buffer containing the .env bytes.
  46421. * @returns the environment file info (the json header) if successfully parsed.
  46422. */
  46423. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46424. /**
  46425. * Creates an environment texture from a loaded cube texture.
  46426. * @param texture defines the cube texture to convert in env file
  46427. * @return a promise containing the environment data if succesfull.
  46428. */
  46429. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46430. /**
  46431. * Creates a JSON representation of the spherical data.
  46432. * @param texture defines the texture containing the polynomials
  46433. * @return the JSON representation of the spherical info
  46434. */
  46435. private static _CreateEnvTextureIrradiance;
  46436. /**
  46437. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46438. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46439. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46440. * @return the views described by info providing access to the underlying buffer
  46441. */
  46442. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46443. /**
  46444. * Uploads the texture info contained in the env file to the GPU.
  46445. * @param texture defines the internal texture to upload to
  46446. * @param arrayBuffer defines the buffer cotaining the data to load
  46447. * @param info defines the texture info retrieved through the GetEnvInfo method
  46448. * @returns a promise
  46449. */
  46450. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46451. private static _OnImageReadyAsync;
  46452. /**
  46453. * Uploads the levels of image data to the GPU.
  46454. * @param texture defines the internal texture to upload to
  46455. * @param imageData defines the array buffer views of image data [mipmap][face]
  46456. * @returns a promise
  46457. */
  46458. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46459. /**
  46460. * Uploads spherical polynomials information to the texture.
  46461. * @param texture defines the texture we are trying to upload the information to
  46462. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46463. */
  46464. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46465. /** @hidden */
  46466. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46467. }
  46468. }
  46469. declare module "babylonjs/Maths/math.vertexFormat" {
  46470. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46471. /**
  46472. * Contains position and normal vectors for a vertex
  46473. */
  46474. export class PositionNormalVertex {
  46475. /** the position of the vertex (defaut: 0,0,0) */
  46476. position: Vector3;
  46477. /** the normal of the vertex (defaut: 0,1,0) */
  46478. normal: Vector3;
  46479. /**
  46480. * Creates a PositionNormalVertex
  46481. * @param position the position of the vertex (defaut: 0,0,0)
  46482. * @param normal the normal of the vertex (defaut: 0,1,0)
  46483. */
  46484. constructor(
  46485. /** the position of the vertex (defaut: 0,0,0) */
  46486. position?: Vector3,
  46487. /** the normal of the vertex (defaut: 0,1,0) */
  46488. normal?: Vector3);
  46489. /**
  46490. * Clones the PositionNormalVertex
  46491. * @returns the cloned PositionNormalVertex
  46492. */
  46493. clone(): PositionNormalVertex;
  46494. }
  46495. /**
  46496. * Contains position, normal and uv vectors for a vertex
  46497. */
  46498. export class PositionNormalTextureVertex {
  46499. /** the position of the vertex (defaut: 0,0,0) */
  46500. position: Vector3;
  46501. /** the normal of the vertex (defaut: 0,1,0) */
  46502. normal: Vector3;
  46503. /** the uv of the vertex (default: 0,0) */
  46504. uv: Vector2;
  46505. /**
  46506. * Creates a PositionNormalTextureVertex
  46507. * @param position the position of the vertex (defaut: 0,0,0)
  46508. * @param normal the normal of the vertex (defaut: 0,1,0)
  46509. * @param uv the uv of the vertex (default: 0,0)
  46510. */
  46511. constructor(
  46512. /** the position of the vertex (defaut: 0,0,0) */
  46513. position?: Vector3,
  46514. /** the normal of the vertex (defaut: 0,1,0) */
  46515. normal?: Vector3,
  46516. /** the uv of the vertex (default: 0,0) */
  46517. uv?: Vector2);
  46518. /**
  46519. * Clones the PositionNormalTextureVertex
  46520. * @returns the cloned PositionNormalTextureVertex
  46521. */
  46522. clone(): PositionNormalTextureVertex;
  46523. }
  46524. }
  46525. declare module "babylonjs/Maths/math" {
  46526. export * from "babylonjs/Maths/math.axis";
  46527. export * from "babylonjs/Maths/math.color";
  46528. export * from "babylonjs/Maths/math.constants";
  46529. export * from "babylonjs/Maths/math.frustum";
  46530. export * from "babylonjs/Maths/math.path";
  46531. export * from "babylonjs/Maths/math.plane";
  46532. export * from "babylonjs/Maths/math.size";
  46533. export * from "babylonjs/Maths/math.vector";
  46534. export * from "babylonjs/Maths/math.vertexFormat";
  46535. export * from "babylonjs/Maths/math.viewport";
  46536. }
  46537. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46538. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46539. /** @hidden */
  46540. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46541. private _genericAttributeLocation;
  46542. private _varyingLocationCount;
  46543. private _varyingLocationMap;
  46544. private _replacements;
  46545. private _textureCount;
  46546. private _uniforms;
  46547. lineProcessor(line: string): string;
  46548. attributeProcessor(attribute: string): string;
  46549. varyingProcessor(varying: string, isFragment: boolean): string;
  46550. uniformProcessor(uniform: string): string;
  46551. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46552. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46553. }
  46554. }
  46555. declare module "babylonjs/Engines/nativeEngine" {
  46556. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46557. import { Engine } from "babylonjs/Engines/engine";
  46558. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46559. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46560. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46561. import { Effect } from "babylonjs/Materials/effect";
  46562. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46563. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46564. import { Scene } from "babylonjs/scene";
  46565. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46566. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46567. /**
  46568. * Container for accessors for natively-stored mesh data buffers.
  46569. */
  46570. class NativeDataBuffer extends DataBuffer {
  46571. /**
  46572. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46573. */
  46574. nativeIndexBuffer?: any;
  46575. /**
  46576. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46577. */
  46578. nativeVertexBuffer?: any;
  46579. }
  46580. /** @hidden */
  46581. export class NativeEngine extends Engine {
  46582. private readonly _native;
  46583. getHardwareScalingLevel(): number;
  46584. constructor();
  46585. /**
  46586. * Can be used to override the current requestAnimationFrame requester.
  46587. * @hidden
  46588. */
  46589. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46590. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46591. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46592. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46593. recordVertexArrayObject(vertexBuffers: {
  46594. [key: string]: VertexBuffer;
  46595. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46596. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46597. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46598. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46599. /**
  46600. * Draw a list of indexed primitives
  46601. * @param fillMode defines the primitive to use
  46602. * @param indexStart defines the starting index
  46603. * @param indexCount defines the number of index to draw
  46604. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46605. */
  46606. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46607. /**
  46608. * Draw a list of unindexed primitives
  46609. * @param fillMode defines the primitive to use
  46610. * @param verticesStart defines the index of first vertex to draw
  46611. * @param verticesCount defines the count of vertices to draw
  46612. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46613. */
  46614. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46615. createPipelineContext(): IPipelineContext;
  46616. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46617. /** @hidden */
  46618. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46619. /** @hidden */
  46620. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46621. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46622. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46623. protected _setProgram(program: WebGLProgram): void;
  46624. _releaseEffect(effect: Effect): void;
  46625. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46626. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46627. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46628. bindSamplers(effect: Effect): void;
  46629. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46630. getRenderWidth(useScreen?: boolean): number;
  46631. getRenderHeight(useScreen?: boolean): number;
  46632. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46633. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46634. /**
  46635. * Set the z offset to apply to current rendering
  46636. * @param value defines the offset to apply
  46637. */
  46638. setZOffset(value: number): void;
  46639. /**
  46640. * Gets the current value of the zOffset
  46641. * @returns the current zOffset state
  46642. */
  46643. getZOffset(): number;
  46644. /**
  46645. * Enable or disable depth buffering
  46646. * @param enable defines the state to set
  46647. */
  46648. setDepthBuffer(enable: boolean): void;
  46649. /**
  46650. * Gets a boolean indicating if depth writing is enabled
  46651. * @returns the current depth writing state
  46652. */
  46653. getDepthWrite(): boolean;
  46654. /**
  46655. * Enable or disable depth writing
  46656. * @param enable defines the state to set
  46657. */
  46658. setDepthWrite(enable: boolean): void;
  46659. /**
  46660. * Enable or disable color writing
  46661. * @param enable defines the state to set
  46662. */
  46663. setColorWrite(enable: boolean): void;
  46664. /**
  46665. * Gets a boolean indicating if color writing is enabled
  46666. * @returns the current color writing state
  46667. */
  46668. getColorWrite(): boolean;
  46669. /**
  46670. * Sets alpha constants used by some alpha blending modes
  46671. * @param r defines the red component
  46672. * @param g defines the green component
  46673. * @param b defines the blue component
  46674. * @param a defines the alpha component
  46675. */
  46676. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46677. /**
  46678. * Sets the current alpha mode
  46679. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46680. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46681. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46682. */
  46683. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46684. /**
  46685. * Gets the current alpha mode
  46686. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46687. * @returns the current alpha mode
  46688. */
  46689. getAlphaMode(): number;
  46690. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46691. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46692. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46693. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46694. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46695. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46696. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46697. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46698. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46699. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46700. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46701. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46702. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46703. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46704. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46705. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46706. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46707. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46708. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46709. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46710. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46711. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46712. wipeCaches(bruteForce?: boolean): void;
  46713. _createTexture(): WebGLTexture;
  46714. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46715. /**
  46716. * Usually called from BABYLON.Texture.ts.
  46717. * Passed information to create a WebGLTexture
  46718. * @param urlArg defines a value which contains one of the following:
  46719. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46720. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46721. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46722. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46723. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46724. * @param scene needed for loading to the correct scene
  46725. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46726. * @param onLoad optional callback to be called upon successful completion
  46727. * @param onError optional callback to be called upon failure
  46728. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46729. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46730. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46731. * @param forcedExtension defines the extension to use to pick the right loader
  46732. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46733. */
  46734. 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;
  46735. /**
  46736. * Creates a cube texture
  46737. * @param rootUrl defines the url where the files to load is located
  46738. * @param scene defines the current scene
  46739. * @param files defines the list of files to load (1 per face)
  46740. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46741. * @param onLoad defines an optional callback raised when the texture is loaded
  46742. * @param onError defines an optional callback raised if there is an issue to load the texture
  46743. * @param format defines the format of the data
  46744. * @param forcedExtension defines the extension to use to pick the right loader
  46745. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46746. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46747. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46748. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46749. * @returns the cube texture as an InternalTexture
  46750. */
  46751. 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;
  46752. private _getSamplingFilter;
  46753. private static _GetNativeTextureFormat;
  46754. createRenderTargetTexture(size: number | {
  46755. width: number;
  46756. height: number;
  46757. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46758. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46759. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46760. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46761. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46762. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46763. /**
  46764. * Updates a dynamic vertex buffer.
  46765. * @param vertexBuffer the vertex buffer to update
  46766. * @param data the data used to update the vertex buffer
  46767. * @param byteOffset the byte offset of the data (optional)
  46768. * @param byteLength the byte length of the data (optional)
  46769. */
  46770. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46771. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46772. private _updateAnisotropicLevel;
  46773. private _getAddressMode;
  46774. /** @hidden */
  46775. _bindTexture(channel: number, texture: InternalTexture): void;
  46776. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46777. releaseEffects(): void;
  46778. /** @hidden */
  46779. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46780. /** @hidden */
  46781. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46782. /** @hidden */
  46783. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46784. /** @hidden */
  46785. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46786. }
  46787. }
  46788. declare module "babylonjs/Engines/index" {
  46789. export * from "babylonjs/Engines/constants";
  46790. export * from "babylonjs/Engines/engineCapabilities";
  46791. export * from "babylonjs/Engines/instancingAttributeInfo";
  46792. export * from "babylonjs/Engines/thinEngine";
  46793. export * from "babylonjs/Engines/engine";
  46794. export * from "babylonjs/Engines/engineStore";
  46795. export * from "babylonjs/Engines/nullEngine";
  46796. export * from "babylonjs/Engines/Extensions/index";
  46797. export * from "babylonjs/Engines/IPipelineContext";
  46798. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46799. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46800. export * from "babylonjs/Engines/nativeEngine";
  46801. }
  46802. declare module "babylonjs/Events/clipboardEvents" {
  46803. /**
  46804. * Gather the list of clipboard event types as constants.
  46805. */
  46806. export class ClipboardEventTypes {
  46807. /**
  46808. * The clipboard event is fired when a copy command is active (pressed).
  46809. */
  46810. static readonly COPY: number;
  46811. /**
  46812. * The clipboard event is fired when a cut command is active (pressed).
  46813. */
  46814. static readonly CUT: number;
  46815. /**
  46816. * The clipboard event is fired when a paste command is active (pressed).
  46817. */
  46818. static readonly PASTE: number;
  46819. }
  46820. /**
  46821. * This class is used to store clipboard related info for the onClipboardObservable event.
  46822. */
  46823. export class ClipboardInfo {
  46824. /**
  46825. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46826. */
  46827. type: number;
  46828. /**
  46829. * Defines the related dom event
  46830. */
  46831. event: ClipboardEvent;
  46832. /**
  46833. *Creates an instance of ClipboardInfo.
  46834. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46835. * @param event Defines the related dom event
  46836. */
  46837. constructor(
  46838. /**
  46839. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46840. */
  46841. type: number,
  46842. /**
  46843. * Defines the related dom event
  46844. */
  46845. event: ClipboardEvent);
  46846. /**
  46847. * Get the clipboard event's type from the keycode.
  46848. * @param keyCode Defines the keyCode for the current keyboard event.
  46849. * @return {number}
  46850. */
  46851. static GetTypeFromCharacter(keyCode: number): number;
  46852. }
  46853. }
  46854. declare module "babylonjs/Events/index" {
  46855. export * from "babylonjs/Events/keyboardEvents";
  46856. export * from "babylonjs/Events/pointerEvents";
  46857. export * from "babylonjs/Events/clipboardEvents";
  46858. }
  46859. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46860. import { Scene } from "babylonjs/scene";
  46861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46862. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46863. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46864. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46865. /**
  46866. * Google Daydream controller
  46867. */
  46868. export class DaydreamController extends WebVRController {
  46869. /**
  46870. * Base Url for the controller model.
  46871. */
  46872. static MODEL_BASE_URL: string;
  46873. /**
  46874. * File name for the controller model.
  46875. */
  46876. static MODEL_FILENAME: string;
  46877. /**
  46878. * Gamepad Id prefix used to identify Daydream Controller.
  46879. */
  46880. static readonly GAMEPAD_ID_PREFIX: string;
  46881. /**
  46882. * Creates a new DaydreamController from a gamepad
  46883. * @param vrGamepad the gamepad that the controller should be created from
  46884. */
  46885. constructor(vrGamepad: any);
  46886. /**
  46887. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46888. * @param scene scene in which to add meshes
  46889. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46890. */
  46891. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46892. /**
  46893. * Called once for each button that changed state since the last frame
  46894. * @param buttonIdx Which button index changed
  46895. * @param state New state of the button
  46896. * @param changes Which properties on the state changed since last frame
  46897. */
  46898. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46899. }
  46900. }
  46901. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46902. import { Scene } from "babylonjs/scene";
  46903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46904. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46905. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46906. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46907. /**
  46908. * Gear VR Controller
  46909. */
  46910. export class GearVRController extends WebVRController {
  46911. /**
  46912. * Base Url for the controller model.
  46913. */
  46914. static MODEL_BASE_URL: string;
  46915. /**
  46916. * File name for the controller model.
  46917. */
  46918. static MODEL_FILENAME: string;
  46919. /**
  46920. * Gamepad Id prefix used to identify this controller.
  46921. */
  46922. static readonly GAMEPAD_ID_PREFIX: string;
  46923. private readonly _buttonIndexToObservableNameMap;
  46924. /**
  46925. * Creates a new GearVRController from a gamepad
  46926. * @param vrGamepad the gamepad that the controller should be created from
  46927. */
  46928. constructor(vrGamepad: any);
  46929. /**
  46930. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46931. * @param scene scene in which to add meshes
  46932. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46933. */
  46934. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46935. /**
  46936. * Called once for each button that changed state since the last frame
  46937. * @param buttonIdx Which button index changed
  46938. * @param state New state of the button
  46939. * @param changes Which properties on the state changed since last frame
  46940. */
  46941. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46942. }
  46943. }
  46944. declare module "babylonjs/Gamepads/Controllers/index" {
  46945. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46946. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46947. export * from "babylonjs/Gamepads/Controllers/genericController";
  46948. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46949. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46950. export * from "babylonjs/Gamepads/Controllers/viveController";
  46951. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46952. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46953. }
  46954. declare module "babylonjs/Gamepads/index" {
  46955. export * from "babylonjs/Gamepads/Controllers/index";
  46956. export * from "babylonjs/Gamepads/gamepad";
  46957. export * from "babylonjs/Gamepads/gamepadManager";
  46958. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46959. export * from "babylonjs/Gamepads/xboxGamepad";
  46960. export * from "babylonjs/Gamepads/dualShockGamepad";
  46961. }
  46962. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46963. import { Scene } from "babylonjs/scene";
  46964. import { Vector4 } from "babylonjs/Maths/math.vector";
  46965. import { Color4 } from "babylonjs/Maths/math.color";
  46966. import { Mesh } from "babylonjs/Meshes/mesh";
  46967. import { Nullable } from "babylonjs/types";
  46968. /**
  46969. * Class containing static functions to help procedurally build meshes
  46970. */
  46971. export class PolyhedronBuilder {
  46972. /**
  46973. * Creates a polyhedron mesh
  46974. * * 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
  46975. * * The parameter `size` (positive float, default 1) sets the polygon size
  46976. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46977. * * 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`
  46978. * * 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
  46979. * * 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)`)
  46980. * * 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
  46981. * * 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
  46982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46985. * @param name defines the name of the mesh
  46986. * @param options defines the options used to create the mesh
  46987. * @param scene defines the hosting scene
  46988. * @returns the polyhedron mesh
  46989. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46990. */
  46991. static CreatePolyhedron(name: string, options: {
  46992. type?: number;
  46993. size?: number;
  46994. sizeX?: number;
  46995. sizeY?: number;
  46996. sizeZ?: number;
  46997. custom?: any;
  46998. faceUV?: Vector4[];
  46999. faceColors?: Color4[];
  47000. flat?: boolean;
  47001. updatable?: boolean;
  47002. sideOrientation?: number;
  47003. frontUVs?: Vector4;
  47004. backUVs?: Vector4;
  47005. }, scene?: Nullable<Scene>): Mesh;
  47006. }
  47007. }
  47008. declare module "babylonjs/Gizmos/scaleGizmo" {
  47009. import { Observable } from "babylonjs/Misc/observable";
  47010. import { Nullable } from "babylonjs/types";
  47011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47012. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47013. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47014. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47015. /**
  47016. * Gizmo that enables scaling a mesh along 3 axis
  47017. */
  47018. export class ScaleGizmo extends Gizmo {
  47019. /**
  47020. * Internal gizmo used for interactions on the x axis
  47021. */
  47022. xGizmo: AxisScaleGizmo;
  47023. /**
  47024. * Internal gizmo used for interactions on the y axis
  47025. */
  47026. yGizmo: AxisScaleGizmo;
  47027. /**
  47028. * Internal gizmo used for interactions on the z axis
  47029. */
  47030. zGizmo: AxisScaleGizmo;
  47031. /**
  47032. * Internal gizmo used to scale all axis equally
  47033. */
  47034. uniformScaleGizmo: AxisScaleGizmo;
  47035. private _meshAttached;
  47036. private _updateGizmoRotationToMatchAttachedMesh;
  47037. private _snapDistance;
  47038. private _scaleRatio;
  47039. private _uniformScalingMesh;
  47040. private _octahedron;
  47041. /** Fires an event when any of it's sub gizmos are dragged */
  47042. onDragStartObservable: Observable<unknown>;
  47043. /** Fires an event when any of it's sub gizmos are released from dragging */
  47044. onDragEndObservable: Observable<unknown>;
  47045. attachedMesh: Nullable<AbstractMesh>;
  47046. /**
  47047. * Creates a ScaleGizmo
  47048. * @param gizmoLayer The utility layer the gizmo will be added to
  47049. */
  47050. constructor(gizmoLayer?: UtilityLayerRenderer);
  47051. updateGizmoRotationToMatchAttachedMesh: boolean;
  47052. /**
  47053. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47054. */
  47055. snapDistance: number;
  47056. /**
  47057. * Ratio for the scale of the gizmo (Default: 1)
  47058. */
  47059. scaleRatio: number;
  47060. /**
  47061. * Disposes of the gizmo
  47062. */
  47063. dispose(): void;
  47064. }
  47065. }
  47066. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47067. import { Observable } from "babylonjs/Misc/observable";
  47068. import { Nullable } from "babylonjs/types";
  47069. import { Vector3 } from "babylonjs/Maths/math.vector";
  47070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47071. import { Mesh } from "babylonjs/Meshes/mesh";
  47072. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47073. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47074. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47075. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47076. import { Color3 } from "babylonjs/Maths/math.color";
  47077. /**
  47078. * Single axis scale gizmo
  47079. */
  47080. export class AxisScaleGizmo extends Gizmo {
  47081. /**
  47082. * Drag behavior responsible for the gizmos dragging interactions
  47083. */
  47084. dragBehavior: PointerDragBehavior;
  47085. private _pointerObserver;
  47086. /**
  47087. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47088. */
  47089. snapDistance: number;
  47090. /**
  47091. * Event that fires each time the gizmo snaps to a new location.
  47092. * * snapDistance is the the change in distance
  47093. */
  47094. onSnapObservable: Observable<{
  47095. snapDistance: number;
  47096. }>;
  47097. /**
  47098. * If the scaling operation should be done on all axis (default: false)
  47099. */
  47100. uniformScaling: boolean;
  47101. private _isEnabled;
  47102. private _parent;
  47103. private _arrow;
  47104. private _coloredMaterial;
  47105. private _hoverMaterial;
  47106. /**
  47107. * Creates an AxisScaleGizmo
  47108. * @param gizmoLayer The utility layer the gizmo will be added to
  47109. * @param dragAxis The axis which the gizmo will be able to scale on
  47110. * @param color The color of the gizmo
  47111. */
  47112. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47113. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47114. /**
  47115. * If the gizmo is enabled
  47116. */
  47117. isEnabled: boolean;
  47118. /**
  47119. * Disposes of the gizmo
  47120. */
  47121. dispose(): void;
  47122. /**
  47123. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47124. * @param mesh The mesh to replace the default mesh of the gizmo
  47125. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47126. */
  47127. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47128. }
  47129. }
  47130. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47131. import { Observable } from "babylonjs/Misc/observable";
  47132. import { Nullable } from "babylonjs/types";
  47133. import { Vector3 } from "babylonjs/Maths/math.vector";
  47134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47135. import { Mesh } from "babylonjs/Meshes/mesh";
  47136. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47137. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47138. import { Color3 } from "babylonjs/Maths/math.color";
  47139. import "babylonjs/Meshes/Builders/boxBuilder";
  47140. /**
  47141. * Bounding box gizmo
  47142. */
  47143. export class BoundingBoxGizmo extends Gizmo {
  47144. private _lineBoundingBox;
  47145. private _rotateSpheresParent;
  47146. private _scaleBoxesParent;
  47147. private _boundingDimensions;
  47148. private _renderObserver;
  47149. private _pointerObserver;
  47150. private _scaleDragSpeed;
  47151. private _tmpQuaternion;
  47152. private _tmpVector;
  47153. private _tmpRotationMatrix;
  47154. /**
  47155. * 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)
  47156. */
  47157. ignoreChildren: boolean;
  47158. /**
  47159. * 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)
  47160. */
  47161. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47162. /**
  47163. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47164. */
  47165. rotationSphereSize: number;
  47166. /**
  47167. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47168. */
  47169. scaleBoxSize: number;
  47170. /**
  47171. * 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)
  47172. */
  47173. fixedDragMeshScreenSize: boolean;
  47174. /**
  47175. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47176. */
  47177. fixedDragMeshScreenSizeDistanceFactor: number;
  47178. /**
  47179. * Fired when a rotation sphere or scale box is dragged
  47180. */
  47181. onDragStartObservable: Observable<{}>;
  47182. /**
  47183. * Fired when a scale box is dragged
  47184. */
  47185. onScaleBoxDragObservable: Observable<{}>;
  47186. /**
  47187. * Fired when a scale box drag is ended
  47188. */
  47189. onScaleBoxDragEndObservable: Observable<{}>;
  47190. /**
  47191. * Fired when a rotation sphere is dragged
  47192. */
  47193. onRotationSphereDragObservable: Observable<{}>;
  47194. /**
  47195. * Fired when a rotation sphere drag is ended
  47196. */
  47197. onRotationSphereDragEndObservable: Observable<{}>;
  47198. /**
  47199. * 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)
  47200. */
  47201. scalePivot: Nullable<Vector3>;
  47202. /**
  47203. * Mesh used as a pivot to rotate the attached mesh
  47204. */
  47205. private _anchorMesh;
  47206. private _existingMeshScale;
  47207. private _dragMesh;
  47208. private pointerDragBehavior;
  47209. private coloredMaterial;
  47210. private hoverColoredMaterial;
  47211. /**
  47212. * Sets the color of the bounding box gizmo
  47213. * @param color the color to set
  47214. */
  47215. setColor(color: Color3): void;
  47216. /**
  47217. * Creates an BoundingBoxGizmo
  47218. * @param gizmoLayer The utility layer the gizmo will be added to
  47219. * @param color The color of the gizmo
  47220. */
  47221. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47222. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47223. private _selectNode;
  47224. /**
  47225. * Updates the bounding box information for the Gizmo
  47226. */
  47227. updateBoundingBox(): void;
  47228. private _updateRotationSpheres;
  47229. private _updateScaleBoxes;
  47230. /**
  47231. * Enables rotation on the specified axis and disables rotation on the others
  47232. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47233. */
  47234. setEnabledRotationAxis(axis: string): void;
  47235. /**
  47236. * Enables/disables scaling
  47237. * @param enable if scaling should be enabled
  47238. */
  47239. setEnabledScaling(enable: boolean): void;
  47240. private _updateDummy;
  47241. /**
  47242. * Enables a pointer drag behavior on the bounding box of the gizmo
  47243. */
  47244. enableDragBehavior(): void;
  47245. /**
  47246. * Disposes of the gizmo
  47247. */
  47248. dispose(): void;
  47249. /**
  47250. * 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)
  47251. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47252. * @returns the bounding box mesh with the passed in mesh as a child
  47253. */
  47254. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47255. /**
  47256. * CustomMeshes are not supported by this gizmo
  47257. * @param mesh The mesh to replace the default mesh of the gizmo
  47258. */
  47259. setCustomMesh(mesh: Mesh): void;
  47260. }
  47261. }
  47262. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47263. import { Observable } from "babylonjs/Misc/observable";
  47264. import { Nullable } from "babylonjs/types";
  47265. import { Vector3 } from "babylonjs/Maths/math.vector";
  47266. import { Color3 } from "babylonjs/Maths/math.color";
  47267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47268. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47269. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47270. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47271. import "babylonjs/Meshes/Builders/linesBuilder";
  47272. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47273. /**
  47274. * Single plane rotation gizmo
  47275. */
  47276. export class PlaneRotationGizmo extends Gizmo {
  47277. /**
  47278. * Drag behavior responsible for the gizmos dragging interactions
  47279. */
  47280. dragBehavior: PointerDragBehavior;
  47281. private _pointerObserver;
  47282. /**
  47283. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47284. */
  47285. snapDistance: number;
  47286. /**
  47287. * Event that fires each time the gizmo snaps to a new location.
  47288. * * snapDistance is the the change in distance
  47289. */
  47290. onSnapObservable: Observable<{
  47291. snapDistance: number;
  47292. }>;
  47293. private _isEnabled;
  47294. private _parent;
  47295. /**
  47296. * Creates a PlaneRotationGizmo
  47297. * @param gizmoLayer The utility layer the gizmo will be added to
  47298. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47299. * @param color The color of the gizmo
  47300. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47301. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47302. */
  47303. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47304. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47305. /**
  47306. * If the gizmo is enabled
  47307. */
  47308. isEnabled: boolean;
  47309. /**
  47310. * Disposes of the gizmo
  47311. */
  47312. dispose(): void;
  47313. }
  47314. }
  47315. declare module "babylonjs/Gizmos/rotationGizmo" {
  47316. import { Observable } from "babylonjs/Misc/observable";
  47317. import { Nullable } from "babylonjs/types";
  47318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47319. import { Mesh } from "babylonjs/Meshes/mesh";
  47320. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47321. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47322. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47323. /**
  47324. * Gizmo that enables rotating a mesh along 3 axis
  47325. */
  47326. export class RotationGizmo extends Gizmo {
  47327. /**
  47328. * Internal gizmo used for interactions on the x axis
  47329. */
  47330. xGizmo: PlaneRotationGizmo;
  47331. /**
  47332. * Internal gizmo used for interactions on the y axis
  47333. */
  47334. yGizmo: PlaneRotationGizmo;
  47335. /**
  47336. * Internal gizmo used for interactions on the z axis
  47337. */
  47338. zGizmo: PlaneRotationGizmo;
  47339. /** Fires an event when any of it's sub gizmos are dragged */
  47340. onDragStartObservable: Observable<unknown>;
  47341. /** Fires an event when any of it's sub gizmos are released from dragging */
  47342. onDragEndObservable: Observable<unknown>;
  47343. private _meshAttached;
  47344. attachedMesh: Nullable<AbstractMesh>;
  47345. /**
  47346. * Creates a RotationGizmo
  47347. * @param gizmoLayer The utility layer the gizmo will be added to
  47348. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47349. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47350. */
  47351. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47352. updateGizmoRotationToMatchAttachedMesh: boolean;
  47353. /**
  47354. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47355. */
  47356. snapDistance: number;
  47357. /**
  47358. * Ratio for the scale of the gizmo (Default: 1)
  47359. */
  47360. scaleRatio: number;
  47361. /**
  47362. * Disposes of the gizmo
  47363. */
  47364. dispose(): void;
  47365. /**
  47366. * CustomMeshes are not supported by this gizmo
  47367. * @param mesh The mesh to replace the default mesh of the gizmo
  47368. */
  47369. setCustomMesh(mesh: Mesh): void;
  47370. }
  47371. }
  47372. declare module "babylonjs/Gizmos/gizmoManager" {
  47373. import { Observable } from "babylonjs/Misc/observable";
  47374. import { Nullable } from "babylonjs/types";
  47375. import { Scene, IDisposable } from "babylonjs/scene";
  47376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47377. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47378. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47379. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47380. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47381. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47382. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47383. /**
  47384. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47385. */
  47386. export class GizmoManager implements IDisposable {
  47387. private scene;
  47388. /**
  47389. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47390. */
  47391. gizmos: {
  47392. positionGizmo: Nullable<PositionGizmo>;
  47393. rotationGizmo: Nullable<RotationGizmo>;
  47394. scaleGizmo: Nullable<ScaleGizmo>;
  47395. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47396. };
  47397. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47398. clearGizmoOnEmptyPointerEvent: boolean;
  47399. /** Fires an event when the manager is attached to a mesh */
  47400. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47401. private _gizmosEnabled;
  47402. private _pointerObserver;
  47403. private _attachedMesh;
  47404. private _boundingBoxColor;
  47405. private _defaultUtilityLayer;
  47406. private _defaultKeepDepthUtilityLayer;
  47407. /**
  47408. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47409. */
  47410. boundingBoxDragBehavior: SixDofDragBehavior;
  47411. /**
  47412. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47413. */
  47414. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47415. /**
  47416. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47417. */
  47418. usePointerToAttachGizmos: boolean;
  47419. /**
  47420. * Utility layer that the bounding box gizmo belongs to
  47421. */
  47422. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47423. /**
  47424. * Utility layer that all gizmos besides bounding box belong to
  47425. */
  47426. readonly utilityLayer: UtilityLayerRenderer;
  47427. /**
  47428. * Instatiates a gizmo manager
  47429. * @param scene the scene to overlay the gizmos on top of
  47430. */
  47431. constructor(scene: Scene);
  47432. /**
  47433. * Attaches a set of gizmos to the specified mesh
  47434. * @param mesh The mesh the gizmo's should be attached to
  47435. */
  47436. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47437. /**
  47438. * If the position gizmo is enabled
  47439. */
  47440. positionGizmoEnabled: boolean;
  47441. /**
  47442. * If the rotation gizmo is enabled
  47443. */
  47444. rotationGizmoEnabled: boolean;
  47445. /**
  47446. * If the scale gizmo is enabled
  47447. */
  47448. scaleGizmoEnabled: boolean;
  47449. /**
  47450. * If the boundingBox gizmo is enabled
  47451. */
  47452. boundingBoxGizmoEnabled: boolean;
  47453. /**
  47454. * Disposes of the gizmo manager
  47455. */
  47456. dispose(): void;
  47457. }
  47458. }
  47459. declare module "babylonjs/Lights/directionalLight" {
  47460. import { Camera } from "babylonjs/Cameras/camera";
  47461. import { Scene } from "babylonjs/scene";
  47462. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47464. import { Light } from "babylonjs/Lights/light";
  47465. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47466. import { Effect } from "babylonjs/Materials/effect";
  47467. /**
  47468. * A directional light is defined by a direction (what a surprise!).
  47469. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47470. * 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.
  47471. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47472. */
  47473. export class DirectionalLight extends ShadowLight {
  47474. private _shadowFrustumSize;
  47475. /**
  47476. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47477. */
  47478. /**
  47479. * Specifies a fix frustum size for the shadow generation.
  47480. */
  47481. shadowFrustumSize: number;
  47482. private _shadowOrthoScale;
  47483. /**
  47484. * Gets the shadow projection scale against the optimal computed one.
  47485. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47486. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47487. */
  47488. /**
  47489. * Sets the shadow projection scale against the optimal computed one.
  47490. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47491. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47492. */
  47493. shadowOrthoScale: number;
  47494. /**
  47495. * Automatically compute the projection matrix to best fit (including all the casters)
  47496. * on each frame.
  47497. */
  47498. autoUpdateExtends: boolean;
  47499. private _orthoLeft;
  47500. private _orthoRight;
  47501. private _orthoTop;
  47502. private _orthoBottom;
  47503. /**
  47504. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47505. * The directional light is emitted from everywhere in the given direction.
  47506. * It can cast shadows.
  47507. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47508. * @param name The friendly name of the light
  47509. * @param direction The direction of the light
  47510. * @param scene The scene the light belongs to
  47511. */
  47512. constructor(name: string, direction: Vector3, scene: Scene);
  47513. /**
  47514. * Returns the string "DirectionalLight".
  47515. * @return The class name
  47516. */
  47517. getClassName(): string;
  47518. /**
  47519. * Returns the integer 1.
  47520. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47521. */
  47522. getTypeID(): number;
  47523. /**
  47524. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47525. * Returns the DirectionalLight Shadow projection matrix.
  47526. */
  47527. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47528. /**
  47529. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47530. * Returns the DirectionalLight Shadow projection matrix.
  47531. */
  47532. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47533. /**
  47534. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47535. * Returns the DirectionalLight Shadow projection matrix.
  47536. */
  47537. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47538. protected _buildUniformLayout(): void;
  47539. /**
  47540. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47541. * @param effect The effect to update
  47542. * @param lightIndex The index of the light in the effect to update
  47543. * @returns The directional light
  47544. */
  47545. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47546. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47547. /**
  47548. * Gets the minZ used for shadow according to both the scene and the light.
  47549. *
  47550. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47551. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47552. * @param activeCamera The camera we are returning the min for
  47553. * @returns the depth min z
  47554. */
  47555. getDepthMinZ(activeCamera: Camera): number;
  47556. /**
  47557. * Gets the maxZ used for shadow according to both the scene and the light.
  47558. *
  47559. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47560. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47561. * @param activeCamera The camera we are returning the max for
  47562. * @returns the depth max z
  47563. */
  47564. getDepthMaxZ(activeCamera: Camera): number;
  47565. /**
  47566. * Prepares the list of defines specific to the light type.
  47567. * @param defines the list of defines
  47568. * @param lightIndex defines the index of the light for the effect
  47569. */
  47570. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47571. }
  47572. }
  47573. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47574. import { Mesh } from "babylonjs/Meshes/mesh";
  47575. /**
  47576. * Class containing static functions to help procedurally build meshes
  47577. */
  47578. export class HemisphereBuilder {
  47579. /**
  47580. * Creates a hemisphere mesh
  47581. * @param name defines the name of the mesh
  47582. * @param options defines the options used to create the mesh
  47583. * @param scene defines the hosting scene
  47584. * @returns the hemisphere mesh
  47585. */
  47586. static CreateHemisphere(name: string, options: {
  47587. segments?: number;
  47588. diameter?: number;
  47589. sideOrientation?: number;
  47590. }, scene: any): Mesh;
  47591. }
  47592. }
  47593. declare module "babylonjs/Lights/spotLight" {
  47594. import { Nullable } from "babylonjs/types";
  47595. import { Scene } from "babylonjs/scene";
  47596. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47598. import { Effect } from "babylonjs/Materials/effect";
  47599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47600. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47601. /**
  47602. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47603. * These values define a cone of light starting from the position, emitting toward the direction.
  47604. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47605. * and the exponent defines the speed of the decay of the light with distance (reach).
  47606. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47607. */
  47608. export class SpotLight extends ShadowLight {
  47609. private _angle;
  47610. private _innerAngle;
  47611. private _cosHalfAngle;
  47612. private _lightAngleScale;
  47613. private _lightAngleOffset;
  47614. /**
  47615. * Gets the cone angle of the spot light in Radians.
  47616. */
  47617. /**
  47618. * Sets the cone angle of the spot light in Radians.
  47619. */
  47620. angle: number;
  47621. /**
  47622. * Only used in gltf falloff mode, this defines the angle where
  47623. * the directional falloff will start before cutting at angle which could be seen
  47624. * as outer angle.
  47625. */
  47626. /**
  47627. * Only used in gltf falloff mode, this defines the angle where
  47628. * the directional falloff will start before cutting at angle which could be seen
  47629. * as outer angle.
  47630. */
  47631. innerAngle: number;
  47632. private _shadowAngleScale;
  47633. /**
  47634. * Allows scaling the angle of the light for shadow generation only.
  47635. */
  47636. /**
  47637. * Allows scaling the angle of the light for shadow generation only.
  47638. */
  47639. shadowAngleScale: number;
  47640. /**
  47641. * The light decay speed with the distance from the emission spot.
  47642. */
  47643. exponent: number;
  47644. private _projectionTextureMatrix;
  47645. /**
  47646. * Allows reading the projecton texture
  47647. */
  47648. readonly projectionTextureMatrix: Matrix;
  47649. protected _projectionTextureLightNear: number;
  47650. /**
  47651. * Gets the near clip of the Spotlight for texture projection.
  47652. */
  47653. /**
  47654. * Sets the near clip of the Spotlight for texture projection.
  47655. */
  47656. projectionTextureLightNear: number;
  47657. protected _projectionTextureLightFar: number;
  47658. /**
  47659. * Gets the far clip of the Spotlight for texture projection.
  47660. */
  47661. /**
  47662. * Sets the far clip of the Spotlight for texture projection.
  47663. */
  47664. projectionTextureLightFar: number;
  47665. protected _projectionTextureUpDirection: Vector3;
  47666. /**
  47667. * Gets the Up vector of the Spotlight for texture projection.
  47668. */
  47669. /**
  47670. * Sets the Up vector of the Spotlight for texture projection.
  47671. */
  47672. projectionTextureUpDirection: Vector3;
  47673. private _projectionTexture;
  47674. /**
  47675. * Gets the projection texture of the light.
  47676. */
  47677. /**
  47678. * Sets the projection texture of the light.
  47679. */
  47680. projectionTexture: Nullable<BaseTexture>;
  47681. private _projectionTextureViewLightDirty;
  47682. private _projectionTextureProjectionLightDirty;
  47683. private _projectionTextureDirty;
  47684. private _projectionTextureViewTargetVector;
  47685. private _projectionTextureViewLightMatrix;
  47686. private _projectionTextureProjectionLightMatrix;
  47687. private _projectionTextureScalingMatrix;
  47688. /**
  47689. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47690. * It can cast shadows.
  47691. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47692. * @param name The light friendly name
  47693. * @param position The position of the spot light in the scene
  47694. * @param direction The direction of the light in the scene
  47695. * @param angle The cone angle of the light in Radians
  47696. * @param exponent The light decay speed with the distance from the emission spot
  47697. * @param scene The scene the lights belongs to
  47698. */
  47699. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47700. /**
  47701. * Returns the string "SpotLight".
  47702. * @returns the class name
  47703. */
  47704. getClassName(): string;
  47705. /**
  47706. * Returns the integer 2.
  47707. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47708. */
  47709. getTypeID(): number;
  47710. /**
  47711. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47712. */
  47713. protected _setDirection(value: Vector3): void;
  47714. /**
  47715. * Overrides the position setter to recompute the projection texture view light Matrix.
  47716. */
  47717. protected _setPosition(value: Vector3): void;
  47718. /**
  47719. * 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.
  47720. * Returns the SpotLight.
  47721. */
  47722. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47723. protected _computeProjectionTextureViewLightMatrix(): void;
  47724. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47725. /**
  47726. * Main function for light texture projection matrix computing.
  47727. */
  47728. protected _computeProjectionTextureMatrix(): void;
  47729. protected _buildUniformLayout(): void;
  47730. private _computeAngleValues;
  47731. /**
  47732. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47733. * @param effect The effect to update
  47734. * @param lightIndex The index of the light in the effect to update
  47735. * @returns The spot light
  47736. */
  47737. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47738. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47739. /**
  47740. * Disposes the light and the associated resources.
  47741. */
  47742. dispose(): void;
  47743. /**
  47744. * Prepares the list of defines specific to the light type.
  47745. * @param defines the list of defines
  47746. * @param lightIndex defines the index of the light for the effect
  47747. */
  47748. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47749. }
  47750. }
  47751. declare module "babylonjs/Gizmos/lightGizmo" {
  47752. import { Nullable } from "babylonjs/types";
  47753. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47754. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47755. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47756. import { Light } from "babylonjs/Lights/light";
  47757. /**
  47758. * Gizmo that enables viewing a light
  47759. */
  47760. export class LightGizmo extends Gizmo {
  47761. private _lightMesh;
  47762. private _material;
  47763. private cachedPosition;
  47764. private cachedForward;
  47765. /**
  47766. * Creates a LightGizmo
  47767. * @param gizmoLayer The utility layer the gizmo will be added to
  47768. */
  47769. constructor(gizmoLayer?: UtilityLayerRenderer);
  47770. private _light;
  47771. /**
  47772. * The light that the gizmo is attached to
  47773. */
  47774. light: Nullable<Light>;
  47775. /**
  47776. * Gets the material used to render the light gizmo
  47777. */
  47778. readonly material: StandardMaterial;
  47779. /**
  47780. * @hidden
  47781. * Updates the gizmo to match the attached mesh's position/rotation
  47782. */
  47783. protected _update(): void;
  47784. private static _Scale;
  47785. /**
  47786. * Creates the lines for a light mesh
  47787. */
  47788. private static _createLightLines;
  47789. /**
  47790. * Disposes of the light gizmo
  47791. */
  47792. dispose(): void;
  47793. private static _CreateHemisphericLightMesh;
  47794. private static _CreatePointLightMesh;
  47795. private static _CreateSpotLightMesh;
  47796. private static _CreateDirectionalLightMesh;
  47797. }
  47798. }
  47799. declare module "babylonjs/Gizmos/index" {
  47800. export * from "babylonjs/Gizmos/axisDragGizmo";
  47801. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47802. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47803. export * from "babylonjs/Gizmos/gizmo";
  47804. export * from "babylonjs/Gizmos/gizmoManager";
  47805. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47806. export * from "babylonjs/Gizmos/positionGizmo";
  47807. export * from "babylonjs/Gizmos/rotationGizmo";
  47808. export * from "babylonjs/Gizmos/scaleGizmo";
  47809. export * from "babylonjs/Gizmos/lightGizmo";
  47810. export * from "babylonjs/Gizmos/planeDragGizmo";
  47811. }
  47812. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47813. /** @hidden */
  47814. export var backgroundFragmentDeclaration: {
  47815. name: string;
  47816. shader: string;
  47817. };
  47818. }
  47819. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47820. /** @hidden */
  47821. export var backgroundUboDeclaration: {
  47822. name: string;
  47823. shader: string;
  47824. };
  47825. }
  47826. declare module "babylonjs/Shaders/background.fragment" {
  47827. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47828. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47829. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47830. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47831. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47832. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47833. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47834. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47835. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47836. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47837. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47838. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47839. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47840. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47841. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47842. /** @hidden */
  47843. export var backgroundPixelShader: {
  47844. name: string;
  47845. shader: string;
  47846. };
  47847. }
  47848. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47849. /** @hidden */
  47850. export var backgroundVertexDeclaration: {
  47851. name: string;
  47852. shader: string;
  47853. };
  47854. }
  47855. declare module "babylonjs/Shaders/background.vertex" {
  47856. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47857. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47858. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47859. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47860. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47861. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47862. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47863. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47864. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47865. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47866. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47867. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47868. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47869. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47870. /** @hidden */
  47871. export var backgroundVertexShader: {
  47872. name: string;
  47873. shader: string;
  47874. };
  47875. }
  47876. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47877. import { Nullable, int, float } from "babylonjs/types";
  47878. import { Scene } from "babylonjs/scene";
  47879. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47880. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47882. import { Mesh } from "babylonjs/Meshes/mesh";
  47883. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47884. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47885. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47886. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47887. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47888. import { Color3 } from "babylonjs/Maths/math.color";
  47889. import "babylonjs/Shaders/background.fragment";
  47890. import "babylonjs/Shaders/background.vertex";
  47891. /**
  47892. * Background material used to create an efficient environement around your scene.
  47893. */
  47894. export class BackgroundMaterial extends PushMaterial {
  47895. /**
  47896. * Standard reflectance value at parallel view angle.
  47897. */
  47898. static StandardReflectance0: number;
  47899. /**
  47900. * Standard reflectance value at grazing angle.
  47901. */
  47902. static StandardReflectance90: number;
  47903. protected _primaryColor: Color3;
  47904. /**
  47905. * Key light Color (multiply against the environement texture)
  47906. */
  47907. primaryColor: Color3;
  47908. protected __perceptualColor: Nullable<Color3>;
  47909. /**
  47910. * Experimental Internal Use Only.
  47911. *
  47912. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47913. * This acts as a helper to set the primary color to a more "human friendly" value.
  47914. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47915. * output color as close as possible from the chosen value.
  47916. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47917. * part of lighting setup.)
  47918. */
  47919. _perceptualColor: Nullable<Color3>;
  47920. protected _primaryColorShadowLevel: float;
  47921. /**
  47922. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47923. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47924. */
  47925. primaryColorShadowLevel: float;
  47926. protected _primaryColorHighlightLevel: float;
  47927. /**
  47928. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47929. * The primary color is used at the level chosen to define what the white area would look.
  47930. */
  47931. primaryColorHighlightLevel: float;
  47932. protected _reflectionTexture: Nullable<BaseTexture>;
  47933. /**
  47934. * Reflection Texture used in the material.
  47935. * Should be author in a specific way for the best result (refer to the documentation).
  47936. */
  47937. reflectionTexture: Nullable<BaseTexture>;
  47938. protected _reflectionBlur: float;
  47939. /**
  47940. * Reflection Texture level of blur.
  47941. *
  47942. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47943. * texture twice.
  47944. */
  47945. reflectionBlur: float;
  47946. protected _diffuseTexture: Nullable<BaseTexture>;
  47947. /**
  47948. * Diffuse Texture used in the material.
  47949. * Should be author in a specific way for the best result (refer to the documentation).
  47950. */
  47951. diffuseTexture: Nullable<BaseTexture>;
  47952. protected _shadowLights: Nullable<IShadowLight[]>;
  47953. /**
  47954. * Specify the list of lights casting shadow on the material.
  47955. * All scene shadow lights will be included if null.
  47956. */
  47957. shadowLights: Nullable<IShadowLight[]>;
  47958. protected _shadowLevel: float;
  47959. /**
  47960. * Helps adjusting the shadow to a softer level if required.
  47961. * 0 means black shadows and 1 means no shadows.
  47962. */
  47963. shadowLevel: float;
  47964. protected _sceneCenter: Vector3;
  47965. /**
  47966. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47967. * It is usually zero but might be interesting to modify according to your setup.
  47968. */
  47969. sceneCenter: Vector3;
  47970. protected _opacityFresnel: boolean;
  47971. /**
  47972. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47973. * This helps ensuring a nice transition when the camera goes under the ground.
  47974. */
  47975. opacityFresnel: boolean;
  47976. protected _reflectionFresnel: boolean;
  47977. /**
  47978. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47979. * This helps adding a mirror texture on the ground.
  47980. */
  47981. reflectionFresnel: boolean;
  47982. protected _reflectionFalloffDistance: number;
  47983. /**
  47984. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47985. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47986. */
  47987. reflectionFalloffDistance: number;
  47988. protected _reflectionAmount: number;
  47989. /**
  47990. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47991. */
  47992. reflectionAmount: number;
  47993. protected _reflectionReflectance0: number;
  47994. /**
  47995. * This specifies the weight of the reflection at grazing angle.
  47996. */
  47997. reflectionReflectance0: number;
  47998. protected _reflectionReflectance90: number;
  47999. /**
  48000. * This specifies the weight of the reflection at a perpendicular point of view.
  48001. */
  48002. reflectionReflectance90: number;
  48003. /**
  48004. * Sets the reflection reflectance fresnel values according to the default standard
  48005. * empirically know to work well :-)
  48006. */
  48007. reflectionStandardFresnelWeight: number;
  48008. protected _useRGBColor: boolean;
  48009. /**
  48010. * Helps to directly use the maps channels instead of their level.
  48011. */
  48012. useRGBColor: boolean;
  48013. protected _enableNoise: boolean;
  48014. /**
  48015. * This helps reducing the banding effect that could occur on the background.
  48016. */
  48017. enableNoise: boolean;
  48018. /**
  48019. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48020. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48021. * Recommended to be keep at 1.0 except for special cases.
  48022. */
  48023. fovMultiplier: number;
  48024. private _fovMultiplier;
  48025. /**
  48026. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48027. */
  48028. useEquirectangularFOV: boolean;
  48029. private _maxSimultaneousLights;
  48030. /**
  48031. * Number of Simultaneous lights allowed on the material.
  48032. */
  48033. maxSimultaneousLights: int;
  48034. /**
  48035. * Default configuration related to image processing available in the Background Material.
  48036. */
  48037. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48038. /**
  48039. * Keep track of the image processing observer to allow dispose and replace.
  48040. */
  48041. private _imageProcessingObserver;
  48042. /**
  48043. * Attaches a new image processing configuration to the PBR Material.
  48044. * @param configuration (if null the scene configuration will be use)
  48045. */
  48046. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48047. /**
  48048. * Gets the image processing configuration used either in this material.
  48049. */
  48050. /**
  48051. * Sets the Default image processing configuration used either in the this material.
  48052. *
  48053. * If sets to null, the scene one is in use.
  48054. */
  48055. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48056. /**
  48057. * Gets wether the color curves effect is enabled.
  48058. */
  48059. /**
  48060. * Sets wether the color curves effect is enabled.
  48061. */
  48062. cameraColorCurvesEnabled: boolean;
  48063. /**
  48064. * Gets wether the color grading effect is enabled.
  48065. */
  48066. /**
  48067. * Gets wether the color grading effect is enabled.
  48068. */
  48069. cameraColorGradingEnabled: boolean;
  48070. /**
  48071. * Gets wether tonemapping is enabled or not.
  48072. */
  48073. /**
  48074. * Sets wether tonemapping is enabled or not
  48075. */
  48076. cameraToneMappingEnabled: boolean;
  48077. /**
  48078. * The camera exposure used on this material.
  48079. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48080. * This corresponds to a photographic exposure.
  48081. */
  48082. /**
  48083. * The camera exposure used on this material.
  48084. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48085. * This corresponds to a photographic exposure.
  48086. */
  48087. cameraExposure: float;
  48088. /**
  48089. * Gets The camera contrast used on this material.
  48090. */
  48091. /**
  48092. * Sets The camera contrast used on this material.
  48093. */
  48094. cameraContrast: float;
  48095. /**
  48096. * Gets the Color Grading 2D Lookup Texture.
  48097. */
  48098. /**
  48099. * Sets the Color Grading 2D Lookup Texture.
  48100. */
  48101. cameraColorGradingTexture: Nullable<BaseTexture>;
  48102. /**
  48103. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48104. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48105. * 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;
  48106. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48107. */
  48108. /**
  48109. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48110. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48111. * 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;
  48112. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48113. */
  48114. cameraColorCurves: Nullable<ColorCurves>;
  48115. /**
  48116. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48117. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48118. */
  48119. switchToBGR: boolean;
  48120. private _renderTargets;
  48121. private _reflectionControls;
  48122. private _white;
  48123. private _primaryShadowColor;
  48124. private _primaryHighlightColor;
  48125. /**
  48126. * Instantiates a Background Material in the given scene
  48127. * @param name The friendly name of the material
  48128. * @param scene The scene to add the material to
  48129. */
  48130. constructor(name: string, scene: Scene);
  48131. /**
  48132. * Gets a boolean indicating that current material needs to register RTT
  48133. */
  48134. readonly hasRenderTargetTextures: boolean;
  48135. /**
  48136. * The entire material has been created in order to prevent overdraw.
  48137. * @returns false
  48138. */
  48139. needAlphaTesting(): boolean;
  48140. /**
  48141. * The entire material has been created in order to prevent overdraw.
  48142. * @returns true if blending is enable
  48143. */
  48144. needAlphaBlending(): boolean;
  48145. /**
  48146. * Checks wether the material is ready to be rendered for a given mesh.
  48147. * @param mesh The mesh to render
  48148. * @param subMesh The submesh to check against
  48149. * @param useInstances Specify wether or not the material is used with instances
  48150. * @returns true if all the dependencies are ready (Textures, Effects...)
  48151. */
  48152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48153. /**
  48154. * Compute the primary color according to the chosen perceptual color.
  48155. */
  48156. private _computePrimaryColorFromPerceptualColor;
  48157. /**
  48158. * Compute the highlights and shadow colors according to their chosen levels.
  48159. */
  48160. private _computePrimaryColors;
  48161. /**
  48162. * Build the uniform buffer used in the material.
  48163. */
  48164. buildUniformLayout(): void;
  48165. /**
  48166. * Unbind the material.
  48167. */
  48168. unbind(): void;
  48169. /**
  48170. * Bind only the world matrix to the material.
  48171. * @param world The world matrix to bind.
  48172. */
  48173. bindOnlyWorldMatrix(world: Matrix): void;
  48174. /**
  48175. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48176. * @param world The world matrix to bind.
  48177. * @param subMesh The submesh to bind for.
  48178. */
  48179. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48180. /**
  48181. * Checks to see if a texture is used in the material.
  48182. * @param texture - Base texture to use.
  48183. * @returns - Boolean specifying if a texture is used in the material.
  48184. */
  48185. hasTexture(texture: BaseTexture): boolean;
  48186. /**
  48187. * Dispose the material.
  48188. * @param forceDisposeEffect Force disposal of the associated effect.
  48189. * @param forceDisposeTextures Force disposal of the associated textures.
  48190. */
  48191. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48192. /**
  48193. * Clones the material.
  48194. * @param name The cloned name.
  48195. * @returns The cloned material.
  48196. */
  48197. clone(name: string): BackgroundMaterial;
  48198. /**
  48199. * Serializes the current material to its JSON representation.
  48200. * @returns The JSON representation.
  48201. */
  48202. serialize(): any;
  48203. /**
  48204. * Gets the class name of the material
  48205. * @returns "BackgroundMaterial"
  48206. */
  48207. getClassName(): string;
  48208. /**
  48209. * Parse a JSON input to create back a background material.
  48210. * @param source The JSON data to parse
  48211. * @param scene The scene to create the parsed material in
  48212. * @param rootUrl The root url of the assets the material depends upon
  48213. * @returns the instantiated BackgroundMaterial.
  48214. */
  48215. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48216. }
  48217. }
  48218. declare module "babylonjs/Helpers/environmentHelper" {
  48219. import { Observable } from "babylonjs/Misc/observable";
  48220. import { Nullable } from "babylonjs/types";
  48221. import { Scene } from "babylonjs/scene";
  48222. import { Vector3 } from "babylonjs/Maths/math.vector";
  48223. import { Color3 } from "babylonjs/Maths/math.color";
  48224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48225. import { Mesh } from "babylonjs/Meshes/mesh";
  48226. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48227. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48228. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48229. import "babylonjs/Meshes/Builders/planeBuilder";
  48230. import "babylonjs/Meshes/Builders/boxBuilder";
  48231. /**
  48232. * Represents the different options available during the creation of
  48233. * a Environment helper.
  48234. *
  48235. * This can control the default ground, skybox and image processing setup of your scene.
  48236. */
  48237. export interface IEnvironmentHelperOptions {
  48238. /**
  48239. * Specifies wether or not to create a ground.
  48240. * True by default.
  48241. */
  48242. createGround: boolean;
  48243. /**
  48244. * Specifies the ground size.
  48245. * 15 by default.
  48246. */
  48247. groundSize: number;
  48248. /**
  48249. * The texture used on the ground for the main color.
  48250. * Comes from the BabylonJS CDN by default.
  48251. *
  48252. * Remarks: Can be either a texture or a url.
  48253. */
  48254. groundTexture: string | BaseTexture;
  48255. /**
  48256. * The color mixed in the ground texture by default.
  48257. * BabylonJS clearColor by default.
  48258. */
  48259. groundColor: Color3;
  48260. /**
  48261. * Specifies the ground opacity.
  48262. * 1 by default.
  48263. */
  48264. groundOpacity: number;
  48265. /**
  48266. * Enables the ground to receive shadows.
  48267. * True by default.
  48268. */
  48269. enableGroundShadow: boolean;
  48270. /**
  48271. * Helps preventing the shadow to be fully black on the ground.
  48272. * 0.5 by default.
  48273. */
  48274. groundShadowLevel: number;
  48275. /**
  48276. * Creates a mirror texture attach to the ground.
  48277. * false by default.
  48278. */
  48279. enableGroundMirror: boolean;
  48280. /**
  48281. * Specifies the ground mirror size ratio.
  48282. * 0.3 by default as the default kernel is 64.
  48283. */
  48284. groundMirrorSizeRatio: number;
  48285. /**
  48286. * Specifies the ground mirror blur kernel size.
  48287. * 64 by default.
  48288. */
  48289. groundMirrorBlurKernel: number;
  48290. /**
  48291. * Specifies the ground mirror visibility amount.
  48292. * 1 by default
  48293. */
  48294. groundMirrorAmount: number;
  48295. /**
  48296. * Specifies the ground mirror reflectance weight.
  48297. * This uses the standard weight of the background material to setup the fresnel effect
  48298. * of the mirror.
  48299. * 1 by default.
  48300. */
  48301. groundMirrorFresnelWeight: number;
  48302. /**
  48303. * Specifies the ground mirror Falloff distance.
  48304. * This can helps reducing the size of the reflection.
  48305. * 0 by Default.
  48306. */
  48307. groundMirrorFallOffDistance: number;
  48308. /**
  48309. * Specifies the ground mirror texture type.
  48310. * Unsigned Int by Default.
  48311. */
  48312. groundMirrorTextureType: number;
  48313. /**
  48314. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48315. * the shown objects.
  48316. */
  48317. groundYBias: number;
  48318. /**
  48319. * Specifies wether or not to create a skybox.
  48320. * True by default.
  48321. */
  48322. createSkybox: boolean;
  48323. /**
  48324. * Specifies the skybox size.
  48325. * 20 by default.
  48326. */
  48327. skyboxSize: number;
  48328. /**
  48329. * The texture used on the skybox for the main color.
  48330. * Comes from the BabylonJS CDN by default.
  48331. *
  48332. * Remarks: Can be either a texture or a url.
  48333. */
  48334. skyboxTexture: string | BaseTexture;
  48335. /**
  48336. * The color mixed in the skybox texture by default.
  48337. * BabylonJS clearColor by default.
  48338. */
  48339. skyboxColor: Color3;
  48340. /**
  48341. * The background rotation around the Y axis of the scene.
  48342. * This helps aligning the key lights of your scene with the background.
  48343. * 0 by default.
  48344. */
  48345. backgroundYRotation: number;
  48346. /**
  48347. * Compute automatically the size of the elements to best fit with the scene.
  48348. */
  48349. sizeAuto: boolean;
  48350. /**
  48351. * Default position of the rootMesh if autoSize is not true.
  48352. */
  48353. rootPosition: Vector3;
  48354. /**
  48355. * Sets up the image processing in the scene.
  48356. * true by default.
  48357. */
  48358. setupImageProcessing: boolean;
  48359. /**
  48360. * The texture used as your environment texture in the scene.
  48361. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48362. *
  48363. * Remarks: Can be either a texture or a url.
  48364. */
  48365. environmentTexture: string | BaseTexture;
  48366. /**
  48367. * The value of the exposure to apply to the scene.
  48368. * 0.6 by default if setupImageProcessing is true.
  48369. */
  48370. cameraExposure: number;
  48371. /**
  48372. * The value of the contrast to apply to the scene.
  48373. * 1.6 by default if setupImageProcessing is true.
  48374. */
  48375. cameraContrast: number;
  48376. /**
  48377. * Specifies wether or not tonemapping should be enabled in the scene.
  48378. * true by default if setupImageProcessing is true.
  48379. */
  48380. toneMappingEnabled: boolean;
  48381. }
  48382. /**
  48383. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48384. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48385. * It also helps with the default setup of your imageProcessing configuration.
  48386. */
  48387. export class EnvironmentHelper {
  48388. /**
  48389. * Default ground texture URL.
  48390. */
  48391. private static _groundTextureCDNUrl;
  48392. /**
  48393. * Default skybox texture URL.
  48394. */
  48395. private static _skyboxTextureCDNUrl;
  48396. /**
  48397. * Default environment texture URL.
  48398. */
  48399. private static _environmentTextureCDNUrl;
  48400. /**
  48401. * Creates the default options for the helper.
  48402. */
  48403. private static _getDefaultOptions;
  48404. private _rootMesh;
  48405. /**
  48406. * Gets the root mesh created by the helper.
  48407. */
  48408. readonly rootMesh: Mesh;
  48409. private _skybox;
  48410. /**
  48411. * Gets the skybox created by the helper.
  48412. */
  48413. readonly skybox: Nullable<Mesh>;
  48414. private _skyboxTexture;
  48415. /**
  48416. * Gets the skybox texture created by the helper.
  48417. */
  48418. readonly skyboxTexture: Nullable<BaseTexture>;
  48419. private _skyboxMaterial;
  48420. /**
  48421. * Gets the skybox material created by the helper.
  48422. */
  48423. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48424. private _ground;
  48425. /**
  48426. * Gets the ground mesh created by the helper.
  48427. */
  48428. readonly ground: Nullable<Mesh>;
  48429. private _groundTexture;
  48430. /**
  48431. * Gets the ground texture created by the helper.
  48432. */
  48433. readonly groundTexture: Nullable<BaseTexture>;
  48434. private _groundMirror;
  48435. /**
  48436. * Gets the ground mirror created by the helper.
  48437. */
  48438. readonly groundMirror: Nullable<MirrorTexture>;
  48439. /**
  48440. * Gets the ground mirror render list to helps pushing the meshes
  48441. * you wish in the ground reflection.
  48442. */
  48443. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48444. private _groundMaterial;
  48445. /**
  48446. * Gets the ground material created by the helper.
  48447. */
  48448. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48449. /**
  48450. * Stores the creation options.
  48451. */
  48452. private readonly _scene;
  48453. private _options;
  48454. /**
  48455. * This observable will be notified with any error during the creation of the environment,
  48456. * mainly texture creation errors.
  48457. */
  48458. onErrorObservable: Observable<{
  48459. message?: string;
  48460. exception?: any;
  48461. }>;
  48462. /**
  48463. * constructor
  48464. * @param options Defines the options we want to customize the helper
  48465. * @param scene The scene to add the material to
  48466. */
  48467. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48468. /**
  48469. * Updates the background according to the new options
  48470. * @param options
  48471. */
  48472. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48473. /**
  48474. * Sets the primary color of all the available elements.
  48475. * @param color the main color to affect to the ground and the background
  48476. */
  48477. setMainColor(color: Color3): void;
  48478. /**
  48479. * Setup the image processing according to the specified options.
  48480. */
  48481. private _setupImageProcessing;
  48482. /**
  48483. * Setup the environment texture according to the specified options.
  48484. */
  48485. private _setupEnvironmentTexture;
  48486. /**
  48487. * Setup the background according to the specified options.
  48488. */
  48489. private _setupBackground;
  48490. /**
  48491. * Get the scene sizes according to the setup.
  48492. */
  48493. private _getSceneSize;
  48494. /**
  48495. * Setup the ground according to the specified options.
  48496. */
  48497. private _setupGround;
  48498. /**
  48499. * Setup the ground material according to the specified options.
  48500. */
  48501. private _setupGroundMaterial;
  48502. /**
  48503. * Setup the ground diffuse texture according to the specified options.
  48504. */
  48505. private _setupGroundDiffuseTexture;
  48506. /**
  48507. * Setup the ground mirror texture according to the specified options.
  48508. */
  48509. private _setupGroundMirrorTexture;
  48510. /**
  48511. * Setup the ground to receive the mirror texture.
  48512. */
  48513. private _setupMirrorInGroundMaterial;
  48514. /**
  48515. * Setup the skybox according to the specified options.
  48516. */
  48517. private _setupSkybox;
  48518. /**
  48519. * Setup the skybox material according to the specified options.
  48520. */
  48521. private _setupSkyboxMaterial;
  48522. /**
  48523. * Setup the skybox reflection texture according to the specified options.
  48524. */
  48525. private _setupSkyboxReflectionTexture;
  48526. private _errorHandler;
  48527. /**
  48528. * Dispose all the elements created by the Helper.
  48529. */
  48530. dispose(): void;
  48531. }
  48532. }
  48533. declare module "babylonjs/Helpers/photoDome" {
  48534. import { Observable } from "babylonjs/Misc/observable";
  48535. import { Nullable } from "babylonjs/types";
  48536. import { Scene } from "babylonjs/scene";
  48537. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48538. import { Mesh } from "babylonjs/Meshes/mesh";
  48539. import { Texture } from "babylonjs/Materials/Textures/texture";
  48540. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48541. import "babylonjs/Meshes/Builders/sphereBuilder";
  48542. /**
  48543. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48544. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48545. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48546. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48547. */
  48548. export class PhotoDome extends TransformNode {
  48549. /**
  48550. * Define the image as a Monoscopic panoramic 360 image.
  48551. */
  48552. static readonly MODE_MONOSCOPIC: number;
  48553. /**
  48554. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48555. */
  48556. static readonly MODE_TOPBOTTOM: number;
  48557. /**
  48558. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48559. */
  48560. static readonly MODE_SIDEBYSIDE: number;
  48561. private _useDirectMapping;
  48562. /**
  48563. * The texture being displayed on the sphere
  48564. */
  48565. protected _photoTexture: Texture;
  48566. /**
  48567. * Gets or sets the texture being displayed on the sphere
  48568. */
  48569. photoTexture: Texture;
  48570. /**
  48571. * Observable raised when an error occured while loading the 360 image
  48572. */
  48573. onLoadErrorObservable: Observable<string>;
  48574. /**
  48575. * The skybox material
  48576. */
  48577. protected _material: BackgroundMaterial;
  48578. /**
  48579. * The surface used for the skybox
  48580. */
  48581. protected _mesh: Mesh;
  48582. /**
  48583. * Gets the mesh used for the skybox.
  48584. */
  48585. readonly mesh: Mesh;
  48586. /**
  48587. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48588. * Also see the options.resolution property.
  48589. */
  48590. fovMultiplier: number;
  48591. private _imageMode;
  48592. /**
  48593. * Gets or set the current video mode for the video. It can be:
  48594. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48595. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48596. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48597. */
  48598. imageMode: number;
  48599. /**
  48600. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48601. * @param name Element's name, child elements will append suffixes for their own names.
  48602. * @param urlsOfPhoto defines the url of the photo to display
  48603. * @param options defines an object containing optional or exposed sub element properties
  48604. * @param onError defines a callback called when an error occured while loading the texture
  48605. */
  48606. constructor(name: string, urlOfPhoto: string, options: {
  48607. resolution?: number;
  48608. size?: number;
  48609. useDirectMapping?: boolean;
  48610. faceForward?: boolean;
  48611. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48612. private _onBeforeCameraRenderObserver;
  48613. private _changeImageMode;
  48614. /**
  48615. * Releases resources associated with this node.
  48616. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48617. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48618. */
  48619. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48620. }
  48621. }
  48622. declare module "babylonjs/Misc/rgbdTextureTools" {
  48623. import "babylonjs/Shaders/rgbdDecode.fragment";
  48624. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48625. import { Texture } from "babylonjs/Materials/Textures/texture";
  48626. /**
  48627. * Class used to host RGBD texture specific utilities
  48628. */
  48629. export class RGBDTextureTools {
  48630. /**
  48631. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48632. * @param texture the texture to expand.
  48633. */
  48634. static ExpandRGBDTexture(texture: Texture): void;
  48635. }
  48636. }
  48637. declare module "babylonjs/Misc/brdfTextureTools" {
  48638. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48639. import { Scene } from "babylonjs/scene";
  48640. /**
  48641. * Class used to host texture specific utilities
  48642. */
  48643. export class BRDFTextureTools {
  48644. /**
  48645. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48646. * @param scene defines the hosting scene
  48647. * @returns the environment BRDF texture
  48648. */
  48649. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48650. private static _environmentBRDFBase64Texture;
  48651. }
  48652. }
  48653. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48654. import { Nullable } from "babylonjs/types";
  48655. import { Color3 } from "babylonjs/Maths/math.color";
  48656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48657. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48658. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48659. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48660. import { Engine } from "babylonjs/Engines/engine";
  48661. import { Scene } from "babylonjs/scene";
  48662. /**
  48663. * @hidden
  48664. */
  48665. export interface IMaterialClearCoatDefines {
  48666. CLEARCOAT: boolean;
  48667. CLEARCOAT_DEFAULTIOR: boolean;
  48668. CLEARCOAT_TEXTURE: boolean;
  48669. CLEARCOAT_TEXTUREDIRECTUV: number;
  48670. CLEARCOAT_BUMP: boolean;
  48671. CLEARCOAT_BUMPDIRECTUV: number;
  48672. CLEARCOAT_TINT: boolean;
  48673. CLEARCOAT_TINT_TEXTURE: boolean;
  48674. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48675. /** @hidden */
  48676. _areTexturesDirty: boolean;
  48677. }
  48678. /**
  48679. * Define the code related to the clear coat parameters of the pbr material.
  48680. */
  48681. export class PBRClearCoatConfiguration {
  48682. /**
  48683. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48684. * The default fits with a polyurethane material.
  48685. */
  48686. private static readonly _DefaultIndexOfRefraction;
  48687. private _isEnabled;
  48688. /**
  48689. * Defines if the clear coat is enabled in the material.
  48690. */
  48691. isEnabled: boolean;
  48692. /**
  48693. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48694. */
  48695. intensity: number;
  48696. /**
  48697. * Defines the clear coat layer roughness.
  48698. */
  48699. roughness: number;
  48700. private _indexOfRefraction;
  48701. /**
  48702. * Defines the index of refraction of the clear coat.
  48703. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48704. * The default fits with a polyurethane material.
  48705. * Changing the default value is more performance intensive.
  48706. */
  48707. indexOfRefraction: number;
  48708. private _texture;
  48709. /**
  48710. * Stores the clear coat values in a texture.
  48711. */
  48712. texture: Nullable<BaseTexture>;
  48713. private _bumpTexture;
  48714. /**
  48715. * Define the clear coat specific bump texture.
  48716. */
  48717. bumpTexture: Nullable<BaseTexture>;
  48718. private _isTintEnabled;
  48719. /**
  48720. * Defines if the clear coat tint is enabled in the material.
  48721. */
  48722. isTintEnabled: boolean;
  48723. /**
  48724. * Defines the clear coat tint of the material.
  48725. * This is only use if tint is enabled
  48726. */
  48727. tintColor: Color3;
  48728. /**
  48729. * Defines the distance at which the tint color should be found in the
  48730. * clear coat media.
  48731. * This is only use if tint is enabled
  48732. */
  48733. tintColorAtDistance: number;
  48734. /**
  48735. * Defines the clear coat layer thickness.
  48736. * This is only use if tint is enabled
  48737. */
  48738. tintThickness: number;
  48739. private _tintTexture;
  48740. /**
  48741. * Stores the clear tint values in a texture.
  48742. * rgb is tint
  48743. * a is a thickness factor
  48744. */
  48745. tintTexture: Nullable<BaseTexture>;
  48746. /** @hidden */
  48747. private _internalMarkAllSubMeshesAsTexturesDirty;
  48748. /** @hidden */
  48749. _markAllSubMeshesAsTexturesDirty(): void;
  48750. /**
  48751. * Instantiate a new istance of clear coat configuration.
  48752. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48753. */
  48754. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48755. /**
  48756. * Gets wehter the submesh is ready to be used or not.
  48757. * @param defines the list of "defines" to update.
  48758. * @param scene defines the scene the material belongs to.
  48759. * @param engine defines the engine the material belongs to.
  48760. * @param disableBumpMap defines wether the material disables bump or not.
  48761. * @returns - boolean indicating that the submesh is ready or not.
  48762. */
  48763. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48764. /**
  48765. * Checks to see if a texture is used in the material.
  48766. * @param defines the list of "defines" to update.
  48767. * @param scene defines the scene to the material belongs to.
  48768. */
  48769. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48770. /**
  48771. * Binds the material data.
  48772. * @param uniformBuffer defines the Uniform buffer to fill in.
  48773. * @param scene defines the scene the material belongs to.
  48774. * @param engine defines the engine the material belongs to.
  48775. * @param disableBumpMap defines wether the material disables bump or not.
  48776. * @param isFrozen defines wether the material is frozen or not.
  48777. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48778. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48779. */
  48780. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48781. /**
  48782. * Checks to see if a texture is used in the material.
  48783. * @param texture - Base texture to use.
  48784. * @returns - Boolean specifying if a texture is used in the material.
  48785. */
  48786. hasTexture(texture: BaseTexture): boolean;
  48787. /**
  48788. * Returns an array of the actively used textures.
  48789. * @param activeTextures Array of BaseTextures
  48790. */
  48791. getActiveTextures(activeTextures: BaseTexture[]): void;
  48792. /**
  48793. * Returns the animatable textures.
  48794. * @param animatables Array of animatable textures.
  48795. */
  48796. getAnimatables(animatables: IAnimatable[]): void;
  48797. /**
  48798. * Disposes the resources of the material.
  48799. * @param forceDisposeTextures - Forces the disposal of all textures.
  48800. */
  48801. dispose(forceDisposeTextures?: boolean): void;
  48802. /**
  48803. * Get the current class name of the texture useful for serialization or dynamic coding.
  48804. * @returns "PBRClearCoatConfiguration"
  48805. */
  48806. getClassName(): string;
  48807. /**
  48808. * Add fallbacks to the effect fallbacks list.
  48809. * @param defines defines the Base texture to use.
  48810. * @param fallbacks defines the current fallback list.
  48811. * @param currentRank defines the current fallback rank.
  48812. * @returns the new fallback rank.
  48813. */
  48814. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48815. /**
  48816. * Add the required uniforms to the current list.
  48817. * @param uniforms defines the current uniform list.
  48818. */
  48819. static AddUniforms(uniforms: string[]): void;
  48820. /**
  48821. * Add the required samplers to the current list.
  48822. * @param samplers defines the current sampler list.
  48823. */
  48824. static AddSamplers(samplers: string[]): void;
  48825. /**
  48826. * Add the required uniforms to the current buffer.
  48827. * @param uniformBuffer defines the current uniform buffer.
  48828. */
  48829. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48830. /**
  48831. * Makes a duplicate of the current configuration into another one.
  48832. * @param clearCoatConfiguration define the config where to copy the info
  48833. */
  48834. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48835. /**
  48836. * Serializes this clear coat configuration.
  48837. * @returns - An object with the serialized config.
  48838. */
  48839. serialize(): any;
  48840. /**
  48841. * Parses a anisotropy Configuration from a serialized object.
  48842. * @param source - Serialized object.
  48843. * @param scene Defines the scene we are parsing for
  48844. * @param rootUrl Defines the rootUrl to load from
  48845. */
  48846. parse(source: any, scene: Scene, rootUrl: string): void;
  48847. }
  48848. }
  48849. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48850. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48852. import { Vector2 } from "babylonjs/Maths/math.vector";
  48853. import { Scene } from "babylonjs/scene";
  48854. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48855. import { Nullable } from "babylonjs/types";
  48856. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48857. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48858. /**
  48859. * @hidden
  48860. */
  48861. export interface IMaterialAnisotropicDefines {
  48862. ANISOTROPIC: boolean;
  48863. ANISOTROPIC_TEXTURE: boolean;
  48864. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48865. MAINUV1: boolean;
  48866. _areTexturesDirty: boolean;
  48867. _needUVs: boolean;
  48868. }
  48869. /**
  48870. * Define the code related to the anisotropic parameters of the pbr material.
  48871. */
  48872. export class PBRAnisotropicConfiguration {
  48873. private _isEnabled;
  48874. /**
  48875. * Defines if the anisotropy is enabled in the material.
  48876. */
  48877. isEnabled: boolean;
  48878. /**
  48879. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48880. */
  48881. intensity: number;
  48882. /**
  48883. * Defines if the effect is along the tangents, bitangents or in between.
  48884. * By default, the effect is "strectching" the highlights along the tangents.
  48885. */
  48886. direction: Vector2;
  48887. private _texture;
  48888. /**
  48889. * Stores the anisotropy values in a texture.
  48890. * rg is direction (like normal from -1 to 1)
  48891. * b is a intensity
  48892. */
  48893. texture: Nullable<BaseTexture>;
  48894. /** @hidden */
  48895. private _internalMarkAllSubMeshesAsTexturesDirty;
  48896. /** @hidden */
  48897. _markAllSubMeshesAsTexturesDirty(): void;
  48898. /**
  48899. * Instantiate a new istance of anisotropy configuration.
  48900. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48901. */
  48902. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48903. /**
  48904. * Specifies that the submesh is ready to be used.
  48905. * @param defines the list of "defines" to update.
  48906. * @param scene defines the scene the material belongs to.
  48907. * @returns - boolean indicating that the submesh is ready or not.
  48908. */
  48909. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48910. /**
  48911. * Checks to see if a texture is used in the material.
  48912. * @param defines the list of "defines" to update.
  48913. * @param mesh the mesh we are preparing the defines for.
  48914. * @param scene defines the scene the material belongs to.
  48915. */
  48916. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48917. /**
  48918. * Binds the material data.
  48919. * @param uniformBuffer defines the Uniform buffer to fill in.
  48920. * @param scene defines the scene the material belongs to.
  48921. * @param isFrozen defines wether the material is frozen or not.
  48922. */
  48923. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48924. /**
  48925. * Checks to see if a texture is used in the material.
  48926. * @param texture - Base texture to use.
  48927. * @returns - Boolean specifying if a texture is used in the material.
  48928. */
  48929. hasTexture(texture: BaseTexture): boolean;
  48930. /**
  48931. * Returns an array of the actively used textures.
  48932. * @param activeTextures Array of BaseTextures
  48933. */
  48934. getActiveTextures(activeTextures: BaseTexture[]): void;
  48935. /**
  48936. * Returns the animatable textures.
  48937. * @param animatables Array of animatable textures.
  48938. */
  48939. getAnimatables(animatables: IAnimatable[]): void;
  48940. /**
  48941. * Disposes the resources of the material.
  48942. * @param forceDisposeTextures - Forces the disposal of all textures.
  48943. */
  48944. dispose(forceDisposeTextures?: boolean): void;
  48945. /**
  48946. * Get the current class name of the texture useful for serialization or dynamic coding.
  48947. * @returns "PBRAnisotropicConfiguration"
  48948. */
  48949. getClassName(): string;
  48950. /**
  48951. * Add fallbacks to the effect fallbacks list.
  48952. * @param defines defines the Base texture to use.
  48953. * @param fallbacks defines the current fallback list.
  48954. * @param currentRank defines the current fallback rank.
  48955. * @returns the new fallback rank.
  48956. */
  48957. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48958. /**
  48959. * Add the required uniforms to the current list.
  48960. * @param uniforms defines the current uniform list.
  48961. */
  48962. static AddUniforms(uniforms: string[]): void;
  48963. /**
  48964. * Add the required uniforms to the current buffer.
  48965. * @param uniformBuffer defines the current uniform buffer.
  48966. */
  48967. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48968. /**
  48969. * Add the required samplers to the current list.
  48970. * @param samplers defines the current sampler list.
  48971. */
  48972. static AddSamplers(samplers: string[]): void;
  48973. /**
  48974. * Makes a duplicate of the current configuration into another one.
  48975. * @param anisotropicConfiguration define the config where to copy the info
  48976. */
  48977. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48978. /**
  48979. * Serializes this anisotropy configuration.
  48980. * @returns - An object with the serialized config.
  48981. */
  48982. serialize(): any;
  48983. /**
  48984. * Parses a anisotropy Configuration from a serialized object.
  48985. * @param source - Serialized object.
  48986. * @param scene Defines the scene we are parsing for
  48987. * @param rootUrl Defines the rootUrl to load from
  48988. */
  48989. parse(source: any, scene: Scene, rootUrl: string): void;
  48990. }
  48991. }
  48992. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48993. import { Scene } from "babylonjs/scene";
  48994. /**
  48995. * @hidden
  48996. */
  48997. export interface IMaterialBRDFDefines {
  48998. BRDF_V_HEIGHT_CORRELATED: boolean;
  48999. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49000. SPHERICAL_HARMONICS: boolean;
  49001. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49002. /** @hidden */
  49003. _areMiscDirty: boolean;
  49004. }
  49005. /**
  49006. * Define the code related to the BRDF parameters of the pbr material.
  49007. */
  49008. export class PBRBRDFConfiguration {
  49009. /**
  49010. * Default value used for the energy conservation.
  49011. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49012. */
  49013. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49014. /**
  49015. * Default value used for the Smith Visibility Height Correlated mode.
  49016. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49017. */
  49018. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49019. /**
  49020. * Default value used for the IBL diffuse part.
  49021. * This can help switching back to the polynomials mode globally which is a tiny bit
  49022. * less GPU intensive at the drawback of a lower quality.
  49023. */
  49024. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49025. /**
  49026. * Default value used for activating energy conservation for the specular workflow.
  49027. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49028. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49029. */
  49030. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49031. private _useEnergyConservation;
  49032. /**
  49033. * Defines if the material uses energy conservation.
  49034. */
  49035. useEnergyConservation: boolean;
  49036. private _useSmithVisibilityHeightCorrelated;
  49037. /**
  49038. * LEGACY Mode set to false
  49039. * Defines if the material uses height smith correlated visibility term.
  49040. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49041. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49042. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49043. * Not relying on height correlated will also disable energy conservation.
  49044. */
  49045. useSmithVisibilityHeightCorrelated: boolean;
  49046. private _useSphericalHarmonics;
  49047. /**
  49048. * LEGACY Mode set to false
  49049. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49050. * diffuse part of the IBL.
  49051. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49052. * to the ground truth.
  49053. */
  49054. useSphericalHarmonics: boolean;
  49055. private _useSpecularGlossinessInputEnergyConservation;
  49056. /**
  49057. * Defines if the material uses energy conservation, when the specular workflow is active.
  49058. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49059. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49060. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49061. */
  49062. useSpecularGlossinessInputEnergyConservation: boolean;
  49063. /** @hidden */
  49064. private _internalMarkAllSubMeshesAsMiscDirty;
  49065. /** @hidden */
  49066. _markAllSubMeshesAsMiscDirty(): void;
  49067. /**
  49068. * Instantiate a new istance of clear coat configuration.
  49069. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49070. */
  49071. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49072. /**
  49073. * Checks to see if a texture is used in the material.
  49074. * @param defines the list of "defines" to update.
  49075. */
  49076. prepareDefines(defines: IMaterialBRDFDefines): void;
  49077. /**
  49078. * Get the current class name of the texture useful for serialization or dynamic coding.
  49079. * @returns "PBRClearCoatConfiguration"
  49080. */
  49081. getClassName(): string;
  49082. /**
  49083. * Makes a duplicate of the current configuration into another one.
  49084. * @param brdfConfiguration define the config where to copy the info
  49085. */
  49086. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49087. /**
  49088. * Serializes this BRDF configuration.
  49089. * @returns - An object with the serialized config.
  49090. */
  49091. serialize(): any;
  49092. /**
  49093. * Parses a anisotropy Configuration from a serialized object.
  49094. * @param source - Serialized object.
  49095. * @param scene Defines the scene we are parsing for
  49096. * @param rootUrl Defines the rootUrl to load from
  49097. */
  49098. parse(source: any, scene: Scene, rootUrl: string): void;
  49099. }
  49100. }
  49101. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49102. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49103. import { Color3 } from "babylonjs/Maths/math.color";
  49104. import { Scene } from "babylonjs/scene";
  49105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49106. import { Nullable } from "babylonjs/types";
  49107. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49108. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49109. /**
  49110. * @hidden
  49111. */
  49112. export interface IMaterialSheenDefines {
  49113. SHEEN: boolean;
  49114. SHEEN_TEXTURE: boolean;
  49115. SHEEN_TEXTUREDIRECTUV: number;
  49116. SHEEN_LINKWITHALBEDO: boolean;
  49117. /** @hidden */
  49118. _areTexturesDirty: boolean;
  49119. }
  49120. /**
  49121. * Define the code related to the Sheen parameters of the pbr material.
  49122. */
  49123. export class PBRSheenConfiguration {
  49124. private _isEnabled;
  49125. /**
  49126. * Defines if the material uses sheen.
  49127. */
  49128. isEnabled: boolean;
  49129. private _linkSheenWithAlbedo;
  49130. /**
  49131. * Defines if the sheen is linked to the sheen color.
  49132. */
  49133. linkSheenWithAlbedo: boolean;
  49134. /**
  49135. * Defines the sheen intensity.
  49136. */
  49137. intensity: number;
  49138. /**
  49139. * Defines the sheen color.
  49140. */
  49141. color: Color3;
  49142. private _texture;
  49143. /**
  49144. * Stores the sheen tint values in a texture.
  49145. * rgb is tint
  49146. * a is a intensity
  49147. */
  49148. texture: Nullable<BaseTexture>;
  49149. /** @hidden */
  49150. private _internalMarkAllSubMeshesAsTexturesDirty;
  49151. /** @hidden */
  49152. _markAllSubMeshesAsTexturesDirty(): void;
  49153. /**
  49154. * Instantiate a new istance of clear coat configuration.
  49155. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49156. */
  49157. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49158. /**
  49159. * Specifies that the submesh is ready to be used.
  49160. * @param defines the list of "defines" to update.
  49161. * @param scene defines the scene the material belongs to.
  49162. * @returns - boolean indicating that the submesh is ready or not.
  49163. */
  49164. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49165. /**
  49166. * Checks to see if a texture is used in the material.
  49167. * @param defines the list of "defines" to update.
  49168. * @param scene defines the scene the material belongs to.
  49169. */
  49170. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49171. /**
  49172. * Binds the material data.
  49173. * @param uniformBuffer defines the Uniform buffer to fill in.
  49174. * @param scene defines the scene the material belongs to.
  49175. * @param isFrozen defines wether the material is frozen or not.
  49176. */
  49177. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49178. /**
  49179. * Checks to see if a texture is used in the material.
  49180. * @param texture - Base texture to use.
  49181. * @returns - Boolean specifying if a texture is used in the material.
  49182. */
  49183. hasTexture(texture: BaseTexture): boolean;
  49184. /**
  49185. * Returns an array of the actively used textures.
  49186. * @param activeTextures Array of BaseTextures
  49187. */
  49188. getActiveTextures(activeTextures: BaseTexture[]): void;
  49189. /**
  49190. * Returns the animatable textures.
  49191. * @param animatables Array of animatable textures.
  49192. */
  49193. getAnimatables(animatables: IAnimatable[]): void;
  49194. /**
  49195. * Disposes the resources of the material.
  49196. * @param forceDisposeTextures - Forces the disposal of all textures.
  49197. */
  49198. dispose(forceDisposeTextures?: boolean): void;
  49199. /**
  49200. * Get the current class name of the texture useful for serialization or dynamic coding.
  49201. * @returns "PBRSheenConfiguration"
  49202. */
  49203. getClassName(): string;
  49204. /**
  49205. * Add fallbacks to the effect fallbacks list.
  49206. * @param defines defines the Base texture to use.
  49207. * @param fallbacks defines the current fallback list.
  49208. * @param currentRank defines the current fallback rank.
  49209. * @returns the new fallback rank.
  49210. */
  49211. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49212. /**
  49213. * Add the required uniforms to the current list.
  49214. * @param uniforms defines the current uniform list.
  49215. */
  49216. static AddUniforms(uniforms: string[]): void;
  49217. /**
  49218. * Add the required uniforms to the current buffer.
  49219. * @param uniformBuffer defines the current uniform buffer.
  49220. */
  49221. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49222. /**
  49223. * Add the required samplers to the current list.
  49224. * @param samplers defines the current sampler list.
  49225. */
  49226. static AddSamplers(samplers: string[]): void;
  49227. /**
  49228. * Makes a duplicate of the current configuration into another one.
  49229. * @param sheenConfiguration define the config where to copy the info
  49230. */
  49231. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49232. /**
  49233. * Serializes this BRDF configuration.
  49234. * @returns - An object with the serialized config.
  49235. */
  49236. serialize(): any;
  49237. /**
  49238. * Parses a anisotropy Configuration from a serialized object.
  49239. * @param source - Serialized object.
  49240. * @param scene Defines the scene we are parsing for
  49241. * @param rootUrl Defines the rootUrl to load from
  49242. */
  49243. parse(source: any, scene: Scene, rootUrl: string): void;
  49244. }
  49245. }
  49246. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49247. import { Nullable } from "babylonjs/types";
  49248. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49249. import { Color3 } from "babylonjs/Maths/math.color";
  49250. import { SmartArray } from "babylonjs/Misc/smartArray";
  49251. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49252. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49253. import { Effect } from "babylonjs/Materials/effect";
  49254. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49255. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49256. import { Engine } from "babylonjs/Engines/engine";
  49257. import { Scene } from "babylonjs/scene";
  49258. /**
  49259. * @hidden
  49260. */
  49261. export interface IMaterialSubSurfaceDefines {
  49262. SUBSURFACE: boolean;
  49263. SS_REFRACTION: boolean;
  49264. SS_TRANSLUCENCY: boolean;
  49265. SS_SCATERRING: boolean;
  49266. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49267. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49268. SS_REFRACTIONMAP_3D: boolean;
  49269. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49270. SS_LODINREFRACTIONALPHA: boolean;
  49271. SS_GAMMAREFRACTION: boolean;
  49272. SS_RGBDREFRACTION: boolean;
  49273. SS_LINEARSPECULARREFRACTION: boolean;
  49274. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49275. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49276. /** @hidden */
  49277. _areTexturesDirty: boolean;
  49278. }
  49279. /**
  49280. * Define the code related to the sub surface parameters of the pbr material.
  49281. */
  49282. export class PBRSubSurfaceConfiguration {
  49283. private _isRefractionEnabled;
  49284. /**
  49285. * Defines if the refraction is enabled in the material.
  49286. */
  49287. isRefractionEnabled: boolean;
  49288. private _isTranslucencyEnabled;
  49289. /**
  49290. * Defines if the translucency is enabled in the material.
  49291. */
  49292. isTranslucencyEnabled: boolean;
  49293. private _isScatteringEnabled;
  49294. /**
  49295. * Defines the refraction intensity of the material.
  49296. * The refraction when enabled replaces the Diffuse part of the material.
  49297. * The intensity helps transitionning between diffuse and refraction.
  49298. */
  49299. refractionIntensity: number;
  49300. /**
  49301. * Defines the translucency intensity of the material.
  49302. * When translucency has been enabled, this defines how much of the "translucency"
  49303. * is addded to the diffuse part of the material.
  49304. */
  49305. translucencyIntensity: number;
  49306. /**
  49307. * Defines the scattering intensity of the material.
  49308. * When scattering has been enabled, this defines how much of the "scattered light"
  49309. * is addded to the diffuse part of the material.
  49310. */
  49311. scatteringIntensity: number;
  49312. private _thicknessTexture;
  49313. /**
  49314. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49315. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49316. * 0 would mean minimumThickness
  49317. * 1 would mean maximumThickness
  49318. * The other channels might be use as a mask to vary the different effects intensity.
  49319. */
  49320. thicknessTexture: Nullable<BaseTexture>;
  49321. private _refractionTexture;
  49322. /**
  49323. * Defines the texture to use for refraction.
  49324. */
  49325. refractionTexture: Nullable<BaseTexture>;
  49326. private _indexOfRefraction;
  49327. /**
  49328. * Defines the index of refraction used in the material.
  49329. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49330. */
  49331. indexOfRefraction: number;
  49332. private _invertRefractionY;
  49333. /**
  49334. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49335. */
  49336. invertRefractionY: boolean;
  49337. private _linkRefractionWithTransparency;
  49338. /**
  49339. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49340. * Materials half opaque for instance using refraction could benefit from this control.
  49341. */
  49342. linkRefractionWithTransparency: boolean;
  49343. /**
  49344. * Defines the minimum thickness stored in the thickness map.
  49345. * If no thickness map is defined, this value will be used to simulate thickness.
  49346. */
  49347. minimumThickness: number;
  49348. /**
  49349. * Defines the maximum thickness stored in the thickness map.
  49350. */
  49351. maximumThickness: number;
  49352. /**
  49353. * Defines the volume tint of the material.
  49354. * This is used for both translucency and scattering.
  49355. */
  49356. tintColor: Color3;
  49357. /**
  49358. * Defines the distance at which the tint color should be found in the media.
  49359. * This is used for refraction only.
  49360. */
  49361. tintColorAtDistance: number;
  49362. /**
  49363. * Defines how far each channel transmit through the media.
  49364. * It is defined as a color to simplify it selection.
  49365. */
  49366. diffusionDistance: Color3;
  49367. private _useMaskFromThicknessTexture;
  49368. /**
  49369. * Stores the intensity of the different subsurface effects in the thickness texture.
  49370. * * the green channel is the translucency intensity.
  49371. * * the blue channel is the scattering intensity.
  49372. * * the alpha channel is the refraction intensity.
  49373. */
  49374. useMaskFromThicknessTexture: boolean;
  49375. /** @hidden */
  49376. private _internalMarkAllSubMeshesAsTexturesDirty;
  49377. /** @hidden */
  49378. _markAllSubMeshesAsTexturesDirty(): void;
  49379. /**
  49380. * Instantiate a new istance of sub surface configuration.
  49381. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49382. */
  49383. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49384. /**
  49385. * Gets wehter the submesh is ready to be used or not.
  49386. * @param defines the list of "defines" to update.
  49387. * @param scene defines the scene the material belongs to.
  49388. * @returns - boolean indicating that the submesh is ready or not.
  49389. */
  49390. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49391. /**
  49392. * Checks to see if a texture is used in the material.
  49393. * @param defines the list of "defines" to update.
  49394. * @param scene defines the scene to the material belongs to.
  49395. */
  49396. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49397. /**
  49398. * Binds the material data.
  49399. * @param uniformBuffer defines the Uniform buffer to fill in.
  49400. * @param scene defines the scene the material belongs to.
  49401. * @param engine defines the engine the material belongs to.
  49402. * @param isFrozen defines wether the material is frozen or not.
  49403. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49404. */
  49405. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49406. /**
  49407. * Unbinds the material from the mesh.
  49408. * @param activeEffect defines the effect that should be unbound from.
  49409. * @returns true if unbound, otherwise false
  49410. */
  49411. unbind(activeEffect: Effect): boolean;
  49412. /**
  49413. * Returns the texture used for refraction or null if none is used.
  49414. * @param scene defines the scene the material belongs to.
  49415. * @returns - Refraction texture if present. If no refraction texture and refraction
  49416. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49417. */
  49418. private _getRefractionTexture;
  49419. /**
  49420. * Returns true if alpha blending should be disabled.
  49421. */
  49422. readonly disableAlphaBlending: boolean;
  49423. /**
  49424. * Fills the list of render target textures.
  49425. * @param renderTargets the list of render targets to update
  49426. */
  49427. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49428. /**
  49429. * Checks to see if a texture is used in the material.
  49430. * @param texture - Base texture to use.
  49431. * @returns - Boolean specifying if a texture is used in the material.
  49432. */
  49433. hasTexture(texture: BaseTexture): boolean;
  49434. /**
  49435. * Gets a boolean indicating that current material needs to register RTT
  49436. * @returns true if this uses a render target otherwise false.
  49437. */
  49438. hasRenderTargetTextures(): boolean;
  49439. /**
  49440. * Returns an array of the actively used textures.
  49441. * @param activeTextures Array of BaseTextures
  49442. */
  49443. getActiveTextures(activeTextures: BaseTexture[]): void;
  49444. /**
  49445. * Returns the animatable textures.
  49446. * @param animatables Array of animatable textures.
  49447. */
  49448. getAnimatables(animatables: IAnimatable[]): void;
  49449. /**
  49450. * Disposes the resources of the material.
  49451. * @param forceDisposeTextures - Forces the disposal of all textures.
  49452. */
  49453. dispose(forceDisposeTextures?: boolean): void;
  49454. /**
  49455. * Get the current class name of the texture useful for serialization or dynamic coding.
  49456. * @returns "PBRSubSurfaceConfiguration"
  49457. */
  49458. getClassName(): string;
  49459. /**
  49460. * Add fallbacks to the effect fallbacks list.
  49461. * @param defines defines the Base texture to use.
  49462. * @param fallbacks defines the current fallback list.
  49463. * @param currentRank defines the current fallback rank.
  49464. * @returns the new fallback rank.
  49465. */
  49466. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49467. /**
  49468. * Add the required uniforms to the current list.
  49469. * @param uniforms defines the current uniform list.
  49470. */
  49471. static AddUniforms(uniforms: string[]): void;
  49472. /**
  49473. * Add the required samplers to the current list.
  49474. * @param samplers defines the current sampler list.
  49475. */
  49476. static AddSamplers(samplers: string[]): void;
  49477. /**
  49478. * Add the required uniforms to the current buffer.
  49479. * @param uniformBuffer defines the current uniform buffer.
  49480. */
  49481. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49482. /**
  49483. * Makes a duplicate of the current configuration into another one.
  49484. * @param configuration define the config where to copy the info
  49485. */
  49486. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49487. /**
  49488. * Serializes this Sub Surface configuration.
  49489. * @returns - An object with the serialized config.
  49490. */
  49491. serialize(): any;
  49492. /**
  49493. * Parses a anisotropy Configuration from a serialized object.
  49494. * @param source - Serialized object.
  49495. * @param scene Defines the scene we are parsing for
  49496. * @param rootUrl Defines the rootUrl to load from
  49497. */
  49498. parse(source: any, scene: Scene, rootUrl: string): void;
  49499. }
  49500. }
  49501. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49502. /** @hidden */
  49503. export var pbrFragmentDeclaration: {
  49504. name: string;
  49505. shader: string;
  49506. };
  49507. }
  49508. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49509. /** @hidden */
  49510. export var pbrUboDeclaration: {
  49511. name: string;
  49512. shader: string;
  49513. };
  49514. }
  49515. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49516. /** @hidden */
  49517. export var pbrFragmentExtraDeclaration: {
  49518. name: string;
  49519. shader: string;
  49520. };
  49521. }
  49522. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49523. /** @hidden */
  49524. export var pbrFragmentSamplersDeclaration: {
  49525. name: string;
  49526. shader: string;
  49527. };
  49528. }
  49529. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49530. /** @hidden */
  49531. export var pbrHelperFunctions: {
  49532. name: string;
  49533. shader: string;
  49534. };
  49535. }
  49536. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49537. /** @hidden */
  49538. export var harmonicsFunctions: {
  49539. name: string;
  49540. shader: string;
  49541. };
  49542. }
  49543. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49544. /** @hidden */
  49545. export var pbrDirectLightingSetupFunctions: {
  49546. name: string;
  49547. shader: string;
  49548. };
  49549. }
  49550. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49551. /** @hidden */
  49552. export var pbrDirectLightingFalloffFunctions: {
  49553. name: string;
  49554. shader: string;
  49555. };
  49556. }
  49557. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49558. /** @hidden */
  49559. export var pbrBRDFFunctions: {
  49560. name: string;
  49561. shader: string;
  49562. };
  49563. }
  49564. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49565. /** @hidden */
  49566. export var pbrDirectLightingFunctions: {
  49567. name: string;
  49568. shader: string;
  49569. };
  49570. }
  49571. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49572. /** @hidden */
  49573. export var pbrIBLFunctions: {
  49574. name: string;
  49575. shader: string;
  49576. };
  49577. }
  49578. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49579. /** @hidden */
  49580. export var pbrDebug: {
  49581. name: string;
  49582. shader: string;
  49583. };
  49584. }
  49585. declare module "babylonjs/Shaders/pbr.fragment" {
  49586. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49587. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49588. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49589. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49590. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49591. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49592. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49593. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49594. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49595. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49596. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49597. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49598. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49599. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49600. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49601. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49602. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49603. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49604. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49605. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49606. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49607. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49608. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49609. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49610. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49611. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49612. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49613. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49614. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49615. /** @hidden */
  49616. export var pbrPixelShader: {
  49617. name: string;
  49618. shader: string;
  49619. };
  49620. }
  49621. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49622. /** @hidden */
  49623. export var pbrVertexDeclaration: {
  49624. name: string;
  49625. shader: string;
  49626. };
  49627. }
  49628. declare module "babylonjs/Shaders/pbr.vertex" {
  49629. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49630. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49631. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49632. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49633. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49634. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49635. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49636. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49637. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49638. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49639. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49640. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49641. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49642. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49643. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49644. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49645. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49646. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49647. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49648. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49649. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49650. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49651. /** @hidden */
  49652. export var pbrVertexShader: {
  49653. name: string;
  49654. shader: string;
  49655. };
  49656. }
  49657. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49658. import { Nullable } from "babylonjs/types";
  49659. import { Scene } from "babylonjs/scene";
  49660. import { Matrix } from "babylonjs/Maths/math.vector";
  49661. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49663. import { Mesh } from "babylonjs/Meshes/mesh";
  49664. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49665. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49666. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49667. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49668. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49669. import { Color3 } from "babylonjs/Maths/math.color";
  49670. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49671. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  49672. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49673. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49675. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49676. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49677. import "babylonjs/Shaders/pbr.fragment";
  49678. import "babylonjs/Shaders/pbr.vertex";
  49679. /**
  49680. * Manages the defines for the PBR Material.
  49681. * @hidden
  49682. */
  49683. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49684. PBR: boolean;
  49685. MAINUV1: boolean;
  49686. MAINUV2: boolean;
  49687. UV1: boolean;
  49688. UV2: boolean;
  49689. ALBEDO: boolean;
  49690. ALBEDODIRECTUV: number;
  49691. VERTEXCOLOR: boolean;
  49692. AMBIENT: boolean;
  49693. AMBIENTDIRECTUV: number;
  49694. AMBIENTINGRAYSCALE: boolean;
  49695. OPACITY: boolean;
  49696. VERTEXALPHA: boolean;
  49697. OPACITYDIRECTUV: number;
  49698. OPACITYRGB: boolean;
  49699. ALPHATEST: boolean;
  49700. DEPTHPREPASS: boolean;
  49701. ALPHABLEND: boolean;
  49702. ALPHAFROMALBEDO: boolean;
  49703. ALPHATESTVALUE: string;
  49704. SPECULAROVERALPHA: boolean;
  49705. RADIANCEOVERALPHA: boolean;
  49706. ALPHAFRESNEL: boolean;
  49707. LINEARALPHAFRESNEL: boolean;
  49708. PREMULTIPLYALPHA: boolean;
  49709. EMISSIVE: boolean;
  49710. EMISSIVEDIRECTUV: number;
  49711. REFLECTIVITY: boolean;
  49712. REFLECTIVITYDIRECTUV: number;
  49713. SPECULARTERM: boolean;
  49714. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49715. MICROSURFACEAUTOMATIC: boolean;
  49716. LODBASEDMICROSFURACE: boolean;
  49717. MICROSURFACEMAP: boolean;
  49718. MICROSURFACEMAPDIRECTUV: number;
  49719. METALLICWORKFLOW: boolean;
  49720. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49721. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49722. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49723. AOSTOREINMETALMAPRED: boolean;
  49724. ENVIRONMENTBRDF: boolean;
  49725. ENVIRONMENTBRDF_RGBD: boolean;
  49726. NORMAL: boolean;
  49727. TANGENT: boolean;
  49728. BUMP: boolean;
  49729. BUMPDIRECTUV: number;
  49730. OBJECTSPACE_NORMALMAP: boolean;
  49731. PARALLAX: boolean;
  49732. PARALLAXOCCLUSION: boolean;
  49733. NORMALXYSCALE: boolean;
  49734. LIGHTMAP: boolean;
  49735. LIGHTMAPDIRECTUV: number;
  49736. USELIGHTMAPASSHADOWMAP: boolean;
  49737. GAMMALIGHTMAP: boolean;
  49738. RGBDLIGHTMAP: boolean;
  49739. REFLECTION: boolean;
  49740. REFLECTIONMAP_3D: boolean;
  49741. REFLECTIONMAP_SPHERICAL: boolean;
  49742. REFLECTIONMAP_PLANAR: boolean;
  49743. REFLECTIONMAP_CUBIC: boolean;
  49744. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49745. REFLECTIONMAP_PROJECTION: boolean;
  49746. REFLECTIONMAP_SKYBOX: boolean;
  49747. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49748. REFLECTIONMAP_EXPLICIT: boolean;
  49749. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49750. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49751. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49752. INVERTCUBICMAP: boolean;
  49753. USESPHERICALFROMREFLECTIONMAP: boolean;
  49754. USEIRRADIANCEMAP: boolean;
  49755. SPHERICAL_HARMONICS: boolean;
  49756. USESPHERICALINVERTEX: boolean;
  49757. REFLECTIONMAP_OPPOSITEZ: boolean;
  49758. LODINREFLECTIONALPHA: boolean;
  49759. GAMMAREFLECTION: boolean;
  49760. RGBDREFLECTION: boolean;
  49761. LINEARSPECULARREFLECTION: boolean;
  49762. RADIANCEOCCLUSION: boolean;
  49763. HORIZONOCCLUSION: boolean;
  49764. INSTANCES: boolean;
  49765. NUM_BONE_INFLUENCERS: number;
  49766. BonesPerMesh: number;
  49767. BONETEXTURE: boolean;
  49768. NONUNIFORMSCALING: boolean;
  49769. MORPHTARGETS: boolean;
  49770. MORPHTARGETS_NORMAL: boolean;
  49771. MORPHTARGETS_TANGENT: boolean;
  49772. MORPHTARGETS_UV: boolean;
  49773. NUM_MORPH_INFLUENCERS: number;
  49774. IMAGEPROCESSING: boolean;
  49775. VIGNETTE: boolean;
  49776. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49777. VIGNETTEBLENDMODEOPAQUE: boolean;
  49778. TONEMAPPING: boolean;
  49779. TONEMAPPING_ACES: boolean;
  49780. CONTRAST: boolean;
  49781. COLORCURVES: boolean;
  49782. COLORGRADING: boolean;
  49783. COLORGRADING3D: boolean;
  49784. SAMPLER3DGREENDEPTH: boolean;
  49785. SAMPLER3DBGRMAP: boolean;
  49786. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49787. EXPOSURE: boolean;
  49788. MULTIVIEW: boolean;
  49789. USEPHYSICALLIGHTFALLOFF: boolean;
  49790. USEGLTFLIGHTFALLOFF: boolean;
  49791. TWOSIDEDLIGHTING: boolean;
  49792. SHADOWFLOAT: boolean;
  49793. CLIPPLANE: boolean;
  49794. CLIPPLANE2: boolean;
  49795. CLIPPLANE3: boolean;
  49796. CLIPPLANE4: boolean;
  49797. POINTSIZE: boolean;
  49798. FOG: boolean;
  49799. LOGARITHMICDEPTH: boolean;
  49800. FORCENORMALFORWARD: boolean;
  49801. SPECULARAA: boolean;
  49802. CLEARCOAT: boolean;
  49803. CLEARCOAT_DEFAULTIOR: boolean;
  49804. CLEARCOAT_TEXTURE: boolean;
  49805. CLEARCOAT_TEXTUREDIRECTUV: number;
  49806. CLEARCOAT_BUMP: boolean;
  49807. CLEARCOAT_BUMPDIRECTUV: number;
  49808. CLEARCOAT_TINT: boolean;
  49809. CLEARCOAT_TINT_TEXTURE: boolean;
  49810. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49811. ANISOTROPIC: boolean;
  49812. ANISOTROPIC_TEXTURE: boolean;
  49813. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49814. BRDF_V_HEIGHT_CORRELATED: boolean;
  49815. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49816. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49817. SHEEN: boolean;
  49818. SHEEN_TEXTURE: boolean;
  49819. SHEEN_TEXTUREDIRECTUV: number;
  49820. SHEEN_LINKWITHALBEDO: boolean;
  49821. SUBSURFACE: boolean;
  49822. SS_REFRACTION: boolean;
  49823. SS_TRANSLUCENCY: boolean;
  49824. SS_SCATERRING: boolean;
  49825. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49826. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49827. SS_REFRACTIONMAP_3D: boolean;
  49828. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49829. SS_LODINREFRACTIONALPHA: boolean;
  49830. SS_GAMMAREFRACTION: boolean;
  49831. SS_RGBDREFRACTION: boolean;
  49832. SS_LINEARSPECULARREFRACTION: boolean;
  49833. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49834. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49835. UNLIT: boolean;
  49836. DEBUGMODE: number;
  49837. /**
  49838. * Initializes the PBR Material defines.
  49839. */
  49840. constructor();
  49841. /**
  49842. * Resets the PBR Material defines.
  49843. */
  49844. reset(): void;
  49845. }
  49846. /**
  49847. * The Physically based material base class of BJS.
  49848. *
  49849. * This offers the main features of a standard PBR material.
  49850. * For more information, please refer to the documentation :
  49851. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49852. */
  49853. export abstract class PBRBaseMaterial extends PushMaterial {
  49854. /**
  49855. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49856. */
  49857. static readonly PBRMATERIAL_OPAQUE: number;
  49858. /**
  49859. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49860. */
  49861. static readonly PBRMATERIAL_ALPHATEST: number;
  49862. /**
  49863. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49864. */
  49865. static readonly PBRMATERIAL_ALPHABLEND: number;
  49866. /**
  49867. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49868. * They are also discarded below the alpha cutoff threshold to improve performances.
  49869. */
  49870. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49871. /**
  49872. * Defines the default value of how much AO map is occluding the analytical lights
  49873. * (point spot...).
  49874. */
  49875. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49876. /**
  49877. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49878. */
  49879. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49880. /**
  49881. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49882. * to enhance interoperability with other engines.
  49883. */
  49884. static readonly LIGHTFALLOFF_GLTF: number;
  49885. /**
  49886. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49887. * to enhance interoperability with other materials.
  49888. */
  49889. static readonly LIGHTFALLOFF_STANDARD: number;
  49890. /**
  49891. * Intensity of the direct lights e.g. the four lights available in your scene.
  49892. * This impacts both the direct diffuse and specular highlights.
  49893. */
  49894. protected _directIntensity: number;
  49895. /**
  49896. * Intensity of the emissive part of the material.
  49897. * This helps controlling the emissive effect without modifying the emissive color.
  49898. */
  49899. protected _emissiveIntensity: number;
  49900. /**
  49901. * Intensity of the environment e.g. how much the environment will light the object
  49902. * either through harmonics for rough material or through the refelction for shiny ones.
  49903. */
  49904. protected _environmentIntensity: number;
  49905. /**
  49906. * This is a special control allowing the reduction of the specular highlights coming from the
  49907. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49908. */
  49909. protected _specularIntensity: number;
  49910. /**
  49911. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49912. */
  49913. private _lightingInfos;
  49914. /**
  49915. * Debug Control allowing disabling the bump map on this material.
  49916. */
  49917. protected _disableBumpMap: boolean;
  49918. /**
  49919. * AKA Diffuse Texture in standard nomenclature.
  49920. */
  49921. protected _albedoTexture: Nullable<BaseTexture>;
  49922. /**
  49923. * AKA Occlusion Texture in other nomenclature.
  49924. */
  49925. protected _ambientTexture: Nullable<BaseTexture>;
  49926. /**
  49927. * AKA Occlusion Texture Intensity in other nomenclature.
  49928. */
  49929. protected _ambientTextureStrength: number;
  49930. /**
  49931. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49932. * 1 means it completely occludes it
  49933. * 0 mean it has no impact
  49934. */
  49935. protected _ambientTextureImpactOnAnalyticalLights: number;
  49936. /**
  49937. * Stores the alpha values in a texture.
  49938. */
  49939. protected _opacityTexture: Nullable<BaseTexture>;
  49940. /**
  49941. * Stores the reflection values in a texture.
  49942. */
  49943. protected _reflectionTexture: Nullable<BaseTexture>;
  49944. /**
  49945. * Stores the emissive values in a texture.
  49946. */
  49947. protected _emissiveTexture: Nullable<BaseTexture>;
  49948. /**
  49949. * AKA Specular texture in other nomenclature.
  49950. */
  49951. protected _reflectivityTexture: Nullable<BaseTexture>;
  49952. /**
  49953. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49954. */
  49955. protected _metallicTexture: Nullable<BaseTexture>;
  49956. /**
  49957. * Specifies the metallic scalar of the metallic/roughness workflow.
  49958. * Can also be used to scale the metalness values of the metallic texture.
  49959. */
  49960. protected _metallic: Nullable<number>;
  49961. /**
  49962. * Specifies the roughness scalar of the metallic/roughness workflow.
  49963. * Can also be used to scale the roughness values of the metallic texture.
  49964. */
  49965. protected _roughness: Nullable<number>;
  49966. /**
  49967. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49968. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49969. */
  49970. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49971. /**
  49972. * Stores surface normal data used to displace a mesh in a texture.
  49973. */
  49974. protected _bumpTexture: Nullable<BaseTexture>;
  49975. /**
  49976. * Stores the pre-calculated light information of a mesh in a texture.
  49977. */
  49978. protected _lightmapTexture: Nullable<BaseTexture>;
  49979. /**
  49980. * The color of a material in ambient lighting.
  49981. */
  49982. protected _ambientColor: Color3;
  49983. /**
  49984. * AKA Diffuse Color in other nomenclature.
  49985. */
  49986. protected _albedoColor: Color3;
  49987. /**
  49988. * AKA Specular Color in other nomenclature.
  49989. */
  49990. protected _reflectivityColor: Color3;
  49991. /**
  49992. * The color applied when light is reflected from a material.
  49993. */
  49994. protected _reflectionColor: Color3;
  49995. /**
  49996. * The color applied when light is emitted from a material.
  49997. */
  49998. protected _emissiveColor: Color3;
  49999. /**
  50000. * AKA Glossiness in other nomenclature.
  50001. */
  50002. protected _microSurface: number;
  50003. /**
  50004. * Specifies that the material will use the light map as a show map.
  50005. */
  50006. protected _useLightmapAsShadowmap: boolean;
  50007. /**
  50008. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50009. * makes the reflect vector face the model (under horizon).
  50010. */
  50011. protected _useHorizonOcclusion: boolean;
  50012. /**
  50013. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50014. * too much the area relying on ambient texture to define their ambient occlusion.
  50015. */
  50016. protected _useRadianceOcclusion: boolean;
  50017. /**
  50018. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50019. */
  50020. protected _useAlphaFromAlbedoTexture: boolean;
  50021. /**
  50022. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50023. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50024. */
  50025. protected _useSpecularOverAlpha: boolean;
  50026. /**
  50027. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50028. */
  50029. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50030. /**
  50031. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50032. */
  50033. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50034. /**
  50035. * Specifies if the metallic texture contains the roughness information in its green channel.
  50036. */
  50037. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50038. /**
  50039. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50040. */
  50041. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50042. /**
  50043. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50044. */
  50045. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50046. /**
  50047. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50048. */
  50049. protected _useAmbientInGrayScale: boolean;
  50050. /**
  50051. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50052. * The material will try to infer what glossiness each pixel should be.
  50053. */
  50054. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50055. /**
  50056. * Defines the falloff type used in this material.
  50057. * It by default is Physical.
  50058. */
  50059. protected _lightFalloff: number;
  50060. /**
  50061. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50062. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50063. */
  50064. protected _useRadianceOverAlpha: boolean;
  50065. /**
  50066. * Allows using an object space normal map (instead of tangent space).
  50067. */
  50068. protected _useObjectSpaceNormalMap: boolean;
  50069. /**
  50070. * Allows using the bump map in parallax mode.
  50071. */
  50072. protected _useParallax: boolean;
  50073. /**
  50074. * Allows using the bump map in parallax occlusion mode.
  50075. */
  50076. protected _useParallaxOcclusion: boolean;
  50077. /**
  50078. * Controls the scale bias of the parallax mode.
  50079. */
  50080. protected _parallaxScaleBias: number;
  50081. /**
  50082. * If sets to true, disables all the lights affecting the material.
  50083. */
  50084. protected _disableLighting: boolean;
  50085. /**
  50086. * Number of Simultaneous lights allowed on the material.
  50087. */
  50088. protected _maxSimultaneousLights: number;
  50089. /**
  50090. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50091. */
  50092. protected _invertNormalMapX: boolean;
  50093. /**
  50094. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50095. */
  50096. protected _invertNormalMapY: boolean;
  50097. /**
  50098. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50099. */
  50100. protected _twoSidedLighting: boolean;
  50101. /**
  50102. * Defines the alpha limits in alpha test mode.
  50103. */
  50104. protected _alphaCutOff: number;
  50105. /**
  50106. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50107. */
  50108. protected _forceAlphaTest: boolean;
  50109. /**
  50110. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50111. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50112. */
  50113. protected _useAlphaFresnel: boolean;
  50114. /**
  50115. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50116. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50117. */
  50118. protected _useLinearAlphaFresnel: boolean;
  50119. /**
  50120. * The transparency mode of the material.
  50121. */
  50122. protected _transparencyMode: Nullable<number>;
  50123. /**
  50124. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50125. * from cos thetav and roughness:
  50126. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50127. */
  50128. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50129. /**
  50130. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50131. */
  50132. protected _forceIrradianceInFragment: boolean;
  50133. /**
  50134. * Force normal to face away from face.
  50135. */
  50136. protected _forceNormalForward: boolean;
  50137. /**
  50138. * Enables specular anti aliasing in the PBR shader.
  50139. * It will both interacts on the Geometry for analytical and IBL lighting.
  50140. * It also prefilter the roughness map based on the bump values.
  50141. */
  50142. protected _enableSpecularAntiAliasing: boolean;
  50143. /**
  50144. * Default configuration related to image processing available in the PBR Material.
  50145. */
  50146. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50147. /**
  50148. * Keep track of the image processing observer to allow dispose and replace.
  50149. */
  50150. private _imageProcessingObserver;
  50151. /**
  50152. * Attaches a new image processing configuration to the PBR Material.
  50153. * @param configuration
  50154. */
  50155. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50156. /**
  50157. * Stores the available render targets.
  50158. */
  50159. private _renderTargets;
  50160. /**
  50161. * Sets the global ambient color for the material used in lighting calculations.
  50162. */
  50163. private _globalAmbientColor;
  50164. /**
  50165. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50166. */
  50167. private _useLogarithmicDepth;
  50168. /**
  50169. * If set to true, no lighting calculations will be applied.
  50170. */
  50171. private _unlit;
  50172. private _debugMode;
  50173. /**
  50174. * @hidden
  50175. * This is reserved for the inspector.
  50176. * Defines the material debug mode.
  50177. * It helps seeing only some components of the material while troubleshooting.
  50178. */
  50179. debugMode: number;
  50180. /**
  50181. * @hidden
  50182. * This is reserved for the inspector.
  50183. * Specify from where on screen the debug mode should start.
  50184. * The value goes from -1 (full screen) to 1 (not visible)
  50185. * It helps with side by side comparison against the final render
  50186. * This defaults to -1
  50187. */
  50188. private debugLimit;
  50189. /**
  50190. * @hidden
  50191. * This is reserved for the inspector.
  50192. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50193. * You can use the factor to better multiply the final value.
  50194. */
  50195. private debugFactor;
  50196. /**
  50197. * Defines the clear coat layer parameters for the material.
  50198. */
  50199. readonly clearCoat: PBRClearCoatConfiguration;
  50200. /**
  50201. * Defines the anisotropic parameters for the material.
  50202. */
  50203. readonly anisotropy: PBRAnisotropicConfiguration;
  50204. /**
  50205. * Defines the BRDF parameters for the material.
  50206. */
  50207. readonly brdf: PBRBRDFConfiguration;
  50208. /**
  50209. * Defines the Sheen parameters for the material.
  50210. */
  50211. readonly sheen: PBRSheenConfiguration;
  50212. /**
  50213. * Defines the SubSurface parameters for the material.
  50214. */
  50215. readonly subSurface: PBRSubSurfaceConfiguration;
  50216. /**
  50217. * Custom callback helping to override the default shader used in the material.
  50218. */
  50219. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50220. protected _rebuildInParallel: boolean;
  50221. /**
  50222. * Instantiates a new PBRMaterial instance.
  50223. *
  50224. * @param name The material name
  50225. * @param scene The scene the material will be use in.
  50226. */
  50227. constructor(name: string, scene: Scene);
  50228. /**
  50229. * Gets a boolean indicating that current material needs to register RTT
  50230. */
  50231. readonly hasRenderTargetTextures: boolean;
  50232. /**
  50233. * Gets the name of the material class.
  50234. */
  50235. getClassName(): string;
  50236. /**
  50237. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50238. */
  50239. /**
  50240. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50241. */
  50242. useLogarithmicDepth: boolean;
  50243. /**
  50244. * Gets the current transparency mode.
  50245. */
  50246. /**
  50247. * Sets the transparency mode of the material.
  50248. *
  50249. * | Value | Type | Description |
  50250. * | ----- | ----------------------------------- | ----------- |
  50251. * | 0 | OPAQUE | |
  50252. * | 1 | ALPHATEST | |
  50253. * | 2 | ALPHABLEND | |
  50254. * | 3 | ALPHATESTANDBLEND | |
  50255. *
  50256. */
  50257. transparencyMode: Nullable<number>;
  50258. /**
  50259. * Returns true if alpha blending should be disabled.
  50260. */
  50261. private readonly _disableAlphaBlending;
  50262. /**
  50263. * Specifies whether or not this material should be rendered in alpha blend mode.
  50264. */
  50265. needAlphaBlending(): boolean;
  50266. /**
  50267. * Specifies if the mesh will require alpha blending.
  50268. * @param mesh - BJS mesh.
  50269. */
  50270. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50271. /**
  50272. * Specifies whether or not this material should be rendered in alpha test mode.
  50273. */
  50274. needAlphaTesting(): boolean;
  50275. /**
  50276. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50277. */
  50278. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50279. /**
  50280. * Gets the texture used for the alpha test.
  50281. */
  50282. getAlphaTestTexture(): Nullable<BaseTexture>;
  50283. /**
  50284. * Specifies that the submesh is ready to be used.
  50285. * @param mesh - BJS mesh.
  50286. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50287. * @param useInstances - Specifies that instances should be used.
  50288. * @returns - boolean indicating that the submesh is ready or not.
  50289. */
  50290. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50291. /**
  50292. * Specifies if the material uses metallic roughness workflow.
  50293. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50294. */
  50295. isMetallicWorkflow(): boolean;
  50296. private _prepareEffect;
  50297. private _prepareDefines;
  50298. /**
  50299. * Force shader compilation
  50300. */
  50301. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50302. /**
  50303. * Initializes the uniform buffer layout for the shader.
  50304. */
  50305. buildUniformLayout(): void;
  50306. /**
  50307. * Unbinds the material from the mesh
  50308. */
  50309. unbind(): void;
  50310. /**
  50311. * Binds the submesh data.
  50312. * @param world - The world matrix.
  50313. * @param mesh - The BJS mesh.
  50314. * @param subMesh - A submesh of the BJS mesh.
  50315. */
  50316. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50317. /**
  50318. * Returns the animatable textures.
  50319. * @returns - Array of animatable textures.
  50320. */
  50321. getAnimatables(): IAnimatable[];
  50322. /**
  50323. * Returns the texture used for reflections.
  50324. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50325. */
  50326. private _getReflectionTexture;
  50327. /**
  50328. * Returns an array of the actively used textures.
  50329. * @returns - Array of BaseTextures
  50330. */
  50331. getActiveTextures(): BaseTexture[];
  50332. /**
  50333. * Checks to see if a texture is used in the material.
  50334. * @param texture - Base texture to use.
  50335. * @returns - Boolean specifying if a texture is used in the material.
  50336. */
  50337. hasTexture(texture: BaseTexture): boolean;
  50338. /**
  50339. * Disposes the resources of the material.
  50340. * @param forceDisposeEffect - Forces the disposal of effects.
  50341. * @param forceDisposeTextures - Forces the disposal of all textures.
  50342. */
  50343. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50344. }
  50345. }
  50346. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50347. import { Nullable } from "babylonjs/types";
  50348. import { Scene } from "babylonjs/scene";
  50349. import { Color3 } from "babylonjs/Maths/math.color";
  50350. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50351. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50352. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50353. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50354. /**
  50355. * The Physically based material of BJS.
  50356. *
  50357. * This offers the main features of a standard PBR material.
  50358. * For more information, please refer to the documentation :
  50359. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50360. */
  50361. export class PBRMaterial extends PBRBaseMaterial {
  50362. /**
  50363. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50364. */
  50365. static readonly PBRMATERIAL_OPAQUE: number;
  50366. /**
  50367. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50368. */
  50369. static readonly PBRMATERIAL_ALPHATEST: number;
  50370. /**
  50371. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50372. */
  50373. static readonly PBRMATERIAL_ALPHABLEND: number;
  50374. /**
  50375. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50376. * They are also discarded below the alpha cutoff threshold to improve performances.
  50377. */
  50378. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50379. /**
  50380. * Defines the default value of how much AO map is occluding the analytical lights
  50381. * (point spot...).
  50382. */
  50383. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50384. /**
  50385. * Intensity of the direct lights e.g. the four lights available in your scene.
  50386. * This impacts both the direct diffuse and specular highlights.
  50387. */
  50388. directIntensity: number;
  50389. /**
  50390. * Intensity of the emissive part of the material.
  50391. * This helps controlling the emissive effect without modifying the emissive color.
  50392. */
  50393. emissiveIntensity: number;
  50394. /**
  50395. * Intensity of the environment e.g. how much the environment will light the object
  50396. * either through harmonics for rough material or through the refelction for shiny ones.
  50397. */
  50398. environmentIntensity: number;
  50399. /**
  50400. * This is a special control allowing the reduction of the specular highlights coming from the
  50401. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50402. */
  50403. specularIntensity: number;
  50404. /**
  50405. * Debug Control allowing disabling the bump map on this material.
  50406. */
  50407. disableBumpMap: boolean;
  50408. /**
  50409. * AKA Diffuse Texture in standard nomenclature.
  50410. */
  50411. albedoTexture: BaseTexture;
  50412. /**
  50413. * AKA Occlusion Texture in other nomenclature.
  50414. */
  50415. ambientTexture: BaseTexture;
  50416. /**
  50417. * AKA Occlusion Texture Intensity in other nomenclature.
  50418. */
  50419. ambientTextureStrength: number;
  50420. /**
  50421. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50422. * 1 means it completely occludes it
  50423. * 0 mean it has no impact
  50424. */
  50425. ambientTextureImpactOnAnalyticalLights: number;
  50426. /**
  50427. * Stores the alpha values in a texture.
  50428. */
  50429. opacityTexture: BaseTexture;
  50430. /**
  50431. * Stores the reflection values in a texture.
  50432. */
  50433. reflectionTexture: Nullable<BaseTexture>;
  50434. /**
  50435. * Stores the emissive values in a texture.
  50436. */
  50437. emissiveTexture: BaseTexture;
  50438. /**
  50439. * AKA Specular texture in other nomenclature.
  50440. */
  50441. reflectivityTexture: BaseTexture;
  50442. /**
  50443. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50444. */
  50445. metallicTexture: BaseTexture;
  50446. /**
  50447. * Specifies the metallic scalar of the metallic/roughness workflow.
  50448. * Can also be used to scale the metalness values of the metallic texture.
  50449. */
  50450. metallic: Nullable<number>;
  50451. /**
  50452. * Specifies the roughness scalar of the metallic/roughness workflow.
  50453. * Can also be used to scale the roughness values of the metallic texture.
  50454. */
  50455. roughness: Nullable<number>;
  50456. /**
  50457. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50458. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50459. */
  50460. microSurfaceTexture: BaseTexture;
  50461. /**
  50462. * Stores surface normal data used to displace a mesh in a texture.
  50463. */
  50464. bumpTexture: BaseTexture;
  50465. /**
  50466. * Stores the pre-calculated light information of a mesh in a texture.
  50467. */
  50468. lightmapTexture: BaseTexture;
  50469. /**
  50470. * Stores the refracted light information in a texture.
  50471. */
  50472. refractionTexture: Nullable<BaseTexture>;
  50473. /**
  50474. * The color of a material in ambient lighting.
  50475. */
  50476. ambientColor: Color3;
  50477. /**
  50478. * AKA Diffuse Color in other nomenclature.
  50479. */
  50480. albedoColor: Color3;
  50481. /**
  50482. * AKA Specular Color in other nomenclature.
  50483. */
  50484. reflectivityColor: Color3;
  50485. /**
  50486. * The color reflected from the material.
  50487. */
  50488. reflectionColor: Color3;
  50489. /**
  50490. * The color emitted from the material.
  50491. */
  50492. emissiveColor: Color3;
  50493. /**
  50494. * AKA Glossiness in other nomenclature.
  50495. */
  50496. microSurface: number;
  50497. /**
  50498. * source material index of refraction (IOR)' / 'destination material IOR.
  50499. */
  50500. indexOfRefraction: number;
  50501. /**
  50502. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50503. */
  50504. invertRefractionY: boolean;
  50505. /**
  50506. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50507. * Materials half opaque for instance using refraction could benefit from this control.
  50508. */
  50509. linkRefractionWithTransparency: boolean;
  50510. /**
  50511. * If true, the light map contains occlusion information instead of lighting info.
  50512. */
  50513. useLightmapAsShadowmap: boolean;
  50514. /**
  50515. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50516. */
  50517. useAlphaFromAlbedoTexture: boolean;
  50518. /**
  50519. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50520. */
  50521. forceAlphaTest: boolean;
  50522. /**
  50523. * Defines the alpha limits in alpha test mode.
  50524. */
  50525. alphaCutOff: number;
  50526. /**
  50527. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50528. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50529. */
  50530. useSpecularOverAlpha: boolean;
  50531. /**
  50532. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50533. */
  50534. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50535. /**
  50536. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50537. */
  50538. useRoughnessFromMetallicTextureAlpha: boolean;
  50539. /**
  50540. * Specifies if the metallic texture contains the roughness information in its green channel.
  50541. */
  50542. useRoughnessFromMetallicTextureGreen: boolean;
  50543. /**
  50544. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50545. */
  50546. useMetallnessFromMetallicTextureBlue: boolean;
  50547. /**
  50548. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50549. */
  50550. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50551. /**
  50552. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50553. */
  50554. useAmbientInGrayScale: boolean;
  50555. /**
  50556. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50557. * The material will try to infer what glossiness each pixel should be.
  50558. */
  50559. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50560. /**
  50561. * BJS is using an harcoded light falloff based on a manually sets up range.
  50562. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50563. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50564. */
  50565. /**
  50566. * BJS is using an harcoded light falloff based on a manually sets up range.
  50567. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50568. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50569. */
  50570. usePhysicalLightFalloff: boolean;
  50571. /**
  50572. * In order to support the falloff compatibility with gltf, a special mode has been added
  50573. * to reproduce the gltf light falloff.
  50574. */
  50575. /**
  50576. * In order to support the falloff compatibility with gltf, a special mode has been added
  50577. * to reproduce the gltf light falloff.
  50578. */
  50579. useGLTFLightFalloff: boolean;
  50580. /**
  50581. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50582. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50583. */
  50584. useRadianceOverAlpha: boolean;
  50585. /**
  50586. * Allows using an object space normal map (instead of tangent space).
  50587. */
  50588. useObjectSpaceNormalMap: boolean;
  50589. /**
  50590. * Allows using the bump map in parallax mode.
  50591. */
  50592. useParallax: boolean;
  50593. /**
  50594. * Allows using the bump map in parallax occlusion mode.
  50595. */
  50596. useParallaxOcclusion: boolean;
  50597. /**
  50598. * Controls the scale bias of the parallax mode.
  50599. */
  50600. parallaxScaleBias: number;
  50601. /**
  50602. * If sets to true, disables all the lights affecting the material.
  50603. */
  50604. disableLighting: boolean;
  50605. /**
  50606. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50607. */
  50608. forceIrradianceInFragment: boolean;
  50609. /**
  50610. * Number of Simultaneous lights allowed on the material.
  50611. */
  50612. maxSimultaneousLights: number;
  50613. /**
  50614. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50615. */
  50616. invertNormalMapX: boolean;
  50617. /**
  50618. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50619. */
  50620. invertNormalMapY: boolean;
  50621. /**
  50622. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50623. */
  50624. twoSidedLighting: boolean;
  50625. /**
  50626. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50627. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50628. */
  50629. useAlphaFresnel: boolean;
  50630. /**
  50631. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50632. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50633. */
  50634. useLinearAlphaFresnel: boolean;
  50635. /**
  50636. * Let user defines the brdf lookup texture used for IBL.
  50637. * A default 8bit version is embedded but you could point at :
  50638. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50639. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50640. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50641. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50642. */
  50643. environmentBRDFTexture: Nullable<BaseTexture>;
  50644. /**
  50645. * Force normal to face away from face.
  50646. */
  50647. forceNormalForward: boolean;
  50648. /**
  50649. * Enables specular anti aliasing in the PBR shader.
  50650. * It will both interacts on the Geometry for analytical and IBL lighting.
  50651. * It also prefilter the roughness map based on the bump values.
  50652. */
  50653. enableSpecularAntiAliasing: boolean;
  50654. /**
  50655. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50656. * makes the reflect vector face the model (under horizon).
  50657. */
  50658. useHorizonOcclusion: boolean;
  50659. /**
  50660. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50661. * too much the area relying on ambient texture to define their ambient occlusion.
  50662. */
  50663. useRadianceOcclusion: boolean;
  50664. /**
  50665. * If set to true, no lighting calculations will be applied.
  50666. */
  50667. unlit: boolean;
  50668. /**
  50669. * Gets the image processing configuration used either in this material.
  50670. */
  50671. /**
  50672. * Sets the Default image processing configuration used either in the this material.
  50673. *
  50674. * If sets to null, the scene one is in use.
  50675. */
  50676. imageProcessingConfiguration: ImageProcessingConfiguration;
  50677. /**
  50678. * Gets wether the color curves effect is enabled.
  50679. */
  50680. /**
  50681. * Sets wether the color curves effect is enabled.
  50682. */
  50683. cameraColorCurvesEnabled: boolean;
  50684. /**
  50685. * Gets wether the color grading effect is enabled.
  50686. */
  50687. /**
  50688. * Gets wether the color grading effect is enabled.
  50689. */
  50690. cameraColorGradingEnabled: boolean;
  50691. /**
  50692. * Gets wether tonemapping is enabled or not.
  50693. */
  50694. /**
  50695. * Sets wether tonemapping is enabled or not
  50696. */
  50697. cameraToneMappingEnabled: boolean;
  50698. /**
  50699. * The camera exposure used on this material.
  50700. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50701. * This corresponds to a photographic exposure.
  50702. */
  50703. /**
  50704. * The camera exposure used on this material.
  50705. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50706. * This corresponds to a photographic exposure.
  50707. */
  50708. cameraExposure: number;
  50709. /**
  50710. * Gets The camera contrast used on this material.
  50711. */
  50712. /**
  50713. * Sets The camera contrast used on this material.
  50714. */
  50715. cameraContrast: number;
  50716. /**
  50717. * Gets the Color Grading 2D Lookup Texture.
  50718. */
  50719. /**
  50720. * Sets the Color Grading 2D Lookup Texture.
  50721. */
  50722. cameraColorGradingTexture: Nullable<BaseTexture>;
  50723. /**
  50724. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50725. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50726. * 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;
  50727. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50728. */
  50729. /**
  50730. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50731. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50732. * 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;
  50733. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50734. */
  50735. cameraColorCurves: Nullable<ColorCurves>;
  50736. /**
  50737. * Instantiates a new PBRMaterial instance.
  50738. *
  50739. * @param name The material name
  50740. * @param scene The scene the material will be use in.
  50741. */
  50742. constructor(name: string, scene: Scene);
  50743. /**
  50744. * Returns the name of this material class.
  50745. */
  50746. getClassName(): string;
  50747. /**
  50748. * Makes a duplicate of the current material.
  50749. * @param name - name to use for the new material.
  50750. */
  50751. clone(name: string): PBRMaterial;
  50752. /**
  50753. * Serializes this PBR Material.
  50754. * @returns - An object with the serialized material.
  50755. */
  50756. serialize(): any;
  50757. /**
  50758. * Parses a PBR Material from a serialized object.
  50759. * @param source - Serialized object.
  50760. * @param scene - BJS scene instance.
  50761. * @param rootUrl - url for the scene object
  50762. * @returns - PBRMaterial
  50763. */
  50764. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50765. }
  50766. }
  50767. declare module "babylonjs/Misc/dds" {
  50768. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50769. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50770. import { Nullable } from "babylonjs/types";
  50771. import { Scene } from "babylonjs/scene";
  50772. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50773. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50774. /**
  50775. * Direct draw surface info
  50776. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50777. */
  50778. export interface DDSInfo {
  50779. /**
  50780. * Width of the texture
  50781. */
  50782. width: number;
  50783. /**
  50784. * Width of the texture
  50785. */
  50786. height: number;
  50787. /**
  50788. * Number of Mipmaps for the texture
  50789. * @see https://en.wikipedia.org/wiki/Mipmap
  50790. */
  50791. mipmapCount: number;
  50792. /**
  50793. * If the textures format is a known fourCC format
  50794. * @see https://www.fourcc.org/
  50795. */
  50796. isFourCC: boolean;
  50797. /**
  50798. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50799. */
  50800. isRGB: boolean;
  50801. /**
  50802. * If the texture is a lumincance format
  50803. */
  50804. isLuminance: boolean;
  50805. /**
  50806. * If this is a cube texture
  50807. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50808. */
  50809. isCube: boolean;
  50810. /**
  50811. * If the texture is a compressed format eg. FOURCC_DXT1
  50812. */
  50813. isCompressed: boolean;
  50814. /**
  50815. * The dxgiFormat of the texture
  50816. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50817. */
  50818. dxgiFormat: number;
  50819. /**
  50820. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50821. */
  50822. textureType: number;
  50823. /**
  50824. * Sphericle polynomial created for the dds texture
  50825. */
  50826. sphericalPolynomial?: SphericalPolynomial;
  50827. }
  50828. /**
  50829. * Class used to provide DDS decompression tools
  50830. */
  50831. export class DDSTools {
  50832. /**
  50833. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50834. */
  50835. static StoreLODInAlphaChannel: boolean;
  50836. /**
  50837. * Gets DDS information from an array buffer
  50838. * @param arrayBuffer defines the array buffer to read data from
  50839. * @returns the DDS information
  50840. */
  50841. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50842. private static _FloatView;
  50843. private static _Int32View;
  50844. private static _ToHalfFloat;
  50845. private static _FromHalfFloat;
  50846. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50847. private static _GetHalfFloatRGBAArrayBuffer;
  50848. private static _GetFloatRGBAArrayBuffer;
  50849. private static _GetFloatAsUIntRGBAArrayBuffer;
  50850. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50851. private static _GetRGBAArrayBuffer;
  50852. private static _ExtractLongWordOrder;
  50853. private static _GetRGBArrayBuffer;
  50854. private static _GetLuminanceArrayBuffer;
  50855. /**
  50856. * Uploads DDS Levels to a Babylon Texture
  50857. * @hidden
  50858. */
  50859. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50860. }
  50861. module "babylonjs/Engines/thinEngine" {
  50862. interface ThinEngine {
  50863. /**
  50864. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50865. * @param rootUrl defines the url where the file to load is located
  50866. * @param scene defines the current scene
  50867. * @param lodScale defines scale to apply to the mip map selection
  50868. * @param lodOffset defines offset to apply to the mip map selection
  50869. * @param onLoad defines an optional callback raised when the texture is loaded
  50870. * @param onError defines an optional callback raised if there is an issue to load the texture
  50871. * @param format defines the format of the data
  50872. * @param forcedExtension defines the extension to use to pick the right loader
  50873. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50874. * @returns the cube texture as an InternalTexture
  50875. */
  50876. 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;
  50877. }
  50878. }
  50879. }
  50880. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50881. import { Nullable } from "babylonjs/types";
  50882. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50883. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50884. /**
  50885. * Implementation of the DDS Texture Loader.
  50886. * @hidden
  50887. */
  50888. export class _DDSTextureLoader implements IInternalTextureLoader {
  50889. /**
  50890. * Defines wether the loader supports cascade loading the different faces.
  50891. */
  50892. readonly supportCascades: boolean;
  50893. /**
  50894. * This returns if the loader support the current file information.
  50895. * @param extension defines the file extension of the file being loaded
  50896. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50897. * @param fallback defines the fallback internal texture if any
  50898. * @param isBase64 defines whether the texture is encoded as a base64
  50899. * @param isBuffer defines whether the texture data are stored as a buffer
  50900. * @returns true if the loader can load the specified file
  50901. */
  50902. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50903. /**
  50904. * Transform the url before loading if required.
  50905. * @param rootUrl the url of the texture
  50906. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50907. * @returns the transformed texture
  50908. */
  50909. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50910. /**
  50911. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50912. * @param rootUrl the url of the texture
  50913. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50914. * @returns the fallback texture
  50915. */
  50916. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50917. /**
  50918. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50919. * @param data contains the texture data
  50920. * @param texture defines the BabylonJS internal texture
  50921. * @param createPolynomials will be true if polynomials have been requested
  50922. * @param onLoad defines the callback to trigger once the texture is ready
  50923. * @param onError defines the callback to trigger in case of error
  50924. */
  50925. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50926. /**
  50927. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50928. * @param data contains the texture data
  50929. * @param texture defines the BabylonJS internal texture
  50930. * @param callback defines the method to call once ready to upload
  50931. */
  50932. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50933. }
  50934. }
  50935. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50936. import { Nullable } from "babylonjs/types";
  50937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50938. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50939. /**
  50940. * Implementation of the ENV Texture Loader.
  50941. * @hidden
  50942. */
  50943. export class _ENVTextureLoader implements IInternalTextureLoader {
  50944. /**
  50945. * Defines wether the loader supports cascade loading the different faces.
  50946. */
  50947. readonly supportCascades: boolean;
  50948. /**
  50949. * This returns if the loader support the current file information.
  50950. * @param extension defines the file extension of the file being loaded
  50951. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50952. * @param fallback defines the fallback internal texture if any
  50953. * @param isBase64 defines whether the texture is encoded as a base64
  50954. * @param isBuffer defines whether the texture data are stored as a buffer
  50955. * @returns true if the loader can load the specified file
  50956. */
  50957. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50958. /**
  50959. * Transform the url before loading if required.
  50960. * @param rootUrl the url of the texture
  50961. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50962. * @returns the transformed texture
  50963. */
  50964. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50965. /**
  50966. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50967. * @param rootUrl the url of the texture
  50968. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50969. * @returns the fallback texture
  50970. */
  50971. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50972. /**
  50973. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50974. * @param data contains the texture data
  50975. * @param texture defines the BabylonJS internal texture
  50976. * @param createPolynomials will be true if polynomials have been requested
  50977. * @param onLoad defines the callback to trigger once the texture is ready
  50978. * @param onError defines the callback to trigger in case of error
  50979. */
  50980. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50981. /**
  50982. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50983. * @param data contains the texture data
  50984. * @param texture defines the BabylonJS internal texture
  50985. * @param callback defines the method to call once ready to upload
  50986. */
  50987. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50988. }
  50989. }
  50990. declare module "babylonjs/Misc/khronosTextureContainer" {
  50991. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50992. /**
  50993. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50994. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50995. */
  50996. export class KhronosTextureContainer {
  50997. /** contents of the KTX container file */
  50998. arrayBuffer: any;
  50999. private static HEADER_LEN;
  51000. private static COMPRESSED_2D;
  51001. private static COMPRESSED_3D;
  51002. private static TEX_2D;
  51003. private static TEX_3D;
  51004. /**
  51005. * Gets the openGL type
  51006. */
  51007. glType: number;
  51008. /**
  51009. * Gets the openGL type size
  51010. */
  51011. glTypeSize: number;
  51012. /**
  51013. * Gets the openGL format
  51014. */
  51015. glFormat: number;
  51016. /**
  51017. * Gets the openGL internal format
  51018. */
  51019. glInternalFormat: number;
  51020. /**
  51021. * Gets the base internal format
  51022. */
  51023. glBaseInternalFormat: number;
  51024. /**
  51025. * Gets image width in pixel
  51026. */
  51027. pixelWidth: number;
  51028. /**
  51029. * Gets image height in pixel
  51030. */
  51031. pixelHeight: number;
  51032. /**
  51033. * Gets image depth in pixels
  51034. */
  51035. pixelDepth: number;
  51036. /**
  51037. * Gets the number of array elements
  51038. */
  51039. numberOfArrayElements: number;
  51040. /**
  51041. * Gets the number of faces
  51042. */
  51043. numberOfFaces: number;
  51044. /**
  51045. * Gets the number of mipmap levels
  51046. */
  51047. numberOfMipmapLevels: number;
  51048. /**
  51049. * Gets the bytes of key value data
  51050. */
  51051. bytesOfKeyValueData: number;
  51052. /**
  51053. * Gets the load type
  51054. */
  51055. loadType: number;
  51056. /**
  51057. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51058. */
  51059. isInvalid: boolean;
  51060. /**
  51061. * Creates a new KhronosTextureContainer
  51062. * @param arrayBuffer contents of the KTX container file
  51063. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51064. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51065. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51066. */
  51067. constructor(
  51068. /** contents of the KTX container file */
  51069. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51070. /**
  51071. * Uploads KTX content to a Babylon Texture.
  51072. * It is assumed that the texture has already been created & is currently bound
  51073. * @hidden
  51074. */
  51075. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51076. private _upload2DCompressedLevels;
  51077. }
  51078. }
  51079. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51080. import { Nullable } from "babylonjs/types";
  51081. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51082. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51083. /**
  51084. * Implementation of the KTX Texture Loader.
  51085. * @hidden
  51086. */
  51087. export class _KTXTextureLoader implements IInternalTextureLoader {
  51088. /**
  51089. * Defines wether the loader supports cascade loading the different faces.
  51090. */
  51091. readonly supportCascades: boolean;
  51092. /**
  51093. * This returns if the loader support the current file information.
  51094. * @param extension defines the file extension of the file being loaded
  51095. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51096. * @param fallback defines the fallback internal texture if any
  51097. * @param isBase64 defines whether the texture is encoded as a base64
  51098. * @param isBuffer defines whether the texture data are stored as a buffer
  51099. * @returns true if the loader can load the specified file
  51100. */
  51101. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51102. /**
  51103. * Transform the url before loading if required.
  51104. * @param rootUrl the url of the texture
  51105. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51106. * @returns the transformed texture
  51107. */
  51108. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51109. /**
  51110. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51111. * @param rootUrl the url of the texture
  51112. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51113. * @returns the fallback texture
  51114. */
  51115. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51116. /**
  51117. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51118. * @param data contains the texture data
  51119. * @param texture defines the BabylonJS internal texture
  51120. * @param createPolynomials will be true if polynomials have been requested
  51121. * @param onLoad defines the callback to trigger once the texture is ready
  51122. * @param onError defines the callback to trigger in case of error
  51123. */
  51124. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51125. /**
  51126. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51127. * @param data contains the texture data
  51128. * @param texture defines the BabylonJS internal texture
  51129. * @param callback defines the method to call once ready to upload
  51130. */
  51131. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51132. }
  51133. }
  51134. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51135. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51136. import { Scene } from "babylonjs/scene";
  51137. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51138. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51139. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51140. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51141. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  51142. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51144. /**
  51145. * Options for the default xr helper
  51146. */
  51147. export class WebXRDefaultExperienceOptions {
  51148. /**
  51149. * Floor meshes that should be used for teleporting
  51150. */
  51151. floorMeshes: Array<AbstractMesh>;
  51152. }
  51153. /**
  51154. * Default experience which provides a similar setup to the previous webVRExperience
  51155. */
  51156. export class WebXRDefaultExperience {
  51157. /**
  51158. * Base experience
  51159. */
  51160. baseExperience: WebXRExperienceHelper;
  51161. /**
  51162. * Input experience extension
  51163. */
  51164. input: WebXRInput;
  51165. /**
  51166. * Loads the controller models
  51167. */
  51168. controllerModelLoader: WebXRControllerModelLoader;
  51169. /**
  51170. * Enables laser pointer and selection
  51171. */
  51172. pointerSelection: WebXRControllerPointerSelection;
  51173. /**
  51174. * Enables teleportation
  51175. */
  51176. teleportation: WebXRControllerTeleportation;
  51177. /**
  51178. * Enables ui for enetering/exiting xr
  51179. */
  51180. enterExitUI: WebXREnterExitUI;
  51181. /**
  51182. * Default output canvas xr should render to
  51183. */
  51184. outputCanvas: WebXRManagedOutputCanvas;
  51185. /**
  51186. * Creates the default xr experience
  51187. * @param scene scene
  51188. * @param options options for basic configuration
  51189. * @returns resulting WebXRDefaultExperience
  51190. */
  51191. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51192. private constructor();
  51193. /**
  51194. * DIsposes of the experience helper
  51195. */
  51196. dispose(): void;
  51197. }
  51198. }
  51199. declare module "babylonjs/Helpers/sceneHelpers" {
  51200. import { Nullable } from "babylonjs/types";
  51201. import { Mesh } from "babylonjs/Meshes/mesh";
  51202. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51203. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51204. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51205. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51206. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51207. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51208. import "babylonjs/Meshes/Builders/boxBuilder";
  51209. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51210. /** @hidden */
  51211. export var _forceSceneHelpersToBundle: boolean;
  51212. module "babylonjs/scene" {
  51213. interface Scene {
  51214. /**
  51215. * Creates a default light for the scene.
  51216. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51217. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51218. */
  51219. createDefaultLight(replace?: boolean): void;
  51220. /**
  51221. * Creates a default camera for the scene.
  51222. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51223. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51224. * @param replace has default false, when true replaces the active camera in the scene
  51225. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51226. */
  51227. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51228. /**
  51229. * Creates a default camera and a default light.
  51230. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51231. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51232. * @param replace has the default false, when true replaces the active camera/light in the scene
  51233. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51234. */
  51235. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51236. /**
  51237. * Creates a new sky box
  51238. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51239. * @param environmentTexture defines the texture to use as environment texture
  51240. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51241. * @param scale defines the overall scale of the skybox
  51242. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51243. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51244. * @returns a new mesh holding the sky box
  51245. */
  51246. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51247. /**
  51248. * Creates a new environment
  51249. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51250. * @param options defines the options you can use to configure the environment
  51251. * @returns the new EnvironmentHelper
  51252. */
  51253. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51254. /**
  51255. * Creates a new VREXperienceHelper
  51256. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51257. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51258. * @returns a new VREXperienceHelper
  51259. */
  51260. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51261. /**
  51262. * Creates a new WebXRDefaultExperience
  51263. * @see http://doc.babylonjs.com/how_to/webxr
  51264. * @param options experience options
  51265. * @returns a promise for a new WebXRDefaultExperience
  51266. */
  51267. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51268. }
  51269. }
  51270. }
  51271. declare module "babylonjs/Helpers/videoDome" {
  51272. import { Scene } from "babylonjs/scene";
  51273. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51274. import { Mesh } from "babylonjs/Meshes/mesh";
  51275. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51276. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51277. import "babylonjs/Meshes/Builders/sphereBuilder";
  51278. /**
  51279. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51280. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51281. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51282. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51283. */
  51284. export class VideoDome extends TransformNode {
  51285. /**
  51286. * Define the video source as a Monoscopic panoramic 360 video.
  51287. */
  51288. static readonly MODE_MONOSCOPIC: number;
  51289. /**
  51290. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51291. */
  51292. static readonly MODE_TOPBOTTOM: number;
  51293. /**
  51294. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51295. */
  51296. static readonly MODE_SIDEBYSIDE: number;
  51297. private _halfDome;
  51298. private _useDirectMapping;
  51299. /**
  51300. * The video texture being displayed on the sphere
  51301. */
  51302. protected _videoTexture: VideoTexture;
  51303. /**
  51304. * Gets the video texture being displayed on the sphere
  51305. */
  51306. readonly videoTexture: VideoTexture;
  51307. /**
  51308. * The skybox material
  51309. */
  51310. protected _material: BackgroundMaterial;
  51311. /**
  51312. * The surface used for the skybox
  51313. */
  51314. protected _mesh: Mesh;
  51315. /**
  51316. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51317. */
  51318. private _halfDomeMask;
  51319. /**
  51320. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51321. * Also see the options.resolution property.
  51322. */
  51323. fovMultiplier: number;
  51324. private _videoMode;
  51325. /**
  51326. * Gets or set the current video mode for the video. It can be:
  51327. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51328. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51329. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51330. */
  51331. videoMode: number;
  51332. /**
  51333. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51334. *
  51335. */
  51336. /**
  51337. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51338. */
  51339. halfDome: boolean;
  51340. /**
  51341. * Oberserver used in Stereoscopic VR Mode.
  51342. */
  51343. private _onBeforeCameraRenderObserver;
  51344. /**
  51345. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51346. * @param name Element's name, child elements will append suffixes for their own names.
  51347. * @param urlsOrVideo defines the url(s) or the video element to use
  51348. * @param options An object containing optional or exposed sub element properties
  51349. */
  51350. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51351. resolution?: number;
  51352. clickToPlay?: boolean;
  51353. autoPlay?: boolean;
  51354. loop?: boolean;
  51355. size?: number;
  51356. poster?: string;
  51357. faceForward?: boolean;
  51358. useDirectMapping?: boolean;
  51359. halfDomeMode?: boolean;
  51360. }, scene: Scene);
  51361. private _changeVideoMode;
  51362. /**
  51363. * Releases resources associated with this node.
  51364. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51365. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51366. */
  51367. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51368. }
  51369. }
  51370. declare module "babylonjs/Helpers/index" {
  51371. export * from "babylonjs/Helpers/environmentHelper";
  51372. export * from "babylonjs/Helpers/photoDome";
  51373. export * from "babylonjs/Helpers/sceneHelpers";
  51374. export * from "babylonjs/Helpers/videoDome";
  51375. }
  51376. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51377. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51378. import { IDisposable } from "babylonjs/scene";
  51379. import { Engine } from "babylonjs/Engines/engine";
  51380. /**
  51381. * This class can be used to get instrumentation data from a Babylon engine
  51382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51383. */
  51384. export class EngineInstrumentation implements IDisposable {
  51385. /**
  51386. * Define the instrumented engine.
  51387. */
  51388. engine: Engine;
  51389. private _captureGPUFrameTime;
  51390. private _gpuFrameTimeToken;
  51391. private _gpuFrameTime;
  51392. private _captureShaderCompilationTime;
  51393. private _shaderCompilationTime;
  51394. private _onBeginFrameObserver;
  51395. private _onEndFrameObserver;
  51396. private _onBeforeShaderCompilationObserver;
  51397. private _onAfterShaderCompilationObserver;
  51398. /**
  51399. * Gets the perf counter used for GPU frame time
  51400. */
  51401. readonly gpuFrameTimeCounter: PerfCounter;
  51402. /**
  51403. * Gets the GPU frame time capture status
  51404. */
  51405. /**
  51406. * Enable or disable the GPU frame time capture
  51407. */
  51408. captureGPUFrameTime: boolean;
  51409. /**
  51410. * Gets the perf counter used for shader compilation time
  51411. */
  51412. readonly shaderCompilationTimeCounter: PerfCounter;
  51413. /**
  51414. * Gets the shader compilation time capture status
  51415. */
  51416. /**
  51417. * Enable or disable the shader compilation time capture
  51418. */
  51419. captureShaderCompilationTime: boolean;
  51420. /**
  51421. * Instantiates a new engine instrumentation.
  51422. * This class can be used to get instrumentation data from a Babylon engine
  51423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51424. * @param engine Defines the engine to instrument
  51425. */
  51426. constructor(
  51427. /**
  51428. * Define the instrumented engine.
  51429. */
  51430. engine: Engine);
  51431. /**
  51432. * Dispose and release associated resources.
  51433. */
  51434. dispose(): void;
  51435. }
  51436. }
  51437. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51438. import { Scene, IDisposable } from "babylonjs/scene";
  51439. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51440. /**
  51441. * This class can be used to get instrumentation data from a Babylon engine
  51442. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51443. */
  51444. export class SceneInstrumentation implements IDisposable {
  51445. /**
  51446. * Defines the scene to instrument
  51447. */
  51448. scene: Scene;
  51449. private _captureActiveMeshesEvaluationTime;
  51450. private _activeMeshesEvaluationTime;
  51451. private _captureRenderTargetsRenderTime;
  51452. private _renderTargetsRenderTime;
  51453. private _captureFrameTime;
  51454. private _frameTime;
  51455. private _captureRenderTime;
  51456. private _renderTime;
  51457. private _captureInterFrameTime;
  51458. private _interFrameTime;
  51459. private _captureParticlesRenderTime;
  51460. private _particlesRenderTime;
  51461. private _captureSpritesRenderTime;
  51462. private _spritesRenderTime;
  51463. private _capturePhysicsTime;
  51464. private _physicsTime;
  51465. private _captureAnimationsTime;
  51466. private _animationsTime;
  51467. private _captureCameraRenderTime;
  51468. private _cameraRenderTime;
  51469. private _onBeforeActiveMeshesEvaluationObserver;
  51470. private _onAfterActiveMeshesEvaluationObserver;
  51471. private _onBeforeRenderTargetsRenderObserver;
  51472. private _onAfterRenderTargetsRenderObserver;
  51473. private _onAfterRenderObserver;
  51474. private _onBeforeDrawPhaseObserver;
  51475. private _onAfterDrawPhaseObserver;
  51476. private _onBeforeAnimationsObserver;
  51477. private _onBeforeParticlesRenderingObserver;
  51478. private _onAfterParticlesRenderingObserver;
  51479. private _onBeforeSpritesRenderingObserver;
  51480. private _onAfterSpritesRenderingObserver;
  51481. private _onBeforePhysicsObserver;
  51482. private _onAfterPhysicsObserver;
  51483. private _onAfterAnimationsObserver;
  51484. private _onBeforeCameraRenderObserver;
  51485. private _onAfterCameraRenderObserver;
  51486. /**
  51487. * Gets the perf counter used for active meshes evaluation time
  51488. */
  51489. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51490. /**
  51491. * Gets the active meshes evaluation time capture status
  51492. */
  51493. /**
  51494. * Enable or disable the active meshes evaluation time capture
  51495. */
  51496. captureActiveMeshesEvaluationTime: boolean;
  51497. /**
  51498. * Gets the perf counter used for render targets render time
  51499. */
  51500. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51501. /**
  51502. * Gets the render targets render time capture status
  51503. */
  51504. /**
  51505. * Enable or disable the render targets render time capture
  51506. */
  51507. captureRenderTargetsRenderTime: boolean;
  51508. /**
  51509. * Gets the perf counter used for particles render time
  51510. */
  51511. readonly particlesRenderTimeCounter: PerfCounter;
  51512. /**
  51513. * Gets the particles render time capture status
  51514. */
  51515. /**
  51516. * Enable or disable the particles render time capture
  51517. */
  51518. captureParticlesRenderTime: boolean;
  51519. /**
  51520. * Gets the perf counter used for sprites render time
  51521. */
  51522. readonly spritesRenderTimeCounter: PerfCounter;
  51523. /**
  51524. * Gets the sprites render time capture status
  51525. */
  51526. /**
  51527. * Enable or disable the sprites render time capture
  51528. */
  51529. captureSpritesRenderTime: boolean;
  51530. /**
  51531. * Gets the perf counter used for physics time
  51532. */
  51533. readonly physicsTimeCounter: PerfCounter;
  51534. /**
  51535. * Gets the physics time capture status
  51536. */
  51537. /**
  51538. * Enable or disable the physics time capture
  51539. */
  51540. capturePhysicsTime: boolean;
  51541. /**
  51542. * Gets the perf counter used for animations time
  51543. */
  51544. readonly animationsTimeCounter: PerfCounter;
  51545. /**
  51546. * Gets the animations time capture status
  51547. */
  51548. /**
  51549. * Enable or disable the animations time capture
  51550. */
  51551. captureAnimationsTime: boolean;
  51552. /**
  51553. * Gets the perf counter used for frame time capture
  51554. */
  51555. readonly frameTimeCounter: PerfCounter;
  51556. /**
  51557. * Gets the frame time capture status
  51558. */
  51559. /**
  51560. * Enable or disable the frame time capture
  51561. */
  51562. captureFrameTime: boolean;
  51563. /**
  51564. * Gets the perf counter used for inter-frames time capture
  51565. */
  51566. readonly interFrameTimeCounter: PerfCounter;
  51567. /**
  51568. * Gets the inter-frames time capture status
  51569. */
  51570. /**
  51571. * Enable or disable the inter-frames time capture
  51572. */
  51573. captureInterFrameTime: boolean;
  51574. /**
  51575. * Gets the perf counter used for render time capture
  51576. */
  51577. readonly renderTimeCounter: PerfCounter;
  51578. /**
  51579. * Gets the render time capture status
  51580. */
  51581. /**
  51582. * Enable or disable the render time capture
  51583. */
  51584. captureRenderTime: boolean;
  51585. /**
  51586. * Gets the perf counter used for camera render time capture
  51587. */
  51588. readonly cameraRenderTimeCounter: PerfCounter;
  51589. /**
  51590. * Gets the camera render time capture status
  51591. */
  51592. /**
  51593. * Enable or disable the camera render time capture
  51594. */
  51595. captureCameraRenderTime: boolean;
  51596. /**
  51597. * Gets the perf counter used for draw calls
  51598. */
  51599. readonly drawCallsCounter: PerfCounter;
  51600. /**
  51601. * Instantiates a new scene instrumentation.
  51602. * This class can be used to get instrumentation data from a Babylon engine
  51603. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51604. * @param scene Defines the scene to instrument
  51605. */
  51606. constructor(
  51607. /**
  51608. * Defines the scene to instrument
  51609. */
  51610. scene: Scene);
  51611. /**
  51612. * Dispose and release associated resources.
  51613. */
  51614. dispose(): void;
  51615. }
  51616. }
  51617. declare module "babylonjs/Instrumentation/index" {
  51618. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51619. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51620. export * from "babylonjs/Instrumentation/timeToken";
  51621. }
  51622. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51623. /** @hidden */
  51624. export var glowMapGenerationPixelShader: {
  51625. name: string;
  51626. shader: string;
  51627. };
  51628. }
  51629. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51630. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51631. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51632. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51633. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51634. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51635. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51636. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51637. /** @hidden */
  51638. export var glowMapGenerationVertexShader: {
  51639. name: string;
  51640. shader: string;
  51641. };
  51642. }
  51643. declare module "babylonjs/Layers/effectLayer" {
  51644. import { Observable } from "babylonjs/Misc/observable";
  51645. import { Nullable } from "babylonjs/types";
  51646. import { Camera } from "babylonjs/Cameras/camera";
  51647. import { Scene } from "babylonjs/scene";
  51648. import { ISize } from "babylonjs/Maths/math.size";
  51649. import { Color4 } from "babylonjs/Maths/math.color";
  51650. import { Engine } from "babylonjs/Engines/engine";
  51651. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51653. import { Mesh } from "babylonjs/Meshes/mesh";
  51654. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51655. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51656. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51657. import { Effect } from "babylonjs/Materials/effect";
  51658. import { Material } from "babylonjs/Materials/material";
  51659. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51660. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51661. /**
  51662. * Effect layer options. This helps customizing the behaviour
  51663. * of the effect layer.
  51664. */
  51665. export interface IEffectLayerOptions {
  51666. /**
  51667. * Multiplication factor apply to the canvas size to compute the render target size
  51668. * used to generated the objects (the smaller the faster).
  51669. */
  51670. mainTextureRatio: number;
  51671. /**
  51672. * Enforces a fixed size texture to ensure effect stability across devices.
  51673. */
  51674. mainTextureFixedSize?: number;
  51675. /**
  51676. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51677. */
  51678. alphaBlendingMode: number;
  51679. /**
  51680. * The camera attached to the layer.
  51681. */
  51682. camera: Nullable<Camera>;
  51683. /**
  51684. * The rendering group to draw the layer in.
  51685. */
  51686. renderingGroupId: number;
  51687. }
  51688. /**
  51689. * The effect layer Helps adding post process effect blended with the main pass.
  51690. *
  51691. * This can be for instance use to generate glow or higlight effects on the scene.
  51692. *
  51693. * The effect layer class can not be used directly and is intented to inherited from to be
  51694. * customized per effects.
  51695. */
  51696. export abstract class EffectLayer {
  51697. private _vertexBuffers;
  51698. private _indexBuffer;
  51699. private _cachedDefines;
  51700. private _effectLayerMapGenerationEffect;
  51701. private _effectLayerOptions;
  51702. private _mergeEffect;
  51703. protected _scene: Scene;
  51704. protected _engine: Engine;
  51705. protected _maxSize: number;
  51706. protected _mainTextureDesiredSize: ISize;
  51707. protected _mainTexture: RenderTargetTexture;
  51708. protected _shouldRender: boolean;
  51709. protected _postProcesses: PostProcess[];
  51710. protected _textures: BaseTexture[];
  51711. protected _emissiveTextureAndColor: {
  51712. texture: Nullable<BaseTexture>;
  51713. color: Color4;
  51714. };
  51715. /**
  51716. * The name of the layer
  51717. */
  51718. name: string;
  51719. /**
  51720. * The clear color of the texture used to generate the glow map.
  51721. */
  51722. neutralColor: Color4;
  51723. /**
  51724. * Specifies wether the highlight layer is enabled or not.
  51725. */
  51726. isEnabled: boolean;
  51727. /**
  51728. * Gets the camera attached to the layer.
  51729. */
  51730. readonly camera: Nullable<Camera>;
  51731. /**
  51732. * Gets the rendering group id the layer should render in.
  51733. */
  51734. renderingGroupId: number;
  51735. /**
  51736. * An event triggered when the effect layer has been disposed.
  51737. */
  51738. onDisposeObservable: Observable<EffectLayer>;
  51739. /**
  51740. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51741. */
  51742. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51743. /**
  51744. * An event triggered when the generated texture is being merged in the scene.
  51745. */
  51746. onBeforeComposeObservable: Observable<EffectLayer>;
  51747. /**
  51748. * An event triggered when the generated texture has been merged in the scene.
  51749. */
  51750. onAfterComposeObservable: Observable<EffectLayer>;
  51751. /**
  51752. * An event triggered when the efffect layer changes its size.
  51753. */
  51754. onSizeChangedObservable: Observable<EffectLayer>;
  51755. /** @hidden */
  51756. static _SceneComponentInitialization: (scene: Scene) => void;
  51757. /**
  51758. * Instantiates a new effect Layer and references it in the scene.
  51759. * @param name The name of the layer
  51760. * @param scene The scene to use the layer in
  51761. */
  51762. constructor(
  51763. /** The Friendly of the effect in the scene */
  51764. name: string, scene: Scene);
  51765. /**
  51766. * Get the effect name of the layer.
  51767. * @return The effect name
  51768. */
  51769. abstract getEffectName(): string;
  51770. /**
  51771. * Checks for the readiness of the element composing the layer.
  51772. * @param subMesh the mesh to check for
  51773. * @param useInstances specify wether or not to use instances to render the mesh
  51774. * @return true if ready otherwise, false
  51775. */
  51776. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51777. /**
  51778. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51779. * @returns true if the effect requires stencil during the main canvas render pass.
  51780. */
  51781. abstract needStencil(): boolean;
  51782. /**
  51783. * Create the merge effect. This is the shader use to blit the information back
  51784. * to the main canvas at the end of the scene rendering.
  51785. * @returns The effect containing the shader used to merge the effect on the main canvas
  51786. */
  51787. protected abstract _createMergeEffect(): Effect;
  51788. /**
  51789. * Creates the render target textures and post processes used in the effect layer.
  51790. */
  51791. protected abstract _createTextureAndPostProcesses(): void;
  51792. /**
  51793. * Implementation specific of rendering the generating effect on the main canvas.
  51794. * @param effect The effect used to render through
  51795. */
  51796. protected abstract _internalRender(effect: Effect): void;
  51797. /**
  51798. * Sets the required values for both the emissive texture and and the main color.
  51799. */
  51800. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51801. /**
  51802. * Free any resources and references associated to a mesh.
  51803. * Internal use
  51804. * @param mesh The mesh to free.
  51805. */
  51806. abstract _disposeMesh(mesh: Mesh): void;
  51807. /**
  51808. * Serializes this layer (Glow or Highlight for example)
  51809. * @returns a serialized layer object
  51810. */
  51811. abstract serialize?(): any;
  51812. /**
  51813. * Initializes the effect layer with the required options.
  51814. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51815. */
  51816. protected _init(options: Partial<IEffectLayerOptions>): void;
  51817. /**
  51818. * Generates the index buffer of the full screen quad blending to the main canvas.
  51819. */
  51820. private _generateIndexBuffer;
  51821. /**
  51822. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51823. */
  51824. private _generateVertexBuffer;
  51825. /**
  51826. * Sets the main texture desired size which is the closest power of two
  51827. * of the engine canvas size.
  51828. */
  51829. private _setMainTextureSize;
  51830. /**
  51831. * Creates the main texture for the effect layer.
  51832. */
  51833. protected _createMainTexture(): void;
  51834. /**
  51835. * Adds specific effects defines.
  51836. * @param defines The defines to add specifics to.
  51837. */
  51838. protected _addCustomEffectDefines(defines: string[]): void;
  51839. /**
  51840. * Checks for the readiness of the element composing the layer.
  51841. * @param subMesh the mesh to check for
  51842. * @param useInstances specify wether or not to use instances to render the mesh
  51843. * @param emissiveTexture the associated emissive texture used to generate the glow
  51844. * @return true if ready otherwise, false
  51845. */
  51846. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51847. /**
  51848. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51849. */
  51850. render(): void;
  51851. /**
  51852. * Determine if a given mesh will be used in the current effect.
  51853. * @param mesh mesh to test
  51854. * @returns true if the mesh will be used
  51855. */
  51856. hasMesh(mesh: AbstractMesh): boolean;
  51857. /**
  51858. * Returns true if the layer contains information to display, otherwise false.
  51859. * @returns true if the glow layer should be rendered
  51860. */
  51861. shouldRender(): boolean;
  51862. /**
  51863. * Returns true if the mesh should render, otherwise false.
  51864. * @param mesh The mesh to render
  51865. * @returns true if it should render otherwise false
  51866. */
  51867. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51868. /**
  51869. * Returns true if the mesh can be rendered, otherwise false.
  51870. * @param mesh The mesh to render
  51871. * @param material The material used on the mesh
  51872. * @returns true if it can be rendered otherwise false
  51873. */
  51874. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51875. /**
  51876. * Returns true if the mesh should render, otherwise false.
  51877. * @param mesh The mesh to render
  51878. * @returns true if it should render otherwise false
  51879. */
  51880. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51881. /**
  51882. * Renders the submesh passed in parameter to the generation map.
  51883. */
  51884. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51885. /**
  51886. * Rebuild the required buffers.
  51887. * @hidden Internal use only.
  51888. */
  51889. _rebuild(): void;
  51890. /**
  51891. * Dispose only the render target textures and post process.
  51892. */
  51893. private _disposeTextureAndPostProcesses;
  51894. /**
  51895. * Dispose the highlight layer and free resources.
  51896. */
  51897. dispose(): void;
  51898. /**
  51899. * Gets the class name of the effect layer
  51900. * @returns the string with the class name of the effect layer
  51901. */
  51902. getClassName(): string;
  51903. /**
  51904. * Creates an effect layer from parsed effect layer data
  51905. * @param parsedEffectLayer defines effect layer data
  51906. * @param scene defines the current scene
  51907. * @param rootUrl defines the root URL containing the effect layer information
  51908. * @returns a parsed effect Layer
  51909. */
  51910. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51911. }
  51912. }
  51913. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51914. import { Scene } from "babylonjs/scene";
  51915. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51916. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51917. import { AbstractScene } from "babylonjs/abstractScene";
  51918. module "babylonjs/abstractScene" {
  51919. interface AbstractScene {
  51920. /**
  51921. * The list of effect layers (highlights/glow) added to the scene
  51922. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51923. * @see http://doc.babylonjs.com/how_to/glow_layer
  51924. */
  51925. effectLayers: Array<EffectLayer>;
  51926. /**
  51927. * Removes the given effect layer from this scene.
  51928. * @param toRemove defines the effect layer to remove
  51929. * @returns the index of the removed effect layer
  51930. */
  51931. removeEffectLayer(toRemove: EffectLayer): number;
  51932. /**
  51933. * Adds the given effect layer to this scene
  51934. * @param newEffectLayer defines the effect layer to add
  51935. */
  51936. addEffectLayer(newEffectLayer: EffectLayer): void;
  51937. }
  51938. }
  51939. /**
  51940. * Defines the layer scene component responsible to manage any effect layers
  51941. * in a given scene.
  51942. */
  51943. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51944. /**
  51945. * The component name helpfull to identify the component in the list of scene components.
  51946. */
  51947. readonly name: string;
  51948. /**
  51949. * The scene the component belongs to.
  51950. */
  51951. scene: Scene;
  51952. private _engine;
  51953. private _renderEffects;
  51954. private _needStencil;
  51955. private _previousStencilState;
  51956. /**
  51957. * Creates a new instance of the component for the given scene
  51958. * @param scene Defines the scene to register the component in
  51959. */
  51960. constructor(scene: Scene);
  51961. /**
  51962. * Registers the component in a given scene
  51963. */
  51964. register(): void;
  51965. /**
  51966. * Rebuilds the elements related to this component in case of
  51967. * context lost for instance.
  51968. */
  51969. rebuild(): void;
  51970. /**
  51971. * Serializes the component data to the specified json object
  51972. * @param serializationObject The object to serialize to
  51973. */
  51974. serialize(serializationObject: any): void;
  51975. /**
  51976. * Adds all the elements from the container to the scene
  51977. * @param container the container holding the elements
  51978. */
  51979. addFromContainer(container: AbstractScene): void;
  51980. /**
  51981. * Removes all the elements in the container from the scene
  51982. * @param container contains the elements to remove
  51983. * @param dispose if the removed element should be disposed (default: false)
  51984. */
  51985. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51986. /**
  51987. * Disposes the component and the associated ressources.
  51988. */
  51989. dispose(): void;
  51990. private _isReadyForMesh;
  51991. private _renderMainTexture;
  51992. private _setStencil;
  51993. private _setStencilBack;
  51994. private _draw;
  51995. private _drawCamera;
  51996. private _drawRenderingGroup;
  51997. }
  51998. }
  51999. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52000. /** @hidden */
  52001. export var glowMapMergePixelShader: {
  52002. name: string;
  52003. shader: string;
  52004. };
  52005. }
  52006. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52007. /** @hidden */
  52008. export var glowMapMergeVertexShader: {
  52009. name: string;
  52010. shader: string;
  52011. };
  52012. }
  52013. declare module "babylonjs/Layers/glowLayer" {
  52014. import { Nullable } from "babylonjs/types";
  52015. import { Camera } from "babylonjs/Cameras/camera";
  52016. import { Scene } from "babylonjs/scene";
  52017. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52019. import { Mesh } from "babylonjs/Meshes/mesh";
  52020. import { Texture } from "babylonjs/Materials/Textures/texture";
  52021. import { Effect } from "babylonjs/Materials/effect";
  52022. import { Material } from "babylonjs/Materials/material";
  52023. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52024. import { Color4 } from "babylonjs/Maths/math.color";
  52025. import "babylonjs/Shaders/glowMapMerge.fragment";
  52026. import "babylonjs/Shaders/glowMapMerge.vertex";
  52027. import "babylonjs/Layers/effectLayerSceneComponent";
  52028. module "babylonjs/abstractScene" {
  52029. interface AbstractScene {
  52030. /**
  52031. * Return a the first highlight layer of the scene with a given name.
  52032. * @param name The name of the highlight layer to look for.
  52033. * @return The highlight layer if found otherwise null.
  52034. */
  52035. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52036. }
  52037. }
  52038. /**
  52039. * Glow layer options. This helps customizing the behaviour
  52040. * of the glow layer.
  52041. */
  52042. export interface IGlowLayerOptions {
  52043. /**
  52044. * Multiplication factor apply to the canvas size to compute the render target size
  52045. * used to generated the glowing objects (the smaller the faster).
  52046. */
  52047. mainTextureRatio: number;
  52048. /**
  52049. * Enforces a fixed size texture to ensure resize independant blur.
  52050. */
  52051. mainTextureFixedSize?: number;
  52052. /**
  52053. * How big is the kernel of the blur texture.
  52054. */
  52055. blurKernelSize: number;
  52056. /**
  52057. * The camera attached to the layer.
  52058. */
  52059. camera: Nullable<Camera>;
  52060. /**
  52061. * Enable MSAA by chosing the number of samples.
  52062. */
  52063. mainTextureSamples?: number;
  52064. /**
  52065. * The rendering group to draw the layer in.
  52066. */
  52067. renderingGroupId: number;
  52068. }
  52069. /**
  52070. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52071. *
  52072. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52073. * glowy meshes to your scene.
  52074. *
  52075. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52076. */
  52077. export class GlowLayer extends EffectLayer {
  52078. /**
  52079. * Effect Name of the layer.
  52080. */
  52081. static readonly EffectName: string;
  52082. /**
  52083. * The default blur kernel size used for the glow.
  52084. */
  52085. static DefaultBlurKernelSize: number;
  52086. /**
  52087. * The default texture size ratio used for the glow.
  52088. */
  52089. static DefaultTextureRatio: number;
  52090. /**
  52091. * Sets the kernel size of the blur.
  52092. */
  52093. /**
  52094. * Gets the kernel size of the blur.
  52095. */
  52096. blurKernelSize: number;
  52097. /**
  52098. * Sets the glow intensity.
  52099. */
  52100. /**
  52101. * Gets the glow intensity.
  52102. */
  52103. intensity: number;
  52104. private _options;
  52105. private _intensity;
  52106. private _horizontalBlurPostprocess1;
  52107. private _verticalBlurPostprocess1;
  52108. private _horizontalBlurPostprocess2;
  52109. private _verticalBlurPostprocess2;
  52110. private _blurTexture1;
  52111. private _blurTexture2;
  52112. private _postProcesses1;
  52113. private _postProcesses2;
  52114. private _includedOnlyMeshes;
  52115. private _excludedMeshes;
  52116. /**
  52117. * Callback used to let the user override the color selection on a per mesh basis
  52118. */
  52119. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52120. /**
  52121. * Callback used to let the user override the texture selection on a per mesh basis
  52122. */
  52123. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52124. /**
  52125. * Instantiates a new glow Layer and references it to the scene.
  52126. * @param name The name of the layer
  52127. * @param scene The scene to use the layer in
  52128. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52129. */
  52130. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52131. /**
  52132. * Get the effect name of the layer.
  52133. * @return The effect name
  52134. */
  52135. getEffectName(): string;
  52136. /**
  52137. * Create the merge effect. This is the shader use to blit the information back
  52138. * to the main canvas at the end of the scene rendering.
  52139. */
  52140. protected _createMergeEffect(): Effect;
  52141. /**
  52142. * Creates the render target textures and post processes used in the glow layer.
  52143. */
  52144. protected _createTextureAndPostProcesses(): void;
  52145. /**
  52146. * Checks for the readiness of the element composing the layer.
  52147. * @param subMesh the mesh to check for
  52148. * @param useInstances specify wether or not to use instances to render the mesh
  52149. * @param emissiveTexture the associated emissive texture used to generate the glow
  52150. * @return true if ready otherwise, false
  52151. */
  52152. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52153. /**
  52154. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52155. */
  52156. needStencil(): boolean;
  52157. /**
  52158. * Returns true if the mesh can be rendered, otherwise false.
  52159. * @param mesh The mesh to render
  52160. * @param material The material used on the mesh
  52161. * @returns true if it can be rendered otherwise false
  52162. */
  52163. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52164. /**
  52165. * Implementation specific of rendering the generating effect on the main canvas.
  52166. * @param effect The effect used to render through
  52167. */
  52168. protected _internalRender(effect: Effect): void;
  52169. /**
  52170. * Sets the required values for both the emissive texture and and the main color.
  52171. */
  52172. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52173. /**
  52174. * Returns true if the mesh should render, otherwise false.
  52175. * @param mesh The mesh to render
  52176. * @returns true if it should render otherwise false
  52177. */
  52178. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52179. /**
  52180. * Adds specific effects defines.
  52181. * @param defines The defines to add specifics to.
  52182. */
  52183. protected _addCustomEffectDefines(defines: string[]): void;
  52184. /**
  52185. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52186. * @param mesh The mesh to exclude from the glow layer
  52187. */
  52188. addExcludedMesh(mesh: Mesh): void;
  52189. /**
  52190. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52191. * @param mesh The mesh to remove
  52192. */
  52193. removeExcludedMesh(mesh: Mesh): void;
  52194. /**
  52195. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52196. * @param mesh The mesh to include in the glow layer
  52197. */
  52198. addIncludedOnlyMesh(mesh: Mesh): void;
  52199. /**
  52200. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52201. * @param mesh The mesh to remove
  52202. */
  52203. removeIncludedOnlyMesh(mesh: Mesh): void;
  52204. /**
  52205. * Determine if a given mesh will be used in the glow layer
  52206. * @param mesh The mesh to test
  52207. * @returns true if the mesh will be highlighted by the current glow layer
  52208. */
  52209. hasMesh(mesh: AbstractMesh): boolean;
  52210. /**
  52211. * Free any resources and references associated to a mesh.
  52212. * Internal use
  52213. * @param mesh The mesh to free.
  52214. * @hidden
  52215. */
  52216. _disposeMesh(mesh: Mesh): void;
  52217. /**
  52218. * Gets the class name of the effect layer
  52219. * @returns the string with the class name of the effect layer
  52220. */
  52221. getClassName(): string;
  52222. /**
  52223. * Serializes this glow layer
  52224. * @returns a serialized glow layer object
  52225. */
  52226. serialize(): any;
  52227. /**
  52228. * Creates a Glow Layer from parsed glow layer data
  52229. * @param parsedGlowLayer defines glow layer data
  52230. * @param scene defines the current scene
  52231. * @param rootUrl defines the root URL containing the glow layer information
  52232. * @returns a parsed Glow Layer
  52233. */
  52234. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52235. }
  52236. }
  52237. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52238. /** @hidden */
  52239. export var glowBlurPostProcessPixelShader: {
  52240. name: string;
  52241. shader: string;
  52242. };
  52243. }
  52244. declare module "babylonjs/Layers/highlightLayer" {
  52245. import { Observable } from "babylonjs/Misc/observable";
  52246. import { Nullable } from "babylonjs/types";
  52247. import { Camera } from "babylonjs/Cameras/camera";
  52248. import { Scene } from "babylonjs/scene";
  52249. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52251. import { Mesh } from "babylonjs/Meshes/mesh";
  52252. import { Effect } from "babylonjs/Materials/effect";
  52253. import { Material } from "babylonjs/Materials/material";
  52254. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52255. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52256. import "babylonjs/Shaders/glowMapMerge.fragment";
  52257. import "babylonjs/Shaders/glowMapMerge.vertex";
  52258. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52259. module "babylonjs/abstractScene" {
  52260. interface AbstractScene {
  52261. /**
  52262. * Return a the first highlight layer of the scene with a given name.
  52263. * @param name The name of the highlight layer to look for.
  52264. * @return The highlight layer if found otherwise null.
  52265. */
  52266. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52267. }
  52268. }
  52269. /**
  52270. * Highlight layer options. This helps customizing the behaviour
  52271. * of the highlight layer.
  52272. */
  52273. export interface IHighlightLayerOptions {
  52274. /**
  52275. * Multiplication factor apply to the canvas size to compute the render target size
  52276. * used to generated the glowing objects (the smaller the faster).
  52277. */
  52278. mainTextureRatio: number;
  52279. /**
  52280. * Enforces a fixed size texture to ensure resize independant blur.
  52281. */
  52282. mainTextureFixedSize?: number;
  52283. /**
  52284. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52285. * of the picture to blur (the smaller the faster).
  52286. */
  52287. blurTextureSizeRatio: number;
  52288. /**
  52289. * How big in texel of the blur texture is the vertical blur.
  52290. */
  52291. blurVerticalSize: number;
  52292. /**
  52293. * How big in texel of the blur texture is the horizontal blur.
  52294. */
  52295. blurHorizontalSize: number;
  52296. /**
  52297. * Alpha blending mode used to apply the blur. Default is combine.
  52298. */
  52299. alphaBlendingMode: number;
  52300. /**
  52301. * The camera attached to the layer.
  52302. */
  52303. camera: Nullable<Camera>;
  52304. /**
  52305. * Should we display highlight as a solid stroke?
  52306. */
  52307. isStroke?: boolean;
  52308. /**
  52309. * The rendering group to draw the layer in.
  52310. */
  52311. renderingGroupId: number;
  52312. }
  52313. /**
  52314. * The highlight layer Helps adding a glow effect around a mesh.
  52315. *
  52316. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52317. * glowy meshes to your scene.
  52318. *
  52319. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52320. */
  52321. export class HighlightLayer extends EffectLayer {
  52322. name: string;
  52323. /**
  52324. * Effect Name of the highlight layer.
  52325. */
  52326. static readonly EffectName: string;
  52327. /**
  52328. * The neutral color used during the preparation of the glow effect.
  52329. * This is black by default as the blend operation is a blend operation.
  52330. */
  52331. static NeutralColor: Color4;
  52332. /**
  52333. * Stencil value used for glowing meshes.
  52334. */
  52335. static GlowingMeshStencilReference: number;
  52336. /**
  52337. * Stencil value used for the other meshes in the scene.
  52338. */
  52339. static NormalMeshStencilReference: number;
  52340. /**
  52341. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52342. */
  52343. innerGlow: boolean;
  52344. /**
  52345. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52346. */
  52347. outerGlow: boolean;
  52348. /**
  52349. * Specifies the horizontal size of the blur.
  52350. */
  52351. /**
  52352. * Gets the horizontal size of the blur.
  52353. */
  52354. blurHorizontalSize: number;
  52355. /**
  52356. * Specifies the vertical size of the blur.
  52357. */
  52358. /**
  52359. * Gets the vertical size of the blur.
  52360. */
  52361. blurVerticalSize: number;
  52362. /**
  52363. * An event triggered when the highlight layer is being blurred.
  52364. */
  52365. onBeforeBlurObservable: Observable<HighlightLayer>;
  52366. /**
  52367. * An event triggered when the highlight layer has been blurred.
  52368. */
  52369. onAfterBlurObservable: Observable<HighlightLayer>;
  52370. private _instanceGlowingMeshStencilReference;
  52371. private _options;
  52372. private _downSamplePostprocess;
  52373. private _horizontalBlurPostprocess;
  52374. private _verticalBlurPostprocess;
  52375. private _blurTexture;
  52376. private _meshes;
  52377. private _excludedMeshes;
  52378. /**
  52379. * Instantiates a new highlight Layer and references it to the scene..
  52380. * @param name The name of the layer
  52381. * @param scene The scene to use the layer in
  52382. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52383. */
  52384. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52385. /**
  52386. * Get the effect name of the layer.
  52387. * @return The effect name
  52388. */
  52389. getEffectName(): string;
  52390. /**
  52391. * Create the merge effect. This is the shader use to blit the information back
  52392. * to the main canvas at the end of the scene rendering.
  52393. */
  52394. protected _createMergeEffect(): Effect;
  52395. /**
  52396. * Creates the render target textures and post processes used in the highlight layer.
  52397. */
  52398. protected _createTextureAndPostProcesses(): void;
  52399. /**
  52400. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52401. */
  52402. needStencil(): boolean;
  52403. /**
  52404. * Checks for the readiness of the element composing the layer.
  52405. * @param subMesh the mesh to check for
  52406. * @param useInstances specify wether or not to use instances to render the mesh
  52407. * @param emissiveTexture the associated emissive texture used to generate the glow
  52408. * @return true if ready otherwise, false
  52409. */
  52410. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52411. /**
  52412. * Implementation specific of rendering the generating effect on the main canvas.
  52413. * @param effect The effect used to render through
  52414. */
  52415. protected _internalRender(effect: Effect): void;
  52416. /**
  52417. * Returns true if the layer contains information to display, otherwise false.
  52418. */
  52419. shouldRender(): boolean;
  52420. /**
  52421. * Returns true if the mesh should render, otherwise false.
  52422. * @param mesh The mesh to render
  52423. * @returns true if it should render otherwise false
  52424. */
  52425. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52426. /**
  52427. * Sets the required values for both the emissive texture and and the main color.
  52428. */
  52429. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52430. /**
  52431. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52432. * @param mesh The mesh to exclude from the highlight layer
  52433. */
  52434. addExcludedMesh(mesh: Mesh): void;
  52435. /**
  52436. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52437. * @param mesh The mesh to highlight
  52438. */
  52439. removeExcludedMesh(mesh: Mesh): void;
  52440. /**
  52441. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52442. * @param mesh mesh to test
  52443. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52444. */
  52445. hasMesh(mesh: AbstractMesh): boolean;
  52446. /**
  52447. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52448. * @param mesh The mesh to highlight
  52449. * @param color The color of the highlight
  52450. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52451. */
  52452. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52453. /**
  52454. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52455. * @param mesh The mesh to highlight
  52456. */
  52457. removeMesh(mesh: Mesh): void;
  52458. /**
  52459. * Force the stencil to the normal expected value for none glowing parts
  52460. */
  52461. private _defaultStencilReference;
  52462. /**
  52463. * Free any resources and references associated to a mesh.
  52464. * Internal use
  52465. * @param mesh The mesh to free.
  52466. * @hidden
  52467. */
  52468. _disposeMesh(mesh: Mesh): void;
  52469. /**
  52470. * Dispose the highlight layer and free resources.
  52471. */
  52472. dispose(): void;
  52473. /**
  52474. * Gets the class name of the effect layer
  52475. * @returns the string with the class name of the effect layer
  52476. */
  52477. getClassName(): string;
  52478. /**
  52479. * Serializes this Highlight layer
  52480. * @returns a serialized Highlight layer object
  52481. */
  52482. serialize(): any;
  52483. /**
  52484. * Creates a Highlight layer from parsed Highlight layer data
  52485. * @param parsedHightlightLayer defines the Highlight layer data
  52486. * @param scene defines the current scene
  52487. * @param rootUrl defines the root URL containing the Highlight layer information
  52488. * @returns a parsed Highlight layer
  52489. */
  52490. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52491. }
  52492. }
  52493. declare module "babylonjs/Layers/layerSceneComponent" {
  52494. import { Scene } from "babylonjs/scene";
  52495. import { ISceneComponent } from "babylonjs/sceneComponent";
  52496. import { Layer } from "babylonjs/Layers/layer";
  52497. import { AbstractScene } from "babylonjs/abstractScene";
  52498. module "babylonjs/abstractScene" {
  52499. interface AbstractScene {
  52500. /**
  52501. * The list of layers (background and foreground) of the scene
  52502. */
  52503. layers: Array<Layer>;
  52504. }
  52505. }
  52506. /**
  52507. * Defines the layer scene component responsible to manage any layers
  52508. * in a given scene.
  52509. */
  52510. export class LayerSceneComponent implements ISceneComponent {
  52511. /**
  52512. * The component name helpfull to identify the component in the list of scene components.
  52513. */
  52514. readonly name: string;
  52515. /**
  52516. * The scene the component belongs to.
  52517. */
  52518. scene: Scene;
  52519. private _engine;
  52520. /**
  52521. * Creates a new instance of the component for the given scene
  52522. * @param scene Defines the scene to register the component in
  52523. */
  52524. constructor(scene: Scene);
  52525. /**
  52526. * Registers the component in a given scene
  52527. */
  52528. register(): void;
  52529. /**
  52530. * Rebuilds the elements related to this component in case of
  52531. * context lost for instance.
  52532. */
  52533. rebuild(): void;
  52534. /**
  52535. * Disposes the component and the associated ressources.
  52536. */
  52537. dispose(): void;
  52538. private _draw;
  52539. private _drawCameraPredicate;
  52540. private _drawCameraBackground;
  52541. private _drawCameraForeground;
  52542. private _drawRenderTargetPredicate;
  52543. private _drawRenderTargetBackground;
  52544. private _drawRenderTargetForeground;
  52545. /**
  52546. * Adds all the elements from the container to the scene
  52547. * @param container the container holding the elements
  52548. */
  52549. addFromContainer(container: AbstractScene): void;
  52550. /**
  52551. * Removes all the elements in the container from the scene
  52552. * @param container contains the elements to remove
  52553. * @param dispose if the removed element should be disposed (default: false)
  52554. */
  52555. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52556. }
  52557. }
  52558. declare module "babylonjs/Shaders/layer.fragment" {
  52559. /** @hidden */
  52560. export var layerPixelShader: {
  52561. name: string;
  52562. shader: string;
  52563. };
  52564. }
  52565. declare module "babylonjs/Shaders/layer.vertex" {
  52566. /** @hidden */
  52567. export var layerVertexShader: {
  52568. name: string;
  52569. shader: string;
  52570. };
  52571. }
  52572. declare module "babylonjs/Layers/layer" {
  52573. import { Observable } from "babylonjs/Misc/observable";
  52574. import { Nullable } from "babylonjs/types";
  52575. import { Scene } from "babylonjs/scene";
  52576. import { Vector2 } from "babylonjs/Maths/math.vector";
  52577. import { Color4 } from "babylonjs/Maths/math.color";
  52578. import { Texture } from "babylonjs/Materials/Textures/texture";
  52579. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52580. import "babylonjs/Shaders/layer.fragment";
  52581. import "babylonjs/Shaders/layer.vertex";
  52582. /**
  52583. * This represents a full screen 2d layer.
  52584. * This can be useful to display a picture in the background of your scene for instance.
  52585. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52586. */
  52587. export class Layer {
  52588. /**
  52589. * Define the name of the layer.
  52590. */
  52591. name: string;
  52592. /**
  52593. * Define the texture the layer should display.
  52594. */
  52595. texture: Nullable<Texture>;
  52596. /**
  52597. * Is the layer in background or foreground.
  52598. */
  52599. isBackground: boolean;
  52600. /**
  52601. * Define the color of the layer (instead of texture).
  52602. */
  52603. color: Color4;
  52604. /**
  52605. * Define the scale of the layer in order to zoom in out of the texture.
  52606. */
  52607. scale: Vector2;
  52608. /**
  52609. * Define an offset for the layer in order to shift the texture.
  52610. */
  52611. offset: Vector2;
  52612. /**
  52613. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52614. */
  52615. alphaBlendingMode: number;
  52616. /**
  52617. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52618. * Alpha test will not mix with the background color in case of transparency.
  52619. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52620. */
  52621. alphaTest: boolean;
  52622. /**
  52623. * Define a mask to restrict the layer to only some of the scene cameras.
  52624. */
  52625. layerMask: number;
  52626. /**
  52627. * Define the list of render target the layer is visible into.
  52628. */
  52629. renderTargetTextures: RenderTargetTexture[];
  52630. /**
  52631. * Define if the layer is only used in renderTarget or if it also
  52632. * renders in the main frame buffer of the canvas.
  52633. */
  52634. renderOnlyInRenderTargetTextures: boolean;
  52635. private _scene;
  52636. private _vertexBuffers;
  52637. private _indexBuffer;
  52638. private _effect;
  52639. private _alphaTestEffect;
  52640. /**
  52641. * An event triggered when the layer is disposed.
  52642. */
  52643. onDisposeObservable: Observable<Layer>;
  52644. private _onDisposeObserver;
  52645. /**
  52646. * Back compatibility with callback before the onDisposeObservable existed.
  52647. * The set callback will be triggered when the layer has been disposed.
  52648. */
  52649. onDispose: () => void;
  52650. /**
  52651. * An event triggered before rendering the scene
  52652. */
  52653. onBeforeRenderObservable: Observable<Layer>;
  52654. private _onBeforeRenderObserver;
  52655. /**
  52656. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52657. * The set callback will be triggered just before rendering the layer.
  52658. */
  52659. onBeforeRender: () => void;
  52660. /**
  52661. * An event triggered after rendering the scene
  52662. */
  52663. onAfterRenderObservable: Observable<Layer>;
  52664. private _onAfterRenderObserver;
  52665. /**
  52666. * Back compatibility with callback before the onAfterRenderObservable existed.
  52667. * The set callback will be triggered just after rendering the layer.
  52668. */
  52669. onAfterRender: () => void;
  52670. /**
  52671. * Instantiates a new layer.
  52672. * This represents a full screen 2d layer.
  52673. * This can be useful to display a picture in the background of your scene for instance.
  52674. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52675. * @param name Define the name of the layer in the scene
  52676. * @param imgUrl Define the url of the texture to display in the layer
  52677. * @param scene Define the scene the layer belongs to
  52678. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52679. * @param color Defines a color for the layer
  52680. */
  52681. constructor(
  52682. /**
  52683. * Define the name of the layer.
  52684. */
  52685. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52686. private _createIndexBuffer;
  52687. /** @hidden */
  52688. _rebuild(): void;
  52689. /**
  52690. * Renders the layer in the scene.
  52691. */
  52692. render(): void;
  52693. /**
  52694. * Disposes and releases the associated ressources.
  52695. */
  52696. dispose(): void;
  52697. }
  52698. }
  52699. declare module "babylonjs/Layers/index" {
  52700. export * from "babylonjs/Layers/effectLayer";
  52701. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52702. export * from "babylonjs/Layers/glowLayer";
  52703. export * from "babylonjs/Layers/highlightLayer";
  52704. export * from "babylonjs/Layers/layer";
  52705. export * from "babylonjs/Layers/layerSceneComponent";
  52706. }
  52707. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52708. /** @hidden */
  52709. export var lensFlarePixelShader: {
  52710. name: string;
  52711. shader: string;
  52712. };
  52713. }
  52714. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52715. /** @hidden */
  52716. export var lensFlareVertexShader: {
  52717. name: string;
  52718. shader: string;
  52719. };
  52720. }
  52721. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52722. import { Scene } from "babylonjs/scene";
  52723. import { Vector3 } from "babylonjs/Maths/math.vector";
  52724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52725. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52726. import "babylonjs/Shaders/lensFlare.fragment";
  52727. import "babylonjs/Shaders/lensFlare.vertex";
  52728. import { Viewport } from "babylonjs/Maths/math.viewport";
  52729. /**
  52730. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52731. * It is usually composed of several `lensFlare`.
  52732. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52733. */
  52734. export class LensFlareSystem {
  52735. /**
  52736. * Define the name of the lens flare system
  52737. */
  52738. name: string;
  52739. /**
  52740. * List of lens flares used in this system.
  52741. */
  52742. lensFlares: LensFlare[];
  52743. /**
  52744. * Define a limit from the border the lens flare can be visible.
  52745. */
  52746. borderLimit: number;
  52747. /**
  52748. * Define a viewport border we do not want to see the lens flare in.
  52749. */
  52750. viewportBorder: number;
  52751. /**
  52752. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52753. */
  52754. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52755. /**
  52756. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52757. */
  52758. layerMask: number;
  52759. /**
  52760. * Define the id of the lens flare system in the scene.
  52761. * (equal to name by default)
  52762. */
  52763. id: string;
  52764. private _scene;
  52765. private _emitter;
  52766. private _vertexBuffers;
  52767. private _indexBuffer;
  52768. private _effect;
  52769. private _positionX;
  52770. private _positionY;
  52771. private _isEnabled;
  52772. /** @hidden */
  52773. static _SceneComponentInitialization: (scene: Scene) => void;
  52774. /**
  52775. * Instantiates a lens flare system.
  52776. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52777. * It is usually composed of several `lensFlare`.
  52778. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52779. * @param name Define the name of the lens flare system in the scene
  52780. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52781. * @param scene Define the scene the lens flare system belongs to
  52782. */
  52783. constructor(
  52784. /**
  52785. * Define the name of the lens flare system
  52786. */
  52787. name: string, emitter: any, scene: Scene);
  52788. /**
  52789. * Define if the lens flare system is enabled.
  52790. */
  52791. isEnabled: boolean;
  52792. /**
  52793. * Get the scene the effects belongs to.
  52794. * @returns the scene holding the lens flare system
  52795. */
  52796. getScene(): Scene;
  52797. /**
  52798. * Get the emitter of the lens flare system.
  52799. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52800. * @returns the emitter of the lens flare system
  52801. */
  52802. getEmitter(): any;
  52803. /**
  52804. * Set the emitter of the lens flare system.
  52805. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52806. * @param newEmitter Define the new emitter of the system
  52807. */
  52808. setEmitter(newEmitter: any): void;
  52809. /**
  52810. * Get the lens flare system emitter position.
  52811. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52812. * @returns the position
  52813. */
  52814. getEmitterPosition(): Vector3;
  52815. /**
  52816. * @hidden
  52817. */
  52818. computeEffectivePosition(globalViewport: Viewport): boolean;
  52819. /** @hidden */
  52820. _isVisible(): boolean;
  52821. /**
  52822. * @hidden
  52823. */
  52824. render(): boolean;
  52825. /**
  52826. * Dispose and release the lens flare with its associated resources.
  52827. */
  52828. dispose(): void;
  52829. /**
  52830. * Parse a lens flare system from a JSON repressentation
  52831. * @param parsedLensFlareSystem Define the JSON to parse
  52832. * @param scene Define the scene the parsed system should be instantiated in
  52833. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52834. * @returns the parsed system
  52835. */
  52836. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52837. /**
  52838. * Serialize the current Lens Flare System into a JSON representation.
  52839. * @returns the serialized JSON
  52840. */
  52841. serialize(): any;
  52842. }
  52843. }
  52844. declare module "babylonjs/LensFlares/lensFlare" {
  52845. import { Nullable } from "babylonjs/types";
  52846. import { Color3 } from "babylonjs/Maths/math.color";
  52847. import { Texture } from "babylonjs/Materials/Textures/texture";
  52848. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52849. /**
  52850. * This represents one of the lens effect in a `lensFlareSystem`.
  52851. * It controls one of the indiviual texture used in the effect.
  52852. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52853. */
  52854. export class LensFlare {
  52855. /**
  52856. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52857. */
  52858. size: number;
  52859. /**
  52860. * 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.
  52861. */
  52862. position: number;
  52863. /**
  52864. * Define the lens color.
  52865. */
  52866. color: Color3;
  52867. /**
  52868. * Define the lens texture.
  52869. */
  52870. texture: Nullable<Texture>;
  52871. /**
  52872. * Define the alpha mode to render this particular lens.
  52873. */
  52874. alphaMode: number;
  52875. private _system;
  52876. /**
  52877. * Creates a new Lens Flare.
  52878. * This represents one of the lens effect in a `lensFlareSystem`.
  52879. * It controls one of the indiviual texture used in the effect.
  52880. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52881. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52882. * @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.
  52883. * @param color Define the lens color
  52884. * @param imgUrl Define the lens texture url
  52885. * @param system Define the `lensFlareSystem` this flare is part of
  52886. * @returns The newly created Lens Flare
  52887. */
  52888. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52889. /**
  52890. * Instantiates a new Lens Flare.
  52891. * This represents one of the lens effect in a `lensFlareSystem`.
  52892. * It controls one of the indiviual texture used in the effect.
  52893. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52894. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52895. * @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.
  52896. * @param color Define the lens color
  52897. * @param imgUrl Define the lens texture url
  52898. * @param system Define the `lensFlareSystem` this flare is part of
  52899. */
  52900. constructor(
  52901. /**
  52902. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52903. */
  52904. size: number,
  52905. /**
  52906. * 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.
  52907. */
  52908. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52909. /**
  52910. * Dispose and release the lens flare with its associated resources.
  52911. */
  52912. dispose(): void;
  52913. }
  52914. }
  52915. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52916. import { Nullable } from "babylonjs/types";
  52917. import { Scene } from "babylonjs/scene";
  52918. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52919. import { AbstractScene } from "babylonjs/abstractScene";
  52920. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52921. module "babylonjs/abstractScene" {
  52922. interface AbstractScene {
  52923. /**
  52924. * The list of lens flare system added to the scene
  52925. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52926. */
  52927. lensFlareSystems: Array<LensFlareSystem>;
  52928. /**
  52929. * Removes the given lens flare system from this scene.
  52930. * @param toRemove The lens flare system to remove
  52931. * @returns The index of the removed lens flare system
  52932. */
  52933. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52934. /**
  52935. * Adds the given lens flare system to this scene
  52936. * @param newLensFlareSystem The lens flare system to add
  52937. */
  52938. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52939. /**
  52940. * Gets a lens flare system using its name
  52941. * @param name defines the name to look for
  52942. * @returns the lens flare system or null if not found
  52943. */
  52944. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52945. /**
  52946. * Gets a lens flare system using its id
  52947. * @param id defines the id to look for
  52948. * @returns the lens flare system or null if not found
  52949. */
  52950. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52951. }
  52952. }
  52953. /**
  52954. * Defines the lens flare scene component responsible to manage any lens flares
  52955. * in a given scene.
  52956. */
  52957. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52958. /**
  52959. * The component name helpfull to identify the component in the list of scene components.
  52960. */
  52961. readonly name: string;
  52962. /**
  52963. * The scene the component belongs to.
  52964. */
  52965. scene: Scene;
  52966. /**
  52967. * Creates a new instance of the component for the given scene
  52968. * @param scene Defines the scene to register the component in
  52969. */
  52970. constructor(scene: Scene);
  52971. /**
  52972. * Registers the component in a given scene
  52973. */
  52974. register(): void;
  52975. /**
  52976. * Rebuilds the elements related to this component in case of
  52977. * context lost for instance.
  52978. */
  52979. rebuild(): void;
  52980. /**
  52981. * Adds all the elements from the container to the scene
  52982. * @param container the container holding the elements
  52983. */
  52984. addFromContainer(container: AbstractScene): void;
  52985. /**
  52986. * Removes all the elements in the container from the scene
  52987. * @param container contains the elements to remove
  52988. * @param dispose if the removed element should be disposed (default: false)
  52989. */
  52990. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52991. /**
  52992. * Serializes the component data to the specified json object
  52993. * @param serializationObject The object to serialize to
  52994. */
  52995. serialize(serializationObject: any): void;
  52996. /**
  52997. * Disposes the component and the associated ressources.
  52998. */
  52999. dispose(): void;
  53000. private _draw;
  53001. }
  53002. }
  53003. declare module "babylonjs/LensFlares/index" {
  53004. export * from "babylonjs/LensFlares/lensFlare";
  53005. export * from "babylonjs/LensFlares/lensFlareSystem";
  53006. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53007. }
  53008. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53009. import { Scene } from "babylonjs/scene";
  53010. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53011. import { AbstractScene } from "babylonjs/abstractScene";
  53012. /**
  53013. * Defines the shadow generator component responsible to manage any shadow generators
  53014. * in a given scene.
  53015. */
  53016. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53017. /**
  53018. * The component name helpfull to identify the component in the list of scene components.
  53019. */
  53020. readonly name: string;
  53021. /**
  53022. * The scene the component belongs to.
  53023. */
  53024. scene: Scene;
  53025. /**
  53026. * Creates a new instance of the component for the given scene
  53027. * @param scene Defines the scene to register the component in
  53028. */
  53029. constructor(scene: Scene);
  53030. /**
  53031. * Registers the component in a given scene
  53032. */
  53033. register(): void;
  53034. /**
  53035. * Rebuilds the elements related to this component in case of
  53036. * context lost for instance.
  53037. */
  53038. rebuild(): void;
  53039. /**
  53040. * Serializes the component data to the specified json object
  53041. * @param serializationObject The object to serialize to
  53042. */
  53043. serialize(serializationObject: any): void;
  53044. /**
  53045. * Adds all the elements from the container to the scene
  53046. * @param container the container holding the elements
  53047. */
  53048. addFromContainer(container: AbstractScene): void;
  53049. /**
  53050. * Removes all the elements in the container from the scene
  53051. * @param container contains the elements to remove
  53052. * @param dispose if the removed element should be disposed (default: false)
  53053. */
  53054. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53055. /**
  53056. * Rebuilds the elements related to this component in case of
  53057. * context lost for instance.
  53058. */
  53059. dispose(): void;
  53060. private _gatherRenderTargets;
  53061. }
  53062. }
  53063. declare module "babylonjs/Lights/Shadows/index" {
  53064. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53065. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53066. }
  53067. declare module "babylonjs/Lights/pointLight" {
  53068. import { Scene } from "babylonjs/scene";
  53069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53071. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53072. import { Effect } from "babylonjs/Materials/effect";
  53073. /**
  53074. * A point light is a light defined by an unique point in world space.
  53075. * The light is emitted in every direction from this point.
  53076. * A good example of a point light is a standard light bulb.
  53077. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53078. */
  53079. export class PointLight extends ShadowLight {
  53080. private _shadowAngle;
  53081. /**
  53082. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53083. * This specifies what angle the shadow will use to be created.
  53084. *
  53085. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53086. */
  53087. /**
  53088. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53089. * This specifies what angle the shadow will use to be created.
  53090. *
  53091. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53092. */
  53093. shadowAngle: number;
  53094. /**
  53095. * Gets the direction if it has been set.
  53096. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53097. */
  53098. /**
  53099. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53100. */
  53101. direction: Vector3;
  53102. /**
  53103. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53104. * A PointLight emits the light in every direction.
  53105. * It can cast shadows.
  53106. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53107. * ```javascript
  53108. * var pointLight = new PointLight("pl", camera.position, scene);
  53109. * ```
  53110. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53111. * @param name The light friendly name
  53112. * @param position The position of the point light in the scene
  53113. * @param scene The scene the lights belongs to
  53114. */
  53115. constructor(name: string, position: Vector3, scene: Scene);
  53116. /**
  53117. * Returns the string "PointLight"
  53118. * @returns the class name
  53119. */
  53120. getClassName(): string;
  53121. /**
  53122. * Returns the integer 0.
  53123. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53124. */
  53125. getTypeID(): number;
  53126. /**
  53127. * Specifies wether or not the shadowmap should be a cube texture.
  53128. * @returns true if the shadowmap needs to be a cube texture.
  53129. */
  53130. needCube(): boolean;
  53131. /**
  53132. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53133. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53134. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53135. */
  53136. getShadowDirection(faceIndex?: number): Vector3;
  53137. /**
  53138. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53139. * - fov = PI / 2
  53140. * - aspect ratio : 1.0
  53141. * - z-near and far equal to the active camera minZ and maxZ.
  53142. * Returns the PointLight.
  53143. */
  53144. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53145. protected _buildUniformLayout(): void;
  53146. /**
  53147. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53148. * @param effect The effect to update
  53149. * @param lightIndex The index of the light in the effect to update
  53150. * @returns The point light
  53151. */
  53152. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53153. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53154. /**
  53155. * Prepares the list of defines specific to the light type.
  53156. * @param defines the list of defines
  53157. * @param lightIndex defines the index of the light for the effect
  53158. */
  53159. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53160. }
  53161. }
  53162. declare module "babylonjs/Lights/index" {
  53163. export * from "babylonjs/Lights/light";
  53164. export * from "babylonjs/Lights/shadowLight";
  53165. export * from "babylonjs/Lights/Shadows/index";
  53166. export * from "babylonjs/Lights/directionalLight";
  53167. export * from "babylonjs/Lights/hemisphericLight";
  53168. export * from "babylonjs/Lights/pointLight";
  53169. export * from "babylonjs/Lights/spotLight";
  53170. }
  53171. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53172. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53173. /**
  53174. * Header information of HDR texture files.
  53175. */
  53176. export interface HDRInfo {
  53177. /**
  53178. * The height of the texture in pixels.
  53179. */
  53180. height: number;
  53181. /**
  53182. * The width of the texture in pixels.
  53183. */
  53184. width: number;
  53185. /**
  53186. * The index of the beginning of the data in the binary file.
  53187. */
  53188. dataPosition: number;
  53189. }
  53190. /**
  53191. * This groups tools to convert HDR texture to native colors array.
  53192. */
  53193. export class HDRTools {
  53194. private static Ldexp;
  53195. private static Rgbe2float;
  53196. private static readStringLine;
  53197. /**
  53198. * Reads header information from an RGBE texture stored in a native array.
  53199. * More information on this format are available here:
  53200. * https://en.wikipedia.org/wiki/RGBE_image_format
  53201. *
  53202. * @param uint8array The binary file stored in native array.
  53203. * @return The header information.
  53204. */
  53205. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53206. /**
  53207. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53208. * This RGBE texture needs to store the information as a panorama.
  53209. *
  53210. * More information on this format are available here:
  53211. * https://en.wikipedia.org/wiki/RGBE_image_format
  53212. *
  53213. * @param buffer The binary file stored in an array buffer.
  53214. * @param size The expected size of the extracted cubemap.
  53215. * @return The Cube Map information.
  53216. */
  53217. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53218. /**
  53219. * Returns the pixels data extracted from an RGBE texture.
  53220. * This pixels will be stored left to right up to down in the R G B order in one array.
  53221. *
  53222. * More information on this format are available here:
  53223. * https://en.wikipedia.org/wiki/RGBE_image_format
  53224. *
  53225. * @param uint8array The binary file stored in an array buffer.
  53226. * @param hdrInfo The header information of the file.
  53227. * @return The pixels data in RGB right to left up to down order.
  53228. */
  53229. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53230. private static RGBE_ReadPixels_RLE;
  53231. }
  53232. }
  53233. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53234. import { Nullable } from "babylonjs/types";
  53235. import { Scene } from "babylonjs/scene";
  53236. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53238. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53239. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53240. /**
  53241. * This represents a texture coming from an HDR input.
  53242. *
  53243. * The only supported format is currently panorama picture stored in RGBE format.
  53244. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53245. */
  53246. export class HDRCubeTexture extends BaseTexture {
  53247. private static _facesMapping;
  53248. private _generateHarmonics;
  53249. private _noMipmap;
  53250. private _textureMatrix;
  53251. private _size;
  53252. private _onLoad;
  53253. private _onError;
  53254. /**
  53255. * The texture URL.
  53256. */
  53257. url: string;
  53258. /**
  53259. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53260. */
  53261. coordinatesMode: number;
  53262. protected _isBlocking: boolean;
  53263. /**
  53264. * Sets wether or not the texture is blocking during loading.
  53265. */
  53266. /**
  53267. * Gets wether or not the texture is blocking during loading.
  53268. */
  53269. isBlocking: boolean;
  53270. protected _rotationY: number;
  53271. /**
  53272. * Sets texture matrix rotation angle around Y axis in radians.
  53273. */
  53274. /**
  53275. * Gets texture matrix rotation angle around Y axis radians.
  53276. */
  53277. rotationY: number;
  53278. /**
  53279. * Gets or sets the center of the bounding box associated with the cube texture
  53280. * It must define where the camera used to render the texture was set
  53281. */
  53282. boundingBoxPosition: Vector3;
  53283. private _boundingBoxSize;
  53284. /**
  53285. * Gets or sets the size of the bounding box associated with the cube texture
  53286. * When defined, the cubemap will switch to local mode
  53287. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53288. * @example https://www.babylonjs-playground.com/#RNASML
  53289. */
  53290. boundingBoxSize: Vector3;
  53291. /**
  53292. * Instantiates an HDRTexture from the following parameters.
  53293. *
  53294. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53295. * @param scene The scene the texture will be used in
  53296. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53297. * @param noMipmap Forces to not generate the mipmap if true
  53298. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53299. * @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)
  53300. * @param reserved Reserved flag for internal use.
  53301. */
  53302. 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>);
  53303. /**
  53304. * Get the current class name of the texture useful for serialization or dynamic coding.
  53305. * @returns "HDRCubeTexture"
  53306. */
  53307. getClassName(): string;
  53308. /**
  53309. * Occurs when the file is raw .hdr file.
  53310. */
  53311. private loadTexture;
  53312. clone(): HDRCubeTexture;
  53313. delayLoad(): void;
  53314. /**
  53315. * Get the texture reflection matrix used to rotate/transform the reflection.
  53316. * @returns the reflection matrix
  53317. */
  53318. getReflectionTextureMatrix(): Matrix;
  53319. /**
  53320. * Set the texture reflection matrix used to rotate/transform the reflection.
  53321. * @param value Define the reflection matrix to set
  53322. */
  53323. setReflectionTextureMatrix(value: Matrix): void;
  53324. /**
  53325. * Parses a JSON representation of an HDR Texture in order to create the texture
  53326. * @param parsedTexture Define the JSON representation
  53327. * @param scene Define the scene the texture should be created in
  53328. * @param rootUrl Define the root url in case we need to load relative dependencies
  53329. * @returns the newly created texture after parsing
  53330. */
  53331. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53332. serialize(): any;
  53333. }
  53334. }
  53335. declare module "babylonjs/Physics/physicsEngine" {
  53336. import { Nullable } from "babylonjs/types";
  53337. import { Vector3 } from "babylonjs/Maths/math.vector";
  53338. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53339. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53340. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53341. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53342. /**
  53343. * Class used to control physics engine
  53344. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53345. */
  53346. export class PhysicsEngine implements IPhysicsEngine {
  53347. private _physicsPlugin;
  53348. /**
  53349. * Global value used to control the smallest number supported by the simulation
  53350. */
  53351. static Epsilon: number;
  53352. private _impostors;
  53353. private _joints;
  53354. /**
  53355. * Gets the gravity vector used by the simulation
  53356. */
  53357. gravity: Vector3;
  53358. /**
  53359. * Factory used to create the default physics plugin.
  53360. * @returns The default physics plugin
  53361. */
  53362. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53363. /**
  53364. * Creates a new Physics Engine
  53365. * @param gravity defines the gravity vector used by the simulation
  53366. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53367. */
  53368. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53369. /**
  53370. * Sets the gravity vector used by the simulation
  53371. * @param gravity defines the gravity vector to use
  53372. */
  53373. setGravity(gravity: Vector3): void;
  53374. /**
  53375. * Set the time step of the physics engine.
  53376. * Default is 1/60.
  53377. * To slow it down, enter 1/600 for example.
  53378. * To speed it up, 1/30
  53379. * @param newTimeStep defines the new timestep to apply to this world.
  53380. */
  53381. setTimeStep(newTimeStep?: number): void;
  53382. /**
  53383. * Get the time step of the physics engine.
  53384. * @returns the current time step
  53385. */
  53386. getTimeStep(): number;
  53387. /**
  53388. * Release all resources
  53389. */
  53390. dispose(): void;
  53391. /**
  53392. * Gets the name of the current physics plugin
  53393. * @returns the name of the plugin
  53394. */
  53395. getPhysicsPluginName(): string;
  53396. /**
  53397. * Adding a new impostor for the impostor tracking.
  53398. * This will be done by the impostor itself.
  53399. * @param impostor the impostor to add
  53400. */
  53401. addImpostor(impostor: PhysicsImpostor): void;
  53402. /**
  53403. * Remove an impostor from the engine.
  53404. * This impostor and its mesh will not longer be updated by the physics engine.
  53405. * @param impostor the impostor to remove
  53406. */
  53407. removeImpostor(impostor: PhysicsImpostor): void;
  53408. /**
  53409. * Add a joint to the physics engine
  53410. * @param mainImpostor defines the main impostor to which the joint is added.
  53411. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53412. * @param joint defines the joint that will connect both impostors.
  53413. */
  53414. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53415. /**
  53416. * Removes a joint from the simulation
  53417. * @param mainImpostor defines the impostor used with the joint
  53418. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53419. * @param joint defines the joint to remove
  53420. */
  53421. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53422. /**
  53423. * Called by the scene. No need to call it.
  53424. * @param delta defines the timespam between frames
  53425. */
  53426. _step(delta: number): void;
  53427. /**
  53428. * Gets the current plugin used to run the simulation
  53429. * @returns current plugin
  53430. */
  53431. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53432. /**
  53433. * Gets the list of physic impostors
  53434. * @returns an array of PhysicsImpostor
  53435. */
  53436. getImpostors(): Array<PhysicsImpostor>;
  53437. /**
  53438. * Gets the impostor for a physics enabled object
  53439. * @param object defines the object impersonated by the impostor
  53440. * @returns the PhysicsImpostor or null if not found
  53441. */
  53442. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53443. /**
  53444. * Gets the impostor for a physics body object
  53445. * @param body defines physics body used by the impostor
  53446. * @returns the PhysicsImpostor or null if not found
  53447. */
  53448. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53449. /**
  53450. * Does a raycast in the physics world
  53451. * @param from when should the ray start?
  53452. * @param to when should the ray end?
  53453. * @returns PhysicsRaycastResult
  53454. */
  53455. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53456. }
  53457. }
  53458. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53459. import { Nullable } from "babylonjs/types";
  53460. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53462. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53463. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53464. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53465. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53466. /** @hidden */
  53467. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53468. private _useDeltaForWorldStep;
  53469. world: any;
  53470. name: string;
  53471. private _physicsMaterials;
  53472. private _fixedTimeStep;
  53473. private _cannonRaycastResult;
  53474. private _raycastResult;
  53475. private _physicsBodysToRemoveAfterStep;
  53476. BJSCANNON: any;
  53477. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53478. setGravity(gravity: Vector3): void;
  53479. setTimeStep(timeStep: number): void;
  53480. getTimeStep(): number;
  53481. executeStep(delta: number): void;
  53482. private _removeMarkedPhysicsBodiesFromWorld;
  53483. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53484. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53485. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53486. private _processChildMeshes;
  53487. removePhysicsBody(impostor: PhysicsImpostor): void;
  53488. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53489. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53490. private _addMaterial;
  53491. private _checkWithEpsilon;
  53492. private _createShape;
  53493. private _createHeightmap;
  53494. private _minus90X;
  53495. private _plus90X;
  53496. private _tmpPosition;
  53497. private _tmpDeltaPosition;
  53498. private _tmpUnityRotation;
  53499. private _updatePhysicsBodyTransformation;
  53500. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53501. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53502. isSupported(): boolean;
  53503. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53504. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53505. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53506. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53507. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53508. getBodyMass(impostor: PhysicsImpostor): number;
  53509. getBodyFriction(impostor: PhysicsImpostor): number;
  53510. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53511. getBodyRestitution(impostor: PhysicsImpostor): number;
  53512. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53513. sleepBody(impostor: PhysicsImpostor): void;
  53514. wakeUpBody(impostor: PhysicsImpostor): void;
  53515. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53516. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53517. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53518. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53519. getRadius(impostor: PhysicsImpostor): number;
  53520. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53521. dispose(): void;
  53522. private _extendNamespace;
  53523. /**
  53524. * Does a raycast in the physics world
  53525. * @param from when should the ray start?
  53526. * @param to when should the ray end?
  53527. * @returns PhysicsRaycastResult
  53528. */
  53529. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53530. }
  53531. }
  53532. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53533. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53534. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53535. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53537. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53538. import { Nullable } from "babylonjs/types";
  53539. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53540. /** @hidden */
  53541. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53542. world: any;
  53543. name: string;
  53544. BJSOIMO: any;
  53545. private _raycastResult;
  53546. constructor(iterations?: number, oimoInjection?: any);
  53547. setGravity(gravity: Vector3): void;
  53548. setTimeStep(timeStep: number): void;
  53549. getTimeStep(): number;
  53550. private _tmpImpostorsArray;
  53551. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53552. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53553. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53554. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53555. private _tmpPositionVector;
  53556. removePhysicsBody(impostor: PhysicsImpostor): void;
  53557. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53558. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53559. isSupported(): boolean;
  53560. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53561. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53562. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53563. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53564. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53565. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53566. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53567. getBodyMass(impostor: PhysicsImpostor): number;
  53568. getBodyFriction(impostor: PhysicsImpostor): number;
  53569. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53570. getBodyRestitution(impostor: PhysicsImpostor): number;
  53571. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53572. sleepBody(impostor: PhysicsImpostor): void;
  53573. wakeUpBody(impostor: PhysicsImpostor): void;
  53574. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53575. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53576. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53577. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53578. getRadius(impostor: PhysicsImpostor): number;
  53579. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53580. dispose(): void;
  53581. /**
  53582. * Does a raycast in the physics world
  53583. * @param from when should the ray start?
  53584. * @param to when should the ray end?
  53585. * @returns PhysicsRaycastResult
  53586. */
  53587. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53588. }
  53589. }
  53590. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53591. import { Nullable } from "babylonjs/types";
  53592. import { Scene } from "babylonjs/scene";
  53593. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53594. import { Color4 } from "babylonjs/Maths/math.color";
  53595. import { Mesh } from "babylonjs/Meshes/mesh";
  53596. /**
  53597. * Class containing static functions to help procedurally build meshes
  53598. */
  53599. export class RibbonBuilder {
  53600. /**
  53601. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53602. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53603. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53604. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53605. * * 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
  53606. * * 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
  53607. * * 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
  53608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53610. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53611. * * 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
  53612. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53613. * * 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
  53614. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53616. * @param name defines the name of the mesh
  53617. * @param options defines the options used to create the mesh
  53618. * @param scene defines the hosting scene
  53619. * @returns the ribbon mesh
  53620. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53621. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53622. */
  53623. static CreateRibbon(name: string, options: {
  53624. pathArray: Vector3[][];
  53625. closeArray?: boolean;
  53626. closePath?: boolean;
  53627. offset?: number;
  53628. updatable?: boolean;
  53629. sideOrientation?: number;
  53630. frontUVs?: Vector4;
  53631. backUVs?: Vector4;
  53632. instance?: Mesh;
  53633. invertUV?: boolean;
  53634. uvs?: Vector2[];
  53635. colors?: Color4[];
  53636. }, scene?: Nullable<Scene>): Mesh;
  53637. }
  53638. }
  53639. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53640. import { Nullable } from "babylonjs/types";
  53641. import { Scene } from "babylonjs/scene";
  53642. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53643. import { Mesh } from "babylonjs/Meshes/mesh";
  53644. /**
  53645. * Class containing static functions to help procedurally build meshes
  53646. */
  53647. export class ShapeBuilder {
  53648. /**
  53649. * 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.
  53650. * * 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.
  53651. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53652. * * 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.
  53653. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53654. * * 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
  53655. * * 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
  53656. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53659. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53661. * @param name defines the name of the mesh
  53662. * @param options defines the options used to create the mesh
  53663. * @param scene defines the hosting scene
  53664. * @returns the extruded shape mesh
  53665. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53667. */
  53668. static ExtrudeShape(name: string, options: {
  53669. shape: Vector3[];
  53670. path: Vector3[];
  53671. scale?: number;
  53672. rotation?: number;
  53673. cap?: number;
  53674. updatable?: boolean;
  53675. sideOrientation?: number;
  53676. frontUVs?: Vector4;
  53677. backUVs?: Vector4;
  53678. instance?: Mesh;
  53679. invertUV?: boolean;
  53680. }, scene?: Nullable<Scene>): Mesh;
  53681. /**
  53682. * Creates an custom extruded shape mesh.
  53683. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53684. * * 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.
  53685. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53686. * * 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
  53687. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53688. * * 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
  53689. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53690. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53691. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53692. * * 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
  53693. * * 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
  53694. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53697. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53699. * @param name defines the name of the mesh
  53700. * @param options defines the options used to create the mesh
  53701. * @param scene defines the hosting scene
  53702. * @returns the custom extruded shape mesh
  53703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53704. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53706. */
  53707. static ExtrudeShapeCustom(name: string, options: {
  53708. shape: Vector3[];
  53709. path: Vector3[];
  53710. scaleFunction?: any;
  53711. rotationFunction?: any;
  53712. ribbonCloseArray?: boolean;
  53713. ribbonClosePath?: boolean;
  53714. cap?: number;
  53715. updatable?: boolean;
  53716. sideOrientation?: number;
  53717. frontUVs?: Vector4;
  53718. backUVs?: Vector4;
  53719. instance?: Mesh;
  53720. invertUV?: boolean;
  53721. }, scene?: Nullable<Scene>): Mesh;
  53722. private static _ExtrudeShapeGeneric;
  53723. }
  53724. }
  53725. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53726. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53727. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53728. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53729. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53730. import { Nullable } from "babylonjs/types";
  53731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53732. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53733. /**
  53734. * AmmoJS Physics plugin
  53735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53736. * @see https://github.com/kripken/ammo.js/
  53737. */
  53738. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53739. private _useDeltaForWorldStep;
  53740. /**
  53741. * Reference to the Ammo library
  53742. */
  53743. bjsAMMO: any;
  53744. /**
  53745. * Created ammoJS world which physics bodies are added to
  53746. */
  53747. world: any;
  53748. /**
  53749. * Name of the plugin
  53750. */
  53751. name: string;
  53752. private _timeStep;
  53753. private _fixedTimeStep;
  53754. private _maxSteps;
  53755. private _tmpQuaternion;
  53756. private _tmpAmmoTransform;
  53757. private _tmpAmmoQuaternion;
  53758. private _tmpAmmoConcreteContactResultCallback;
  53759. private _collisionConfiguration;
  53760. private _dispatcher;
  53761. private _overlappingPairCache;
  53762. private _solver;
  53763. private _softBodySolver;
  53764. private _tmpAmmoVectorA;
  53765. private _tmpAmmoVectorB;
  53766. private _tmpAmmoVectorC;
  53767. private _tmpAmmoVectorD;
  53768. private _tmpContactCallbackResult;
  53769. private _tmpAmmoVectorRCA;
  53770. private _tmpAmmoVectorRCB;
  53771. private _raycastResult;
  53772. private static readonly DISABLE_COLLISION_FLAG;
  53773. private static readonly KINEMATIC_FLAG;
  53774. private static readonly DISABLE_DEACTIVATION_FLAG;
  53775. /**
  53776. * Initializes the ammoJS plugin
  53777. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53778. * @param ammoInjection can be used to inject your own ammo reference
  53779. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53780. */
  53781. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53782. /**
  53783. * Sets the gravity of the physics world (m/(s^2))
  53784. * @param gravity Gravity to set
  53785. */
  53786. setGravity(gravity: Vector3): void;
  53787. /**
  53788. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53789. * @param timeStep timestep to use in seconds
  53790. */
  53791. setTimeStep(timeStep: number): void;
  53792. /**
  53793. * 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)
  53794. * @param fixedTimeStep fixedTimeStep to use in seconds
  53795. */
  53796. setFixedTimeStep(fixedTimeStep: number): void;
  53797. /**
  53798. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53799. * @param maxSteps the maximum number of steps by the physics engine per frame
  53800. */
  53801. setMaxSteps(maxSteps: number): void;
  53802. /**
  53803. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53804. * @returns the current timestep in seconds
  53805. */
  53806. getTimeStep(): number;
  53807. private _isImpostorInContact;
  53808. private _isImpostorPairInContact;
  53809. private _stepSimulation;
  53810. /**
  53811. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53812. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53813. * After the step the babylon meshes are set to the position of the physics imposters
  53814. * @param delta amount of time to step forward
  53815. * @param impostors array of imposters to update before/after the step
  53816. */
  53817. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53818. /**
  53819. * Update babylon mesh to match physics world object
  53820. * @param impostor imposter to match
  53821. */
  53822. private _afterSoftStep;
  53823. /**
  53824. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53825. * @param impostor imposter to match
  53826. */
  53827. private _ropeStep;
  53828. /**
  53829. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53830. * @param impostor imposter to match
  53831. */
  53832. private _softbodyOrClothStep;
  53833. private _tmpVector;
  53834. private _tmpMatrix;
  53835. /**
  53836. * Applies an impulse on the imposter
  53837. * @param impostor imposter to apply impulse to
  53838. * @param force amount of force to be applied to the imposter
  53839. * @param contactPoint the location to apply the impulse on the imposter
  53840. */
  53841. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53842. /**
  53843. * Applies a force on the imposter
  53844. * @param impostor imposter to apply force
  53845. * @param force amount of force to be applied to the imposter
  53846. * @param contactPoint the location to apply the force on the imposter
  53847. */
  53848. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53849. /**
  53850. * Creates a physics body using the plugin
  53851. * @param impostor the imposter to create the physics body on
  53852. */
  53853. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53854. /**
  53855. * Removes the physics body from the imposter and disposes of the body's memory
  53856. * @param impostor imposter to remove the physics body from
  53857. */
  53858. removePhysicsBody(impostor: PhysicsImpostor): void;
  53859. /**
  53860. * Generates a joint
  53861. * @param impostorJoint the imposter joint to create the joint with
  53862. */
  53863. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53864. /**
  53865. * Removes a joint
  53866. * @param impostorJoint the imposter joint to remove the joint from
  53867. */
  53868. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53869. private _addMeshVerts;
  53870. /**
  53871. * Initialise the soft body vertices to match its object's (mesh) vertices
  53872. * Softbody vertices (nodes) are in world space and to match this
  53873. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53874. * @param impostor to create the softbody for
  53875. */
  53876. private _softVertexData;
  53877. /**
  53878. * Create an impostor's soft body
  53879. * @param impostor to create the softbody for
  53880. */
  53881. private _createSoftbody;
  53882. /**
  53883. * Create cloth for an impostor
  53884. * @param impostor to create the softbody for
  53885. */
  53886. private _createCloth;
  53887. /**
  53888. * Create rope for an impostor
  53889. * @param impostor to create the softbody for
  53890. */
  53891. private _createRope;
  53892. private _addHullVerts;
  53893. private _createShape;
  53894. /**
  53895. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53896. * @param impostor imposter containing the physics body and babylon object
  53897. */
  53898. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53899. /**
  53900. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53901. * @param impostor imposter containing the physics body and babylon object
  53902. * @param newPosition new position
  53903. * @param newRotation new rotation
  53904. */
  53905. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53906. /**
  53907. * If this plugin is supported
  53908. * @returns true if its supported
  53909. */
  53910. isSupported(): boolean;
  53911. /**
  53912. * Sets the linear velocity of the physics body
  53913. * @param impostor imposter to set the velocity on
  53914. * @param velocity velocity to set
  53915. */
  53916. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53917. /**
  53918. * Sets the angular velocity of the physics body
  53919. * @param impostor imposter to set the velocity on
  53920. * @param velocity velocity to set
  53921. */
  53922. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53923. /**
  53924. * gets the linear velocity
  53925. * @param impostor imposter to get linear velocity from
  53926. * @returns linear velocity
  53927. */
  53928. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53929. /**
  53930. * gets the angular velocity
  53931. * @param impostor imposter to get angular velocity from
  53932. * @returns angular velocity
  53933. */
  53934. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53935. /**
  53936. * Sets the mass of physics body
  53937. * @param impostor imposter to set the mass on
  53938. * @param mass mass to set
  53939. */
  53940. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53941. /**
  53942. * Gets the mass of the physics body
  53943. * @param impostor imposter to get the mass from
  53944. * @returns mass
  53945. */
  53946. getBodyMass(impostor: PhysicsImpostor): number;
  53947. /**
  53948. * Gets friction of the impostor
  53949. * @param impostor impostor to get friction from
  53950. * @returns friction value
  53951. */
  53952. getBodyFriction(impostor: PhysicsImpostor): number;
  53953. /**
  53954. * Sets friction of the impostor
  53955. * @param impostor impostor to set friction on
  53956. * @param friction friction value
  53957. */
  53958. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53959. /**
  53960. * Gets restitution of the impostor
  53961. * @param impostor impostor to get restitution from
  53962. * @returns restitution value
  53963. */
  53964. getBodyRestitution(impostor: PhysicsImpostor): number;
  53965. /**
  53966. * Sets resitution of the impostor
  53967. * @param impostor impostor to set resitution on
  53968. * @param restitution resitution value
  53969. */
  53970. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53971. /**
  53972. * Gets pressure inside the impostor
  53973. * @param impostor impostor to get pressure from
  53974. * @returns pressure value
  53975. */
  53976. getBodyPressure(impostor: PhysicsImpostor): number;
  53977. /**
  53978. * Sets pressure inside a soft body impostor
  53979. * Cloth and rope must remain 0 pressure
  53980. * @param impostor impostor to set pressure on
  53981. * @param pressure pressure value
  53982. */
  53983. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53984. /**
  53985. * Gets stiffness of the impostor
  53986. * @param impostor impostor to get stiffness from
  53987. * @returns pressure value
  53988. */
  53989. getBodyStiffness(impostor: PhysicsImpostor): number;
  53990. /**
  53991. * Sets stiffness of the impostor
  53992. * @param impostor impostor to set stiffness on
  53993. * @param stiffness stiffness value from 0 to 1
  53994. */
  53995. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53996. /**
  53997. * Gets velocityIterations of the impostor
  53998. * @param impostor impostor to get velocity iterations from
  53999. * @returns velocityIterations value
  54000. */
  54001. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54002. /**
  54003. * Sets velocityIterations of the impostor
  54004. * @param impostor impostor to set velocity iterations on
  54005. * @param velocityIterations velocityIterations value
  54006. */
  54007. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54008. /**
  54009. * Gets positionIterations of the impostor
  54010. * @param impostor impostor to get position iterations from
  54011. * @returns positionIterations value
  54012. */
  54013. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54014. /**
  54015. * Sets positionIterations of the impostor
  54016. * @param impostor impostor to set position on
  54017. * @param positionIterations positionIterations value
  54018. */
  54019. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54020. /**
  54021. * Append an anchor to a cloth object
  54022. * @param impostor is the cloth impostor to add anchor to
  54023. * @param otherImpostor is the rigid impostor to anchor to
  54024. * @param width ratio across width from 0 to 1
  54025. * @param height ratio up height from 0 to 1
  54026. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54027. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54028. */
  54029. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54030. /**
  54031. * Append an hook to a rope object
  54032. * @param impostor is the rope impostor to add hook to
  54033. * @param otherImpostor is the rigid impostor to hook to
  54034. * @param length ratio along the rope from 0 to 1
  54035. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54036. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54037. */
  54038. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54039. /**
  54040. * Sleeps the physics body and stops it from being active
  54041. * @param impostor impostor to sleep
  54042. */
  54043. sleepBody(impostor: PhysicsImpostor): void;
  54044. /**
  54045. * Activates the physics body
  54046. * @param impostor impostor to activate
  54047. */
  54048. wakeUpBody(impostor: PhysicsImpostor): void;
  54049. /**
  54050. * Updates the distance parameters of the joint
  54051. * @param joint joint to update
  54052. * @param maxDistance maximum distance of the joint
  54053. * @param minDistance minimum distance of the joint
  54054. */
  54055. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54056. /**
  54057. * Sets a motor on the joint
  54058. * @param joint joint to set motor on
  54059. * @param speed speed of the motor
  54060. * @param maxForce maximum force of the motor
  54061. * @param motorIndex index of the motor
  54062. */
  54063. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54064. /**
  54065. * Sets the motors limit
  54066. * @param joint joint to set limit on
  54067. * @param upperLimit upper limit
  54068. * @param lowerLimit lower limit
  54069. */
  54070. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54071. /**
  54072. * Syncs the position and rotation of a mesh with the impostor
  54073. * @param mesh mesh to sync
  54074. * @param impostor impostor to update the mesh with
  54075. */
  54076. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54077. /**
  54078. * Gets the radius of the impostor
  54079. * @param impostor impostor to get radius from
  54080. * @returns the radius
  54081. */
  54082. getRadius(impostor: PhysicsImpostor): number;
  54083. /**
  54084. * Gets the box size of the impostor
  54085. * @param impostor impostor to get box size from
  54086. * @param result the resulting box size
  54087. */
  54088. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54089. /**
  54090. * Disposes of the impostor
  54091. */
  54092. dispose(): void;
  54093. /**
  54094. * Does a raycast in the physics world
  54095. * @param from when should the ray start?
  54096. * @param to when should the ray end?
  54097. * @returns PhysicsRaycastResult
  54098. */
  54099. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54100. }
  54101. }
  54102. declare module "babylonjs/Probes/reflectionProbe" {
  54103. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54104. import { Vector3 } from "babylonjs/Maths/math.vector";
  54105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54106. import { Nullable } from "babylonjs/types";
  54107. import { Scene } from "babylonjs/scene";
  54108. module "babylonjs/abstractScene" {
  54109. interface AbstractScene {
  54110. /**
  54111. * The list of reflection probes added to the scene
  54112. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54113. */
  54114. reflectionProbes: Array<ReflectionProbe>;
  54115. /**
  54116. * Removes the given reflection probe from this scene.
  54117. * @param toRemove The reflection probe to remove
  54118. * @returns The index of the removed reflection probe
  54119. */
  54120. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54121. /**
  54122. * Adds the given reflection probe to this scene.
  54123. * @param newReflectionProbe The reflection probe to add
  54124. */
  54125. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54126. }
  54127. }
  54128. /**
  54129. * Class used to generate realtime reflection / refraction cube textures
  54130. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54131. */
  54132. export class ReflectionProbe {
  54133. /** defines the name of the probe */
  54134. name: string;
  54135. private _scene;
  54136. private _renderTargetTexture;
  54137. private _projectionMatrix;
  54138. private _viewMatrix;
  54139. private _target;
  54140. private _add;
  54141. private _attachedMesh;
  54142. private _invertYAxis;
  54143. /** Gets or sets probe position (center of the cube map) */
  54144. position: Vector3;
  54145. /**
  54146. * Creates a new reflection probe
  54147. * @param name defines the name of the probe
  54148. * @param size defines the texture resolution (for each face)
  54149. * @param scene defines the hosting scene
  54150. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54151. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54152. */
  54153. constructor(
  54154. /** defines the name of the probe */
  54155. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54156. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54157. samples: number;
  54158. /** Gets or sets the refresh rate to use (on every frame by default) */
  54159. refreshRate: number;
  54160. /**
  54161. * Gets the hosting scene
  54162. * @returns a Scene
  54163. */
  54164. getScene(): Scene;
  54165. /** Gets the internal CubeTexture used to render to */
  54166. readonly cubeTexture: RenderTargetTexture;
  54167. /** Gets the list of meshes to render */
  54168. readonly renderList: Nullable<AbstractMesh[]>;
  54169. /**
  54170. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54171. * @param mesh defines the mesh to attach to
  54172. */
  54173. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54174. /**
  54175. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54176. * @param renderingGroupId The rendering group id corresponding to its index
  54177. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54178. */
  54179. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54180. /**
  54181. * Clean all associated resources
  54182. */
  54183. dispose(): void;
  54184. /**
  54185. * Converts the reflection probe information to a readable string for debug purpose.
  54186. * @param fullDetails Supports for multiple levels of logging within scene loading
  54187. * @returns the human readable reflection probe info
  54188. */
  54189. toString(fullDetails?: boolean): string;
  54190. /**
  54191. * Get the class name of the relfection probe.
  54192. * @returns "ReflectionProbe"
  54193. */
  54194. getClassName(): string;
  54195. /**
  54196. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54197. * @returns The JSON representation of the texture
  54198. */
  54199. serialize(): any;
  54200. /**
  54201. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54202. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54203. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54204. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54205. * @returns The parsed reflection probe if successful
  54206. */
  54207. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54208. }
  54209. }
  54210. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54211. /** @hidden */
  54212. export var _BabylonLoaderRegistered: boolean;
  54213. }
  54214. declare module "babylonjs/Loading/Plugins/index" {
  54215. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54216. }
  54217. declare module "babylonjs/Loading/index" {
  54218. export * from "babylonjs/Loading/loadingScreen";
  54219. export * from "babylonjs/Loading/Plugins/index";
  54220. export * from "babylonjs/Loading/sceneLoader";
  54221. export * from "babylonjs/Loading/sceneLoaderFlags";
  54222. }
  54223. declare module "babylonjs/Materials/Background/index" {
  54224. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54225. }
  54226. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54227. import { Scene } from "babylonjs/scene";
  54228. import { Color3 } from "babylonjs/Maths/math.color";
  54229. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54230. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54231. /**
  54232. * The Physically based simple base material of BJS.
  54233. *
  54234. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54235. * It is used as the base class for both the specGloss and metalRough conventions.
  54236. */
  54237. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54238. /**
  54239. * Number of Simultaneous lights allowed on the material.
  54240. */
  54241. maxSimultaneousLights: number;
  54242. /**
  54243. * If sets to true, disables all the lights affecting the material.
  54244. */
  54245. disableLighting: boolean;
  54246. /**
  54247. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54248. */
  54249. environmentTexture: BaseTexture;
  54250. /**
  54251. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54252. */
  54253. invertNormalMapX: boolean;
  54254. /**
  54255. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54256. */
  54257. invertNormalMapY: boolean;
  54258. /**
  54259. * Normal map used in the model.
  54260. */
  54261. normalTexture: BaseTexture;
  54262. /**
  54263. * Emissivie color used to self-illuminate the model.
  54264. */
  54265. emissiveColor: Color3;
  54266. /**
  54267. * Emissivie texture used to self-illuminate the model.
  54268. */
  54269. emissiveTexture: BaseTexture;
  54270. /**
  54271. * Occlusion Channel Strenght.
  54272. */
  54273. occlusionStrength: number;
  54274. /**
  54275. * Occlusion Texture of the material (adding extra occlusion effects).
  54276. */
  54277. occlusionTexture: BaseTexture;
  54278. /**
  54279. * Defines the alpha limits in alpha test mode.
  54280. */
  54281. alphaCutOff: number;
  54282. /**
  54283. * Gets the current double sided mode.
  54284. */
  54285. /**
  54286. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54287. */
  54288. doubleSided: boolean;
  54289. /**
  54290. * Stores the pre-calculated light information of a mesh in a texture.
  54291. */
  54292. lightmapTexture: BaseTexture;
  54293. /**
  54294. * If true, the light map contains occlusion information instead of lighting info.
  54295. */
  54296. useLightmapAsShadowmap: boolean;
  54297. /**
  54298. * Instantiates a new PBRMaterial instance.
  54299. *
  54300. * @param name The material name
  54301. * @param scene The scene the material will be use in.
  54302. */
  54303. constructor(name: string, scene: Scene);
  54304. getClassName(): string;
  54305. }
  54306. }
  54307. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54308. import { Scene } from "babylonjs/scene";
  54309. import { Color3 } from "babylonjs/Maths/math.color";
  54310. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54311. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54312. /**
  54313. * The PBR material of BJS following the metal roughness convention.
  54314. *
  54315. * This fits to the PBR convention in the GLTF definition:
  54316. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54317. */
  54318. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54319. /**
  54320. * The base color has two different interpretations depending on the value of metalness.
  54321. * When the material is a metal, the base color is the specific measured reflectance value
  54322. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54323. * of the material.
  54324. */
  54325. baseColor: Color3;
  54326. /**
  54327. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54328. * well as opacity information in the alpha channel.
  54329. */
  54330. baseTexture: BaseTexture;
  54331. /**
  54332. * Specifies the metallic scalar value of the material.
  54333. * Can also be used to scale the metalness values of the metallic texture.
  54334. */
  54335. metallic: number;
  54336. /**
  54337. * Specifies the roughness scalar value of the material.
  54338. * Can also be used to scale the roughness values of the metallic texture.
  54339. */
  54340. roughness: number;
  54341. /**
  54342. * Texture containing both the metallic value in the B channel and the
  54343. * roughness value in the G channel to keep better precision.
  54344. */
  54345. metallicRoughnessTexture: BaseTexture;
  54346. /**
  54347. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54348. *
  54349. * @param name The material name
  54350. * @param scene The scene the material will be use in.
  54351. */
  54352. constructor(name: string, scene: Scene);
  54353. /**
  54354. * Return the currrent class name of the material.
  54355. */
  54356. getClassName(): string;
  54357. /**
  54358. * Makes a duplicate of the current material.
  54359. * @param name - name to use for the new material.
  54360. */
  54361. clone(name: string): PBRMetallicRoughnessMaterial;
  54362. /**
  54363. * Serialize the material to a parsable JSON object.
  54364. */
  54365. serialize(): any;
  54366. /**
  54367. * Parses a JSON object correponding to the serialize function.
  54368. */
  54369. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54370. }
  54371. }
  54372. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54373. import { Scene } from "babylonjs/scene";
  54374. import { Color3 } from "babylonjs/Maths/math.color";
  54375. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54376. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54377. /**
  54378. * The PBR material of BJS following the specular glossiness convention.
  54379. *
  54380. * This fits to the PBR convention in the GLTF definition:
  54381. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54382. */
  54383. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54384. /**
  54385. * Specifies the diffuse color of the material.
  54386. */
  54387. diffuseColor: Color3;
  54388. /**
  54389. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54390. * channel.
  54391. */
  54392. diffuseTexture: BaseTexture;
  54393. /**
  54394. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54395. */
  54396. specularColor: Color3;
  54397. /**
  54398. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54399. */
  54400. glossiness: number;
  54401. /**
  54402. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54403. */
  54404. specularGlossinessTexture: BaseTexture;
  54405. /**
  54406. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54407. *
  54408. * @param name The material name
  54409. * @param scene The scene the material will be use in.
  54410. */
  54411. constructor(name: string, scene: Scene);
  54412. /**
  54413. * Return the currrent class name of the material.
  54414. */
  54415. getClassName(): string;
  54416. /**
  54417. * Makes a duplicate of the current material.
  54418. * @param name - name to use for the new material.
  54419. */
  54420. clone(name: string): PBRSpecularGlossinessMaterial;
  54421. /**
  54422. * Serialize the material to a parsable JSON object.
  54423. */
  54424. serialize(): any;
  54425. /**
  54426. * Parses a JSON object correponding to the serialize function.
  54427. */
  54428. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54429. }
  54430. }
  54431. declare module "babylonjs/Materials/PBR/index" {
  54432. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54433. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54434. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54435. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54436. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54437. }
  54438. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54439. import { Nullable } from "babylonjs/types";
  54440. import { Scene } from "babylonjs/scene";
  54441. import { Matrix } from "babylonjs/Maths/math.vector";
  54442. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54443. /**
  54444. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54445. * It can help converting any input color in a desired output one. This can then be used to create effects
  54446. * from sepia, black and white to sixties or futuristic rendering...
  54447. *
  54448. * The only supported format is currently 3dl.
  54449. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54450. */
  54451. export class ColorGradingTexture extends BaseTexture {
  54452. /**
  54453. * The current texture matrix. (will always be identity in color grading texture)
  54454. */
  54455. private _textureMatrix;
  54456. /**
  54457. * The texture URL.
  54458. */
  54459. url: string;
  54460. /**
  54461. * Empty line regex stored for GC.
  54462. */
  54463. private static _noneEmptyLineRegex;
  54464. private _engine;
  54465. /**
  54466. * Instantiates a ColorGradingTexture from the following parameters.
  54467. *
  54468. * @param url The location of the color gradind data (currently only supporting 3dl)
  54469. * @param scene The scene the texture will be used in
  54470. */
  54471. constructor(url: string, scene: Scene);
  54472. /**
  54473. * Returns the texture matrix used in most of the material.
  54474. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54475. */
  54476. getTextureMatrix(): Matrix;
  54477. /**
  54478. * Occurs when the file being loaded is a .3dl LUT file.
  54479. */
  54480. private load3dlTexture;
  54481. /**
  54482. * Starts the loading process of the texture.
  54483. */
  54484. private loadTexture;
  54485. /**
  54486. * Clones the color gradind texture.
  54487. */
  54488. clone(): ColorGradingTexture;
  54489. /**
  54490. * Called during delayed load for textures.
  54491. */
  54492. delayLoad(): void;
  54493. /**
  54494. * Parses a color grading texture serialized by Babylon.
  54495. * @param parsedTexture The texture information being parsedTexture
  54496. * @param scene The scene to load the texture in
  54497. * @param rootUrl The root url of the data assets to load
  54498. * @return A color gradind texture
  54499. */
  54500. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54501. /**
  54502. * Serializes the LUT texture to json format.
  54503. */
  54504. serialize(): any;
  54505. }
  54506. }
  54507. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54509. import { Scene } from "babylonjs/scene";
  54510. import { Nullable } from "babylonjs/types";
  54511. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54512. /**
  54513. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54514. */
  54515. export class EquiRectangularCubeTexture extends BaseTexture {
  54516. /** The six faces of the cube. */
  54517. private static _FacesMapping;
  54518. private _noMipmap;
  54519. private _onLoad;
  54520. private _onError;
  54521. /** The size of the cubemap. */
  54522. private _size;
  54523. /** The buffer of the image. */
  54524. private _buffer;
  54525. /** The width of the input image. */
  54526. private _width;
  54527. /** The height of the input image. */
  54528. private _height;
  54529. /** The URL to the image. */
  54530. url: string;
  54531. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54532. coordinatesMode: number;
  54533. /**
  54534. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54535. * @param url The location of the image
  54536. * @param scene The scene the texture will be used in
  54537. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54538. * @param noMipmap Forces to not generate the mipmap if true
  54539. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54540. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54541. * @param onLoad — defines a callback called when texture is loaded
  54542. * @param onError — defines a callback called if there is an error
  54543. */
  54544. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54545. /**
  54546. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54547. */
  54548. private loadImage;
  54549. /**
  54550. * Convert the image buffer into a cubemap and create a CubeTexture.
  54551. */
  54552. private loadTexture;
  54553. /**
  54554. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54555. * @param buffer The ArrayBuffer that should be converted.
  54556. * @returns The buffer as Float32Array.
  54557. */
  54558. private getFloat32ArrayFromArrayBuffer;
  54559. /**
  54560. * Get the current class name of the texture useful for serialization or dynamic coding.
  54561. * @returns "EquiRectangularCubeTexture"
  54562. */
  54563. getClassName(): string;
  54564. /**
  54565. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54566. * @returns A clone of the current EquiRectangularCubeTexture.
  54567. */
  54568. clone(): EquiRectangularCubeTexture;
  54569. }
  54570. }
  54571. declare module "babylonjs/Misc/tga" {
  54572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54573. /**
  54574. * Based on jsTGALoader - Javascript loader for TGA file
  54575. * By Vincent Thibault
  54576. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54577. */
  54578. export class TGATools {
  54579. private static _TYPE_INDEXED;
  54580. private static _TYPE_RGB;
  54581. private static _TYPE_GREY;
  54582. private static _TYPE_RLE_INDEXED;
  54583. private static _TYPE_RLE_RGB;
  54584. private static _TYPE_RLE_GREY;
  54585. private static _ORIGIN_MASK;
  54586. private static _ORIGIN_SHIFT;
  54587. private static _ORIGIN_BL;
  54588. private static _ORIGIN_BR;
  54589. private static _ORIGIN_UL;
  54590. private static _ORIGIN_UR;
  54591. /**
  54592. * Gets the header of a TGA file
  54593. * @param data defines the TGA data
  54594. * @returns the header
  54595. */
  54596. static GetTGAHeader(data: Uint8Array): any;
  54597. /**
  54598. * Uploads TGA content to a Babylon Texture
  54599. * @hidden
  54600. */
  54601. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54602. /** @hidden */
  54603. 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;
  54604. /** @hidden */
  54605. 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;
  54606. /** @hidden */
  54607. 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;
  54608. /** @hidden */
  54609. 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;
  54610. /** @hidden */
  54611. 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;
  54612. /** @hidden */
  54613. 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;
  54614. }
  54615. }
  54616. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54617. import { Nullable } from "babylonjs/types";
  54618. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54619. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54620. /**
  54621. * Implementation of the TGA Texture Loader.
  54622. * @hidden
  54623. */
  54624. export class _TGATextureLoader implements IInternalTextureLoader {
  54625. /**
  54626. * Defines wether the loader supports cascade loading the different faces.
  54627. */
  54628. readonly supportCascades: boolean;
  54629. /**
  54630. * This returns if the loader support the current file information.
  54631. * @param extension defines the file extension of the file being loaded
  54632. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54633. * @param fallback defines the fallback internal texture if any
  54634. * @param isBase64 defines whether the texture is encoded as a base64
  54635. * @param isBuffer defines whether the texture data are stored as a buffer
  54636. * @returns true if the loader can load the specified file
  54637. */
  54638. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54639. /**
  54640. * Transform the url before loading if required.
  54641. * @param rootUrl the url of the texture
  54642. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54643. * @returns the transformed texture
  54644. */
  54645. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54646. /**
  54647. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54648. * @param rootUrl the url of the texture
  54649. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54650. * @returns the fallback texture
  54651. */
  54652. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54653. /**
  54654. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54655. * @param data contains the texture data
  54656. * @param texture defines the BabylonJS internal texture
  54657. * @param createPolynomials will be true if polynomials have been requested
  54658. * @param onLoad defines the callback to trigger once the texture is ready
  54659. * @param onError defines the callback to trigger in case of error
  54660. */
  54661. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54662. /**
  54663. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54664. * @param data contains the texture data
  54665. * @param texture defines the BabylonJS internal texture
  54666. * @param callback defines the method to call once ready to upload
  54667. */
  54668. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54669. }
  54670. }
  54671. declare module "babylonjs/Misc/basis" {
  54672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54673. /**
  54674. * Info about the .basis files
  54675. */
  54676. class BasisFileInfo {
  54677. /**
  54678. * If the file has alpha
  54679. */
  54680. hasAlpha: boolean;
  54681. /**
  54682. * Info about each image of the basis file
  54683. */
  54684. images: Array<{
  54685. levels: Array<{
  54686. width: number;
  54687. height: number;
  54688. transcodedPixels: ArrayBufferView;
  54689. }>;
  54690. }>;
  54691. }
  54692. /**
  54693. * Result of transcoding a basis file
  54694. */
  54695. class TranscodeResult {
  54696. /**
  54697. * Info about the .basis file
  54698. */
  54699. fileInfo: BasisFileInfo;
  54700. /**
  54701. * Format to use when loading the file
  54702. */
  54703. format: number;
  54704. }
  54705. /**
  54706. * Configuration options for the Basis transcoder
  54707. */
  54708. export class BasisTranscodeConfiguration {
  54709. /**
  54710. * Supported compression formats used to determine the supported output format of the transcoder
  54711. */
  54712. supportedCompressionFormats?: {
  54713. /**
  54714. * etc1 compression format
  54715. */
  54716. etc1?: boolean;
  54717. /**
  54718. * s3tc compression format
  54719. */
  54720. s3tc?: boolean;
  54721. /**
  54722. * pvrtc compression format
  54723. */
  54724. pvrtc?: boolean;
  54725. /**
  54726. * etc2 compression format
  54727. */
  54728. etc2?: boolean;
  54729. };
  54730. /**
  54731. * If mipmap levels should be loaded for transcoded images (Default: true)
  54732. */
  54733. loadMipmapLevels?: boolean;
  54734. /**
  54735. * Index of a single image to load (Default: all images)
  54736. */
  54737. loadSingleImage?: number;
  54738. }
  54739. /**
  54740. * Used to load .Basis files
  54741. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54742. */
  54743. export class BasisTools {
  54744. private static _IgnoreSupportedFormats;
  54745. /**
  54746. * URL to use when loading the basis transcoder
  54747. */
  54748. static JSModuleURL: string;
  54749. /**
  54750. * URL to use when loading the wasm module for the transcoder
  54751. */
  54752. static WasmModuleURL: string;
  54753. /**
  54754. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54755. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54756. * @returns internal format corresponding to the Basis format
  54757. */
  54758. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54759. private static _WorkerPromise;
  54760. private static _Worker;
  54761. private static _actionId;
  54762. private static _CreateWorkerAsync;
  54763. /**
  54764. * Transcodes a loaded image file to compressed pixel data
  54765. * @param imageData image data to transcode
  54766. * @param config configuration options for the transcoding
  54767. * @returns a promise resulting in the transcoded image
  54768. */
  54769. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54770. /**
  54771. * Loads a texture from the transcode result
  54772. * @param texture texture load to
  54773. * @param transcodeResult the result of transcoding the basis file to load from
  54774. */
  54775. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54776. }
  54777. }
  54778. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54779. import { Nullable } from "babylonjs/types";
  54780. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54781. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54782. /**
  54783. * Loader for .basis file format
  54784. */
  54785. export class _BasisTextureLoader implements IInternalTextureLoader {
  54786. /**
  54787. * Defines whether the loader supports cascade loading the different faces.
  54788. */
  54789. readonly supportCascades: boolean;
  54790. /**
  54791. * This returns if the loader support the current file information.
  54792. * @param extension defines the file extension of the file being loaded
  54793. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54794. * @param fallback defines the fallback internal texture if any
  54795. * @param isBase64 defines whether the texture is encoded as a base64
  54796. * @param isBuffer defines whether the texture data are stored as a buffer
  54797. * @returns true if the loader can load the specified file
  54798. */
  54799. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54800. /**
  54801. * Transform the url before loading if required.
  54802. * @param rootUrl the url of the texture
  54803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54804. * @returns the transformed texture
  54805. */
  54806. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54807. /**
  54808. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54809. * @param rootUrl the url of the texture
  54810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54811. * @returns the fallback texture
  54812. */
  54813. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54814. /**
  54815. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54816. * @param data contains the texture data
  54817. * @param texture defines the BabylonJS internal texture
  54818. * @param createPolynomials will be true if polynomials have been requested
  54819. * @param onLoad defines the callback to trigger once the texture is ready
  54820. * @param onError defines the callback to trigger in case of error
  54821. */
  54822. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54823. /**
  54824. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54825. * @param data contains the texture data
  54826. * @param texture defines the BabylonJS internal texture
  54827. * @param callback defines the method to call once ready to upload
  54828. */
  54829. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54830. }
  54831. }
  54832. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54833. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54834. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54835. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54836. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54837. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54838. }
  54839. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54840. import { Scene } from "babylonjs/scene";
  54841. import { Texture } from "babylonjs/Materials/Textures/texture";
  54842. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54843. /**
  54844. * 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.
  54845. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54846. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54847. */
  54848. export class CustomProceduralTexture extends ProceduralTexture {
  54849. private _animate;
  54850. private _time;
  54851. private _config;
  54852. private _texturePath;
  54853. /**
  54854. * Instantiates a new Custom Procedural Texture.
  54855. * 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.
  54856. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54857. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54858. * @param name Define the name of the texture
  54859. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54860. * @param size Define the size of the texture to create
  54861. * @param scene Define the scene the texture belongs to
  54862. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54863. * @param generateMipMaps Define if the texture should creates mip maps or not
  54864. */
  54865. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54866. private _loadJson;
  54867. /**
  54868. * Is the texture ready to be used ? (rendered at least once)
  54869. * @returns true if ready, otherwise, false.
  54870. */
  54871. isReady(): boolean;
  54872. /**
  54873. * Render the texture to its associated render target.
  54874. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54875. */
  54876. render(useCameraPostProcess?: boolean): void;
  54877. /**
  54878. * Update the list of dependant textures samplers in the shader.
  54879. */
  54880. updateTextures(): void;
  54881. /**
  54882. * Update the uniform values of the procedural texture in the shader.
  54883. */
  54884. updateShaderUniforms(): void;
  54885. /**
  54886. * Define if the texture animates or not.
  54887. */
  54888. animate: boolean;
  54889. }
  54890. }
  54891. declare module "babylonjs/Shaders/noise.fragment" {
  54892. /** @hidden */
  54893. export var noisePixelShader: {
  54894. name: string;
  54895. shader: string;
  54896. };
  54897. }
  54898. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54899. import { Nullable } from "babylonjs/types";
  54900. import { Scene } from "babylonjs/scene";
  54901. import { Texture } from "babylonjs/Materials/Textures/texture";
  54902. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54903. import "babylonjs/Shaders/noise.fragment";
  54904. /**
  54905. * Class used to generate noise procedural textures
  54906. */
  54907. export class NoiseProceduralTexture extends ProceduralTexture {
  54908. private _time;
  54909. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54910. brightness: number;
  54911. /** Defines the number of octaves to process */
  54912. octaves: number;
  54913. /** Defines the level of persistence (0.8 by default) */
  54914. persistence: number;
  54915. /** Gets or sets animation speed factor (default is 1) */
  54916. animationSpeedFactor: number;
  54917. /**
  54918. * Creates a new NoiseProceduralTexture
  54919. * @param name defines the name fo the texture
  54920. * @param size defines the size of the texture (default is 256)
  54921. * @param scene defines the hosting scene
  54922. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54923. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54924. */
  54925. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54926. private _updateShaderUniforms;
  54927. protected _getDefines(): string;
  54928. /** Generate the current state of the procedural texture */
  54929. render(useCameraPostProcess?: boolean): void;
  54930. /**
  54931. * Serializes this noise procedural texture
  54932. * @returns a serialized noise procedural texture object
  54933. */
  54934. serialize(): any;
  54935. /**
  54936. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54937. * @param parsedTexture defines parsed texture data
  54938. * @param scene defines the current scene
  54939. * @param rootUrl defines the root URL containing noise procedural texture information
  54940. * @returns a parsed NoiseProceduralTexture
  54941. */
  54942. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54943. }
  54944. }
  54945. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54946. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54947. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54948. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54949. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54950. }
  54951. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54952. import { Nullable } from "babylonjs/types";
  54953. import { Scene } from "babylonjs/scene";
  54954. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54955. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54956. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54957. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54958. /**
  54959. * Raw cube texture where the raw buffers are passed in
  54960. */
  54961. export class RawCubeTexture extends CubeTexture {
  54962. /**
  54963. * Creates a cube texture where the raw buffers are passed in.
  54964. * @param scene defines the scene the texture is attached to
  54965. * @param data defines the array of data to use to create each face
  54966. * @param size defines the size of the textures
  54967. * @param format defines the format of the data
  54968. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54969. * @param generateMipMaps defines if the engine should generate the mip levels
  54970. * @param invertY defines if data must be stored with Y axis inverted
  54971. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54972. * @param compression defines the compression used (null by default)
  54973. */
  54974. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54975. /**
  54976. * Updates the raw cube texture.
  54977. * @param data defines the data to store
  54978. * @param format defines the data format
  54979. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54980. * @param invertY defines if data must be stored with Y axis inverted
  54981. * @param compression defines the compression used (null by default)
  54982. * @param level defines which level of the texture to update
  54983. */
  54984. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54985. /**
  54986. * Updates a raw cube texture with RGBD encoded data.
  54987. * @param data defines the array of data [mipmap][face] to use to create each face
  54988. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54989. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54990. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54991. * @returns a promsie that resolves when the operation is complete
  54992. */
  54993. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54994. /**
  54995. * Clones the raw cube texture.
  54996. * @return a new cube texture
  54997. */
  54998. clone(): CubeTexture;
  54999. /** @hidden */
  55000. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55001. }
  55002. }
  55003. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55004. import { Scene } from "babylonjs/scene";
  55005. import { Texture } from "babylonjs/Materials/Textures/texture";
  55006. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55007. /**
  55008. * Class used to store 3D textures containing user data
  55009. */
  55010. export class RawTexture3D extends Texture {
  55011. /** Gets or sets the texture format to use */
  55012. format: number;
  55013. private _engine;
  55014. /**
  55015. * Create a new RawTexture3D
  55016. * @param data defines the data of the texture
  55017. * @param width defines the width of the texture
  55018. * @param height defines the height of the texture
  55019. * @param depth defines the depth of the texture
  55020. * @param format defines the texture format to use
  55021. * @param scene defines the hosting scene
  55022. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55023. * @param invertY defines if texture must be stored with Y axis inverted
  55024. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55025. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55026. */
  55027. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55028. /** Gets or sets the texture format to use */
  55029. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55030. /**
  55031. * Update the texture with new data
  55032. * @param data defines the data to store in the texture
  55033. */
  55034. update(data: ArrayBufferView): void;
  55035. }
  55036. }
  55037. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55038. import { Scene } from "babylonjs/scene";
  55039. import { Plane } from "babylonjs/Maths/math.plane";
  55040. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55041. /**
  55042. * Creates a refraction texture used by refraction channel of the standard material.
  55043. * It is like a mirror but to see through a material.
  55044. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55045. */
  55046. export class RefractionTexture extends RenderTargetTexture {
  55047. /**
  55048. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55049. * 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.
  55050. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55051. */
  55052. refractionPlane: Plane;
  55053. /**
  55054. * Define how deep under the surface we should see.
  55055. */
  55056. depth: number;
  55057. /**
  55058. * Creates a refraction texture used by refraction channel of the standard material.
  55059. * It is like a mirror but to see through a material.
  55060. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55061. * @param name Define the texture name
  55062. * @param size Define the size of the underlying texture
  55063. * @param scene Define the scene the refraction belongs to
  55064. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55065. */
  55066. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55067. /**
  55068. * Clone the refraction texture.
  55069. * @returns the cloned texture
  55070. */
  55071. clone(): RefractionTexture;
  55072. /**
  55073. * Serialize the texture to a JSON representation you could use in Parse later on
  55074. * @returns the serialized JSON representation
  55075. */
  55076. serialize(): any;
  55077. }
  55078. }
  55079. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55080. import { Nullable } from "babylonjs/types";
  55081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55082. import { Matrix } from "babylonjs/Maths/math.vector";
  55083. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55084. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55085. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55086. import { Scene } from "babylonjs/scene";
  55087. /**
  55088. * Defines the options related to the creation of an HtmlElementTexture
  55089. */
  55090. export interface IHtmlElementTextureOptions {
  55091. /**
  55092. * Defines wether mip maps should be created or not.
  55093. */
  55094. generateMipMaps?: boolean;
  55095. /**
  55096. * Defines the sampling mode of the texture.
  55097. */
  55098. samplingMode?: number;
  55099. /**
  55100. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55101. */
  55102. engine: Nullable<ThinEngine>;
  55103. /**
  55104. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55105. */
  55106. scene: Nullable<Scene>;
  55107. }
  55108. /**
  55109. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55110. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55111. * is automatically managed.
  55112. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55113. * in your application.
  55114. *
  55115. * As the update is not automatic, you need to call them manually.
  55116. */
  55117. export class HtmlElementTexture extends BaseTexture {
  55118. /**
  55119. * The texture URL.
  55120. */
  55121. element: HTMLVideoElement | HTMLCanvasElement;
  55122. private static readonly DefaultOptions;
  55123. private _textureMatrix;
  55124. private _engine;
  55125. private _isVideo;
  55126. private _generateMipMaps;
  55127. private _samplingMode;
  55128. /**
  55129. * Instantiates a HtmlElementTexture from the following parameters.
  55130. *
  55131. * @param name Defines the name of the texture
  55132. * @param element Defines the video or canvas the texture is filled with
  55133. * @param options Defines the other none mandatory texture creation options
  55134. */
  55135. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55136. private _createInternalTexture;
  55137. /**
  55138. * Returns the texture matrix used in most of the material.
  55139. */
  55140. getTextureMatrix(): Matrix;
  55141. /**
  55142. * Updates the content of the texture.
  55143. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55144. */
  55145. update(invertY?: Nullable<boolean>): void;
  55146. }
  55147. }
  55148. declare module "babylonjs/Materials/Textures/index" {
  55149. export * from "babylonjs/Materials/Textures/baseTexture";
  55150. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55151. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55152. export * from "babylonjs/Materials/Textures/cubeTexture";
  55153. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55154. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55155. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55156. export * from "babylonjs/Materials/Textures/internalTexture";
  55157. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55158. export * from "babylonjs/Materials/Textures/Loaders/index";
  55159. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55160. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55161. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55162. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55163. export * from "babylonjs/Materials/Textures/rawTexture";
  55164. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55165. export * from "babylonjs/Materials/Textures/refractionTexture";
  55166. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55167. export * from "babylonjs/Materials/Textures/texture";
  55168. export * from "babylonjs/Materials/Textures/videoTexture";
  55169. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55170. }
  55171. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55172. /**
  55173. * Enum used to define the target of a block
  55174. */
  55175. export enum NodeMaterialBlockTargets {
  55176. /** Vertex shader */
  55177. Vertex = 1,
  55178. /** Fragment shader */
  55179. Fragment = 2,
  55180. /** Neutral */
  55181. Neutral = 4,
  55182. /** Vertex and Fragment */
  55183. VertexAndFragment = 3
  55184. }
  55185. }
  55186. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55187. /**
  55188. * Defines the kind of connection point for node based material
  55189. */
  55190. export enum NodeMaterialBlockConnectionPointTypes {
  55191. /** Float */
  55192. Float = 1,
  55193. /** Int */
  55194. Int = 2,
  55195. /** Vector2 */
  55196. Vector2 = 4,
  55197. /** Vector3 */
  55198. Vector3 = 8,
  55199. /** Vector4 */
  55200. Vector4 = 16,
  55201. /** Color3 */
  55202. Color3 = 32,
  55203. /** Color4 */
  55204. Color4 = 64,
  55205. /** Matrix */
  55206. Matrix = 128,
  55207. /** Detect type based on connection */
  55208. AutoDetect = 1024,
  55209. /** Output type that will be defined by input type */
  55210. BasedOnInput = 2048
  55211. }
  55212. }
  55213. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55214. /**
  55215. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55216. */
  55217. export enum NodeMaterialBlockConnectionPointMode {
  55218. /** Value is an uniform */
  55219. Uniform = 0,
  55220. /** Value is a mesh attribute */
  55221. Attribute = 1,
  55222. /** Value is a varying between vertex and fragment shaders */
  55223. Varying = 2,
  55224. /** Mode is undefined */
  55225. Undefined = 3
  55226. }
  55227. }
  55228. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55229. /**
  55230. * Enum used to define system values e.g. values automatically provided by the system
  55231. */
  55232. export enum NodeMaterialSystemValues {
  55233. /** World */
  55234. World = 1,
  55235. /** View */
  55236. View = 2,
  55237. /** Projection */
  55238. Projection = 3,
  55239. /** ViewProjection */
  55240. ViewProjection = 4,
  55241. /** WorldView */
  55242. WorldView = 5,
  55243. /** WorldViewProjection */
  55244. WorldViewProjection = 6,
  55245. /** CameraPosition */
  55246. CameraPosition = 7,
  55247. /** Fog Color */
  55248. FogColor = 8,
  55249. /** Delta time */
  55250. DeltaTime = 9
  55251. }
  55252. }
  55253. declare module "babylonjs/Materials/Node/Enums/index" {
  55254. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55255. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55256. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55257. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55258. }
  55259. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55260. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55261. /**
  55262. * Root class for all node material optimizers
  55263. */
  55264. export class NodeMaterialOptimizer {
  55265. /**
  55266. * Function used to optimize a NodeMaterial graph
  55267. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55268. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55269. */
  55270. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55271. }
  55272. }
  55273. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55277. import { Scene } from "babylonjs/scene";
  55278. /**
  55279. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55280. */
  55281. export class TransformBlock extends NodeMaterialBlock {
  55282. /**
  55283. * Defines the value to use to complement W value to transform it to a Vector4
  55284. */
  55285. complementW: number;
  55286. /**
  55287. * Defines the value to use to complement z value to transform it to a Vector4
  55288. */
  55289. complementZ: number;
  55290. /**
  55291. * Creates a new TransformBlock
  55292. * @param name defines the block name
  55293. */
  55294. constructor(name: string);
  55295. /**
  55296. * Gets the current class name
  55297. * @returns the class name
  55298. */
  55299. getClassName(): string;
  55300. /**
  55301. * Gets the vector input
  55302. */
  55303. readonly vector: NodeMaterialConnectionPoint;
  55304. /**
  55305. * Gets the output component
  55306. */
  55307. readonly output: NodeMaterialConnectionPoint;
  55308. /**
  55309. * Gets the matrix transform input
  55310. */
  55311. readonly transform: NodeMaterialConnectionPoint;
  55312. protected _buildBlock(state: NodeMaterialBuildState): this;
  55313. serialize(): any;
  55314. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55315. protected _dumpPropertiesCode(): string;
  55316. }
  55317. }
  55318. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55322. /**
  55323. * Block used to output the vertex position
  55324. */
  55325. export class VertexOutputBlock extends NodeMaterialBlock {
  55326. /**
  55327. * Creates a new VertexOutputBlock
  55328. * @param name defines the block name
  55329. */
  55330. constructor(name: string);
  55331. /**
  55332. * Gets the current class name
  55333. * @returns the class name
  55334. */
  55335. getClassName(): string;
  55336. /**
  55337. * Gets the vector input component
  55338. */
  55339. readonly vector: NodeMaterialConnectionPoint;
  55340. protected _buildBlock(state: NodeMaterialBuildState): this;
  55341. }
  55342. }
  55343. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55344. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55345. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55346. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55347. /**
  55348. * Block used to output the final color
  55349. */
  55350. export class FragmentOutputBlock extends NodeMaterialBlock {
  55351. /**
  55352. * Create a new FragmentOutputBlock
  55353. * @param name defines the block name
  55354. */
  55355. constructor(name: string);
  55356. /**
  55357. * Gets the current class name
  55358. * @returns the class name
  55359. */
  55360. getClassName(): string;
  55361. /**
  55362. * Gets the rgba input component
  55363. */
  55364. readonly rgba: NodeMaterialConnectionPoint;
  55365. /**
  55366. * Gets the rgb input component
  55367. */
  55368. readonly rgb: NodeMaterialConnectionPoint;
  55369. /**
  55370. * Gets the a input component
  55371. */
  55372. readonly a: NodeMaterialConnectionPoint;
  55373. protected _buildBlock(state: NodeMaterialBuildState): this;
  55374. }
  55375. }
  55376. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55377. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55378. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55379. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55382. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55383. import { Effect } from "babylonjs/Materials/effect";
  55384. import { Mesh } from "babylonjs/Meshes/mesh";
  55385. import { Nullable } from "babylonjs/types";
  55386. import { Scene } from "babylonjs/scene";
  55387. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55388. /**
  55389. * Block used to read a reflection texture from a sampler
  55390. */
  55391. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55392. private _define3DName;
  55393. private _defineCubicName;
  55394. private _defineExplicitName;
  55395. private _defineProjectionName;
  55396. private _defineLocalCubicName;
  55397. private _defineSphericalName;
  55398. private _definePlanarName;
  55399. private _defineEquirectangularName;
  55400. private _defineMirroredEquirectangularFixedName;
  55401. private _defineEquirectangularFixedName;
  55402. private _defineSkyboxName;
  55403. private _cubeSamplerName;
  55404. private _2DSamplerName;
  55405. private _positionUVWName;
  55406. private _directionWName;
  55407. private _reflectionCoordsName;
  55408. private _reflection2DCoordsName;
  55409. private _reflectionColorName;
  55410. private _reflectionMatrixName;
  55411. /**
  55412. * Gets or sets the texture associated with the node
  55413. */
  55414. texture: Nullable<BaseTexture>;
  55415. /**
  55416. * Create a new TextureBlock
  55417. * @param name defines the block name
  55418. */
  55419. constructor(name: string);
  55420. /**
  55421. * Gets the current class name
  55422. * @returns the class name
  55423. */
  55424. getClassName(): string;
  55425. /**
  55426. * Gets the world position input component
  55427. */
  55428. readonly position: NodeMaterialConnectionPoint;
  55429. /**
  55430. * Gets the world position input component
  55431. */
  55432. readonly worldPosition: NodeMaterialConnectionPoint;
  55433. /**
  55434. * Gets the world normal input component
  55435. */
  55436. readonly worldNormal: NodeMaterialConnectionPoint;
  55437. /**
  55438. * Gets the world input component
  55439. */
  55440. readonly world: NodeMaterialConnectionPoint;
  55441. /**
  55442. * Gets the camera (or eye) position component
  55443. */
  55444. readonly cameraPosition: NodeMaterialConnectionPoint;
  55445. /**
  55446. * Gets the view input component
  55447. */
  55448. readonly view: NodeMaterialConnectionPoint;
  55449. /**
  55450. * Gets the rgb output component
  55451. */
  55452. readonly rgb: NodeMaterialConnectionPoint;
  55453. /**
  55454. * Gets the r output component
  55455. */
  55456. readonly r: NodeMaterialConnectionPoint;
  55457. /**
  55458. * Gets the g output component
  55459. */
  55460. readonly g: NodeMaterialConnectionPoint;
  55461. /**
  55462. * Gets the b output component
  55463. */
  55464. readonly b: NodeMaterialConnectionPoint;
  55465. autoConfigure(material: NodeMaterial): void;
  55466. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55467. isReady(): boolean;
  55468. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55469. private _injectVertexCode;
  55470. private _writeOutput;
  55471. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55472. serialize(): any;
  55473. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55474. }
  55475. }
  55476. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55478. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55479. import { Scene } from "babylonjs/scene";
  55480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55481. import { Matrix } from "babylonjs/Maths/math.vector";
  55482. import { Mesh } from "babylonjs/Meshes/mesh";
  55483. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55484. import { Observable } from "babylonjs/Misc/observable";
  55485. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55486. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55487. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55488. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55489. import { Nullable } from "babylonjs/types";
  55490. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55491. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55492. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55493. /**
  55494. * Interface used to configure the node material editor
  55495. */
  55496. export interface INodeMaterialEditorOptions {
  55497. /** Define the URl to load node editor script */
  55498. editorURL?: string;
  55499. }
  55500. /** @hidden */
  55501. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55502. /** BONES */
  55503. NUM_BONE_INFLUENCERS: number;
  55504. BonesPerMesh: number;
  55505. BONETEXTURE: boolean;
  55506. /** MORPH TARGETS */
  55507. MORPHTARGETS: boolean;
  55508. MORPHTARGETS_NORMAL: boolean;
  55509. MORPHTARGETS_TANGENT: boolean;
  55510. MORPHTARGETS_UV: boolean;
  55511. NUM_MORPH_INFLUENCERS: number;
  55512. /** IMAGE PROCESSING */
  55513. IMAGEPROCESSING: boolean;
  55514. VIGNETTE: boolean;
  55515. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55516. VIGNETTEBLENDMODEOPAQUE: boolean;
  55517. TONEMAPPING: boolean;
  55518. TONEMAPPING_ACES: boolean;
  55519. CONTRAST: boolean;
  55520. EXPOSURE: boolean;
  55521. COLORCURVES: boolean;
  55522. COLORGRADING: boolean;
  55523. COLORGRADING3D: boolean;
  55524. SAMPLER3DGREENDEPTH: boolean;
  55525. SAMPLER3DBGRMAP: boolean;
  55526. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55527. /** MISC. */
  55528. BUMPDIRECTUV: number;
  55529. constructor();
  55530. setValue(name: string, value: boolean): void;
  55531. }
  55532. /**
  55533. * Class used to configure NodeMaterial
  55534. */
  55535. export interface INodeMaterialOptions {
  55536. /**
  55537. * Defines if blocks should emit comments
  55538. */
  55539. emitComments: boolean;
  55540. }
  55541. /**
  55542. * Class used to create a node based material built by assembling shader blocks
  55543. */
  55544. export class NodeMaterial extends PushMaterial {
  55545. private static _BuildIdGenerator;
  55546. private _options;
  55547. private _vertexCompilationState;
  55548. private _fragmentCompilationState;
  55549. private _sharedData;
  55550. private _buildId;
  55551. private _buildWasSuccessful;
  55552. private _cachedWorldViewMatrix;
  55553. private _cachedWorldViewProjectionMatrix;
  55554. private _optimizers;
  55555. private _animationFrame;
  55556. /** Define the URl to load node editor script */
  55557. static EditorURL: string;
  55558. private BJSNODEMATERIALEDITOR;
  55559. /** Get the inspector from bundle or global */
  55560. private _getGlobalNodeMaterialEditor;
  55561. /**
  55562. * 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)
  55563. */
  55564. ignoreAlpha: boolean;
  55565. /**
  55566. * Defines the maximum number of lights that can be used in the material
  55567. */
  55568. maxSimultaneousLights: number;
  55569. /**
  55570. * Observable raised when the material is built
  55571. */
  55572. onBuildObservable: Observable<NodeMaterial>;
  55573. /**
  55574. * Gets or sets the root nodes of the material vertex shader
  55575. */
  55576. _vertexOutputNodes: NodeMaterialBlock[];
  55577. /**
  55578. * Gets or sets the root nodes of the material fragment (pixel) shader
  55579. */
  55580. _fragmentOutputNodes: NodeMaterialBlock[];
  55581. /** Gets or sets options to control the node material overall behavior */
  55582. options: INodeMaterialOptions;
  55583. /**
  55584. * Default configuration related to image processing available in the standard Material.
  55585. */
  55586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55587. /**
  55588. * Gets the image processing configuration used either in this material.
  55589. */
  55590. /**
  55591. * Sets the Default image processing configuration used either in the this material.
  55592. *
  55593. * If sets to null, the scene one is in use.
  55594. */
  55595. imageProcessingConfiguration: ImageProcessingConfiguration;
  55596. /**
  55597. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55598. */
  55599. attachedBlocks: NodeMaterialBlock[];
  55600. /**
  55601. * Create a new node based material
  55602. * @param name defines the material name
  55603. * @param scene defines the hosting scene
  55604. * @param options defines creation option
  55605. */
  55606. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55607. /**
  55608. * Gets the current class name of the material e.g. "NodeMaterial"
  55609. * @returns the class name
  55610. */
  55611. getClassName(): string;
  55612. /**
  55613. * Keep track of the image processing observer to allow dispose and replace.
  55614. */
  55615. private _imageProcessingObserver;
  55616. /**
  55617. * Attaches a new image processing configuration to the Standard Material.
  55618. * @param configuration
  55619. */
  55620. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55621. /**
  55622. * Get a block by its name
  55623. * @param name defines the name of the block to retrieve
  55624. * @returns the required block or null if not found
  55625. */
  55626. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55627. /**
  55628. * Get a block by its name
  55629. * @param predicate defines the predicate used to find the good candidate
  55630. * @returns the required block or null if not found
  55631. */
  55632. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55633. /**
  55634. * Get an input block by its name
  55635. * @param predicate defines the predicate used to find the good candidate
  55636. * @returns the required input block or null if not found
  55637. */
  55638. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55639. /**
  55640. * Gets the list of input blocks attached to this material
  55641. * @returns an array of InputBlocks
  55642. */
  55643. getInputBlocks(): InputBlock[];
  55644. /**
  55645. * Adds a new optimizer to the list of optimizers
  55646. * @param optimizer defines the optimizers to add
  55647. * @returns the current material
  55648. */
  55649. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55650. /**
  55651. * Remove an optimizer from the list of optimizers
  55652. * @param optimizer defines the optimizers to remove
  55653. * @returns the current material
  55654. */
  55655. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55656. /**
  55657. * Add a new block to the list of output nodes
  55658. * @param node defines the node to add
  55659. * @returns the current material
  55660. */
  55661. addOutputNode(node: NodeMaterialBlock): this;
  55662. /**
  55663. * Remove a block from the list of root nodes
  55664. * @param node defines the node to remove
  55665. * @returns the current material
  55666. */
  55667. removeOutputNode(node: NodeMaterialBlock): this;
  55668. private _addVertexOutputNode;
  55669. private _removeVertexOutputNode;
  55670. private _addFragmentOutputNode;
  55671. private _removeFragmentOutputNode;
  55672. /**
  55673. * Specifies if the material will require alpha blending
  55674. * @returns a boolean specifying if alpha blending is needed
  55675. */
  55676. needAlphaBlending(): boolean;
  55677. /**
  55678. * Specifies if this material should be rendered in alpha test mode
  55679. * @returns a boolean specifying if an alpha test is needed.
  55680. */
  55681. needAlphaTesting(): boolean;
  55682. private _initializeBlock;
  55683. private _resetDualBlocks;
  55684. /**
  55685. * Build the material and generates the inner effect
  55686. * @param verbose defines if the build should log activity
  55687. */
  55688. build(verbose?: boolean): void;
  55689. /**
  55690. * Runs an otpimization phase to try to improve the shader code
  55691. */
  55692. optimize(): void;
  55693. private _prepareDefinesForAttributes;
  55694. /**
  55695. * Get if the submesh is ready to be used and all its information available.
  55696. * Child classes can use it to update shaders
  55697. * @param mesh defines the mesh to check
  55698. * @param subMesh defines which submesh to check
  55699. * @param useInstances specifies that instances should be used
  55700. * @returns a boolean indicating that the submesh is ready or not
  55701. */
  55702. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55703. /**
  55704. * Get a string representing the shaders built by the current node graph
  55705. */
  55706. readonly compiledShaders: string;
  55707. /**
  55708. * Binds the world matrix to the material
  55709. * @param world defines the world transformation matrix
  55710. */
  55711. bindOnlyWorldMatrix(world: Matrix): void;
  55712. /**
  55713. * Binds the submesh to this material by preparing the effect and shader to draw
  55714. * @param world defines the world transformation matrix
  55715. * @param mesh defines the mesh containing the submesh
  55716. * @param subMesh defines the submesh to bind the material to
  55717. */
  55718. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55719. /**
  55720. * Gets the active textures from the material
  55721. * @returns an array of textures
  55722. */
  55723. getActiveTextures(): BaseTexture[];
  55724. /**
  55725. * Gets the list of texture blocks
  55726. * @returns an array of texture blocks
  55727. */
  55728. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55729. /**
  55730. * Specifies if the material uses a texture
  55731. * @param texture defines the texture to check against the material
  55732. * @returns a boolean specifying if the material uses the texture
  55733. */
  55734. hasTexture(texture: BaseTexture): boolean;
  55735. /**
  55736. * Disposes the material
  55737. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55738. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55739. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55740. */
  55741. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55742. /** Creates the node editor window. */
  55743. private _createNodeEditor;
  55744. /**
  55745. * Launch the node material editor
  55746. * @param config Define the configuration of the editor
  55747. * @return a promise fulfilled when the node editor is visible
  55748. */
  55749. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55750. /**
  55751. * Clear the current material
  55752. */
  55753. clear(): void;
  55754. /**
  55755. * Clear the current material and set it to a default state
  55756. */
  55757. setToDefault(): void;
  55758. /**
  55759. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55760. * @param url defines the url to load from
  55761. * @returns a promise that will fullfil when the material is fully loaded
  55762. */
  55763. loadAsync(url: string): Promise<void>;
  55764. private _gatherBlocks;
  55765. /**
  55766. * Generate a string containing the code declaration required to create an equivalent of this material
  55767. * @returns a string
  55768. */
  55769. generateCode(): string;
  55770. /**
  55771. * Serializes this material in a JSON representation
  55772. * @returns the serialized material object
  55773. */
  55774. serialize(): any;
  55775. private _restoreConnections;
  55776. /**
  55777. * Clear the current graph and load a new one from a serialization object
  55778. * @param source defines the JSON representation of the material
  55779. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55780. */
  55781. loadFromSerialization(source: any, rootUrl?: string): void;
  55782. /**
  55783. * Creates a node material from parsed material data
  55784. * @param source defines the JSON representation of the material
  55785. * @param scene defines the hosting scene
  55786. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55787. * @returns a new node material
  55788. */
  55789. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55790. /**
  55791. * Creates a new node material set to default basic configuration
  55792. * @param name defines the name of the material
  55793. * @param scene defines the hosting scene
  55794. * @returns a new NodeMaterial
  55795. */
  55796. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55797. }
  55798. }
  55799. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55802. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55805. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55806. import { Effect } from "babylonjs/Materials/effect";
  55807. import { Mesh } from "babylonjs/Meshes/mesh";
  55808. import { Nullable } from "babylonjs/types";
  55809. import { Texture } from "babylonjs/Materials/Textures/texture";
  55810. import { Scene } from "babylonjs/scene";
  55811. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55812. /**
  55813. * Block used to read a texture from a sampler
  55814. */
  55815. export class TextureBlock extends NodeMaterialBlock {
  55816. private _defineName;
  55817. private _linearDefineName;
  55818. private _samplerName;
  55819. private _transformedUVName;
  55820. private _textureTransformName;
  55821. private _textureInfoName;
  55822. private _mainUVName;
  55823. private _mainUVDefineName;
  55824. /**
  55825. * Gets or sets the texture associated with the node
  55826. */
  55827. texture: Nullable<Texture>;
  55828. /**
  55829. * Create a new TextureBlock
  55830. * @param name defines the block name
  55831. */
  55832. constructor(name: string);
  55833. /**
  55834. * Gets the current class name
  55835. * @returns the class name
  55836. */
  55837. getClassName(): string;
  55838. /**
  55839. * Gets the uv input component
  55840. */
  55841. readonly uv: NodeMaterialConnectionPoint;
  55842. /**
  55843. * Gets the rgba output component
  55844. */
  55845. readonly rgba: NodeMaterialConnectionPoint;
  55846. /**
  55847. * Gets the rgb output component
  55848. */
  55849. readonly rgb: NodeMaterialConnectionPoint;
  55850. /**
  55851. * Gets the r output component
  55852. */
  55853. readonly r: NodeMaterialConnectionPoint;
  55854. /**
  55855. * Gets the g output component
  55856. */
  55857. readonly g: NodeMaterialConnectionPoint;
  55858. /**
  55859. * Gets the b output component
  55860. */
  55861. readonly b: NodeMaterialConnectionPoint;
  55862. /**
  55863. * Gets the a output component
  55864. */
  55865. readonly a: NodeMaterialConnectionPoint;
  55866. readonly target: NodeMaterialBlockTargets;
  55867. autoConfigure(material: NodeMaterial): void;
  55868. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55869. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55870. isReady(): boolean;
  55871. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55872. private readonly _isMixed;
  55873. private _injectVertexCode;
  55874. private _writeOutput;
  55875. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55876. protected _dumpPropertiesCode(): string;
  55877. serialize(): any;
  55878. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55879. }
  55880. }
  55881. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55884. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55885. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55886. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55887. import { Scene } from "babylonjs/scene";
  55888. /**
  55889. * Class used to store shared data between 2 NodeMaterialBuildState
  55890. */
  55891. export class NodeMaterialBuildStateSharedData {
  55892. /**
  55893. * Gets the list of emitted varyings
  55894. */
  55895. temps: string[];
  55896. /**
  55897. * Gets the list of emitted varyings
  55898. */
  55899. varyings: string[];
  55900. /**
  55901. * Gets the varying declaration string
  55902. */
  55903. varyingDeclaration: string;
  55904. /**
  55905. * Input blocks
  55906. */
  55907. inputBlocks: InputBlock[];
  55908. /**
  55909. * Input blocks
  55910. */
  55911. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55912. /**
  55913. * Bindable blocks (Blocks that need to set data to the effect)
  55914. */
  55915. bindableBlocks: NodeMaterialBlock[];
  55916. /**
  55917. * List of blocks that can provide a compilation fallback
  55918. */
  55919. blocksWithFallbacks: NodeMaterialBlock[];
  55920. /**
  55921. * List of blocks that can provide a define update
  55922. */
  55923. blocksWithDefines: NodeMaterialBlock[];
  55924. /**
  55925. * List of blocks that can provide a repeatable content
  55926. */
  55927. repeatableContentBlocks: NodeMaterialBlock[];
  55928. /**
  55929. * List of blocks that can provide a dynamic list of uniforms
  55930. */
  55931. dynamicUniformBlocks: NodeMaterialBlock[];
  55932. /**
  55933. * List of blocks that can block the isReady function for the material
  55934. */
  55935. blockingBlocks: NodeMaterialBlock[];
  55936. /**
  55937. * Gets the list of animated inputs
  55938. */
  55939. animatedInputs: InputBlock[];
  55940. /**
  55941. * Build Id used to avoid multiple recompilations
  55942. */
  55943. buildId: number;
  55944. /** List of emitted variables */
  55945. variableNames: {
  55946. [key: string]: number;
  55947. };
  55948. /** List of emitted defines */
  55949. defineNames: {
  55950. [key: string]: number;
  55951. };
  55952. /** Should emit comments? */
  55953. emitComments: boolean;
  55954. /** Emit build activity */
  55955. verbose: boolean;
  55956. /** Gets or sets the hosting scene */
  55957. scene: Scene;
  55958. /**
  55959. * Gets the compilation hints emitted at compilation time
  55960. */
  55961. hints: {
  55962. needWorldViewMatrix: boolean;
  55963. needWorldViewProjectionMatrix: boolean;
  55964. needAlphaBlending: boolean;
  55965. needAlphaTesting: boolean;
  55966. };
  55967. /**
  55968. * List of compilation checks
  55969. */
  55970. checks: {
  55971. emitVertex: boolean;
  55972. emitFragment: boolean;
  55973. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55974. };
  55975. /** Creates a new shared data */
  55976. constructor();
  55977. /**
  55978. * Emits console errors and exceptions if there is a failing check
  55979. */
  55980. emitErrors(): void;
  55981. }
  55982. }
  55983. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55984. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55985. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55986. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55987. /**
  55988. * Class used to store node based material build state
  55989. */
  55990. export class NodeMaterialBuildState {
  55991. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55992. supportUniformBuffers: boolean;
  55993. /**
  55994. * Gets the list of emitted attributes
  55995. */
  55996. attributes: string[];
  55997. /**
  55998. * Gets the list of emitted uniforms
  55999. */
  56000. uniforms: string[];
  56001. /**
  56002. * Gets the list of emitted constants
  56003. */
  56004. constants: string[];
  56005. /**
  56006. * Gets the list of emitted samplers
  56007. */
  56008. samplers: string[];
  56009. /**
  56010. * Gets the list of emitted functions
  56011. */
  56012. functions: {
  56013. [key: string]: string;
  56014. };
  56015. /**
  56016. * Gets the list of emitted extensions
  56017. */
  56018. extensions: {
  56019. [key: string]: string;
  56020. };
  56021. /**
  56022. * Gets the target of the compilation state
  56023. */
  56024. target: NodeMaterialBlockTargets;
  56025. /**
  56026. * Gets the list of emitted counters
  56027. */
  56028. counters: {
  56029. [key: string]: number;
  56030. };
  56031. /**
  56032. * Shared data between multiple NodeMaterialBuildState instances
  56033. */
  56034. sharedData: NodeMaterialBuildStateSharedData;
  56035. /** @hidden */
  56036. _vertexState: NodeMaterialBuildState;
  56037. /** @hidden */
  56038. _attributeDeclaration: string;
  56039. /** @hidden */
  56040. _uniformDeclaration: string;
  56041. /** @hidden */
  56042. _constantDeclaration: string;
  56043. /** @hidden */
  56044. _samplerDeclaration: string;
  56045. /** @hidden */
  56046. _varyingTransfer: string;
  56047. private _repeatableContentAnchorIndex;
  56048. /** @hidden */
  56049. _builtCompilationString: string;
  56050. /**
  56051. * Gets the emitted compilation strings
  56052. */
  56053. compilationString: string;
  56054. /**
  56055. * Finalize the compilation strings
  56056. * @param state defines the current compilation state
  56057. */
  56058. finalize(state: NodeMaterialBuildState): void;
  56059. /** @hidden */
  56060. readonly _repeatableContentAnchor: string;
  56061. /** @hidden */
  56062. _getFreeVariableName(prefix: string): string;
  56063. /** @hidden */
  56064. _getFreeDefineName(prefix: string): string;
  56065. /** @hidden */
  56066. _excludeVariableName(name: string): void;
  56067. /** @hidden */
  56068. _emit2DSampler(name: string): void;
  56069. /** @hidden */
  56070. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56071. /** @hidden */
  56072. _emitExtension(name: string, extension: string): void;
  56073. /** @hidden */
  56074. _emitFunction(name: string, code: string, comments: string): void;
  56075. /** @hidden */
  56076. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56077. replaceStrings?: {
  56078. search: RegExp;
  56079. replace: string;
  56080. }[];
  56081. repeatKey?: string;
  56082. }): string;
  56083. /** @hidden */
  56084. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56085. repeatKey?: string;
  56086. removeAttributes?: boolean;
  56087. removeUniforms?: boolean;
  56088. removeVaryings?: boolean;
  56089. removeIfDef?: boolean;
  56090. replaceStrings?: {
  56091. search: RegExp;
  56092. replace: string;
  56093. }[];
  56094. }, storeKey?: string): void;
  56095. /** @hidden */
  56096. _registerTempVariable(name: string): boolean;
  56097. /** @hidden */
  56098. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56099. /** @hidden */
  56100. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56101. /** @hidden */
  56102. _emitFloat(value: number): string;
  56103. }
  56104. }
  56105. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56106. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56108. import { Nullable } from "babylonjs/types";
  56109. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56110. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56111. import { Effect } from "babylonjs/Materials/effect";
  56112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56113. import { Mesh } from "babylonjs/Meshes/mesh";
  56114. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56115. import { Scene } from "babylonjs/scene";
  56116. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56117. /**
  56118. * Defines a block that can be used inside a node based material
  56119. */
  56120. export class NodeMaterialBlock {
  56121. private _buildId;
  56122. private _buildTarget;
  56123. private _target;
  56124. private _isFinalMerger;
  56125. private _isInput;
  56126. /** @hidden */
  56127. _codeVariableName: string;
  56128. /** @hidden */
  56129. _inputs: NodeMaterialConnectionPoint[];
  56130. /** @hidden */
  56131. _outputs: NodeMaterialConnectionPoint[];
  56132. /** @hidden */
  56133. _preparationId: number;
  56134. /**
  56135. * Gets or sets the name of the block
  56136. */
  56137. name: string;
  56138. /**
  56139. * Gets or sets the unique id of the node
  56140. */
  56141. uniqueId: number;
  56142. /**
  56143. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56144. */
  56145. readonly isFinalMerger: boolean;
  56146. /**
  56147. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56148. */
  56149. readonly isInput: boolean;
  56150. /**
  56151. * Gets or sets the build Id
  56152. */
  56153. buildId: number;
  56154. /**
  56155. * Gets or sets the target of the block
  56156. */
  56157. target: NodeMaterialBlockTargets;
  56158. /**
  56159. * Gets the list of input points
  56160. */
  56161. readonly inputs: NodeMaterialConnectionPoint[];
  56162. /** Gets the list of output points */
  56163. readonly outputs: NodeMaterialConnectionPoint[];
  56164. /**
  56165. * Find an input by its name
  56166. * @param name defines the name of the input to look for
  56167. * @returns the input or null if not found
  56168. */
  56169. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56170. /**
  56171. * Find an output by its name
  56172. * @param name defines the name of the outputto look for
  56173. * @returns the output or null if not found
  56174. */
  56175. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56176. /**
  56177. * Creates a new NodeMaterialBlock
  56178. * @param name defines the block name
  56179. * @param target defines the target of that block (Vertex by default)
  56180. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56181. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56182. */
  56183. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56184. /**
  56185. * Initialize the block and prepare the context for build
  56186. * @param state defines the state that will be used for the build
  56187. */
  56188. initialize(state: NodeMaterialBuildState): void;
  56189. /**
  56190. * Bind data to effect. Will only be called for blocks with isBindable === true
  56191. * @param effect defines the effect to bind data to
  56192. * @param nodeMaterial defines the hosting NodeMaterial
  56193. * @param mesh defines the mesh that will be rendered
  56194. */
  56195. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56196. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56197. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56198. protected _writeFloat(value: number): string;
  56199. /**
  56200. * Gets the current class name e.g. "NodeMaterialBlock"
  56201. * @returns the class name
  56202. */
  56203. getClassName(): string;
  56204. /**
  56205. * Register a new input. Must be called inside a block constructor
  56206. * @param name defines the connection point name
  56207. * @param type defines the connection point type
  56208. * @param isOptional defines a boolean indicating that this input can be omitted
  56209. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56210. * @returns the current block
  56211. */
  56212. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56213. /**
  56214. * Register a new output. Must be called inside a block constructor
  56215. * @param name defines the connection point name
  56216. * @param type defines the connection point type
  56217. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56218. * @returns the current block
  56219. */
  56220. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56221. /**
  56222. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56223. * @param forOutput defines an optional connection point to check compatibility with
  56224. * @returns the first available input or null
  56225. */
  56226. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56227. /**
  56228. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56229. * @param forBlock defines an optional block to check compatibility with
  56230. * @returns the first available input or null
  56231. */
  56232. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56233. /**
  56234. * Gets the sibling of the given output
  56235. * @param current defines the current output
  56236. * @returns the next output in the list or null
  56237. */
  56238. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56239. /**
  56240. * Connect current block with another block
  56241. * @param other defines the block to connect with
  56242. * @param options define the various options to help pick the right connections
  56243. * @returns the current block
  56244. */
  56245. connectTo(other: NodeMaterialBlock, options?: {
  56246. input?: string;
  56247. output?: string;
  56248. outputSwizzle?: string;
  56249. }): this | undefined;
  56250. protected _buildBlock(state: NodeMaterialBuildState): void;
  56251. /**
  56252. * Add uniforms, samplers and uniform buffers at compilation time
  56253. * @param state defines the state to update
  56254. * @param nodeMaterial defines the node material requesting the update
  56255. * @param defines defines the material defines to update
  56256. * @param uniformBuffers defines the list of uniform buffer names
  56257. */
  56258. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56259. /**
  56260. * Add potential fallbacks if shader compilation fails
  56261. * @param mesh defines the mesh to be rendered
  56262. * @param fallbacks defines the current prioritized list of fallbacks
  56263. */
  56264. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56265. /**
  56266. * Initialize defines for shader compilation
  56267. * @param mesh defines the mesh to be rendered
  56268. * @param nodeMaterial defines the node material requesting the update
  56269. * @param defines defines the material defines to update
  56270. * @param useInstances specifies that instances should be used
  56271. */
  56272. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56273. /**
  56274. * Update defines for shader compilation
  56275. * @param mesh defines the mesh to be rendered
  56276. * @param nodeMaterial defines the node material requesting the update
  56277. * @param defines defines the material defines to update
  56278. * @param useInstances specifies that instances should be used
  56279. */
  56280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56281. /**
  56282. * Lets the block try to connect some inputs automatically
  56283. * @param material defines the hosting NodeMaterial
  56284. */
  56285. autoConfigure(material: NodeMaterial): void;
  56286. /**
  56287. * Function called when a block is declared as repeatable content generator
  56288. * @param vertexShaderState defines the current compilation state for the vertex shader
  56289. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56290. * @param mesh defines the mesh to be rendered
  56291. * @param defines defines the material defines to update
  56292. */
  56293. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56294. /**
  56295. * Checks if the block is ready
  56296. * @param mesh defines the mesh to be rendered
  56297. * @param nodeMaterial defines the node material requesting the update
  56298. * @param defines defines the material defines to update
  56299. * @param useInstances specifies that instances should be used
  56300. * @returns true if the block is ready
  56301. */
  56302. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56303. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56304. private _processBuild;
  56305. /**
  56306. * Compile the current node and generate the shader code
  56307. * @param state defines the current compilation state (uniforms, samplers, current string)
  56308. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56309. * @returns true if already built
  56310. */
  56311. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56312. protected _inputRename(name: string): string;
  56313. protected _outputRename(name: string): string;
  56314. protected _dumpPropertiesCode(): string;
  56315. /** @hidden */
  56316. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56317. /**
  56318. * Clone the current block to a new identical block
  56319. * @param scene defines the hosting scene
  56320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56321. * @returns a copy of the current block
  56322. */
  56323. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56324. /**
  56325. * Serializes this block in a JSON representation
  56326. * @returns the serialized block object
  56327. */
  56328. serialize(): any;
  56329. /** @hidden */
  56330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56331. }
  56332. }
  56333. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56334. /**
  56335. * Enum defining the type of animations supported by InputBlock
  56336. */
  56337. export enum AnimatedInputBlockTypes {
  56338. /** No animation */
  56339. None = 0,
  56340. /** Time based animation. Will only work for floats */
  56341. Time = 1
  56342. }
  56343. }
  56344. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56346. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56347. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56348. import { Nullable } from "babylonjs/types";
  56349. import { Effect } from "babylonjs/Materials/effect";
  56350. import { Matrix } from "babylonjs/Maths/math.vector";
  56351. import { Scene } from "babylonjs/scene";
  56352. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56353. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56354. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56355. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56356. /**
  56357. * Block used to expose an input value
  56358. */
  56359. export class InputBlock extends NodeMaterialBlock {
  56360. private _mode;
  56361. private _associatedVariableName;
  56362. private _storedValue;
  56363. private _valueCallback;
  56364. private _type;
  56365. private _animationType;
  56366. /** Gets or set a value used to limit the range of float values */
  56367. min: number;
  56368. /** Gets or set a value used to limit the range of float values */
  56369. max: number;
  56370. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56371. matrixMode: number;
  56372. /** @hidden */
  56373. _systemValue: Nullable<NodeMaterialSystemValues>;
  56374. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56375. visibleInInspector: boolean;
  56376. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56377. isConstant: boolean;
  56378. /**
  56379. * Gets or sets the connection point type (default is float)
  56380. */
  56381. readonly type: NodeMaterialBlockConnectionPointTypes;
  56382. /**
  56383. * Creates a new InputBlock
  56384. * @param name defines the block name
  56385. * @param target defines the target of that block (Vertex by default)
  56386. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56387. */
  56388. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56389. /**
  56390. * Gets the output component
  56391. */
  56392. readonly output: NodeMaterialConnectionPoint;
  56393. /**
  56394. * Set the source of this connection point to a vertex attribute
  56395. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56396. * @returns the current connection point
  56397. */
  56398. setAsAttribute(attributeName?: string): InputBlock;
  56399. /**
  56400. * Set the source of this connection point to a system value
  56401. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56402. * @returns the current connection point
  56403. */
  56404. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56405. /**
  56406. * Gets or sets the value of that point.
  56407. * Please note that this value will be ignored if valueCallback is defined
  56408. */
  56409. value: any;
  56410. /**
  56411. * Gets or sets a callback used to get the value of that point.
  56412. * Please note that setting this value will force the connection point to ignore the value property
  56413. */
  56414. valueCallback: () => any;
  56415. /**
  56416. * Gets or sets the associated variable name in the shader
  56417. */
  56418. associatedVariableName: string;
  56419. /** Gets or sets the type of animation applied to the input */
  56420. animationType: AnimatedInputBlockTypes;
  56421. /**
  56422. * Gets a boolean indicating that this connection point not defined yet
  56423. */
  56424. readonly isUndefined: boolean;
  56425. /**
  56426. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56427. * In this case the connection point name must be the name of the uniform to use.
  56428. * Can only be set on inputs
  56429. */
  56430. isUniform: boolean;
  56431. /**
  56432. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56433. * In this case the connection point name must be the name of the attribute to use
  56434. * Can only be set on inputs
  56435. */
  56436. isAttribute: boolean;
  56437. /**
  56438. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56439. * Can only be set on exit points
  56440. */
  56441. isVarying: boolean;
  56442. /**
  56443. * Gets a boolean indicating that the current connection point is a system value
  56444. */
  56445. readonly isSystemValue: boolean;
  56446. /**
  56447. * Gets or sets the current well known value or null if not defined as a system value
  56448. */
  56449. systemValue: Nullable<NodeMaterialSystemValues>;
  56450. /**
  56451. * Gets the current class name
  56452. * @returns the class name
  56453. */
  56454. getClassName(): string;
  56455. /**
  56456. * Animate the input if animationType !== None
  56457. * @param scene defines the rendering scene
  56458. */
  56459. animate(scene: Scene): void;
  56460. private _emitDefine;
  56461. initialize(state: NodeMaterialBuildState): void;
  56462. /**
  56463. * Set the input block to its default value (based on its type)
  56464. */
  56465. setDefaultValue(): void;
  56466. private _emitConstant;
  56467. private _emit;
  56468. /** @hidden */
  56469. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56470. /** @hidden */
  56471. _transmit(effect: Effect, scene: Scene): void;
  56472. protected _buildBlock(state: NodeMaterialBuildState): void;
  56473. protected _dumpPropertiesCode(): string;
  56474. serialize(): any;
  56475. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56476. }
  56477. }
  56478. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56479. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56480. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56481. import { Nullable } from "babylonjs/types";
  56482. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56484. /**
  56485. * Defines a connection point for a block
  56486. */
  56487. export class NodeMaterialConnectionPoint {
  56488. /** @hidden */
  56489. _ownerBlock: NodeMaterialBlock;
  56490. /** @hidden */
  56491. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56492. private _endpoints;
  56493. private _associatedVariableName;
  56494. /** @hidden */
  56495. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56496. /** @hidden */
  56497. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56498. private _type;
  56499. /** @hidden */
  56500. _enforceAssociatedVariableName: boolean;
  56501. /**
  56502. * Gets or sets the additional types supported by this connection point
  56503. */
  56504. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56505. /**
  56506. * Gets or sets the additional types excluded by this connection point
  56507. */
  56508. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56509. /**
  56510. * Gets or sets the associated variable name in the shader
  56511. */
  56512. associatedVariableName: string;
  56513. /**
  56514. * Gets or sets the connection point type (default is float)
  56515. */
  56516. type: NodeMaterialBlockConnectionPointTypes;
  56517. /**
  56518. * Gets or sets the connection point name
  56519. */
  56520. name: string;
  56521. /**
  56522. * Gets or sets a boolean indicating that this connection point can be omitted
  56523. */
  56524. isOptional: boolean;
  56525. /**
  56526. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56527. */
  56528. define: string;
  56529. /** Gets or sets the target of that connection point */
  56530. target: NodeMaterialBlockTargets;
  56531. /**
  56532. * Gets a boolean indicating that the current point is connected
  56533. */
  56534. readonly isConnected: boolean;
  56535. /**
  56536. * Gets a boolean indicating that the current point is connected to an input block
  56537. */
  56538. readonly isConnectedToInputBlock: boolean;
  56539. /**
  56540. * Gets a the connected input block (if any)
  56541. */
  56542. readonly connectInputBlock: Nullable<InputBlock>;
  56543. /** Get the other side of the connection (if any) */
  56544. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56545. /** Get the block that owns this connection point */
  56546. readonly ownerBlock: NodeMaterialBlock;
  56547. /** Get the block connected on the other side of this connection (if any) */
  56548. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56549. /** Get the block connected on the endpoints of this connection (if any) */
  56550. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56551. /** Gets the list of connected endpoints */
  56552. readonly endpoints: NodeMaterialConnectionPoint[];
  56553. /** Gets a boolean indicating if that output point is connected to at least one input */
  56554. readonly hasEndpoints: boolean;
  56555. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56556. readonly isConnectedInVertexShader: boolean;
  56557. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56558. readonly isConnectedInFragmentShader: boolean;
  56559. /**
  56560. * Creates a new connection point
  56561. * @param name defines the connection point name
  56562. * @param ownerBlock defines the block hosting this connection point
  56563. */
  56564. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56565. /**
  56566. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56567. * @returns the class name
  56568. */
  56569. getClassName(): string;
  56570. /**
  56571. * Gets an boolean indicating if the current point can be connected to another point
  56572. * @param connectionPoint defines the other connection point
  56573. * @returns true if the connection is possible
  56574. */
  56575. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56576. /**
  56577. * Connect this point to another connection point
  56578. * @param connectionPoint defines the other connection point
  56579. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56580. * @returns the current connection point
  56581. */
  56582. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56583. /**
  56584. * Disconnect this point from one of his endpoint
  56585. * @param endpoint defines the other connection point
  56586. * @returns the current connection point
  56587. */
  56588. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56589. /**
  56590. * Serializes this point in a JSON representation
  56591. * @returns the serialized point object
  56592. */
  56593. serialize(): any;
  56594. }
  56595. }
  56596. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56598. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56600. import { Mesh } from "babylonjs/Meshes/mesh";
  56601. import { Effect } from "babylonjs/Materials/effect";
  56602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56603. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56604. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56605. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56606. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56607. /**
  56608. * Block used to add support for vertex skinning (bones)
  56609. */
  56610. export class BonesBlock extends NodeMaterialBlock {
  56611. /**
  56612. * Creates a new BonesBlock
  56613. * @param name defines the block name
  56614. */
  56615. constructor(name: string);
  56616. /**
  56617. * Initialize the block and prepare the context for build
  56618. * @param state defines the state that will be used for the build
  56619. */
  56620. initialize(state: NodeMaterialBuildState): void;
  56621. /**
  56622. * Gets the current class name
  56623. * @returns the class name
  56624. */
  56625. getClassName(): string;
  56626. /**
  56627. * Gets the matrix indices input component
  56628. */
  56629. readonly matricesIndices: NodeMaterialConnectionPoint;
  56630. /**
  56631. * Gets the matrix weights input component
  56632. */
  56633. readonly matricesWeights: NodeMaterialConnectionPoint;
  56634. /**
  56635. * Gets the extra matrix indices input component
  56636. */
  56637. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56638. /**
  56639. * Gets the extra matrix weights input component
  56640. */
  56641. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56642. /**
  56643. * Gets the world input component
  56644. */
  56645. readonly world: NodeMaterialConnectionPoint;
  56646. /**
  56647. * Gets the output component
  56648. */
  56649. readonly output: NodeMaterialConnectionPoint;
  56650. autoConfigure(material: NodeMaterial): void;
  56651. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56654. protected _buildBlock(state: NodeMaterialBuildState): this;
  56655. }
  56656. }
  56657. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56659. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56662. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56663. /**
  56664. * Block used to add support for instances
  56665. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56666. */
  56667. export class InstancesBlock extends NodeMaterialBlock {
  56668. /**
  56669. * Creates a new InstancesBlock
  56670. * @param name defines the block name
  56671. */
  56672. constructor(name: string);
  56673. /**
  56674. * Gets the current class name
  56675. * @returns the class name
  56676. */
  56677. getClassName(): string;
  56678. /**
  56679. * Gets the first world row input component
  56680. */
  56681. readonly world0: NodeMaterialConnectionPoint;
  56682. /**
  56683. * Gets the second world row input component
  56684. */
  56685. readonly world1: NodeMaterialConnectionPoint;
  56686. /**
  56687. * Gets the third world row input component
  56688. */
  56689. readonly world2: NodeMaterialConnectionPoint;
  56690. /**
  56691. * Gets the forth world row input component
  56692. */
  56693. readonly world3: NodeMaterialConnectionPoint;
  56694. /**
  56695. * Gets the world input component
  56696. */
  56697. readonly world: NodeMaterialConnectionPoint;
  56698. /**
  56699. * Gets the output component
  56700. */
  56701. readonly output: NodeMaterialConnectionPoint;
  56702. autoConfigure(material: NodeMaterial): void;
  56703. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56704. protected _buildBlock(state: NodeMaterialBuildState): this;
  56705. }
  56706. }
  56707. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56712. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56713. import { Effect } from "babylonjs/Materials/effect";
  56714. import { Mesh } from "babylonjs/Meshes/mesh";
  56715. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56716. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56717. /**
  56718. * Block used to add morph targets support to vertex shader
  56719. */
  56720. export class MorphTargetsBlock extends NodeMaterialBlock {
  56721. private _repeatableContentAnchor;
  56722. private _repeatebleContentGenerated;
  56723. /**
  56724. * Create a new MorphTargetsBlock
  56725. * @param name defines the block name
  56726. */
  56727. constructor(name: string);
  56728. /**
  56729. * Gets the current class name
  56730. * @returns the class name
  56731. */
  56732. getClassName(): string;
  56733. /**
  56734. * Gets the position input component
  56735. */
  56736. readonly position: NodeMaterialConnectionPoint;
  56737. /**
  56738. * Gets the normal input component
  56739. */
  56740. readonly normal: NodeMaterialConnectionPoint;
  56741. /**
  56742. * Gets the tangent input component
  56743. */
  56744. readonly tangent: NodeMaterialConnectionPoint;
  56745. /**
  56746. * Gets the tangent input component
  56747. */
  56748. readonly uv: NodeMaterialConnectionPoint;
  56749. /**
  56750. * Gets the position output component
  56751. */
  56752. readonly positionOutput: NodeMaterialConnectionPoint;
  56753. /**
  56754. * Gets the normal output component
  56755. */
  56756. readonly normalOutput: NodeMaterialConnectionPoint;
  56757. /**
  56758. * Gets the tangent output component
  56759. */
  56760. readonly tangentOutput: NodeMaterialConnectionPoint;
  56761. /**
  56762. * Gets the tangent output component
  56763. */
  56764. readonly uvOutput: NodeMaterialConnectionPoint;
  56765. initialize(state: NodeMaterialBuildState): void;
  56766. autoConfigure(material: NodeMaterial): void;
  56767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56768. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56769. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56770. protected _buildBlock(state: NodeMaterialBuildState): this;
  56771. }
  56772. }
  56773. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56774. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56777. import { Nullable } from "babylonjs/types";
  56778. import { Scene } from "babylonjs/scene";
  56779. import { Effect } from "babylonjs/Materials/effect";
  56780. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56781. import { Mesh } from "babylonjs/Meshes/mesh";
  56782. import { Light } from "babylonjs/Lights/light";
  56783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56784. /**
  56785. * Block used to get data information from a light
  56786. */
  56787. export class LightInformationBlock extends NodeMaterialBlock {
  56788. private _lightDataUniformName;
  56789. private _lightColorUniformName;
  56790. private _lightTypeDefineName;
  56791. /**
  56792. * Gets or sets the light associated with this block
  56793. */
  56794. light: Nullable<Light>;
  56795. /**
  56796. * Creates a new LightInformationBlock
  56797. * @param name defines the block name
  56798. */
  56799. constructor(name: string);
  56800. /**
  56801. * Gets the current class name
  56802. * @returns the class name
  56803. */
  56804. getClassName(): string;
  56805. /**
  56806. * Gets the world position input component
  56807. */
  56808. readonly worldPosition: NodeMaterialConnectionPoint;
  56809. /**
  56810. * Gets the direction output component
  56811. */
  56812. readonly direction: NodeMaterialConnectionPoint;
  56813. /**
  56814. * Gets the direction output component
  56815. */
  56816. readonly color: NodeMaterialConnectionPoint;
  56817. /**
  56818. * Gets the direction output component
  56819. */
  56820. readonly intensity: NodeMaterialConnectionPoint;
  56821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56822. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56823. protected _buildBlock(state: NodeMaterialBuildState): this;
  56824. serialize(): any;
  56825. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56826. }
  56827. }
  56828. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56829. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56830. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56831. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56832. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56833. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56834. }
  56835. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56840. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56841. import { Effect } from "babylonjs/Materials/effect";
  56842. import { Mesh } from "babylonjs/Meshes/mesh";
  56843. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56844. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56845. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56846. /**
  56847. * Block used to add image processing support to fragment shader
  56848. */
  56849. export class ImageProcessingBlock extends NodeMaterialBlock {
  56850. /**
  56851. * Create a new ImageProcessingBlock
  56852. * @param name defines the block name
  56853. */
  56854. constructor(name: string);
  56855. /**
  56856. * Gets the current class name
  56857. * @returns the class name
  56858. */
  56859. getClassName(): string;
  56860. /**
  56861. * Gets the color input component
  56862. */
  56863. readonly color: NodeMaterialConnectionPoint;
  56864. /**
  56865. * Gets the output component
  56866. */
  56867. readonly output: NodeMaterialConnectionPoint;
  56868. /**
  56869. * Initialize the block and prepare the context for build
  56870. * @param state defines the state that will be used for the build
  56871. */
  56872. initialize(state: NodeMaterialBuildState): void;
  56873. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56874. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56876. protected _buildBlock(state: NodeMaterialBuildState): this;
  56877. }
  56878. }
  56879. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56881. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56883. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56885. import { Effect } from "babylonjs/Materials/effect";
  56886. import { Mesh } from "babylonjs/Meshes/mesh";
  56887. import { Scene } from "babylonjs/scene";
  56888. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56889. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56890. /**
  56891. * Block used to pertub normals based on a normal map
  56892. */
  56893. export class PerturbNormalBlock extends NodeMaterialBlock {
  56894. private _tangentSpaceParameterName;
  56895. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56896. invertX: boolean;
  56897. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56898. invertY: boolean;
  56899. /**
  56900. * Create a new PerturbNormalBlock
  56901. * @param name defines the block name
  56902. */
  56903. constructor(name: string);
  56904. /**
  56905. * Gets the current class name
  56906. * @returns the class name
  56907. */
  56908. getClassName(): string;
  56909. /**
  56910. * Gets the world position input component
  56911. */
  56912. readonly worldPosition: NodeMaterialConnectionPoint;
  56913. /**
  56914. * Gets the world normal input component
  56915. */
  56916. readonly worldNormal: NodeMaterialConnectionPoint;
  56917. /**
  56918. * Gets the uv input component
  56919. */
  56920. readonly uv: NodeMaterialConnectionPoint;
  56921. /**
  56922. * Gets the normal map color input component
  56923. */
  56924. readonly normalMapColor: NodeMaterialConnectionPoint;
  56925. /**
  56926. * Gets the strength input component
  56927. */
  56928. readonly strength: NodeMaterialConnectionPoint;
  56929. /**
  56930. * Gets the output component
  56931. */
  56932. readonly output: NodeMaterialConnectionPoint;
  56933. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56934. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56935. autoConfigure(material: NodeMaterial): void;
  56936. protected _buildBlock(state: NodeMaterialBuildState): this;
  56937. protected _dumpPropertiesCode(): string;
  56938. serialize(): any;
  56939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56940. }
  56941. }
  56942. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56946. /**
  56947. * Block used to discard a pixel if a value is smaller than a cutoff
  56948. */
  56949. export class DiscardBlock extends NodeMaterialBlock {
  56950. /**
  56951. * Create a new DiscardBlock
  56952. * @param name defines the block name
  56953. */
  56954. constructor(name: string);
  56955. /**
  56956. * Gets the current class name
  56957. * @returns the class name
  56958. */
  56959. getClassName(): string;
  56960. /**
  56961. * Gets the color input component
  56962. */
  56963. readonly value: NodeMaterialConnectionPoint;
  56964. /**
  56965. * Gets the cutoff input component
  56966. */
  56967. readonly cutoff: NodeMaterialConnectionPoint;
  56968. protected _buildBlock(state: NodeMaterialBuildState): this;
  56969. }
  56970. }
  56971. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56972. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56973. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56974. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56975. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56976. }
  56977. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56980. import { Mesh } from "babylonjs/Meshes/mesh";
  56981. import { Effect } from "babylonjs/Materials/effect";
  56982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56984. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56985. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56986. /**
  56987. * Block used to add support for scene fog
  56988. */
  56989. export class FogBlock extends NodeMaterialBlock {
  56990. private _fogDistanceName;
  56991. private _fogParameters;
  56992. /**
  56993. * Create a new FogBlock
  56994. * @param name defines the block name
  56995. */
  56996. constructor(name: string);
  56997. /**
  56998. * Gets the current class name
  56999. * @returns the class name
  57000. */
  57001. getClassName(): string;
  57002. /**
  57003. * Gets the world position input component
  57004. */
  57005. readonly worldPosition: NodeMaterialConnectionPoint;
  57006. /**
  57007. * Gets the view input component
  57008. */
  57009. readonly view: NodeMaterialConnectionPoint;
  57010. /**
  57011. * Gets the color input component
  57012. */
  57013. readonly input: NodeMaterialConnectionPoint;
  57014. /**
  57015. * Gets the fog color input component
  57016. */
  57017. readonly fogColor: NodeMaterialConnectionPoint;
  57018. /**
  57019. * Gets the output component
  57020. */
  57021. readonly output: NodeMaterialConnectionPoint;
  57022. autoConfigure(material: NodeMaterial): void;
  57023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57024. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57025. protected _buildBlock(state: NodeMaterialBuildState): this;
  57026. }
  57027. }
  57028. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57033. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57034. import { Effect } from "babylonjs/Materials/effect";
  57035. import { Mesh } from "babylonjs/Meshes/mesh";
  57036. import { Light } from "babylonjs/Lights/light";
  57037. import { Nullable } from "babylonjs/types";
  57038. import { Scene } from "babylonjs/scene";
  57039. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57040. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57041. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57042. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57043. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57044. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57045. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57046. /**
  57047. * Block used to add light in the fragment shader
  57048. */
  57049. export class LightBlock extends NodeMaterialBlock {
  57050. private _lightId;
  57051. /**
  57052. * Gets or sets the light associated with this block
  57053. */
  57054. light: Nullable<Light>;
  57055. /**
  57056. * Create a new LightBlock
  57057. * @param name defines the block name
  57058. */
  57059. constructor(name: string);
  57060. /**
  57061. * Gets the current class name
  57062. * @returns the class name
  57063. */
  57064. getClassName(): string;
  57065. /**
  57066. * Gets the world position input component
  57067. */
  57068. readonly worldPosition: NodeMaterialConnectionPoint;
  57069. /**
  57070. * Gets the world normal input component
  57071. */
  57072. readonly worldNormal: NodeMaterialConnectionPoint;
  57073. /**
  57074. * Gets the camera (or eye) position component
  57075. */
  57076. readonly cameraPosition: NodeMaterialConnectionPoint;
  57077. /**
  57078. * Gets the glossiness component
  57079. */
  57080. readonly glossiness: NodeMaterialConnectionPoint;
  57081. /**
  57082. * Gets the glossinness power component
  57083. */
  57084. readonly glossPower: NodeMaterialConnectionPoint;
  57085. /**
  57086. * Gets the diffuse color component
  57087. */
  57088. readonly diffuseColor: NodeMaterialConnectionPoint;
  57089. /**
  57090. * Gets the specular color component
  57091. */
  57092. readonly specularColor: NodeMaterialConnectionPoint;
  57093. /**
  57094. * Gets the diffuse output component
  57095. */
  57096. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57097. /**
  57098. * Gets the specular output component
  57099. */
  57100. readonly specularOutput: NodeMaterialConnectionPoint;
  57101. autoConfigure(material: NodeMaterial): void;
  57102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57103. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57104. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57105. private _injectVertexCode;
  57106. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57107. serialize(): any;
  57108. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57109. }
  57110. }
  57111. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57112. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57113. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57114. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57115. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57116. }
  57117. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57118. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57119. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57120. }
  57121. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57125. /**
  57126. * Block used to multiply 2 values
  57127. */
  57128. export class MultiplyBlock extends NodeMaterialBlock {
  57129. /**
  57130. * Creates a new MultiplyBlock
  57131. * @param name defines the block name
  57132. */
  57133. constructor(name: string);
  57134. /**
  57135. * Gets the current class name
  57136. * @returns the class name
  57137. */
  57138. getClassName(): string;
  57139. /**
  57140. * Gets the left operand input component
  57141. */
  57142. readonly left: NodeMaterialConnectionPoint;
  57143. /**
  57144. * Gets the right operand input component
  57145. */
  57146. readonly right: NodeMaterialConnectionPoint;
  57147. /**
  57148. * Gets the output component
  57149. */
  57150. readonly output: NodeMaterialConnectionPoint;
  57151. protected _buildBlock(state: NodeMaterialBuildState): this;
  57152. }
  57153. }
  57154. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57158. /**
  57159. * Block used to add 2 vectors
  57160. */
  57161. export class AddBlock extends NodeMaterialBlock {
  57162. /**
  57163. * Creates a new AddBlock
  57164. * @param name defines the block name
  57165. */
  57166. constructor(name: string);
  57167. /**
  57168. * Gets the current class name
  57169. * @returns the class name
  57170. */
  57171. getClassName(): string;
  57172. /**
  57173. * Gets the left operand input component
  57174. */
  57175. readonly left: NodeMaterialConnectionPoint;
  57176. /**
  57177. * Gets the right operand input component
  57178. */
  57179. readonly right: NodeMaterialConnectionPoint;
  57180. /**
  57181. * Gets the output component
  57182. */
  57183. readonly output: NodeMaterialConnectionPoint;
  57184. protected _buildBlock(state: NodeMaterialBuildState): this;
  57185. }
  57186. }
  57187. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57190. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57191. /**
  57192. * Block used to scale a vector by a float
  57193. */
  57194. export class ScaleBlock extends NodeMaterialBlock {
  57195. /**
  57196. * Creates a new ScaleBlock
  57197. * @param name defines the block name
  57198. */
  57199. constructor(name: string);
  57200. /**
  57201. * Gets the current class name
  57202. * @returns the class name
  57203. */
  57204. getClassName(): string;
  57205. /**
  57206. * Gets the input component
  57207. */
  57208. readonly input: NodeMaterialConnectionPoint;
  57209. /**
  57210. * Gets the factor input component
  57211. */
  57212. readonly factor: NodeMaterialConnectionPoint;
  57213. /**
  57214. * Gets the output component
  57215. */
  57216. readonly output: NodeMaterialConnectionPoint;
  57217. protected _buildBlock(state: NodeMaterialBuildState): this;
  57218. }
  57219. }
  57220. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57221. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57222. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57224. import { Scene } from "babylonjs/scene";
  57225. /**
  57226. * Block used to clamp a float
  57227. */
  57228. export class ClampBlock extends NodeMaterialBlock {
  57229. /** Gets or sets the minimum range */
  57230. minimum: number;
  57231. /** Gets or sets the maximum range */
  57232. maximum: number;
  57233. /**
  57234. * Creates a new ClampBlock
  57235. * @param name defines the block name
  57236. */
  57237. constructor(name: string);
  57238. /**
  57239. * Gets the current class name
  57240. * @returns the class name
  57241. */
  57242. getClassName(): string;
  57243. /**
  57244. * Gets the value input component
  57245. */
  57246. readonly value: NodeMaterialConnectionPoint;
  57247. /**
  57248. * Gets the output component
  57249. */
  57250. readonly output: NodeMaterialConnectionPoint;
  57251. protected _buildBlock(state: NodeMaterialBuildState): this;
  57252. protected _dumpPropertiesCode(): string;
  57253. serialize(): any;
  57254. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57255. }
  57256. }
  57257. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57258. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57259. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57260. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57261. /**
  57262. * Block used to apply a cross product between 2 vectors
  57263. */
  57264. export class CrossBlock extends NodeMaterialBlock {
  57265. /**
  57266. * Creates a new CrossBlock
  57267. * @param name defines the block name
  57268. */
  57269. constructor(name: string);
  57270. /**
  57271. * Gets the current class name
  57272. * @returns the class name
  57273. */
  57274. getClassName(): string;
  57275. /**
  57276. * Gets the left operand input component
  57277. */
  57278. readonly left: NodeMaterialConnectionPoint;
  57279. /**
  57280. * Gets the right operand input component
  57281. */
  57282. readonly right: NodeMaterialConnectionPoint;
  57283. /**
  57284. * Gets the output component
  57285. */
  57286. readonly output: NodeMaterialConnectionPoint;
  57287. protected _buildBlock(state: NodeMaterialBuildState): this;
  57288. }
  57289. }
  57290. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57291. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57292. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57293. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57294. /**
  57295. * Block used to apply a dot product between 2 vectors
  57296. */
  57297. export class DotBlock extends NodeMaterialBlock {
  57298. /**
  57299. * Creates a new DotBlock
  57300. * @param name defines the block name
  57301. */
  57302. constructor(name: string);
  57303. /**
  57304. * Gets the current class name
  57305. * @returns the class name
  57306. */
  57307. getClassName(): string;
  57308. /**
  57309. * Gets the left operand input component
  57310. */
  57311. readonly left: NodeMaterialConnectionPoint;
  57312. /**
  57313. * Gets the right operand input component
  57314. */
  57315. readonly right: NodeMaterialConnectionPoint;
  57316. /**
  57317. * Gets the output component
  57318. */
  57319. readonly output: NodeMaterialConnectionPoint;
  57320. protected _buildBlock(state: NodeMaterialBuildState): this;
  57321. }
  57322. }
  57323. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57327. import { Vector2 } from "babylonjs/Maths/math.vector";
  57328. import { Scene } from "babylonjs/scene";
  57329. /**
  57330. * Block used to remap a float from a range to a new one
  57331. */
  57332. export class RemapBlock extends NodeMaterialBlock {
  57333. /**
  57334. * Gets or sets the source range
  57335. */
  57336. sourceRange: Vector2;
  57337. /**
  57338. * Gets or sets the target range
  57339. */
  57340. targetRange: Vector2;
  57341. /**
  57342. * Creates a new RemapBlock
  57343. * @param name defines the block name
  57344. */
  57345. constructor(name: string);
  57346. /**
  57347. * Gets the current class name
  57348. * @returns the class name
  57349. */
  57350. getClassName(): string;
  57351. /**
  57352. * Gets the input component
  57353. */
  57354. readonly input: NodeMaterialConnectionPoint;
  57355. /**
  57356. * Gets the source min input component
  57357. */
  57358. readonly sourceMin: NodeMaterialConnectionPoint;
  57359. /**
  57360. * Gets the source max input component
  57361. */
  57362. readonly sourceMax: NodeMaterialConnectionPoint;
  57363. /**
  57364. * Gets the target min input component
  57365. */
  57366. readonly targetMin: NodeMaterialConnectionPoint;
  57367. /**
  57368. * Gets the target max input component
  57369. */
  57370. readonly targetMax: NodeMaterialConnectionPoint;
  57371. /**
  57372. * Gets the output component
  57373. */
  57374. readonly output: NodeMaterialConnectionPoint;
  57375. protected _buildBlock(state: NodeMaterialBuildState): this;
  57376. protected _dumpPropertiesCode(): string;
  57377. serialize(): any;
  57378. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57379. }
  57380. }
  57381. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57385. /**
  57386. * Block used to normalize a vector
  57387. */
  57388. export class NormalizeBlock extends NodeMaterialBlock {
  57389. /**
  57390. * Creates a new NormalizeBlock
  57391. * @param name defines the block name
  57392. */
  57393. constructor(name: string);
  57394. /**
  57395. * Gets the current class name
  57396. * @returns the class name
  57397. */
  57398. getClassName(): string;
  57399. /**
  57400. * Gets the input component
  57401. */
  57402. readonly input: NodeMaterialConnectionPoint;
  57403. /**
  57404. * Gets the output component
  57405. */
  57406. readonly output: NodeMaterialConnectionPoint;
  57407. protected _buildBlock(state: NodeMaterialBuildState): this;
  57408. }
  57409. }
  57410. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57414. import { Scene } from "babylonjs/scene";
  57415. /**
  57416. * Operations supported by the Trigonometry block
  57417. */
  57418. export enum TrigonometryBlockOperations {
  57419. /** Cos */
  57420. Cos = 0,
  57421. /** Sin */
  57422. Sin = 1,
  57423. /** Abs */
  57424. Abs = 2,
  57425. /** Exp */
  57426. Exp = 3,
  57427. /** Exp2 */
  57428. Exp2 = 4,
  57429. /** Round */
  57430. Round = 5,
  57431. /** Floor */
  57432. Floor = 6,
  57433. /** Ceiling */
  57434. Ceiling = 7,
  57435. /** Square root */
  57436. Sqrt = 8,
  57437. /** Log */
  57438. Log = 9,
  57439. /** Tangent */
  57440. Tan = 10,
  57441. /** Arc tangent */
  57442. ArcTan = 11,
  57443. /** Arc cosinus */
  57444. ArcCos = 12,
  57445. /** Arc sinus */
  57446. ArcSin = 13,
  57447. /** Fraction */
  57448. Fract = 14,
  57449. /** Sign */
  57450. Sign = 15,
  57451. /** To radians (from degrees) */
  57452. Radians = 16,
  57453. /** To degrees (from radians) */
  57454. Degrees = 17
  57455. }
  57456. /**
  57457. * Block used to apply trigonometry operation to floats
  57458. */
  57459. export class TrigonometryBlock extends NodeMaterialBlock {
  57460. /**
  57461. * Gets or sets the operation applied by the block
  57462. */
  57463. operation: TrigonometryBlockOperations;
  57464. /**
  57465. * Creates a new TrigonometryBlock
  57466. * @param name defines the block name
  57467. */
  57468. constructor(name: string);
  57469. /**
  57470. * Gets the current class name
  57471. * @returns the class name
  57472. */
  57473. getClassName(): string;
  57474. /**
  57475. * Gets the input component
  57476. */
  57477. readonly input: NodeMaterialConnectionPoint;
  57478. /**
  57479. * Gets the output component
  57480. */
  57481. readonly output: NodeMaterialConnectionPoint;
  57482. protected _buildBlock(state: NodeMaterialBuildState): this;
  57483. serialize(): any;
  57484. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57485. }
  57486. }
  57487. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57491. /**
  57492. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57493. */
  57494. export class ColorMergerBlock extends NodeMaterialBlock {
  57495. /**
  57496. * Create a new ColorMergerBlock
  57497. * @param name defines the block name
  57498. */
  57499. constructor(name: string);
  57500. /**
  57501. * Gets the current class name
  57502. * @returns the class name
  57503. */
  57504. getClassName(): string;
  57505. /**
  57506. * Gets the r component (input)
  57507. */
  57508. readonly r: NodeMaterialConnectionPoint;
  57509. /**
  57510. * Gets the g component (input)
  57511. */
  57512. readonly g: NodeMaterialConnectionPoint;
  57513. /**
  57514. * Gets the b component (input)
  57515. */
  57516. readonly b: NodeMaterialConnectionPoint;
  57517. /**
  57518. * Gets the a component (input)
  57519. */
  57520. readonly a: NodeMaterialConnectionPoint;
  57521. /**
  57522. * Gets the rgba component (output)
  57523. */
  57524. readonly rgba: NodeMaterialConnectionPoint;
  57525. /**
  57526. * Gets the rgb component (output)
  57527. */
  57528. readonly rgb: NodeMaterialConnectionPoint;
  57529. protected _buildBlock(state: NodeMaterialBuildState): this;
  57530. }
  57531. }
  57532. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57533. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57534. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57535. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57536. /**
  57537. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57538. */
  57539. export class VectorMergerBlock extends NodeMaterialBlock {
  57540. /**
  57541. * Create a new VectorMergerBlock
  57542. * @param name defines the block name
  57543. */
  57544. constructor(name: string);
  57545. /**
  57546. * Gets the current class name
  57547. * @returns the class name
  57548. */
  57549. getClassName(): string;
  57550. /**
  57551. * Gets the x component (input)
  57552. */
  57553. readonly x: NodeMaterialConnectionPoint;
  57554. /**
  57555. * Gets the y component (input)
  57556. */
  57557. readonly y: NodeMaterialConnectionPoint;
  57558. /**
  57559. * Gets the z component (input)
  57560. */
  57561. readonly z: NodeMaterialConnectionPoint;
  57562. /**
  57563. * Gets the w component (input)
  57564. */
  57565. readonly w: NodeMaterialConnectionPoint;
  57566. /**
  57567. * Gets the xyzw component (output)
  57568. */
  57569. readonly xyzw: NodeMaterialConnectionPoint;
  57570. /**
  57571. * Gets the xyz component (output)
  57572. */
  57573. readonly xyz: NodeMaterialConnectionPoint;
  57574. /**
  57575. * Gets the xy component (output)
  57576. */
  57577. readonly xy: NodeMaterialConnectionPoint;
  57578. protected _buildBlock(state: NodeMaterialBuildState): this;
  57579. }
  57580. }
  57581. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57585. /**
  57586. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57587. */
  57588. export class ColorSplitterBlock extends NodeMaterialBlock {
  57589. /**
  57590. * Create a new ColorSplitterBlock
  57591. * @param name defines the block name
  57592. */
  57593. constructor(name: string);
  57594. /**
  57595. * Gets the current class name
  57596. * @returns the class name
  57597. */
  57598. getClassName(): string;
  57599. /**
  57600. * Gets the rgba component (input)
  57601. */
  57602. readonly rgba: NodeMaterialConnectionPoint;
  57603. /**
  57604. * Gets the rgb component (input)
  57605. */
  57606. readonly rgbIn: NodeMaterialConnectionPoint;
  57607. /**
  57608. * Gets the rgb component (output)
  57609. */
  57610. readonly rgbOut: NodeMaterialConnectionPoint;
  57611. /**
  57612. * Gets the r component (output)
  57613. */
  57614. readonly r: NodeMaterialConnectionPoint;
  57615. /**
  57616. * Gets the g component (output)
  57617. */
  57618. readonly g: NodeMaterialConnectionPoint;
  57619. /**
  57620. * Gets the b component (output)
  57621. */
  57622. readonly b: NodeMaterialConnectionPoint;
  57623. /**
  57624. * Gets the a component (output)
  57625. */
  57626. readonly a: NodeMaterialConnectionPoint;
  57627. protected _inputRename(name: string): string;
  57628. protected _outputRename(name: string): string;
  57629. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57630. }
  57631. }
  57632. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57636. /**
  57637. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57638. */
  57639. export class VectorSplitterBlock extends NodeMaterialBlock {
  57640. /**
  57641. * Create a new VectorSplitterBlock
  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 xyzw component (input)
  57652. */
  57653. readonly xyzw: NodeMaterialConnectionPoint;
  57654. /**
  57655. * Gets the xyz component (input)
  57656. */
  57657. readonly xyzIn: NodeMaterialConnectionPoint;
  57658. /**
  57659. * Gets the xy component (input)
  57660. */
  57661. readonly xyIn: NodeMaterialConnectionPoint;
  57662. /**
  57663. * Gets the xyz component (output)
  57664. */
  57665. readonly xyzOut: NodeMaterialConnectionPoint;
  57666. /**
  57667. * Gets the xy component (output)
  57668. */
  57669. readonly xyOut: NodeMaterialConnectionPoint;
  57670. /**
  57671. * Gets the x component (output)
  57672. */
  57673. readonly x: NodeMaterialConnectionPoint;
  57674. /**
  57675. * Gets the y component (output)
  57676. */
  57677. readonly y: NodeMaterialConnectionPoint;
  57678. /**
  57679. * Gets the z component (output)
  57680. */
  57681. readonly z: NodeMaterialConnectionPoint;
  57682. /**
  57683. * Gets the w component (output)
  57684. */
  57685. readonly w: NodeMaterialConnectionPoint;
  57686. protected _inputRename(name: string): string;
  57687. protected _outputRename(name: string): string;
  57688. protected _buildBlock(state: NodeMaterialBuildState): this;
  57689. }
  57690. }
  57691. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57692. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57693. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57694. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57695. /**
  57696. * Block used to lerp between 2 values
  57697. */
  57698. export class LerpBlock extends NodeMaterialBlock {
  57699. /**
  57700. * Creates a new LerpBlock
  57701. * @param name defines the block name
  57702. */
  57703. constructor(name: string);
  57704. /**
  57705. * Gets the current class name
  57706. * @returns the class name
  57707. */
  57708. getClassName(): string;
  57709. /**
  57710. * Gets the left operand input component
  57711. */
  57712. readonly left: NodeMaterialConnectionPoint;
  57713. /**
  57714. * Gets the right operand input component
  57715. */
  57716. readonly right: NodeMaterialConnectionPoint;
  57717. /**
  57718. * Gets the gradient operand input component
  57719. */
  57720. readonly gradient: NodeMaterialConnectionPoint;
  57721. /**
  57722. * Gets the output component
  57723. */
  57724. readonly output: NodeMaterialConnectionPoint;
  57725. protected _buildBlock(state: NodeMaterialBuildState): this;
  57726. }
  57727. }
  57728. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57729. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57730. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57731. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57732. /**
  57733. * Block used to divide 2 vectors
  57734. */
  57735. export class DivideBlock extends NodeMaterialBlock {
  57736. /**
  57737. * Creates a new DivideBlock
  57738. * @param name defines the block name
  57739. */
  57740. constructor(name: string);
  57741. /**
  57742. * Gets the current class name
  57743. * @returns the class name
  57744. */
  57745. getClassName(): string;
  57746. /**
  57747. * Gets the left operand input component
  57748. */
  57749. readonly left: NodeMaterialConnectionPoint;
  57750. /**
  57751. * Gets the right operand input component
  57752. */
  57753. readonly right: NodeMaterialConnectionPoint;
  57754. /**
  57755. * Gets the output component
  57756. */
  57757. readonly output: NodeMaterialConnectionPoint;
  57758. protected _buildBlock(state: NodeMaterialBuildState): this;
  57759. }
  57760. }
  57761. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57765. /**
  57766. * Block used to subtract 2 vectors
  57767. */
  57768. export class SubtractBlock extends NodeMaterialBlock {
  57769. /**
  57770. * Creates a new SubtractBlock
  57771. * @param name defines the block name
  57772. */
  57773. constructor(name: string);
  57774. /**
  57775. * Gets the current class name
  57776. * @returns the class name
  57777. */
  57778. getClassName(): string;
  57779. /**
  57780. * Gets the left operand input component
  57781. */
  57782. readonly left: NodeMaterialConnectionPoint;
  57783. /**
  57784. * Gets the right operand input component
  57785. */
  57786. readonly right: NodeMaterialConnectionPoint;
  57787. /**
  57788. * Gets the output component
  57789. */
  57790. readonly output: NodeMaterialConnectionPoint;
  57791. protected _buildBlock(state: NodeMaterialBuildState): this;
  57792. }
  57793. }
  57794. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57798. /**
  57799. * Block used to step a value
  57800. */
  57801. export class StepBlock extends NodeMaterialBlock {
  57802. /**
  57803. * Creates a new StepBlock
  57804. * @param name defines the block name
  57805. */
  57806. constructor(name: string);
  57807. /**
  57808. * Gets the current class name
  57809. * @returns the class name
  57810. */
  57811. getClassName(): string;
  57812. /**
  57813. * Gets the value operand input component
  57814. */
  57815. readonly value: NodeMaterialConnectionPoint;
  57816. /**
  57817. * Gets the edge operand input component
  57818. */
  57819. readonly edge: NodeMaterialConnectionPoint;
  57820. /**
  57821. * Gets the output component
  57822. */
  57823. readonly output: NodeMaterialConnectionPoint;
  57824. protected _buildBlock(state: NodeMaterialBuildState): this;
  57825. }
  57826. }
  57827. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57831. /**
  57832. * Block used to get the opposite (1 - x) of a value
  57833. */
  57834. export class OneMinusBlock extends NodeMaterialBlock {
  57835. /**
  57836. * Creates a new OneMinusBlock
  57837. * @param name defines the block name
  57838. */
  57839. constructor(name: string);
  57840. /**
  57841. * Gets the current class name
  57842. * @returns the class name
  57843. */
  57844. getClassName(): string;
  57845. /**
  57846. * Gets the input component
  57847. */
  57848. readonly input: NodeMaterialConnectionPoint;
  57849. /**
  57850. * Gets the output component
  57851. */
  57852. readonly output: NodeMaterialConnectionPoint;
  57853. protected _buildBlock(state: NodeMaterialBuildState): this;
  57854. }
  57855. }
  57856. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57857. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57858. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57860. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57861. /**
  57862. * Block used to get the view direction
  57863. */
  57864. export class ViewDirectionBlock extends NodeMaterialBlock {
  57865. /**
  57866. * Creates a new ViewDirectionBlock
  57867. * @param name defines the block name
  57868. */
  57869. constructor(name: string);
  57870. /**
  57871. * Gets the current class name
  57872. * @returns the class name
  57873. */
  57874. getClassName(): string;
  57875. /**
  57876. * Gets the world position component
  57877. */
  57878. readonly worldPosition: NodeMaterialConnectionPoint;
  57879. /**
  57880. * Gets the camera position component
  57881. */
  57882. readonly cameraPosition: NodeMaterialConnectionPoint;
  57883. /**
  57884. * Gets the output component
  57885. */
  57886. readonly output: NodeMaterialConnectionPoint;
  57887. autoConfigure(material: NodeMaterial): void;
  57888. protected _buildBlock(state: NodeMaterialBuildState): this;
  57889. }
  57890. }
  57891. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57893. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57895. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57896. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57897. /**
  57898. * Block used to compute fresnel value
  57899. */
  57900. export class FresnelBlock extends NodeMaterialBlock {
  57901. /**
  57902. * Create a new FresnelBlock
  57903. * @param name defines the block name
  57904. */
  57905. constructor(name: string);
  57906. /**
  57907. * Gets the current class name
  57908. * @returns the class name
  57909. */
  57910. getClassName(): string;
  57911. /**
  57912. * Gets the world normal input component
  57913. */
  57914. readonly worldNormal: NodeMaterialConnectionPoint;
  57915. /**
  57916. * Gets the view direction input component
  57917. */
  57918. readonly viewDirection: NodeMaterialConnectionPoint;
  57919. /**
  57920. * Gets the bias input component
  57921. */
  57922. readonly bias: NodeMaterialConnectionPoint;
  57923. /**
  57924. * Gets the camera (or eye) position component
  57925. */
  57926. readonly power: NodeMaterialConnectionPoint;
  57927. /**
  57928. * Gets the fresnel output component
  57929. */
  57930. readonly fresnel: NodeMaterialConnectionPoint;
  57931. autoConfigure(material: NodeMaterial): void;
  57932. protected _buildBlock(state: NodeMaterialBuildState): this;
  57933. }
  57934. }
  57935. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57936. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57937. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57939. /**
  57940. * Block used to get the max of 2 values
  57941. */
  57942. export class MaxBlock extends NodeMaterialBlock {
  57943. /**
  57944. * Creates a new MaxBlock
  57945. * @param name defines the block name
  57946. */
  57947. constructor(name: string);
  57948. /**
  57949. * Gets the current class name
  57950. * @returns the class name
  57951. */
  57952. getClassName(): string;
  57953. /**
  57954. * Gets the left operand input component
  57955. */
  57956. readonly left: NodeMaterialConnectionPoint;
  57957. /**
  57958. * Gets the right operand input component
  57959. */
  57960. readonly right: NodeMaterialConnectionPoint;
  57961. /**
  57962. * Gets the output component
  57963. */
  57964. readonly output: NodeMaterialConnectionPoint;
  57965. protected _buildBlock(state: NodeMaterialBuildState): this;
  57966. }
  57967. }
  57968. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57970. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57972. /**
  57973. * Block used to get the min of 2 values
  57974. */
  57975. export class MinBlock extends NodeMaterialBlock {
  57976. /**
  57977. * Creates a new MinBlock
  57978. * @param name defines the block name
  57979. */
  57980. constructor(name: string);
  57981. /**
  57982. * Gets the current class name
  57983. * @returns the class name
  57984. */
  57985. getClassName(): string;
  57986. /**
  57987. * Gets the left operand input component
  57988. */
  57989. readonly left: NodeMaterialConnectionPoint;
  57990. /**
  57991. * Gets the right operand input component
  57992. */
  57993. readonly right: NodeMaterialConnectionPoint;
  57994. /**
  57995. * Gets the output component
  57996. */
  57997. readonly output: NodeMaterialConnectionPoint;
  57998. protected _buildBlock(state: NodeMaterialBuildState): this;
  57999. }
  58000. }
  58001. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58005. /**
  58006. * Block used to get the distance between 2 values
  58007. */
  58008. export class DistanceBlock extends NodeMaterialBlock {
  58009. /**
  58010. * Creates a new DistanceBlock
  58011. * @param name defines the block name
  58012. */
  58013. constructor(name: string);
  58014. /**
  58015. * Gets the current class name
  58016. * @returns the class name
  58017. */
  58018. getClassName(): string;
  58019. /**
  58020. * Gets the left operand input component
  58021. */
  58022. readonly left: NodeMaterialConnectionPoint;
  58023. /**
  58024. * Gets the right operand input component
  58025. */
  58026. readonly right: NodeMaterialConnectionPoint;
  58027. /**
  58028. * Gets the output component
  58029. */
  58030. readonly output: NodeMaterialConnectionPoint;
  58031. protected _buildBlock(state: NodeMaterialBuildState): this;
  58032. }
  58033. }
  58034. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58038. /**
  58039. * Block used to get the length of a vector
  58040. */
  58041. export class LengthBlock extends NodeMaterialBlock {
  58042. /**
  58043. * Creates a new LengthBlock
  58044. * @param name defines the block name
  58045. */
  58046. constructor(name: string);
  58047. /**
  58048. * Gets the current class name
  58049. * @returns the class name
  58050. */
  58051. getClassName(): string;
  58052. /**
  58053. * Gets the value input component
  58054. */
  58055. readonly value: NodeMaterialConnectionPoint;
  58056. /**
  58057. * Gets the output component
  58058. */
  58059. readonly output: NodeMaterialConnectionPoint;
  58060. protected _buildBlock(state: NodeMaterialBuildState): this;
  58061. }
  58062. }
  58063. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58064. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58065. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58066. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58067. /**
  58068. * Block used to get negative version of a value (i.e. x * -1)
  58069. */
  58070. export class NegateBlock extends NodeMaterialBlock {
  58071. /**
  58072. * Creates a new NegateBlock
  58073. * @param name defines the block name
  58074. */
  58075. constructor(name: string);
  58076. /**
  58077. * Gets the current class name
  58078. * @returns the class name
  58079. */
  58080. getClassName(): string;
  58081. /**
  58082. * Gets the value input component
  58083. */
  58084. readonly value: NodeMaterialConnectionPoint;
  58085. /**
  58086. * Gets the output component
  58087. */
  58088. readonly output: NodeMaterialConnectionPoint;
  58089. protected _buildBlock(state: NodeMaterialBuildState): this;
  58090. }
  58091. }
  58092. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58096. /**
  58097. * Block used to get the value of the first parameter raised to the power of the second
  58098. */
  58099. export class PowBlock extends NodeMaterialBlock {
  58100. /**
  58101. * Creates a new PowBlock
  58102. * @param name defines the block name
  58103. */
  58104. constructor(name: string);
  58105. /**
  58106. * Gets the current class name
  58107. * @returns the class name
  58108. */
  58109. getClassName(): string;
  58110. /**
  58111. * Gets the value operand input component
  58112. */
  58113. readonly value: NodeMaterialConnectionPoint;
  58114. /**
  58115. * Gets the power operand input component
  58116. */
  58117. readonly power: NodeMaterialConnectionPoint;
  58118. /**
  58119. * Gets the output component
  58120. */
  58121. readonly output: NodeMaterialConnectionPoint;
  58122. protected _buildBlock(state: NodeMaterialBuildState): this;
  58123. }
  58124. }
  58125. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58127. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58128. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58129. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58130. /**
  58131. * Block used to get a random number
  58132. */
  58133. export class RandomNumberBlock extends NodeMaterialBlock {
  58134. /**
  58135. * Creates a new RandomNumberBlock
  58136. * @param name defines the block name
  58137. */
  58138. constructor(name: string);
  58139. /**
  58140. * Gets the current class name
  58141. * @returns the class name
  58142. */
  58143. getClassName(): string;
  58144. /**
  58145. * Gets the seed input component
  58146. */
  58147. readonly seed: NodeMaterialConnectionPoint;
  58148. /**
  58149. * Gets the output component
  58150. */
  58151. readonly output: NodeMaterialConnectionPoint;
  58152. protected _buildBlock(state: NodeMaterialBuildState): this;
  58153. }
  58154. }
  58155. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58159. /**
  58160. * Block used to compute arc tangent of 2 values
  58161. */
  58162. export class ArcTan2Block extends NodeMaterialBlock {
  58163. /**
  58164. * Creates a new ArcTan2Block
  58165. * @param name defines the block name
  58166. */
  58167. constructor(name: string);
  58168. /**
  58169. * Gets the current class name
  58170. * @returns the class name
  58171. */
  58172. getClassName(): string;
  58173. /**
  58174. * Gets the x operand input component
  58175. */
  58176. readonly x: NodeMaterialConnectionPoint;
  58177. /**
  58178. * Gets the y operand input component
  58179. */
  58180. readonly y: NodeMaterialConnectionPoint;
  58181. /**
  58182. * Gets the output component
  58183. */
  58184. readonly output: NodeMaterialConnectionPoint;
  58185. protected _buildBlock(state: NodeMaterialBuildState): this;
  58186. }
  58187. }
  58188. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58192. /**
  58193. * Block used to smooth step a value
  58194. */
  58195. export class SmoothStepBlock extends NodeMaterialBlock {
  58196. /**
  58197. * Creates a new SmoothStepBlock
  58198. * @param name defines the block name
  58199. */
  58200. constructor(name: string);
  58201. /**
  58202. * Gets the current class name
  58203. * @returns the class name
  58204. */
  58205. getClassName(): string;
  58206. /**
  58207. * Gets the value operand input component
  58208. */
  58209. readonly value: NodeMaterialConnectionPoint;
  58210. /**
  58211. * Gets the first edge operand input component
  58212. */
  58213. readonly edge0: NodeMaterialConnectionPoint;
  58214. /**
  58215. * Gets the second edge operand input component
  58216. */
  58217. readonly edge1: NodeMaterialConnectionPoint;
  58218. /**
  58219. * Gets the output component
  58220. */
  58221. readonly output: NodeMaterialConnectionPoint;
  58222. protected _buildBlock(state: NodeMaterialBuildState): this;
  58223. }
  58224. }
  58225. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58227. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58229. /**
  58230. * Block used to get the reciprocal (1 / x) of a value
  58231. */
  58232. export class ReciprocalBlock extends NodeMaterialBlock {
  58233. /**
  58234. * Creates a new ReciprocalBlock
  58235. * @param name defines the block name
  58236. */
  58237. constructor(name: string);
  58238. /**
  58239. * Gets the current class name
  58240. * @returns the class name
  58241. */
  58242. getClassName(): string;
  58243. /**
  58244. * Gets the input component
  58245. */
  58246. readonly input: 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/replaceColorBlock" {
  58255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58258. /**
  58259. * Block used to replace a color by another one
  58260. */
  58261. export class ReplaceColorBlock extends NodeMaterialBlock {
  58262. /**
  58263. * Creates a new ReplaceColorBlock
  58264. * @param name defines the block name
  58265. */
  58266. constructor(name: string);
  58267. /**
  58268. * Gets the current class name
  58269. * @returns the class name
  58270. */
  58271. getClassName(): string;
  58272. /**
  58273. * Gets the value input component
  58274. */
  58275. readonly value: NodeMaterialConnectionPoint;
  58276. /**
  58277. * Gets the reference input component
  58278. */
  58279. readonly reference: NodeMaterialConnectionPoint;
  58280. /**
  58281. * Gets the distance input component
  58282. */
  58283. readonly distance: NodeMaterialConnectionPoint;
  58284. /**
  58285. * Gets the replacement input component
  58286. */
  58287. readonly replacement: NodeMaterialConnectionPoint;
  58288. /**
  58289. * Gets the output component
  58290. */
  58291. readonly output: NodeMaterialConnectionPoint;
  58292. protected _buildBlock(state: NodeMaterialBuildState): this;
  58293. }
  58294. }
  58295. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58296. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58297. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58298. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58299. /**
  58300. * Block used to posterize a value
  58301. * @see https://en.wikipedia.org/wiki/Posterization
  58302. */
  58303. export class PosterizeBlock extends NodeMaterialBlock {
  58304. /**
  58305. * Creates a new PosterizeBlock
  58306. * @param name defines the block name
  58307. */
  58308. constructor(name: string);
  58309. /**
  58310. * Gets the current class name
  58311. * @returns the class name
  58312. */
  58313. getClassName(): string;
  58314. /**
  58315. * Gets the value input component
  58316. */
  58317. readonly value: NodeMaterialConnectionPoint;
  58318. /**
  58319. * Gets the steps input component
  58320. */
  58321. readonly steps: NodeMaterialConnectionPoint;
  58322. /**
  58323. * Gets the output component
  58324. */
  58325. readonly output: NodeMaterialConnectionPoint;
  58326. protected _buildBlock(state: NodeMaterialBuildState): this;
  58327. }
  58328. }
  58329. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58330. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58331. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58333. import { Scene } from "babylonjs/scene";
  58334. /**
  58335. * Operations supported by the Wave block
  58336. */
  58337. export enum WaveBlockKind {
  58338. /** SawTooth */
  58339. SawTooth = 0,
  58340. /** Square */
  58341. Square = 1,
  58342. /** Triangle */
  58343. Triangle = 2
  58344. }
  58345. /**
  58346. * Block used to apply wave operation to floats
  58347. */
  58348. export class WaveBlock extends NodeMaterialBlock {
  58349. /**
  58350. * Gets or sets the kibnd of wave to be applied by the block
  58351. */
  58352. kind: WaveBlockKind;
  58353. /**
  58354. * Creates a new WaveBlock
  58355. * @param name defines the block name
  58356. */
  58357. constructor(name: string);
  58358. /**
  58359. * Gets the current class name
  58360. * @returns the class name
  58361. */
  58362. getClassName(): string;
  58363. /**
  58364. * Gets the input component
  58365. */
  58366. readonly input: NodeMaterialConnectionPoint;
  58367. /**
  58368. * Gets the output component
  58369. */
  58370. readonly output: NodeMaterialConnectionPoint;
  58371. protected _buildBlock(state: NodeMaterialBuildState): this;
  58372. serialize(): any;
  58373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58374. }
  58375. }
  58376. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58377. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58378. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58379. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58380. import { Color3 } from "babylonjs/Maths/math.color";
  58381. import { Scene } from "babylonjs/scene";
  58382. /**
  58383. * Class used to store a color step for the GradientBlock
  58384. */
  58385. export class GradientBlockColorStep {
  58386. /**
  58387. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58388. */
  58389. step: number;
  58390. /**
  58391. * Gets or sets the color associated with this step
  58392. */
  58393. color: Color3;
  58394. /**
  58395. * Creates a new GradientBlockColorStep
  58396. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58397. * @param color defines the color associated with this step
  58398. */
  58399. constructor(
  58400. /**
  58401. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58402. */
  58403. step: number,
  58404. /**
  58405. * Gets or sets the color associated with this step
  58406. */
  58407. color: Color3);
  58408. }
  58409. /**
  58410. * Block used to return a color from a gradient based on an input value between 0 and 1
  58411. */
  58412. export class GradientBlock extends NodeMaterialBlock {
  58413. /**
  58414. * Gets or sets the list of color steps
  58415. */
  58416. colorSteps: GradientBlockColorStep[];
  58417. /**
  58418. * Creates a new GradientBlock
  58419. * @param name defines the block name
  58420. */
  58421. constructor(name: string);
  58422. /**
  58423. * Gets the current class name
  58424. * @returns the class name
  58425. */
  58426. getClassName(): string;
  58427. /**
  58428. * Gets the gradient input component
  58429. */
  58430. readonly gradient: NodeMaterialConnectionPoint;
  58431. /**
  58432. * Gets the output component
  58433. */
  58434. readonly output: NodeMaterialConnectionPoint;
  58435. private _writeColorConstant;
  58436. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58437. serialize(): any;
  58438. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58439. protected _dumpPropertiesCode(): string;
  58440. }
  58441. }
  58442. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58446. /**
  58447. * Block used to normalize lerp between 2 values
  58448. */
  58449. export class NLerpBlock extends NodeMaterialBlock {
  58450. /**
  58451. * Creates a new NLerpBlock
  58452. * @param name defines the block name
  58453. */
  58454. constructor(name: string);
  58455. /**
  58456. * Gets the current class name
  58457. * @returns the class name
  58458. */
  58459. getClassName(): string;
  58460. /**
  58461. * Gets the left operand input component
  58462. */
  58463. readonly left: NodeMaterialConnectionPoint;
  58464. /**
  58465. * Gets the right operand input component
  58466. */
  58467. readonly right: NodeMaterialConnectionPoint;
  58468. /**
  58469. * Gets the gradient operand input component
  58470. */
  58471. readonly gradient: NodeMaterialConnectionPoint;
  58472. /**
  58473. * Gets the output component
  58474. */
  58475. readonly output: NodeMaterialConnectionPoint;
  58476. protected _buildBlock(state: NodeMaterialBuildState): this;
  58477. }
  58478. }
  58479. declare module "babylonjs/Materials/Node/Blocks/index" {
  58480. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58481. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58482. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58483. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58484. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58485. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58486. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58487. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58488. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58489. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58490. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58491. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58492. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58493. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58494. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58495. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58496. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58497. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58498. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58499. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58500. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58501. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58502. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58503. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58504. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58505. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58506. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58507. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58508. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58509. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58510. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58511. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58512. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58513. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58514. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58515. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58516. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58517. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58518. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58519. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58520. }
  58521. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58522. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58523. }
  58524. declare module "babylonjs/Materials/Node/index" {
  58525. export * from "babylonjs/Materials/Node/Enums/index";
  58526. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58527. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58528. export * from "babylonjs/Materials/Node/nodeMaterial";
  58529. export * from "babylonjs/Materials/Node/Blocks/index";
  58530. export * from "babylonjs/Materials/Node/Optimizers/index";
  58531. }
  58532. declare module "babylonjs/Materials/effectRenderer" {
  58533. import { Nullable } from "babylonjs/types";
  58534. import { Texture } from "babylonjs/Materials/Textures/texture";
  58535. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58536. import { Viewport } from "babylonjs/Maths/math.viewport";
  58537. import { Observable } from "babylonjs/Misc/observable";
  58538. import { Effect } from "babylonjs/Materials/effect";
  58539. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58540. import "babylonjs/Shaders/postprocess.vertex";
  58541. /**
  58542. * Effect Render Options
  58543. */
  58544. export interface IEffectRendererOptions {
  58545. /**
  58546. * Defines the vertices positions.
  58547. */
  58548. positions?: number[];
  58549. /**
  58550. * Defines the indices.
  58551. */
  58552. indices?: number[];
  58553. }
  58554. /**
  58555. * Helper class to render one or more effects
  58556. */
  58557. export class EffectRenderer {
  58558. private engine;
  58559. private static _DefaultOptions;
  58560. private _vertexBuffers;
  58561. private _indexBuffer;
  58562. private _ringBufferIndex;
  58563. private _ringScreenBuffer;
  58564. private _fullscreenViewport;
  58565. private _getNextFrameBuffer;
  58566. /**
  58567. * Creates an effect renderer
  58568. * @param engine the engine to use for rendering
  58569. * @param options defines the options of the effect renderer
  58570. */
  58571. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58572. /**
  58573. * Sets the current viewport in normalized coordinates 0-1
  58574. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58575. */
  58576. setViewport(viewport?: Viewport): void;
  58577. /**
  58578. * Binds the embedded attributes buffer to the effect.
  58579. * @param effect Defines the effect to bind the attributes for
  58580. */
  58581. bindBuffers(effect: Effect): void;
  58582. /**
  58583. * Sets the current effect wrapper to use during draw.
  58584. * The effect needs to be ready before calling this api.
  58585. * This also sets the default full screen position attribute.
  58586. * @param effectWrapper Defines the effect to draw with
  58587. */
  58588. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58589. /**
  58590. * Draws a full screen quad.
  58591. */
  58592. draw(): void;
  58593. /**
  58594. * renders one or more effects to a specified texture
  58595. * @param effectWrappers list of effects to renderer
  58596. * @param outputTexture texture to draw to, if null it will render to the screen
  58597. */
  58598. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58599. /**
  58600. * Disposes of the effect renderer
  58601. */
  58602. dispose(): void;
  58603. }
  58604. /**
  58605. * Options to create an EffectWrapper
  58606. */
  58607. interface EffectWrapperCreationOptions {
  58608. /**
  58609. * Engine to use to create the effect
  58610. */
  58611. engine: ThinEngine;
  58612. /**
  58613. * Fragment shader for the effect
  58614. */
  58615. fragmentShader: string;
  58616. /**
  58617. * Vertex shader for the effect
  58618. */
  58619. vertexShader?: string;
  58620. /**
  58621. * Attributes to use in the shader
  58622. */
  58623. attributeNames?: Array<string>;
  58624. /**
  58625. * Uniforms to use in the shader
  58626. */
  58627. uniformNames?: Array<string>;
  58628. /**
  58629. * Texture sampler names to use in the shader
  58630. */
  58631. samplerNames?: Array<string>;
  58632. /**
  58633. * The friendly name of the effect displayed in Spector.
  58634. */
  58635. name?: string;
  58636. }
  58637. /**
  58638. * Wraps an effect to be used for rendering
  58639. */
  58640. export class EffectWrapper {
  58641. /**
  58642. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58643. */
  58644. onApplyObservable: Observable<{}>;
  58645. /**
  58646. * The underlying effect
  58647. */
  58648. effect: Effect;
  58649. /**
  58650. * Creates an effect to be renderer
  58651. * @param creationOptions options to create the effect
  58652. */
  58653. constructor(creationOptions: EffectWrapperCreationOptions);
  58654. /**
  58655. * Disposes of the effect wrapper
  58656. */
  58657. dispose(): void;
  58658. }
  58659. }
  58660. declare module "babylonjs/Materials/index" {
  58661. export * from "babylonjs/Materials/Background/index";
  58662. export * from "babylonjs/Materials/colorCurves";
  58663. export * from "babylonjs/Materials/iEffectFallbacks";
  58664. export * from "babylonjs/Materials/effectFallbacks";
  58665. export * from "babylonjs/Materials/effect";
  58666. export * from "babylonjs/Materials/fresnelParameters";
  58667. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58668. export * from "babylonjs/Materials/material";
  58669. export * from "babylonjs/Materials/materialDefines";
  58670. export * from "babylonjs/Materials/materialHelper";
  58671. export * from "babylonjs/Materials/multiMaterial";
  58672. export * from "babylonjs/Materials/PBR/index";
  58673. export * from "babylonjs/Materials/pushMaterial";
  58674. export * from "babylonjs/Materials/shaderMaterial";
  58675. export * from "babylonjs/Materials/standardMaterial";
  58676. export * from "babylonjs/Materials/Textures/index";
  58677. export * from "babylonjs/Materials/uniformBuffer";
  58678. export * from "babylonjs/Materials/materialFlags";
  58679. export * from "babylonjs/Materials/Node/index";
  58680. export * from "babylonjs/Materials/effectRenderer";
  58681. }
  58682. declare module "babylonjs/Maths/index" {
  58683. export * from "babylonjs/Maths/math.scalar";
  58684. export * from "babylonjs/Maths/math";
  58685. export * from "babylonjs/Maths/sphericalPolynomial";
  58686. }
  58687. declare module "babylonjs/Misc/workerPool" {
  58688. import { IDisposable } from "babylonjs/scene";
  58689. /**
  58690. * Helper class to push actions to a pool of workers.
  58691. */
  58692. export class WorkerPool implements IDisposable {
  58693. private _workerInfos;
  58694. private _pendingActions;
  58695. /**
  58696. * Constructor
  58697. * @param workers Array of workers to use for actions
  58698. */
  58699. constructor(workers: Array<Worker>);
  58700. /**
  58701. * Terminates all workers and clears any pending actions.
  58702. */
  58703. dispose(): void;
  58704. /**
  58705. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58706. * pended until a worker has completed its action.
  58707. * @param action The action to perform. Call onComplete when the action is complete.
  58708. */
  58709. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58710. private _execute;
  58711. }
  58712. }
  58713. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58714. import { IDisposable } from "babylonjs/scene";
  58715. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58716. /**
  58717. * Configuration for Draco compression
  58718. */
  58719. export interface IDracoCompressionConfiguration {
  58720. /**
  58721. * Configuration for the decoder.
  58722. */
  58723. decoder: {
  58724. /**
  58725. * The url to the WebAssembly module.
  58726. */
  58727. wasmUrl?: string;
  58728. /**
  58729. * The url to the WebAssembly binary.
  58730. */
  58731. wasmBinaryUrl?: string;
  58732. /**
  58733. * The url to the fallback JavaScript module.
  58734. */
  58735. fallbackUrl?: string;
  58736. };
  58737. }
  58738. /**
  58739. * Draco compression (https://google.github.io/draco/)
  58740. *
  58741. * This class wraps the Draco module.
  58742. *
  58743. * **Encoder**
  58744. *
  58745. * The encoder is not currently implemented.
  58746. *
  58747. * **Decoder**
  58748. *
  58749. * 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.
  58750. *
  58751. * To update the configuration, use the following code:
  58752. * ```javascript
  58753. * DracoCompression.Configuration = {
  58754. * decoder: {
  58755. * wasmUrl: "<url to the WebAssembly library>",
  58756. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58757. * fallbackUrl: "<url to the fallback JavaScript library>",
  58758. * }
  58759. * };
  58760. * ```
  58761. *
  58762. * 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.
  58763. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58764. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58765. *
  58766. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58767. * ```javascript
  58768. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58769. * ```
  58770. *
  58771. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58772. */
  58773. export class DracoCompression implements IDisposable {
  58774. private _workerPoolPromise?;
  58775. private _decoderModulePromise?;
  58776. /**
  58777. * The configuration. Defaults to the following urls:
  58778. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58779. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58780. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58781. */
  58782. static Configuration: IDracoCompressionConfiguration;
  58783. /**
  58784. * Returns true if the decoder configuration is available.
  58785. */
  58786. static readonly DecoderAvailable: boolean;
  58787. /**
  58788. * Default number of workers to create when creating the draco compression object.
  58789. */
  58790. static DefaultNumWorkers: number;
  58791. private static GetDefaultNumWorkers;
  58792. private static _Default;
  58793. /**
  58794. * Default instance for the draco compression object.
  58795. */
  58796. static readonly Default: DracoCompression;
  58797. /**
  58798. * Constructor
  58799. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58800. */
  58801. constructor(numWorkers?: number);
  58802. /**
  58803. * Stop all async operations and release resources.
  58804. */
  58805. dispose(): void;
  58806. /**
  58807. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58808. * @returns a promise that resolves when ready
  58809. */
  58810. whenReadyAsync(): Promise<void>;
  58811. /**
  58812. * Decode Draco compressed mesh data to vertex data.
  58813. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58814. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58815. * @returns A promise that resolves with the decoded vertex data
  58816. */
  58817. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58818. [kind: string]: number;
  58819. }): Promise<VertexData>;
  58820. }
  58821. }
  58822. declare module "babylonjs/Meshes/Compression/index" {
  58823. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58824. }
  58825. declare module "babylonjs/Meshes/csg" {
  58826. import { Nullable } from "babylonjs/types";
  58827. import { Scene } from "babylonjs/scene";
  58828. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58829. import { Mesh } from "babylonjs/Meshes/mesh";
  58830. import { Material } from "babylonjs/Materials/material";
  58831. /**
  58832. * Class for building Constructive Solid Geometry
  58833. */
  58834. export class CSG {
  58835. private polygons;
  58836. /**
  58837. * The world matrix
  58838. */
  58839. matrix: Matrix;
  58840. /**
  58841. * Stores the position
  58842. */
  58843. position: Vector3;
  58844. /**
  58845. * Stores the rotation
  58846. */
  58847. rotation: Vector3;
  58848. /**
  58849. * Stores the rotation quaternion
  58850. */
  58851. rotationQuaternion: Nullable<Quaternion>;
  58852. /**
  58853. * Stores the scaling vector
  58854. */
  58855. scaling: Vector3;
  58856. /**
  58857. * Convert the Mesh to CSG
  58858. * @param mesh The Mesh to convert to CSG
  58859. * @returns A new CSG from the Mesh
  58860. */
  58861. static FromMesh(mesh: Mesh): CSG;
  58862. /**
  58863. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58864. * @param polygons Polygons used to construct a CSG solid
  58865. */
  58866. private static FromPolygons;
  58867. /**
  58868. * Clones, or makes a deep copy, of the CSG
  58869. * @returns A new CSG
  58870. */
  58871. clone(): CSG;
  58872. /**
  58873. * Unions this CSG with another CSG
  58874. * @param csg The CSG to union against this CSG
  58875. * @returns The unioned CSG
  58876. */
  58877. union(csg: CSG): CSG;
  58878. /**
  58879. * Unions this CSG with another CSG in place
  58880. * @param csg The CSG to union against this CSG
  58881. */
  58882. unionInPlace(csg: CSG): void;
  58883. /**
  58884. * Subtracts this CSG with another CSG
  58885. * @param csg The CSG to subtract against this CSG
  58886. * @returns A new CSG
  58887. */
  58888. subtract(csg: CSG): CSG;
  58889. /**
  58890. * Subtracts this CSG with another CSG in place
  58891. * @param csg The CSG to subtact against this CSG
  58892. */
  58893. subtractInPlace(csg: CSG): void;
  58894. /**
  58895. * Intersect this CSG with another CSG
  58896. * @param csg The CSG to intersect against this CSG
  58897. * @returns A new CSG
  58898. */
  58899. intersect(csg: CSG): CSG;
  58900. /**
  58901. * Intersects this CSG with another CSG in place
  58902. * @param csg The CSG to intersect against this CSG
  58903. */
  58904. intersectInPlace(csg: CSG): void;
  58905. /**
  58906. * Return a new CSG solid with solid and empty space switched. This solid is
  58907. * not modified.
  58908. * @returns A new CSG solid with solid and empty space switched
  58909. */
  58910. inverse(): CSG;
  58911. /**
  58912. * Inverses the CSG in place
  58913. */
  58914. inverseInPlace(): void;
  58915. /**
  58916. * This is used to keep meshes transformations so they can be restored
  58917. * when we build back a Babylon Mesh
  58918. * NB : All CSG operations are performed in world coordinates
  58919. * @param csg The CSG to copy the transform attributes from
  58920. * @returns This CSG
  58921. */
  58922. copyTransformAttributes(csg: CSG): CSG;
  58923. /**
  58924. * Build Raw mesh from CSG
  58925. * Coordinates here are in world space
  58926. * @param name The name of the mesh geometry
  58927. * @param scene The Scene
  58928. * @param keepSubMeshes Specifies if the submeshes should be kept
  58929. * @returns A new Mesh
  58930. */
  58931. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58932. /**
  58933. * Build Mesh from CSG taking material and transforms into account
  58934. * @param name The name of the Mesh
  58935. * @param material The material of the Mesh
  58936. * @param scene The Scene
  58937. * @param keepSubMeshes Specifies if submeshes should be kept
  58938. * @returns The new Mesh
  58939. */
  58940. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58941. }
  58942. }
  58943. declare module "babylonjs/Meshes/trailMesh" {
  58944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58945. import { Mesh } from "babylonjs/Meshes/mesh";
  58946. import { Scene } from "babylonjs/scene";
  58947. /**
  58948. * Class used to create a trail following a mesh
  58949. */
  58950. export class TrailMesh extends Mesh {
  58951. private _generator;
  58952. private _autoStart;
  58953. private _running;
  58954. private _diameter;
  58955. private _length;
  58956. private _sectionPolygonPointsCount;
  58957. private _sectionVectors;
  58958. private _sectionNormalVectors;
  58959. private _beforeRenderObserver;
  58960. /**
  58961. * @constructor
  58962. * @param name The value used by scene.getMeshByName() to do a lookup.
  58963. * @param generator The mesh to generate a trail.
  58964. * @param scene The scene to add this mesh to.
  58965. * @param diameter Diameter of trailing mesh. Default is 1.
  58966. * @param length Length of trailing mesh. Default is 60.
  58967. * @param autoStart Automatically start trailing mesh. Default true.
  58968. */
  58969. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58970. /**
  58971. * "TrailMesh"
  58972. * @returns "TrailMesh"
  58973. */
  58974. getClassName(): string;
  58975. private _createMesh;
  58976. /**
  58977. * Start trailing mesh.
  58978. */
  58979. start(): void;
  58980. /**
  58981. * Stop trailing mesh.
  58982. */
  58983. stop(): void;
  58984. /**
  58985. * Update trailing mesh geometry.
  58986. */
  58987. update(): void;
  58988. /**
  58989. * Returns a new TrailMesh object.
  58990. * @param name is a string, the name given to the new mesh
  58991. * @param newGenerator use new generator object for cloned trail mesh
  58992. * @returns a new mesh
  58993. */
  58994. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58995. /**
  58996. * Serializes this trail mesh
  58997. * @param serializationObject object to write serialization to
  58998. */
  58999. serialize(serializationObject: any): void;
  59000. /**
  59001. * Parses a serialized trail mesh
  59002. * @param parsedMesh the serialized mesh
  59003. * @param scene the scene to create the trail mesh in
  59004. * @returns the created trail mesh
  59005. */
  59006. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59007. }
  59008. }
  59009. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59010. import { Nullable } from "babylonjs/types";
  59011. import { Scene } from "babylonjs/scene";
  59012. import { Vector4 } from "babylonjs/Maths/math.vector";
  59013. import { Color4 } from "babylonjs/Maths/math.color";
  59014. import { Mesh } from "babylonjs/Meshes/mesh";
  59015. /**
  59016. * Class containing static functions to help procedurally build meshes
  59017. */
  59018. export class TiledBoxBuilder {
  59019. /**
  59020. * Creates a box mesh
  59021. * 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)
  59022. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59026. * @param name defines the name of the mesh
  59027. * @param options defines the options used to create the mesh
  59028. * @param scene defines the hosting scene
  59029. * @returns the box mesh
  59030. */
  59031. static CreateTiledBox(name: string, options: {
  59032. pattern?: number;
  59033. width?: number;
  59034. height?: number;
  59035. depth?: number;
  59036. tileSize?: number;
  59037. tileWidth?: number;
  59038. tileHeight?: number;
  59039. alignHorizontal?: number;
  59040. alignVertical?: number;
  59041. faceUV?: Vector4[];
  59042. faceColors?: Color4[];
  59043. sideOrientation?: number;
  59044. updatable?: boolean;
  59045. }, scene?: Nullable<Scene>): Mesh;
  59046. }
  59047. }
  59048. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59049. import { Vector4 } from "babylonjs/Maths/math.vector";
  59050. import { Mesh } from "babylonjs/Meshes/mesh";
  59051. /**
  59052. * Class containing static functions to help procedurally build meshes
  59053. */
  59054. export class TorusKnotBuilder {
  59055. /**
  59056. * Creates a torus knot mesh
  59057. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59058. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59059. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59060. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59064. * @param name defines the name of the mesh
  59065. * @param options defines the options used to create the mesh
  59066. * @param scene defines the hosting scene
  59067. * @returns the torus knot mesh
  59068. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59069. */
  59070. static CreateTorusKnot(name: string, options: {
  59071. radius?: number;
  59072. tube?: number;
  59073. radialSegments?: number;
  59074. tubularSegments?: number;
  59075. p?: number;
  59076. q?: number;
  59077. updatable?: boolean;
  59078. sideOrientation?: number;
  59079. frontUVs?: Vector4;
  59080. backUVs?: Vector4;
  59081. }, scene: any): Mesh;
  59082. }
  59083. }
  59084. declare module "babylonjs/Meshes/polygonMesh" {
  59085. import { Scene } from "babylonjs/scene";
  59086. import { Vector2 } from "babylonjs/Maths/math.vector";
  59087. import { Mesh } from "babylonjs/Meshes/mesh";
  59088. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59089. import { Path2 } from "babylonjs/Maths/math.path";
  59090. /**
  59091. * Polygon
  59092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59093. */
  59094. export class Polygon {
  59095. /**
  59096. * Creates a rectangle
  59097. * @param xmin bottom X coord
  59098. * @param ymin bottom Y coord
  59099. * @param xmax top X coord
  59100. * @param ymax top Y coord
  59101. * @returns points that make the resulting rectation
  59102. */
  59103. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59104. /**
  59105. * Creates a circle
  59106. * @param radius radius of circle
  59107. * @param cx scale in x
  59108. * @param cy scale in y
  59109. * @param numberOfSides number of sides that make up the circle
  59110. * @returns points that make the resulting circle
  59111. */
  59112. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59113. /**
  59114. * Creates a polygon from input string
  59115. * @param input Input polygon data
  59116. * @returns the parsed points
  59117. */
  59118. static Parse(input: string): Vector2[];
  59119. /**
  59120. * Starts building a polygon from x and y coordinates
  59121. * @param x x coordinate
  59122. * @param y y coordinate
  59123. * @returns the started path2
  59124. */
  59125. static StartingAt(x: number, y: number): Path2;
  59126. }
  59127. /**
  59128. * Builds a polygon
  59129. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59130. */
  59131. export class PolygonMeshBuilder {
  59132. private _points;
  59133. private _outlinepoints;
  59134. private _holes;
  59135. private _name;
  59136. private _scene;
  59137. private _epoints;
  59138. private _eholes;
  59139. private _addToepoint;
  59140. /**
  59141. * Babylon reference to the earcut plugin.
  59142. */
  59143. bjsEarcut: any;
  59144. /**
  59145. * Creates a PolygonMeshBuilder
  59146. * @param name name of the builder
  59147. * @param contours Path of the polygon
  59148. * @param scene scene to add to when creating the mesh
  59149. * @param earcutInjection can be used to inject your own earcut reference
  59150. */
  59151. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59152. /**
  59153. * Adds a whole within the polygon
  59154. * @param hole Array of points defining the hole
  59155. * @returns this
  59156. */
  59157. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59158. /**
  59159. * Creates the polygon
  59160. * @param updatable If the mesh should be updatable
  59161. * @param depth The depth of the mesh created
  59162. * @returns the created mesh
  59163. */
  59164. build(updatable?: boolean, depth?: number): Mesh;
  59165. /**
  59166. * Creates the polygon
  59167. * @param depth The depth of the mesh created
  59168. * @returns the created VertexData
  59169. */
  59170. buildVertexData(depth?: number): VertexData;
  59171. /**
  59172. * Adds a side to the polygon
  59173. * @param positions points that make the polygon
  59174. * @param normals normals of the polygon
  59175. * @param uvs uvs of the polygon
  59176. * @param indices indices of the polygon
  59177. * @param bounds bounds of the polygon
  59178. * @param points points of the polygon
  59179. * @param depth depth of the polygon
  59180. * @param flip flip of the polygon
  59181. */
  59182. private addSide;
  59183. }
  59184. }
  59185. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59186. import { Scene } from "babylonjs/scene";
  59187. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59188. import { Color4 } from "babylonjs/Maths/math.color";
  59189. import { Mesh } from "babylonjs/Meshes/mesh";
  59190. import { Nullable } from "babylonjs/types";
  59191. /**
  59192. * Class containing static functions to help procedurally build meshes
  59193. */
  59194. export class PolygonBuilder {
  59195. /**
  59196. * Creates a polygon mesh
  59197. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59198. * * 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
  59199. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59202. * * Remember you can only change the shape positions, not their number when updating a polygon
  59203. * @param name defines the name of the mesh
  59204. * @param options defines the options used to create the mesh
  59205. * @param scene defines the hosting scene
  59206. * @param earcutInjection can be used to inject your own earcut reference
  59207. * @returns the polygon mesh
  59208. */
  59209. static CreatePolygon(name: string, options: {
  59210. shape: Vector3[];
  59211. holes?: Vector3[][];
  59212. depth?: number;
  59213. faceUV?: Vector4[];
  59214. faceColors?: Color4[];
  59215. updatable?: boolean;
  59216. sideOrientation?: number;
  59217. frontUVs?: Vector4;
  59218. backUVs?: Vector4;
  59219. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59220. /**
  59221. * Creates an extruded polygon mesh, with depth in the Y direction.
  59222. * * 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)
  59223. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59224. * @param name defines the name of the mesh
  59225. * @param options defines the options used to create the mesh
  59226. * @param scene defines the hosting scene
  59227. * @param earcutInjection can be used to inject your own earcut reference
  59228. * @returns the polygon mesh
  59229. */
  59230. static ExtrudePolygon(name: string, options: {
  59231. shape: Vector3[];
  59232. holes?: Vector3[][];
  59233. depth?: number;
  59234. faceUV?: Vector4[];
  59235. faceColors?: Color4[];
  59236. updatable?: boolean;
  59237. sideOrientation?: number;
  59238. frontUVs?: Vector4;
  59239. backUVs?: Vector4;
  59240. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59241. }
  59242. }
  59243. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59244. import { Scene } from "babylonjs/scene";
  59245. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59246. import { Mesh } from "babylonjs/Meshes/mesh";
  59247. import { Nullable } from "babylonjs/types";
  59248. /**
  59249. * Class containing static functions to help procedurally build meshes
  59250. */
  59251. export class LatheBuilder {
  59252. /**
  59253. * Creates lathe mesh.
  59254. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59255. * * 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
  59256. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59257. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59258. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59259. * * 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
  59260. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59261. * * 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
  59262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59264. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59266. * @param name defines the name of the mesh
  59267. * @param options defines the options used to create the mesh
  59268. * @param scene defines the hosting scene
  59269. * @returns the lathe mesh
  59270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59271. */
  59272. static CreateLathe(name: string, options: {
  59273. shape: Vector3[];
  59274. radius?: number;
  59275. tessellation?: number;
  59276. clip?: number;
  59277. arc?: number;
  59278. closed?: boolean;
  59279. updatable?: boolean;
  59280. sideOrientation?: number;
  59281. frontUVs?: Vector4;
  59282. backUVs?: Vector4;
  59283. cap?: number;
  59284. invertUV?: boolean;
  59285. }, scene?: Nullable<Scene>): Mesh;
  59286. }
  59287. }
  59288. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59289. import { Nullable } from "babylonjs/types";
  59290. import { Scene } from "babylonjs/scene";
  59291. import { Vector4 } from "babylonjs/Maths/math.vector";
  59292. import { Mesh } from "babylonjs/Meshes/mesh";
  59293. /**
  59294. * Class containing static functions to help procedurally build meshes
  59295. */
  59296. export class TiledPlaneBuilder {
  59297. /**
  59298. * Creates a tiled plane mesh
  59299. * * The parameter `pattern` will, depending on value, do nothing or
  59300. * * * flip (reflect about central vertical) alternate tiles across and up
  59301. * * * flip every tile on alternate rows
  59302. * * * rotate (180 degs) alternate tiles across and up
  59303. * * * rotate every tile on alternate rows
  59304. * * * flip and rotate alternate tiles across and up
  59305. * * * flip and rotate every tile on alternate rows
  59306. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59307. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59310. * * 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)
  59311. * * 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)
  59312. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59313. * @param name defines the name of the mesh
  59314. * @param options defines the options used to create the mesh
  59315. * @param scene defines the hosting scene
  59316. * @returns the box mesh
  59317. */
  59318. static CreateTiledPlane(name: string, options: {
  59319. pattern?: number;
  59320. tileSize?: number;
  59321. tileWidth?: number;
  59322. tileHeight?: number;
  59323. size?: number;
  59324. width?: number;
  59325. height?: number;
  59326. alignHorizontal?: number;
  59327. alignVertical?: number;
  59328. sideOrientation?: number;
  59329. frontUVs?: Vector4;
  59330. backUVs?: Vector4;
  59331. updatable?: boolean;
  59332. }, scene?: Nullable<Scene>): Mesh;
  59333. }
  59334. }
  59335. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59336. import { Nullable } from "babylonjs/types";
  59337. import { Scene } from "babylonjs/scene";
  59338. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59339. import { Mesh } from "babylonjs/Meshes/mesh";
  59340. /**
  59341. * Class containing static functions to help procedurally build meshes
  59342. */
  59343. export class TubeBuilder {
  59344. /**
  59345. * Creates a tube mesh.
  59346. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59347. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59348. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59349. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59350. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59351. * * 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)
  59352. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59353. * * 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
  59354. * * 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
  59355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59357. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59359. * @param name defines the name of the mesh
  59360. * @param options defines the options used to create the mesh
  59361. * @param scene defines the hosting scene
  59362. * @returns the tube mesh
  59363. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59364. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59365. */
  59366. static CreateTube(name: string, options: {
  59367. path: Vector3[];
  59368. radius?: number;
  59369. tessellation?: number;
  59370. radiusFunction?: {
  59371. (i: number, distance: number): number;
  59372. };
  59373. cap?: number;
  59374. arc?: number;
  59375. updatable?: boolean;
  59376. sideOrientation?: number;
  59377. frontUVs?: Vector4;
  59378. backUVs?: Vector4;
  59379. instance?: Mesh;
  59380. invertUV?: boolean;
  59381. }, scene?: Nullable<Scene>): Mesh;
  59382. }
  59383. }
  59384. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59385. import { Scene } from "babylonjs/scene";
  59386. import { Vector4 } from "babylonjs/Maths/math.vector";
  59387. import { Mesh } from "babylonjs/Meshes/mesh";
  59388. import { Nullable } from "babylonjs/types";
  59389. /**
  59390. * Class containing static functions to help procedurally build meshes
  59391. */
  59392. export class IcoSphereBuilder {
  59393. /**
  59394. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59395. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59396. * * 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`)
  59397. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59398. * * 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
  59399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59402. * @param name defines the name of the mesh
  59403. * @param options defines the options used to create the mesh
  59404. * @param scene defines the hosting scene
  59405. * @returns the icosahedron mesh
  59406. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59407. */
  59408. static CreateIcoSphere(name: string, options: {
  59409. radius?: number;
  59410. radiusX?: number;
  59411. radiusY?: number;
  59412. radiusZ?: number;
  59413. flat?: boolean;
  59414. subdivisions?: number;
  59415. sideOrientation?: number;
  59416. frontUVs?: Vector4;
  59417. backUVs?: Vector4;
  59418. updatable?: boolean;
  59419. }, scene?: Nullable<Scene>): Mesh;
  59420. }
  59421. }
  59422. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59423. import { Vector3 } from "babylonjs/Maths/math.vector";
  59424. import { Mesh } from "babylonjs/Meshes/mesh";
  59425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59426. /**
  59427. * Class containing static functions to help procedurally build meshes
  59428. */
  59429. export class DecalBuilder {
  59430. /**
  59431. * Creates a decal mesh.
  59432. * 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
  59433. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59434. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59435. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59436. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59437. * @param name defines the name of the mesh
  59438. * @param sourceMesh defines the mesh where the decal must be applied
  59439. * @param options defines the options used to create the mesh
  59440. * @param scene defines the hosting scene
  59441. * @returns the decal mesh
  59442. * @see https://doc.babylonjs.com/how_to/decals
  59443. */
  59444. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59445. position?: Vector3;
  59446. normal?: Vector3;
  59447. size?: Vector3;
  59448. angle?: number;
  59449. }): Mesh;
  59450. }
  59451. }
  59452. declare module "babylonjs/Meshes/meshBuilder" {
  59453. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59454. import { Nullable } from "babylonjs/types";
  59455. import { Scene } from "babylonjs/scene";
  59456. import { Mesh } from "babylonjs/Meshes/mesh";
  59457. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59458. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59460. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59461. import { Plane } from "babylonjs/Maths/math.plane";
  59462. /**
  59463. * Class containing static functions to help procedurally build meshes
  59464. */
  59465. export class MeshBuilder {
  59466. /**
  59467. * Creates a box mesh
  59468. * * The parameter `size` sets the size (float) of each box side (default 1)
  59469. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59470. * * 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)
  59471. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59475. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59476. * @param name defines the name of the mesh
  59477. * @param options defines the options used to create the mesh
  59478. * @param scene defines the hosting scene
  59479. * @returns the box mesh
  59480. */
  59481. static CreateBox(name: string, options: {
  59482. size?: number;
  59483. width?: number;
  59484. height?: number;
  59485. depth?: number;
  59486. faceUV?: Vector4[];
  59487. faceColors?: Color4[];
  59488. sideOrientation?: number;
  59489. frontUVs?: Vector4;
  59490. backUVs?: Vector4;
  59491. updatable?: boolean;
  59492. }, scene?: Nullable<Scene>): Mesh;
  59493. /**
  59494. * Creates a tiled box mesh
  59495. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59497. * @param name defines the name of the mesh
  59498. * @param options defines the options used to create the mesh
  59499. * @param scene defines the hosting scene
  59500. * @returns the tiled box mesh
  59501. */
  59502. static CreateTiledBox(name: string, options: {
  59503. pattern?: number;
  59504. size?: number;
  59505. width?: number;
  59506. height?: number;
  59507. depth: number;
  59508. tileSize?: number;
  59509. tileWidth?: number;
  59510. tileHeight?: number;
  59511. faceUV?: Vector4[];
  59512. faceColors?: Color4[];
  59513. alignHorizontal?: number;
  59514. alignVertical?: number;
  59515. sideOrientation?: number;
  59516. updatable?: boolean;
  59517. }, scene?: Nullable<Scene>): Mesh;
  59518. /**
  59519. * Creates a sphere mesh
  59520. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59521. * * 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`)
  59522. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59523. * * 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
  59524. * * 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)
  59525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59528. * @param name defines the name of the mesh
  59529. * @param options defines the options used to create the mesh
  59530. * @param scene defines the hosting scene
  59531. * @returns the sphere mesh
  59532. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59533. */
  59534. static CreateSphere(name: string, options: {
  59535. segments?: number;
  59536. diameter?: number;
  59537. diameterX?: number;
  59538. diameterY?: number;
  59539. diameterZ?: number;
  59540. arc?: number;
  59541. slice?: number;
  59542. sideOrientation?: number;
  59543. frontUVs?: Vector4;
  59544. backUVs?: Vector4;
  59545. updatable?: boolean;
  59546. }, scene?: Nullable<Scene>): Mesh;
  59547. /**
  59548. * Creates a plane polygonal mesh. By default, this is a disc
  59549. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59550. * * 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
  59551. * * 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
  59552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59555. * @param name defines the name of the mesh
  59556. * @param options defines the options used to create the mesh
  59557. * @param scene defines the hosting scene
  59558. * @returns the plane polygonal mesh
  59559. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59560. */
  59561. static CreateDisc(name: string, options: {
  59562. radius?: number;
  59563. tessellation?: number;
  59564. arc?: number;
  59565. updatable?: boolean;
  59566. sideOrientation?: number;
  59567. frontUVs?: Vector4;
  59568. backUVs?: Vector4;
  59569. }, scene?: Nullable<Scene>): Mesh;
  59570. /**
  59571. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59572. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59573. * * 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`)
  59574. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59575. * * 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
  59576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59579. * @param name defines the name of the mesh
  59580. * @param options defines the options used to create the mesh
  59581. * @param scene defines the hosting scene
  59582. * @returns the icosahedron mesh
  59583. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59584. */
  59585. static CreateIcoSphere(name: string, options: {
  59586. radius?: number;
  59587. radiusX?: number;
  59588. radiusY?: number;
  59589. radiusZ?: number;
  59590. flat?: boolean;
  59591. subdivisions?: number;
  59592. sideOrientation?: number;
  59593. frontUVs?: Vector4;
  59594. backUVs?: Vector4;
  59595. updatable?: boolean;
  59596. }, scene?: Nullable<Scene>): Mesh;
  59597. /**
  59598. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59599. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59600. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59601. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59602. * * 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
  59603. * * 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
  59604. * * 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
  59605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59607. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59608. * * 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
  59609. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59610. * * 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
  59611. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59613. * @param name defines the name of the mesh
  59614. * @param options defines the options used to create the mesh
  59615. * @param scene defines the hosting scene
  59616. * @returns the ribbon mesh
  59617. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59618. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59619. */
  59620. static CreateRibbon(name: string, options: {
  59621. pathArray: Vector3[][];
  59622. closeArray?: boolean;
  59623. closePath?: boolean;
  59624. offset?: number;
  59625. updatable?: boolean;
  59626. sideOrientation?: number;
  59627. frontUVs?: Vector4;
  59628. backUVs?: Vector4;
  59629. instance?: Mesh;
  59630. invertUV?: boolean;
  59631. uvs?: Vector2[];
  59632. colors?: Color4[];
  59633. }, scene?: Nullable<Scene>): Mesh;
  59634. /**
  59635. * Creates a cylinder or a cone mesh
  59636. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59637. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59638. * * 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.
  59639. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59640. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59641. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59642. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59643. * * 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).
  59644. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59645. * * 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).
  59646. * * 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
  59647. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59648. * * 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
  59649. * * 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.
  59650. * * If `enclose` is false, a ring surface is one element.
  59651. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59652. * * 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
  59653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59654. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59656. * @param name defines the name of the mesh
  59657. * @param options defines the options used to create the mesh
  59658. * @param scene defines the hosting scene
  59659. * @returns the cylinder mesh
  59660. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59661. */
  59662. static CreateCylinder(name: string, options: {
  59663. height?: number;
  59664. diameterTop?: number;
  59665. diameterBottom?: number;
  59666. diameter?: number;
  59667. tessellation?: number;
  59668. subdivisions?: number;
  59669. arc?: number;
  59670. faceColors?: Color4[];
  59671. faceUV?: Vector4[];
  59672. updatable?: boolean;
  59673. hasRings?: boolean;
  59674. enclose?: boolean;
  59675. cap?: number;
  59676. sideOrientation?: number;
  59677. frontUVs?: Vector4;
  59678. backUVs?: Vector4;
  59679. }, scene?: Nullable<Scene>): Mesh;
  59680. /**
  59681. * Creates a torus mesh
  59682. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59683. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59684. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59688. * @param name defines the name of the mesh
  59689. * @param options defines the options used to create the mesh
  59690. * @param scene defines the hosting scene
  59691. * @returns the torus mesh
  59692. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59693. */
  59694. static CreateTorus(name: string, options: {
  59695. diameter?: number;
  59696. thickness?: number;
  59697. tessellation?: number;
  59698. updatable?: boolean;
  59699. sideOrientation?: number;
  59700. frontUVs?: Vector4;
  59701. backUVs?: Vector4;
  59702. }, scene?: Nullable<Scene>): Mesh;
  59703. /**
  59704. * Creates a torus knot mesh
  59705. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59706. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59707. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59708. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59712. * @param name defines the name of the mesh
  59713. * @param options defines the options used to create the mesh
  59714. * @param scene defines the hosting scene
  59715. * @returns the torus knot mesh
  59716. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59717. */
  59718. static CreateTorusKnot(name: string, options: {
  59719. radius?: number;
  59720. tube?: number;
  59721. radialSegments?: number;
  59722. tubularSegments?: number;
  59723. p?: number;
  59724. q?: number;
  59725. updatable?: boolean;
  59726. sideOrientation?: number;
  59727. frontUVs?: Vector4;
  59728. backUVs?: Vector4;
  59729. }, scene?: Nullable<Scene>): Mesh;
  59730. /**
  59731. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59732. * * 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
  59733. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59734. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59735. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59736. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59737. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59738. * * 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
  59739. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59742. * @param name defines the name of the new line system
  59743. * @param options defines the options used to create the line system
  59744. * @param scene defines the hosting scene
  59745. * @returns a new line system mesh
  59746. */
  59747. static CreateLineSystem(name: string, options: {
  59748. lines: Vector3[][];
  59749. updatable?: boolean;
  59750. instance?: Nullable<LinesMesh>;
  59751. colors?: Nullable<Color4[][]>;
  59752. useVertexAlpha?: boolean;
  59753. }, scene: Nullable<Scene>): LinesMesh;
  59754. /**
  59755. * Creates a line mesh
  59756. * 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
  59757. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59758. * * The parameter `points` is an array successive Vector3
  59759. * * 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
  59760. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59761. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59762. * * When updating an instance, remember that only point positions can change, not the number of points
  59763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59765. * @param name defines the name of the new line system
  59766. * @param options defines the options used to create the line system
  59767. * @param scene defines the hosting scene
  59768. * @returns a new line mesh
  59769. */
  59770. static CreateLines(name: string, options: {
  59771. points: Vector3[];
  59772. updatable?: boolean;
  59773. instance?: Nullable<LinesMesh>;
  59774. colors?: Color4[];
  59775. useVertexAlpha?: boolean;
  59776. }, scene?: Nullable<Scene>): LinesMesh;
  59777. /**
  59778. * Creates a dashed line mesh
  59779. * * 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
  59780. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59781. * * The parameter `points` is an array successive Vector3
  59782. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59783. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59784. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59785. * * 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
  59786. * * When updating an instance, remember that only point positions can change, not the number of points
  59787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59788. * @param name defines the name of the mesh
  59789. * @param options defines the options used to create the mesh
  59790. * @param scene defines the hosting scene
  59791. * @returns the dashed line mesh
  59792. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59793. */
  59794. static CreateDashedLines(name: string, options: {
  59795. points: Vector3[];
  59796. dashSize?: number;
  59797. gapSize?: number;
  59798. dashNb?: number;
  59799. updatable?: boolean;
  59800. instance?: LinesMesh;
  59801. }, scene?: Nullable<Scene>): LinesMesh;
  59802. /**
  59803. * 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.
  59804. * * 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.
  59805. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59806. * * 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.
  59807. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59808. * * 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
  59809. * * 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
  59810. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59813. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59815. * @param name defines the name of the mesh
  59816. * @param options defines the options used to create the mesh
  59817. * @param scene defines the hosting scene
  59818. * @returns the extruded shape mesh
  59819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59821. */
  59822. static ExtrudeShape(name: string, options: {
  59823. shape: Vector3[];
  59824. path: Vector3[];
  59825. scale?: number;
  59826. rotation?: number;
  59827. cap?: number;
  59828. updatable?: boolean;
  59829. sideOrientation?: number;
  59830. frontUVs?: Vector4;
  59831. backUVs?: Vector4;
  59832. instance?: Mesh;
  59833. invertUV?: boolean;
  59834. }, scene?: Nullable<Scene>): Mesh;
  59835. /**
  59836. * Creates an custom extruded shape mesh.
  59837. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59838. * * 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.
  59839. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59840. * * 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
  59841. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59842. * * 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
  59843. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59844. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59845. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59846. * * 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
  59847. * * 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
  59848. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59851. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59853. * @param name defines the name of the mesh
  59854. * @param options defines the options used to create the mesh
  59855. * @param scene defines the hosting scene
  59856. * @returns the custom extruded shape mesh
  59857. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59858. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59860. */
  59861. static ExtrudeShapeCustom(name: string, options: {
  59862. shape: Vector3[];
  59863. path: Vector3[];
  59864. scaleFunction?: any;
  59865. rotationFunction?: any;
  59866. ribbonCloseArray?: boolean;
  59867. ribbonClosePath?: boolean;
  59868. cap?: number;
  59869. updatable?: boolean;
  59870. sideOrientation?: number;
  59871. frontUVs?: Vector4;
  59872. backUVs?: Vector4;
  59873. instance?: Mesh;
  59874. invertUV?: boolean;
  59875. }, scene?: Nullable<Scene>): Mesh;
  59876. /**
  59877. * Creates lathe mesh.
  59878. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59879. * * 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
  59880. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59881. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59882. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59883. * * 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
  59884. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59885. * * 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
  59886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59888. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59890. * @param name defines the name of the mesh
  59891. * @param options defines the options used to create the mesh
  59892. * @param scene defines the hosting scene
  59893. * @returns the lathe mesh
  59894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59895. */
  59896. static CreateLathe(name: string, options: {
  59897. shape: Vector3[];
  59898. radius?: number;
  59899. tessellation?: number;
  59900. clip?: number;
  59901. arc?: number;
  59902. closed?: boolean;
  59903. updatable?: boolean;
  59904. sideOrientation?: number;
  59905. frontUVs?: Vector4;
  59906. backUVs?: Vector4;
  59907. cap?: number;
  59908. invertUV?: boolean;
  59909. }, scene?: Nullable<Scene>): Mesh;
  59910. /**
  59911. * Creates a tiled plane mesh
  59912. * * You can set a limited pattern arrangement with the tiles
  59913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59916. * @param name defines the name of the mesh
  59917. * @param options defines the options used to create the mesh
  59918. * @param scene defines the hosting scene
  59919. * @returns the plane mesh
  59920. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59921. */
  59922. static CreateTiledPlane(name: string, options: {
  59923. pattern?: number;
  59924. tileSize?: number;
  59925. tileWidth?: number;
  59926. tileHeight?: number;
  59927. size?: number;
  59928. width?: number;
  59929. height?: number;
  59930. alignHorizontal?: number;
  59931. alignVertical?: number;
  59932. sideOrientation?: number;
  59933. frontUVs?: Vector4;
  59934. backUVs?: Vector4;
  59935. updatable?: boolean;
  59936. }, scene?: Nullable<Scene>): Mesh;
  59937. /**
  59938. * Creates a plane mesh
  59939. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59940. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59941. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59945. * @param name defines the name of the mesh
  59946. * @param options defines the options used to create the mesh
  59947. * @param scene defines the hosting scene
  59948. * @returns the plane mesh
  59949. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59950. */
  59951. static CreatePlane(name: string, options: {
  59952. size?: number;
  59953. width?: number;
  59954. height?: number;
  59955. sideOrientation?: number;
  59956. frontUVs?: Vector4;
  59957. backUVs?: Vector4;
  59958. updatable?: boolean;
  59959. sourcePlane?: Plane;
  59960. }, scene?: Nullable<Scene>): Mesh;
  59961. /**
  59962. * Creates a ground mesh
  59963. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59964. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59966. * @param name defines the name of the mesh
  59967. * @param options defines the options used to create the mesh
  59968. * @param scene defines the hosting scene
  59969. * @returns the ground mesh
  59970. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59971. */
  59972. static CreateGround(name: string, options: {
  59973. width?: number;
  59974. height?: number;
  59975. subdivisions?: number;
  59976. subdivisionsX?: number;
  59977. subdivisionsY?: number;
  59978. updatable?: boolean;
  59979. }, scene?: Nullable<Scene>): Mesh;
  59980. /**
  59981. * Creates a tiled ground mesh
  59982. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59983. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59984. * * 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
  59985. * * 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
  59986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59987. * @param name defines the name of the mesh
  59988. * @param options defines the options used to create the mesh
  59989. * @param scene defines the hosting scene
  59990. * @returns the tiled ground mesh
  59991. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59992. */
  59993. static CreateTiledGround(name: string, options: {
  59994. xmin: number;
  59995. zmin: number;
  59996. xmax: number;
  59997. zmax: number;
  59998. subdivisions?: {
  59999. w: number;
  60000. h: number;
  60001. };
  60002. precision?: {
  60003. w: number;
  60004. h: number;
  60005. };
  60006. updatable?: boolean;
  60007. }, scene?: Nullable<Scene>): Mesh;
  60008. /**
  60009. * Creates a ground mesh from a height map
  60010. * * The parameter `url` sets the URL of the height map image resource.
  60011. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60012. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60013. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60014. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60015. * * 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.
  60016. * * 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).
  60017. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60019. * @param name defines the name of the mesh
  60020. * @param url defines the url to the height map
  60021. * @param options defines the options used to create the mesh
  60022. * @param scene defines the hosting scene
  60023. * @returns the ground mesh
  60024. * @see https://doc.babylonjs.com/babylon101/height_map
  60025. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60026. */
  60027. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60028. width?: number;
  60029. height?: number;
  60030. subdivisions?: number;
  60031. minHeight?: number;
  60032. maxHeight?: number;
  60033. colorFilter?: Color3;
  60034. alphaFilter?: number;
  60035. updatable?: boolean;
  60036. onReady?: (mesh: GroundMesh) => void;
  60037. }, scene?: Nullable<Scene>): GroundMesh;
  60038. /**
  60039. * Creates a polygon mesh
  60040. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60041. * * 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
  60042. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60044. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60045. * * Remember you can only change the shape positions, not their number when updating a polygon
  60046. * @param name defines the name of the mesh
  60047. * @param options defines the options used to create the mesh
  60048. * @param scene defines the hosting scene
  60049. * @param earcutInjection can be used to inject your own earcut reference
  60050. * @returns the polygon mesh
  60051. */
  60052. static CreatePolygon(name: string, options: {
  60053. shape: Vector3[];
  60054. holes?: Vector3[][];
  60055. depth?: number;
  60056. faceUV?: Vector4[];
  60057. faceColors?: Color4[];
  60058. updatable?: boolean;
  60059. sideOrientation?: number;
  60060. frontUVs?: Vector4;
  60061. backUVs?: Vector4;
  60062. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60063. /**
  60064. * Creates an extruded polygon mesh, with depth in the Y direction.
  60065. * * 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)
  60066. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60067. * @param name defines the name of the mesh
  60068. * @param options defines the options used to create the mesh
  60069. * @param scene defines the hosting scene
  60070. * @param earcutInjection can be used to inject your own earcut reference
  60071. * @returns the polygon mesh
  60072. */
  60073. static ExtrudePolygon(name: string, options: {
  60074. shape: Vector3[];
  60075. holes?: Vector3[][];
  60076. depth?: number;
  60077. faceUV?: Vector4[];
  60078. faceColors?: Color4[];
  60079. updatable?: boolean;
  60080. sideOrientation?: number;
  60081. frontUVs?: Vector4;
  60082. backUVs?: Vector4;
  60083. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60084. /**
  60085. * Creates a tube mesh.
  60086. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60087. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60088. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60089. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60090. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60091. * * 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)
  60092. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60093. * * 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
  60094. * * 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
  60095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60097. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60099. * @param name defines the name of the mesh
  60100. * @param options defines the options used to create the mesh
  60101. * @param scene defines the hosting scene
  60102. * @returns the tube mesh
  60103. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60104. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60105. */
  60106. static CreateTube(name: string, options: {
  60107. path: Vector3[];
  60108. radius?: number;
  60109. tessellation?: number;
  60110. radiusFunction?: {
  60111. (i: number, distance: number): number;
  60112. };
  60113. cap?: number;
  60114. arc?: number;
  60115. updatable?: boolean;
  60116. sideOrientation?: number;
  60117. frontUVs?: Vector4;
  60118. backUVs?: Vector4;
  60119. instance?: Mesh;
  60120. invertUV?: boolean;
  60121. }, scene?: Nullable<Scene>): Mesh;
  60122. /**
  60123. * Creates a polyhedron mesh
  60124. * * 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
  60125. * * The parameter `size` (positive float, default 1) sets the polygon size
  60126. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60127. * * 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`
  60128. * * 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
  60129. * * 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)`)
  60130. * * 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
  60131. * * 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
  60132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60135. * @param name defines the name of the mesh
  60136. * @param options defines the options used to create the mesh
  60137. * @param scene defines the hosting scene
  60138. * @returns the polyhedron mesh
  60139. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60140. */
  60141. static CreatePolyhedron(name: string, options: {
  60142. type?: number;
  60143. size?: number;
  60144. sizeX?: number;
  60145. sizeY?: number;
  60146. sizeZ?: number;
  60147. custom?: any;
  60148. faceUV?: Vector4[];
  60149. faceColors?: Color4[];
  60150. flat?: boolean;
  60151. updatable?: boolean;
  60152. sideOrientation?: number;
  60153. frontUVs?: Vector4;
  60154. backUVs?: Vector4;
  60155. }, scene?: Nullable<Scene>): Mesh;
  60156. /**
  60157. * Creates a decal mesh.
  60158. * 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
  60159. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60160. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60161. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60162. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60163. * @param name defines the name of the mesh
  60164. * @param sourceMesh defines the mesh where the decal must be applied
  60165. * @param options defines the options used to create the mesh
  60166. * @param scene defines the hosting scene
  60167. * @returns the decal mesh
  60168. * @see https://doc.babylonjs.com/how_to/decals
  60169. */
  60170. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60171. position?: Vector3;
  60172. normal?: Vector3;
  60173. size?: Vector3;
  60174. angle?: number;
  60175. }): Mesh;
  60176. }
  60177. }
  60178. declare module "babylonjs/Meshes/meshSimplification" {
  60179. import { Mesh } from "babylonjs/Meshes/mesh";
  60180. /**
  60181. * A simplifier interface for future simplification implementations
  60182. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60183. */
  60184. export interface ISimplifier {
  60185. /**
  60186. * Simplification of a given mesh according to the given settings.
  60187. * Since this requires computation, it is assumed that the function runs async.
  60188. * @param settings The settings of the simplification, including quality and distance
  60189. * @param successCallback A callback that will be called after the mesh was simplified.
  60190. * @param errorCallback in case of an error, this callback will be called. optional.
  60191. */
  60192. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60193. }
  60194. /**
  60195. * Expected simplification settings.
  60196. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60197. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60198. */
  60199. export interface ISimplificationSettings {
  60200. /**
  60201. * Gets or sets the expected quality
  60202. */
  60203. quality: number;
  60204. /**
  60205. * Gets or sets the distance when this optimized version should be used
  60206. */
  60207. distance: number;
  60208. /**
  60209. * Gets an already optimized mesh
  60210. */
  60211. optimizeMesh?: boolean;
  60212. }
  60213. /**
  60214. * Class used to specify simplification options
  60215. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60216. */
  60217. export class SimplificationSettings implements ISimplificationSettings {
  60218. /** expected quality */
  60219. quality: number;
  60220. /** distance when this optimized version should be used */
  60221. distance: number;
  60222. /** already optimized mesh */
  60223. optimizeMesh?: boolean | undefined;
  60224. /**
  60225. * Creates a SimplificationSettings
  60226. * @param quality expected quality
  60227. * @param distance distance when this optimized version should be used
  60228. * @param optimizeMesh already optimized mesh
  60229. */
  60230. constructor(
  60231. /** expected quality */
  60232. quality: number,
  60233. /** distance when this optimized version should be used */
  60234. distance: number,
  60235. /** already optimized mesh */
  60236. optimizeMesh?: boolean | undefined);
  60237. }
  60238. /**
  60239. * Interface used to define a simplification task
  60240. */
  60241. export interface ISimplificationTask {
  60242. /**
  60243. * Array of settings
  60244. */
  60245. settings: Array<ISimplificationSettings>;
  60246. /**
  60247. * Simplification type
  60248. */
  60249. simplificationType: SimplificationType;
  60250. /**
  60251. * Mesh to simplify
  60252. */
  60253. mesh: Mesh;
  60254. /**
  60255. * Callback called on success
  60256. */
  60257. successCallback?: () => void;
  60258. /**
  60259. * Defines if parallel processing can be used
  60260. */
  60261. parallelProcessing: boolean;
  60262. }
  60263. /**
  60264. * Queue used to order the simplification tasks
  60265. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60266. */
  60267. export class SimplificationQueue {
  60268. private _simplificationArray;
  60269. /**
  60270. * Gets a boolean indicating that the process is still running
  60271. */
  60272. running: boolean;
  60273. /**
  60274. * Creates a new queue
  60275. */
  60276. constructor();
  60277. /**
  60278. * Adds a new simplification task
  60279. * @param task defines a task to add
  60280. */
  60281. addTask(task: ISimplificationTask): void;
  60282. /**
  60283. * Execute next task
  60284. */
  60285. executeNext(): void;
  60286. /**
  60287. * Execute a simplification task
  60288. * @param task defines the task to run
  60289. */
  60290. runSimplification(task: ISimplificationTask): void;
  60291. private getSimplifier;
  60292. }
  60293. /**
  60294. * The implemented types of simplification
  60295. * At the moment only Quadratic Error Decimation is implemented
  60296. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60297. */
  60298. export enum SimplificationType {
  60299. /** Quadratic error decimation */
  60300. QUADRATIC = 0
  60301. }
  60302. }
  60303. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60304. import { Scene } from "babylonjs/scene";
  60305. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60306. import { ISceneComponent } from "babylonjs/sceneComponent";
  60307. module "babylonjs/scene" {
  60308. interface Scene {
  60309. /** @hidden (Backing field) */
  60310. _simplificationQueue: SimplificationQueue;
  60311. /**
  60312. * Gets or sets the simplification queue attached to the scene
  60313. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60314. */
  60315. simplificationQueue: SimplificationQueue;
  60316. }
  60317. }
  60318. module "babylonjs/Meshes/mesh" {
  60319. interface Mesh {
  60320. /**
  60321. * Simplify the mesh according to the given array of settings.
  60322. * Function will return immediately and will simplify async
  60323. * @param settings a collection of simplification settings
  60324. * @param parallelProcessing should all levels calculate parallel or one after the other
  60325. * @param simplificationType the type of simplification to run
  60326. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60327. * @returns the current mesh
  60328. */
  60329. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60330. }
  60331. }
  60332. /**
  60333. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60334. * created in a scene
  60335. */
  60336. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60337. /**
  60338. * The component name helpfull to identify the component in the list of scene components.
  60339. */
  60340. readonly name: string;
  60341. /**
  60342. * The scene the component belongs to.
  60343. */
  60344. scene: Scene;
  60345. /**
  60346. * Creates a new instance of the component for the given scene
  60347. * @param scene Defines the scene to register the component in
  60348. */
  60349. constructor(scene: Scene);
  60350. /**
  60351. * Registers the component in a given scene
  60352. */
  60353. register(): void;
  60354. /**
  60355. * Rebuilds the elements related to this component in case of
  60356. * context lost for instance.
  60357. */
  60358. rebuild(): void;
  60359. /**
  60360. * Disposes the component and the associated ressources
  60361. */
  60362. dispose(): void;
  60363. private _beforeCameraUpdate;
  60364. }
  60365. }
  60366. declare module "babylonjs/Meshes/Builders/index" {
  60367. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60368. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60369. export * from "babylonjs/Meshes/Builders/discBuilder";
  60370. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60371. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60372. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60373. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60374. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60375. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60376. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60377. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60378. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60379. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60380. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60381. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60382. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60383. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60384. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60385. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60386. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60387. }
  60388. declare module "babylonjs/Meshes/index" {
  60389. export * from "babylonjs/Meshes/abstractMesh";
  60390. export * from "babylonjs/Meshes/buffer";
  60391. export * from "babylonjs/Meshes/Compression/index";
  60392. export * from "babylonjs/Meshes/csg";
  60393. export * from "babylonjs/Meshes/geometry";
  60394. export * from "babylonjs/Meshes/groundMesh";
  60395. export * from "babylonjs/Meshes/trailMesh";
  60396. export * from "babylonjs/Meshes/instancedMesh";
  60397. export * from "babylonjs/Meshes/linesMesh";
  60398. export * from "babylonjs/Meshes/mesh";
  60399. export * from "babylonjs/Meshes/mesh.vertexData";
  60400. export * from "babylonjs/Meshes/meshBuilder";
  60401. export * from "babylonjs/Meshes/meshSimplification";
  60402. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60403. export * from "babylonjs/Meshes/polygonMesh";
  60404. export * from "babylonjs/Meshes/subMesh";
  60405. export * from "babylonjs/Meshes/meshLODLevel";
  60406. export * from "babylonjs/Meshes/transformNode";
  60407. export * from "babylonjs/Meshes/Builders/index";
  60408. export * from "babylonjs/Meshes/dataBuffer";
  60409. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60410. }
  60411. declare module "babylonjs/Morph/index" {
  60412. export * from "babylonjs/Morph/morphTarget";
  60413. export * from "babylonjs/Morph/morphTargetManager";
  60414. }
  60415. declare module "babylonjs/Navigation/INavigationEngine" {
  60416. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60417. import { Vector3 } from "babylonjs/Maths/math";
  60418. import { Mesh } from "babylonjs/Meshes/mesh";
  60419. import { Scene } from "babylonjs/scene";
  60420. /**
  60421. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60422. */
  60423. export interface INavigationEnginePlugin {
  60424. /**
  60425. * plugin name
  60426. */
  60427. name: string;
  60428. /**
  60429. * Creates a navigation mesh
  60430. * @param meshes array of all the geometry used to compute the navigatio mesh
  60431. * @param parameters bunch of parameters used to filter geometry
  60432. */
  60433. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60434. /**
  60435. * Create a navigation mesh debug mesh
  60436. * @param scene is where the mesh will be added
  60437. * @returns debug display mesh
  60438. */
  60439. createDebugNavMesh(scene: Scene): Mesh;
  60440. /**
  60441. * Get a navigation mesh constrained position, closest to the parameter position
  60442. * @param position world position
  60443. * @returns the closest point to position constrained by the navigation mesh
  60444. */
  60445. getClosestPoint(position: Vector3): Vector3;
  60446. /**
  60447. * Get a navigation mesh constrained position, within a particular radius
  60448. * @param position world position
  60449. * @param maxRadius the maximum distance to the constrained world position
  60450. * @returns the closest point to position constrained by the navigation mesh
  60451. */
  60452. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60453. /**
  60454. * Compute the final position from a segment made of destination-position
  60455. * @param position world position
  60456. * @param destination world position
  60457. * @returns the resulting point along the navmesh
  60458. */
  60459. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60460. /**
  60461. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60462. * @param start world position
  60463. * @param end world position
  60464. * @returns array containing world position composing the path
  60465. */
  60466. computePath(start: Vector3, end: Vector3): Vector3[];
  60467. /**
  60468. * If this plugin is supported
  60469. * @returns true if plugin is supported
  60470. */
  60471. isSupported(): boolean;
  60472. /**
  60473. * Create a new Crowd so you can add agents
  60474. * @param maxAgents the maximum agent count in the crowd
  60475. * @param maxAgentRadius the maximum radius an agent can have
  60476. * @param scene to attach the crowd to
  60477. * @returns the crowd you can add agents to
  60478. */
  60479. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60480. /**
  60481. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60482. * The queries will try to find a solution within those bounds
  60483. * default is (1,1,1)
  60484. * @param extent x,y,z value that define the extent around the queries point of reference
  60485. */
  60486. setDefaultQueryExtent(extent: Vector3): void;
  60487. /**
  60488. * Get the Bounding box extent specified by setDefaultQueryExtent
  60489. * @returns the box extent values
  60490. */
  60491. getDefaultQueryExtent(): Vector3;
  60492. /**
  60493. * Release all resources
  60494. */
  60495. dispose(): void;
  60496. }
  60497. /**
  60498. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60499. */
  60500. export interface ICrowd {
  60501. /**
  60502. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60503. * You can attach anything to that node. The node position is updated in the scene update tick.
  60504. * @param pos world position that will be constrained by the navigation mesh
  60505. * @param parameters agent parameters
  60506. * @param transform hooked to the agent that will be update by the scene
  60507. * @returns agent index
  60508. */
  60509. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60510. /**
  60511. * Returns the agent position in world space
  60512. * @param index agent index returned by addAgent
  60513. * @returns world space position
  60514. */
  60515. getAgentPosition(index: number): Vector3;
  60516. /**
  60517. * Gets the agent velocity in world space
  60518. * @param index agent index returned by addAgent
  60519. * @returns world space velocity
  60520. */
  60521. getAgentVelocity(index: number): Vector3;
  60522. /**
  60523. * remove a particular agent previously created
  60524. * @param index agent index returned by addAgent
  60525. */
  60526. removeAgent(index: number): void;
  60527. /**
  60528. * get the list of all agents attached to this crowd
  60529. * @returns list of agent indices
  60530. */
  60531. getAgents(): number[];
  60532. /**
  60533. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60534. * @param deltaTime in seconds
  60535. */
  60536. update(deltaTime: number): void;
  60537. /**
  60538. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60539. * @param index agent index returned by addAgent
  60540. * @param destination targeted world position
  60541. */
  60542. agentGoto(index: number, destination: Vector3): void;
  60543. /**
  60544. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60545. * The queries will try to find a solution within those bounds
  60546. * default is (1,1,1)
  60547. * @param extent x,y,z value that define the extent around the queries point of reference
  60548. */
  60549. setDefaultQueryExtent(extent: Vector3): void;
  60550. /**
  60551. * Get the Bounding box extent specified by setDefaultQueryExtent
  60552. * @returns the box extent values
  60553. */
  60554. getDefaultQueryExtent(): Vector3;
  60555. /**
  60556. * Release all resources
  60557. */
  60558. dispose(): void;
  60559. }
  60560. /**
  60561. * Configures an agent
  60562. */
  60563. export interface IAgentParameters {
  60564. /**
  60565. * Agent radius. [Limit: >= 0]
  60566. */
  60567. radius: number;
  60568. /**
  60569. * Agent height. [Limit: > 0]
  60570. */
  60571. height: number;
  60572. /**
  60573. * Maximum allowed acceleration. [Limit: >= 0]
  60574. */
  60575. maxAcceleration: number;
  60576. /**
  60577. * Maximum allowed speed. [Limit: >= 0]
  60578. */
  60579. maxSpeed: number;
  60580. /**
  60581. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60582. */
  60583. collisionQueryRange: number;
  60584. /**
  60585. * The path visibility optimization range. [Limit: > 0]
  60586. */
  60587. pathOptimizationRange: number;
  60588. /**
  60589. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60590. */
  60591. separationWeight: number;
  60592. }
  60593. /**
  60594. * Configures the navigation mesh creation
  60595. */
  60596. export interface INavMeshParameters {
  60597. /**
  60598. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60599. */
  60600. cs: number;
  60601. /**
  60602. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60603. */
  60604. ch: number;
  60605. /**
  60606. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60607. */
  60608. walkableSlopeAngle: number;
  60609. /**
  60610. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60611. * be considered walkable. [Limit: >= 3] [Units: vx]
  60612. */
  60613. walkableHeight: number;
  60614. /**
  60615. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60616. */
  60617. walkableClimb: number;
  60618. /**
  60619. * The distance to erode/shrink the walkable area of the heightfield away from
  60620. * obstructions. [Limit: >=0] [Units: vx]
  60621. */
  60622. walkableRadius: number;
  60623. /**
  60624. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60625. */
  60626. maxEdgeLen: number;
  60627. /**
  60628. * The maximum distance a simplfied contour's border edges should deviate
  60629. * the original raw contour. [Limit: >=0] [Units: vx]
  60630. */
  60631. maxSimplificationError: number;
  60632. /**
  60633. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60634. */
  60635. minRegionArea: number;
  60636. /**
  60637. * Any regions with a span count smaller than this value will, if possible,
  60638. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60639. */
  60640. mergeRegionArea: number;
  60641. /**
  60642. * The maximum number of vertices allowed for polygons generated during the
  60643. * contour to polygon conversion process. [Limit: >= 3]
  60644. */
  60645. maxVertsPerPoly: number;
  60646. /**
  60647. * Sets the sampling distance to use when generating the detail mesh.
  60648. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60649. */
  60650. detailSampleDist: number;
  60651. /**
  60652. * The maximum distance the detail mesh surface should deviate from heightfield
  60653. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60654. */
  60655. detailSampleMaxError: number;
  60656. }
  60657. }
  60658. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60659. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60660. import { Mesh } from "babylonjs/Meshes/mesh";
  60661. import { Scene } from "babylonjs/scene";
  60662. import { Vector3 } from "babylonjs/Maths/math";
  60663. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60664. /**
  60665. * RecastJS navigation plugin
  60666. */
  60667. export class RecastJSPlugin implements INavigationEnginePlugin {
  60668. /**
  60669. * Reference to the Recast library
  60670. */
  60671. bjsRECAST: any;
  60672. /**
  60673. * plugin name
  60674. */
  60675. name: string;
  60676. /**
  60677. * the first navmesh created. We might extend this to support multiple navmeshes
  60678. */
  60679. navMesh: any;
  60680. /**
  60681. * Initializes the recastJS plugin
  60682. * @param recastInjection can be used to inject your own recast reference
  60683. */
  60684. constructor(recastInjection?: any);
  60685. /**
  60686. * Creates a navigation mesh
  60687. * @param meshes array of all the geometry used to compute the navigatio mesh
  60688. * @param parameters bunch of parameters used to filter geometry
  60689. */
  60690. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60691. /**
  60692. * Create a navigation mesh debug mesh
  60693. * @param scene is where the mesh will be added
  60694. * @returns debug display mesh
  60695. */
  60696. createDebugNavMesh(scene: Scene): Mesh;
  60697. /**
  60698. * Get a navigation mesh constrained position, closest to the parameter position
  60699. * @param position world position
  60700. * @returns the closest point to position constrained by the navigation mesh
  60701. */
  60702. getClosestPoint(position: Vector3): Vector3;
  60703. /**
  60704. * Get a navigation mesh constrained position, within a particular radius
  60705. * @param position world position
  60706. * @param maxRadius the maximum distance to the constrained world position
  60707. * @returns the closest point to position constrained by the navigation mesh
  60708. */
  60709. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60710. /**
  60711. * Compute the final position from a segment made of destination-position
  60712. * @param position world position
  60713. * @param destination world position
  60714. * @returns the resulting point along the navmesh
  60715. */
  60716. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60717. /**
  60718. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60719. * @param start world position
  60720. * @param end world position
  60721. * @returns array containing world position composing the path
  60722. */
  60723. computePath(start: Vector3, end: Vector3): Vector3[];
  60724. /**
  60725. * Create a new Crowd so you can add agents
  60726. * @param maxAgents the maximum agent count in the crowd
  60727. * @param maxAgentRadius the maximum radius an agent can have
  60728. * @param scene to attach the crowd to
  60729. * @returns the crowd you can add agents to
  60730. */
  60731. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60732. /**
  60733. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60734. * The queries will try to find a solution within those bounds
  60735. * default is (1,1,1)
  60736. * @param extent x,y,z value that define the extent around the queries point of reference
  60737. */
  60738. setDefaultQueryExtent(extent: Vector3): void;
  60739. /**
  60740. * Get the Bounding box extent specified by setDefaultQueryExtent
  60741. * @returns the box extent values
  60742. */
  60743. getDefaultQueryExtent(): Vector3;
  60744. /**
  60745. * Disposes
  60746. */
  60747. dispose(): void;
  60748. /**
  60749. * If this plugin is supported
  60750. * @returns true if plugin is supported
  60751. */
  60752. isSupported(): boolean;
  60753. }
  60754. /**
  60755. * Recast detour crowd implementation
  60756. */
  60757. export class RecastJSCrowd implements ICrowd {
  60758. /**
  60759. * Recast/detour plugin
  60760. */
  60761. bjsRECASTPlugin: RecastJSPlugin;
  60762. /**
  60763. * Link to the detour crowd
  60764. */
  60765. recastCrowd: any;
  60766. /**
  60767. * One transform per agent
  60768. */
  60769. transforms: TransformNode[];
  60770. /**
  60771. * All agents created
  60772. */
  60773. agents: number[];
  60774. /**
  60775. * Link to the scene is kept to unregister the crowd from the scene
  60776. */
  60777. private _scene;
  60778. /**
  60779. * Observer for crowd updates
  60780. */
  60781. private _onBeforeAnimationsObserver;
  60782. /**
  60783. * Constructor
  60784. * @param plugin recastJS plugin
  60785. * @param maxAgents the maximum agent count in the crowd
  60786. * @param maxAgentRadius the maximum radius an agent can have
  60787. * @param scene to attach the crowd to
  60788. * @returns the crowd you can add agents to
  60789. */
  60790. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60791. /**
  60792. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60793. * You can attach anything to that node. The node position is updated in the scene update tick.
  60794. * @param pos world position that will be constrained by the navigation mesh
  60795. * @param parameters agent parameters
  60796. * @param transform hooked to the agent that will be update by the scene
  60797. * @returns agent index
  60798. */
  60799. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60800. /**
  60801. * Returns the agent position in world space
  60802. * @param index agent index returned by addAgent
  60803. * @returns world space position
  60804. */
  60805. getAgentPosition(index: number): Vector3;
  60806. /**
  60807. * Returns the agent velocity in world space
  60808. * @param index agent index returned by addAgent
  60809. * @returns world space velocity
  60810. */
  60811. getAgentVelocity(index: number): Vector3;
  60812. /**
  60813. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60814. * @param index agent index returned by addAgent
  60815. * @param destination targeted world position
  60816. */
  60817. agentGoto(index: number, destination: Vector3): void;
  60818. /**
  60819. * remove a particular agent previously created
  60820. * @param index agent index returned by addAgent
  60821. */
  60822. removeAgent(index: number): void;
  60823. /**
  60824. * get the list of all agents attached to this crowd
  60825. * @returns list of agent indices
  60826. */
  60827. getAgents(): number[];
  60828. /**
  60829. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60830. * @param deltaTime in seconds
  60831. */
  60832. update(deltaTime: number): void;
  60833. /**
  60834. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60835. * The queries will try to find a solution within those bounds
  60836. * default is (1,1,1)
  60837. * @param extent x,y,z value that define the extent around the queries point of reference
  60838. */
  60839. setDefaultQueryExtent(extent: Vector3): void;
  60840. /**
  60841. * Get the Bounding box extent specified by setDefaultQueryExtent
  60842. * @returns the box extent values
  60843. */
  60844. getDefaultQueryExtent(): Vector3;
  60845. /**
  60846. * Release all resources
  60847. */
  60848. dispose(): void;
  60849. }
  60850. }
  60851. declare module "babylonjs/Navigation/Plugins/index" {
  60852. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60853. }
  60854. declare module "babylonjs/Navigation/index" {
  60855. export * from "babylonjs/Navigation/INavigationEngine";
  60856. export * from "babylonjs/Navigation/Plugins/index";
  60857. }
  60858. declare module "babylonjs/Offline/database" {
  60859. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60860. /**
  60861. * Class used to enable access to IndexedDB
  60862. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60863. */
  60864. export class Database implements IOfflineProvider {
  60865. private _callbackManifestChecked;
  60866. private _currentSceneUrl;
  60867. private _db;
  60868. private _enableSceneOffline;
  60869. private _enableTexturesOffline;
  60870. private _manifestVersionFound;
  60871. private _mustUpdateRessources;
  60872. private _hasReachedQuota;
  60873. private _isSupported;
  60874. private _idbFactory;
  60875. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60876. private static IsUASupportingBlobStorage;
  60877. /**
  60878. * Gets a boolean indicating if Database storate is enabled (off by default)
  60879. */
  60880. static IDBStorageEnabled: boolean;
  60881. /**
  60882. * Gets a boolean indicating if scene must be saved in the database
  60883. */
  60884. readonly enableSceneOffline: boolean;
  60885. /**
  60886. * Gets a boolean indicating if textures must be saved in the database
  60887. */
  60888. readonly enableTexturesOffline: boolean;
  60889. /**
  60890. * Creates a new Database
  60891. * @param urlToScene defines the url to load the scene
  60892. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60893. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60894. */
  60895. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60896. private static _ParseURL;
  60897. private static _ReturnFullUrlLocation;
  60898. private _checkManifestFile;
  60899. /**
  60900. * Open the database and make it available
  60901. * @param successCallback defines the callback to call on success
  60902. * @param errorCallback defines the callback to call on error
  60903. */
  60904. open(successCallback: () => void, errorCallback: () => void): void;
  60905. /**
  60906. * Loads an image from the database
  60907. * @param url defines the url to load from
  60908. * @param image defines the target DOM image
  60909. */
  60910. loadImage(url: string, image: HTMLImageElement): void;
  60911. private _loadImageFromDBAsync;
  60912. private _saveImageIntoDBAsync;
  60913. private _checkVersionFromDB;
  60914. private _loadVersionFromDBAsync;
  60915. private _saveVersionIntoDBAsync;
  60916. /**
  60917. * Loads a file from database
  60918. * @param url defines the URL to load from
  60919. * @param sceneLoaded defines a callback to call on success
  60920. * @param progressCallBack defines a callback to call when progress changed
  60921. * @param errorCallback defines a callback to call on error
  60922. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60923. */
  60924. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60925. private _loadFileAsync;
  60926. private _saveFileAsync;
  60927. /**
  60928. * Validates if xhr data is correct
  60929. * @param xhr defines the request to validate
  60930. * @param dataType defines the expected data type
  60931. * @returns true if data is correct
  60932. */
  60933. private static _ValidateXHRData;
  60934. }
  60935. }
  60936. declare module "babylonjs/Offline/index" {
  60937. export * from "babylonjs/Offline/database";
  60938. export * from "babylonjs/Offline/IOfflineProvider";
  60939. }
  60940. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60941. /** @hidden */
  60942. export var gpuUpdateParticlesPixelShader: {
  60943. name: string;
  60944. shader: string;
  60945. };
  60946. }
  60947. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60948. /** @hidden */
  60949. export var gpuUpdateParticlesVertexShader: {
  60950. name: string;
  60951. shader: string;
  60952. };
  60953. }
  60954. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60955. /** @hidden */
  60956. export var clipPlaneFragmentDeclaration2: {
  60957. name: string;
  60958. shader: string;
  60959. };
  60960. }
  60961. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60962. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60963. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60964. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60965. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60966. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60967. /** @hidden */
  60968. export var gpuRenderParticlesPixelShader: {
  60969. name: string;
  60970. shader: string;
  60971. };
  60972. }
  60973. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60974. /** @hidden */
  60975. export var clipPlaneVertexDeclaration2: {
  60976. name: string;
  60977. shader: string;
  60978. };
  60979. }
  60980. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60981. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60982. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60983. /** @hidden */
  60984. export var gpuRenderParticlesVertexShader: {
  60985. name: string;
  60986. shader: string;
  60987. };
  60988. }
  60989. declare module "babylonjs/Particles/gpuParticleSystem" {
  60990. import { Nullable } from "babylonjs/types";
  60991. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60992. import { Observable } from "babylonjs/Misc/observable";
  60993. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60994. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60995. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60996. import { Scene, IDisposable } from "babylonjs/scene";
  60997. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60998. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60999. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61000. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61001. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61002. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61003. /**
  61004. * This represents a GPU particle system in Babylon
  61005. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61006. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61007. */
  61008. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61009. /**
  61010. * The layer mask we are rendering the particles through.
  61011. */
  61012. layerMask: number;
  61013. private _capacity;
  61014. private _activeCount;
  61015. private _currentActiveCount;
  61016. private _accumulatedCount;
  61017. private _renderEffect;
  61018. private _updateEffect;
  61019. private _buffer0;
  61020. private _buffer1;
  61021. private _spriteBuffer;
  61022. private _updateVAO;
  61023. private _renderVAO;
  61024. private _targetIndex;
  61025. private _sourceBuffer;
  61026. private _targetBuffer;
  61027. private _engine;
  61028. private _currentRenderId;
  61029. private _started;
  61030. private _stopped;
  61031. private _timeDelta;
  61032. private _randomTexture;
  61033. private _randomTexture2;
  61034. private _attributesStrideSize;
  61035. private _updateEffectOptions;
  61036. private _randomTextureSize;
  61037. private _actualFrame;
  61038. private readonly _rawTextureWidth;
  61039. /**
  61040. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61041. */
  61042. static readonly IsSupported: boolean;
  61043. /**
  61044. * An event triggered when the system is disposed.
  61045. */
  61046. onDisposeObservable: Observable<GPUParticleSystem>;
  61047. /**
  61048. * Gets the maximum number of particles active at the same time.
  61049. * @returns The max number of active particles.
  61050. */
  61051. getCapacity(): number;
  61052. /**
  61053. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61054. * to override the particles.
  61055. */
  61056. forceDepthWrite: boolean;
  61057. /**
  61058. * Gets or set the number of active particles
  61059. */
  61060. activeParticleCount: number;
  61061. private _preWarmDone;
  61062. /**
  61063. * Is this system ready to be used/rendered
  61064. * @return true if the system is ready
  61065. */
  61066. isReady(): boolean;
  61067. /**
  61068. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61069. * @returns True if it has been started, otherwise false.
  61070. */
  61071. isStarted(): boolean;
  61072. /**
  61073. * Starts the particle system and begins to emit
  61074. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61075. */
  61076. start(delay?: number): void;
  61077. /**
  61078. * Stops the particle system.
  61079. */
  61080. stop(): void;
  61081. /**
  61082. * Remove all active particles
  61083. */
  61084. reset(): void;
  61085. /**
  61086. * Returns the string "GPUParticleSystem"
  61087. * @returns a string containing the class name
  61088. */
  61089. getClassName(): string;
  61090. private _colorGradientsTexture;
  61091. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61092. /**
  61093. * Adds a new color gradient
  61094. * @param gradient defines the gradient to use (between 0 and 1)
  61095. * @param color1 defines the color to affect to the specified gradient
  61096. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61097. * @returns the current particle system
  61098. */
  61099. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61100. /**
  61101. * Remove a specific color gradient
  61102. * @param gradient defines the gradient to remove
  61103. * @returns the current particle system
  61104. */
  61105. removeColorGradient(gradient: number): GPUParticleSystem;
  61106. private _angularSpeedGradientsTexture;
  61107. private _sizeGradientsTexture;
  61108. private _velocityGradientsTexture;
  61109. private _limitVelocityGradientsTexture;
  61110. private _dragGradientsTexture;
  61111. private _addFactorGradient;
  61112. /**
  61113. * Adds a new size gradient
  61114. * @param gradient defines the gradient to use (between 0 and 1)
  61115. * @param factor defines the size factor to affect to the specified gradient
  61116. * @returns the current particle system
  61117. */
  61118. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61119. /**
  61120. * Remove a specific size gradient
  61121. * @param gradient defines the gradient to remove
  61122. * @returns the current particle system
  61123. */
  61124. removeSizeGradient(gradient: number): GPUParticleSystem;
  61125. /**
  61126. * Adds a new angular speed gradient
  61127. * @param gradient defines the gradient to use (between 0 and 1)
  61128. * @param factor defines the angular speed to affect to the specified gradient
  61129. * @returns the current particle system
  61130. */
  61131. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61132. /**
  61133. * Remove a specific angular speed gradient
  61134. * @param gradient defines the gradient to remove
  61135. * @returns the current particle system
  61136. */
  61137. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61138. /**
  61139. * Adds a new velocity gradient
  61140. * @param gradient defines the gradient to use (between 0 and 1)
  61141. * @param factor defines the velocity to affect to the specified gradient
  61142. * @returns the current particle system
  61143. */
  61144. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61145. /**
  61146. * Remove a specific velocity gradient
  61147. * @param gradient defines the gradient to remove
  61148. * @returns the current particle system
  61149. */
  61150. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61151. /**
  61152. * Adds a new limit velocity gradient
  61153. * @param gradient defines the gradient to use (between 0 and 1)
  61154. * @param factor defines the limit velocity value to affect to the specified gradient
  61155. * @returns the current particle system
  61156. */
  61157. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61158. /**
  61159. * Remove a specific limit velocity gradient
  61160. * @param gradient defines the gradient to remove
  61161. * @returns the current particle system
  61162. */
  61163. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61164. /**
  61165. * Adds a new drag gradient
  61166. * @param gradient defines the gradient to use (between 0 and 1)
  61167. * @param factor defines the drag value to affect to the specified gradient
  61168. * @returns the current particle system
  61169. */
  61170. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61171. /**
  61172. * Remove a specific drag gradient
  61173. * @param gradient defines the gradient to remove
  61174. * @returns the current particle system
  61175. */
  61176. removeDragGradient(gradient: number): GPUParticleSystem;
  61177. /**
  61178. * Not supported by GPUParticleSystem
  61179. * @param gradient defines the gradient to use (between 0 and 1)
  61180. * @param factor defines the emit rate value to affect to the specified gradient
  61181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61182. * @returns the current particle system
  61183. */
  61184. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61185. /**
  61186. * Not supported by GPUParticleSystem
  61187. * @param gradient defines the gradient to remove
  61188. * @returns the current particle system
  61189. */
  61190. removeEmitRateGradient(gradient: number): IParticleSystem;
  61191. /**
  61192. * Not supported by GPUParticleSystem
  61193. * @param gradient defines the gradient to use (between 0 and 1)
  61194. * @param factor defines the start size value to affect to the specified gradient
  61195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61196. * @returns the current particle system
  61197. */
  61198. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61199. /**
  61200. * Not supported by GPUParticleSystem
  61201. * @param gradient defines the gradient to remove
  61202. * @returns the current particle system
  61203. */
  61204. removeStartSizeGradient(gradient: number): IParticleSystem;
  61205. /**
  61206. * Not supported by GPUParticleSystem
  61207. * @param gradient defines the gradient to use (between 0 and 1)
  61208. * @param min defines the color remap minimal range
  61209. * @param max defines the color remap maximal range
  61210. * @returns the current particle system
  61211. */
  61212. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61213. /**
  61214. * Not supported by GPUParticleSystem
  61215. * @param gradient defines the gradient to remove
  61216. * @returns the current particle system
  61217. */
  61218. removeColorRemapGradient(): IParticleSystem;
  61219. /**
  61220. * Not supported by GPUParticleSystem
  61221. * @param gradient defines the gradient to use (between 0 and 1)
  61222. * @param min defines the alpha remap minimal range
  61223. * @param max defines the alpha remap maximal range
  61224. * @returns the current particle system
  61225. */
  61226. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61227. /**
  61228. * Not supported by GPUParticleSystem
  61229. * @param gradient defines the gradient to remove
  61230. * @returns the current particle system
  61231. */
  61232. removeAlphaRemapGradient(): IParticleSystem;
  61233. /**
  61234. * Not supported by GPUParticleSystem
  61235. * @param gradient defines the gradient to use (between 0 and 1)
  61236. * @param color defines the color to affect to the specified gradient
  61237. * @returns the current particle system
  61238. */
  61239. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61240. /**
  61241. * Not supported by GPUParticleSystem
  61242. * @param gradient defines the gradient to remove
  61243. * @returns the current particle system
  61244. */
  61245. removeRampGradient(): IParticleSystem;
  61246. /**
  61247. * Not supported by GPUParticleSystem
  61248. * @returns the list of ramp gradients
  61249. */
  61250. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61251. /**
  61252. * Not supported by GPUParticleSystem
  61253. * Gets or sets a boolean indicating that ramp gradients must be used
  61254. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61255. */
  61256. useRampGradients: boolean;
  61257. /**
  61258. * Not supported by GPUParticleSystem
  61259. * @param gradient defines the gradient to use (between 0 and 1)
  61260. * @param factor defines the life time factor to affect to the specified gradient
  61261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61262. * @returns the current particle system
  61263. */
  61264. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61265. /**
  61266. * Not supported by GPUParticleSystem
  61267. * @param gradient defines the gradient to remove
  61268. * @returns the current particle system
  61269. */
  61270. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61271. /**
  61272. * Instantiates a GPU particle system.
  61273. * 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.
  61274. * @param name The name of the particle system
  61275. * @param options The options used to create the system
  61276. * @param scene The scene the particle system belongs to
  61277. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61278. */
  61279. constructor(name: string, options: Partial<{
  61280. capacity: number;
  61281. randomTextureSize: number;
  61282. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61283. protected _reset(): void;
  61284. private _createUpdateVAO;
  61285. private _createRenderVAO;
  61286. private _initialize;
  61287. /** @hidden */
  61288. _recreateUpdateEffect(): void;
  61289. /** @hidden */
  61290. _recreateRenderEffect(): void;
  61291. /**
  61292. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61293. * @param preWarm defines if we are in the pre-warmimg phase
  61294. */
  61295. animate(preWarm?: boolean): void;
  61296. private _createFactorGradientTexture;
  61297. private _createSizeGradientTexture;
  61298. private _createAngularSpeedGradientTexture;
  61299. private _createVelocityGradientTexture;
  61300. private _createLimitVelocityGradientTexture;
  61301. private _createDragGradientTexture;
  61302. private _createColorGradientTexture;
  61303. /**
  61304. * Renders the particle system in its current state
  61305. * @param preWarm defines if the system should only update the particles but not render them
  61306. * @returns the current number of particles
  61307. */
  61308. render(preWarm?: boolean): number;
  61309. /**
  61310. * Rebuilds the particle system
  61311. */
  61312. rebuild(): void;
  61313. private _releaseBuffers;
  61314. private _releaseVAOs;
  61315. /**
  61316. * Disposes the particle system and free the associated resources
  61317. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61318. */
  61319. dispose(disposeTexture?: boolean): void;
  61320. /**
  61321. * Clones the particle system.
  61322. * @param name The name of the cloned object
  61323. * @param newEmitter The new emitter to use
  61324. * @returns the cloned particle system
  61325. */
  61326. clone(name: string, newEmitter: any): GPUParticleSystem;
  61327. /**
  61328. * Serializes the particle system to a JSON object.
  61329. * @returns the JSON object
  61330. */
  61331. serialize(): any;
  61332. /**
  61333. * Parses a JSON object to create a GPU particle system.
  61334. * @param parsedParticleSystem The JSON object to parse
  61335. * @param scene The scene to create the particle system in
  61336. * @param rootUrl The root url to use to load external dependencies like texture
  61337. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61338. * @returns the parsed GPU particle system
  61339. */
  61340. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61341. }
  61342. }
  61343. declare module "babylonjs/Particles/particleSystemSet" {
  61344. import { Nullable } from "babylonjs/types";
  61345. import { Color3 } from "babylonjs/Maths/math.color";
  61346. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61348. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61349. import { Scene, IDisposable } from "babylonjs/scene";
  61350. /**
  61351. * Represents a set of particle systems working together to create a specific effect
  61352. */
  61353. export class ParticleSystemSet implements IDisposable {
  61354. /**
  61355. * Gets or sets base Assets URL
  61356. */
  61357. static BaseAssetsUrl: string;
  61358. private _emitterCreationOptions;
  61359. private _emitterNode;
  61360. /**
  61361. * Gets the particle system list
  61362. */
  61363. systems: IParticleSystem[];
  61364. /**
  61365. * Gets the emitter node used with this set
  61366. */
  61367. readonly emitterNode: Nullable<TransformNode>;
  61368. /**
  61369. * Creates a new emitter mesh as a sphere
  61370. * @param options defines the options used to create the sphere
  61371. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61372. * @param scene defines the hosting scene
  61373. */
  61374. setEmitterAsSphere(options: {
  61375. diameter: number;
  61376. segments: number;
  61377. color: Color3;
  61378. }, renderingGroupId: number, scene: Scene): void;
  61379. /**
  61380. * Starts all particle systems of the set
  61381. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61382. */
  61383. start(emitter?: AbstractMesh): void;
  61384. /**
  61385. * Release all associated resources
  61386. */
  61387. dispose(): void;
  61388. /**
  61389. * Serialize the set into a JSON compatible object
  61390. * @returns a JSON compatible representation of the set
  61391. */
  61392. serialize(): any;
  61393. /**
  61394. * Parse a new ParticleSystemSet from a serialized source
  61395. * @param data defines a JSON compatible representation of the set
  61396. * @param scene defines the hosting scene
  61397. * @param gpu defines if we want GPU particles or CPU particles
  61398. * @returns a new ParticleSystemSet
  61399. */
  61400. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61401. }
  61402. }
  61403. declare module "babylonjs/Particles/particleHelper" {
  61404. import { Nullable } from "babylonjs/types";
  61405. import { Scene } from "babylonjs/scene";
  61406. import { Vector3 } from "babylonjs/Maths/math.vector";
  61407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61408. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61409. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61410. /**
  61411. * This class is made for on one-liner static method to help creating particle system set.
  61412. */
  61413. export class ParticleHelper {
  61414. /**
  61415. * Gets or sets base Assets URL
  61416. */
  61417. static BaseAssetsUrl: string;
  61418. /**
  61419. * Create a default particle system that you can tweak
  61420. * @param emitter defines the emitter to use
  61421. * @param capacity defines the system capacity (default is 500 particles)
  61422. * @param scene defines the hosting scene
  61423. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61424. * @returns the new Particle system
  61425. */
  61426. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61427. /**
  61428. * This is the main static method (one-liner) of this helper to create different particle systems
  61429. * @param type This string represents the type to the particle system to create
  61430. * @param scene The scene where the particle system should live
  61431. * @param gpu If the system will use gpu
  61432. * @returns the ParticleSystemSet created
  61433. */
  61434. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61435. /**
  61436. * Static function used to export a particle system to a ParticleSystemSet variable.
  61437. * Please note that the emitter shape is not exported
  61438. * @param systems defines the particle systems to export
  61439. * @returns the created particle system set
  61440. */
  61441. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61442. }
  61443. }
  61444. declare module "babylonjs/Particles/particleSystemComponent" {
  61445. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61446. import { Effect } from "babylonjs/Materials/effect";
  61447. import "babylonjs/Shaders/particles.vertex";
  61448. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61449. module "babylonjs/Engines/engine" {
  61450. interface Engine {
  61451. /**
  61452. * Create an effect to use with particle systems.
  61453. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61454. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61455. * @param uniformsNames defines a list of attribute names
  61456. * @param samplers defines an array of string used to represent textures
  61457. * @param defines defines the string containing the defines to use to compile the shaders
  61458. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61459. * @param onCompiled defines a function to call when the effect creation is successful
  61460. * @param onError defines a function to call when the effect creation has failed
  61461. * @returns the new Effect
  61462. */
  61463. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61464. }
  61465. }
  61466. module "babylonjs/Meshes/mesh" {
  61467. interface Mesh {
  61468. /**
  61469. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61470. * @returns an array of IParticleSystem
  61471. */
  61472. getEmittedParticleSystems(): IParticleSystem[];
  61473. /**
  61474. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61475. * @returns an array of IParticleSystem
  61476. */
  61477. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61478. }
  61479. }
  61480. /**
  61481. * @hidden
  61482. */
  61483. export var _IDoNeedToBeInTheBuild: number;
  61484. }
  61485. declare module "babylonjs/Particles/pointsCloudSystem" {
  61486. import { Color4 } from "babylonjs/Maths/math";
  61487. import { Mesh } from "babylonjs/Meshes/mesh";
  61488. import { Scene, IDisposable } from "babylonjs/scene";
  61489. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  61490. /** Defines the 4 color options */
  61491. export enum PointColor {
  61492. /** color value */
  61493. Color = 2,
  61494. /** uv value */
  61495. UV = 1,
  61496. /** random value */
  61497. Random = 0,
  61498. /** stated value */
  61499. Stated = 3
  61500. }
  61501. /**
  61502. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61503. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  61504. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61505. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61506. *
  61507. * Full documentation here : TO BE ENTERED
  61508. */
  61509. export class PointsCloudSystem implements IDisposable {
  61510. /**
  61511. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61512. * Example : var p = SPS.particles[i];
  61513. */
  61514. particles: CloudPoint[];
  61515. /**
  61516. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61517. */
  61518. nbParticles: number;
  61519. /**
  61520. * This a counter for your own usage. It's not set by any SPS functions.
  61521. */
  61522. counter: number;
  61523. /**
  61524. * The PCS name. This name is also given to the underlying mesh.
  61525. */
  61526. name: string;
  61527. /**
  61528. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61529. */
  61530. mesh: Mesh;
  61531. /**
  61532. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61533. * Please read :
  61534. */
  61535. vars: any;
  61536. /**
  61537. * @hidden
  61538. */
  61539. _size: number;
  61540. private _scene;
  61541. private _promises;
  61542. private _positions;
  61543. private _indices;
  61544. private _normals;
  61545. private _colors;
  61546. private _uvs;
  61547. private _indices32;
  61548. private _positions32;
  61549. private _colors32;
  61550. private _uvs32;
  61551. private _updatable;
  61552. private _isVisibilityBoxLocked;
  61553. private _alwaysVisible;
  61554. private _groups;
  61555. private _groupCounter;
  61556. private _computeParticleColor;
  61557. private _computeParticleTexture;
  61558. private _computeParticleRotation;
  61559. private _computeBoundingBox;
  61560. private _isReady;
  61561. /**
  61562. * Creates a PCS (Points Cloud System) object
  61563. * @param name (String) is the PCS name, this will be the underlying mesh name
  61564. * @param pointSize (number) is the size for each point
  61565. * @param scene (Scene) is the scene in which the PCS is added
  61566. * @param options defines the options of the PCS e.g.
  61567. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61568. */
  61569. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61570. updatable?: boolean;
  61571. });
  61572. /**
  61573. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61574. * If no points were added to the PCS, the returned mesh is just a single point.
  61575. * @returns a promise for the created mesh
  61576. */
  61577. buildMeshAsync(): Promise<Mesh>;
  61578. /**
  61579. * @hidden
  61580. */
  61581. private _buildMesh;
  61582. private _addParticle;
  61583. private _randomUnitVector;
  61584. private _getColorIndicesForCoord;
  61585. private _setPointsColorOrUV;
  61586. private _colorFromTexture;
  61587. private _calculateDensity;
  61588. /**
  61589. * Adds points to the PCS in random positions within a unit sphere
  61590. * @param nb (positive integer) the number of particles to be created from this model
  61591. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61592. * @returns the number of groups in the system
  61593. */
  61594. addPoints(nb: number, pointFunction?: any): number;
  61595. /**
  61596. * Adds points to the PCS from the surface of the model shape
  61597. * @param mesh is any Mesh object that will be used as a surface model for the points
  61598. * @param nb (positive integer) the number of particles to be created from this model
  61599. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61600. * @param color (color3) to be used when colorWith is stated
  61601. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61602. * @returns the number of groups in the system
  61603. */
  61604. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61605. /**
  61606. * Adds points to the PCS inside the model shape
  61607. * @param mesh is any Mesh object that will be used as a surface model for the points
  61608. * @param nb (positive integer) the number of particles to be created from this model
  61609. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  61610. * @param color (color4) to be used when colorWith is stated
  61611. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61612. * @returns the number of groups in the system
  61613. */
  61614. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61615. /**
  61616. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61617. * This method calls `updateParticle()` for each particle of the SPS.
  61618. * For an animated SPS, it is usually called within the render loop.
  61619. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61620. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61621. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61622. * @returns the PCS.
  61623. */
  61624. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61625. /**
  61626. * Disposes the PCS.
  61627. */
  61628. dispose(): void;
  61629. /**
  61630. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61631. * doc :
  61632. * @returns the PCS.
  61633. */
  61634. refreshVisibleSize(): PointsCloudSystem;
  61635. /**
  61636. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61637. * @param size the size (float) of the visibility box
  61638. * note : this doesn't lock the PCS mesh bounding box.
  61639. * doc :
  61640. */
  61641. setVisibilityBox(size: number): void;
  61642. /**
  61643. * Gets whether the PCS is always visible or not
  61644. * doc :
  61645. */
  61646. /**
  61647. * Sets the PCS as always visible or not
  61648. * doc :
  61649. */
  61650. isAlwaysVisible: boolean;
  61651. /**
  61652. * Tells to `setParticles()` to compute the particle rotations or not
  61653. * Default value : false. The PCS is faster when it's set to false
  61654. * Note : particle rotations are only applied to parent particles
  61655. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61656. */
  61657. computeParticleRotation: boolean;
  61658. /**
  61659. * Tells to `setParticles()` to compute the particle colors or not.
  61660. * Default value : true. The PCS is faster when it's set to false.
  61661. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61662. */
  61663. /**
  61664. * Gets if `setParticles()` computes the particle colors or not.
  61665. * Default value : false. The PCS is faster when it's set to false.
  61666. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61667. */
  61668. computeParticleColor: boolean;
  61669. /**
  61670. * Gets if `setParticles()` computes the particle textures or not.
  61671. * Default value : false. The PCS is faster when it's set to false.
  61672. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61673. */
  61674. computeParticleTexture: boolean;
  61675. /**
  61676. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61677. */
  61678. /**
  61679. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61680. */
  61681. computeBoundingBox: boolean;
  61682. /**
  61683. * This function does nothing. It may be overwritten to set all the particle first values.
  61684. * The PCS doesn't call this function, you may have to call it by your own.
  61685. * doc :
  61686. */
  61687. initParticles(): void;
  61688. /**
  61689. * This function does nothing. It may be overwritten to recycle a particle
  61690. * The PCS doesn't call this function, you can to call it
  61691. * doc :
  61692. * @param particle The particle to recycle
  61693. * @returns the recycled particle
  61694. */
  61695. recycleParticle(particle: CloudPoint): CloudPoint;
  61696. /**
  61697. * Updates a particle : this function should be overwritten by the user.
  61698. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61699. * doc :
  61700. * @example : just set a particle position or velocity and recycle conditions
  61701. * @param particle The particle to update
  61702. * @returns the updated particle
  61703. */
  61704. updateParticle(particle: CloudPoint): CloudPoint;
  61705. /**
  61706. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61707. * This does nothing and may be overwritten by the user.
  61708. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61709. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61710. * @param update the boolean update value actually passed to setParticles()
  61711. */
  61712. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61713. /**
  61714. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61715. * This will be passed three parameters.
  61716. * This does nothing and may be overwritten by the user.
  61717. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61718. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61719. * @param update the boolean update value actually passed to setParticles()
  61720. */
  61721. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61722. }
  61723. }
  61724. declare module "babylonjs/Particles/cloudPoint" {
  61725. import { Nullable } from "babylonjs/types";
  61726. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  61727. import { Mesh } from "babylonjs/Meshes/mesh";
  61728. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61729. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  61730. /**
  61731. * Represents one particle of a points cloud system.
  61732. */
  61733. export class CloudPoint {
  61734. /**
  61735. * particle global index
  61736. */
  61737. idx: number;
  61738. /**
  61739. * The color of the particle
  61740. */
  61741. color: Nullable<Color4>;
  61742. /**
  61743. * The world space position of the particle.
  61744. */
  61745. position: Vector3;
  61746. /**
  61747. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61748. */
  61749. rotation: Vector3;
  61750. /**
  61751. * The world space rotation quaternion of the particle.
  61752. */
  61753. rotationQuaternion: Nullable<Quaternion>;
  61754. /**
  61755. * The uv of the particle.
  61756. */
  61757. uv: Nullable<Vector2>;
  61758. /**
  61759. * The current speed of the particle.
  61760. */
  61761. velocity: Vector3;
  61762. /**
  61763. * The pivot point in the particle local space.
  61764. */
  61765. pivot: Vector3;
  61766. /**
  61767. * Must the particle be translated from its pivot point in its local space ?
  61768. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61769. * Default : false
  61770. */
  61771. translateFromPivot: boolean;
  61772. /**
  61773. * Index of this particle in the global "positions" array (Internal use)
  61774. * @hidden
  61775. */
  61776. _pos: number;
  61777. /**
  61778. * @hidden Index of this particle in the global "indices" array (Internal use)
  61779. */
  61780. _ind: number;
  61781. /**
  61782. * Group this particle belongs to
  61783. */
  61784. _group: PointsGroup;
  61785. /**
  61786. * Group id of this particle
  61787. */
  61788. groupId: number;
  61789. /**
  61790. * Index of the particle in its group id (Internal use)
  61791. */
  61792. idxInGroup: number;
  61793. /**
  61794. * @hidden Particle BoundingInfo object (Internal use)
  61795. */
  61796. _boundingInfo: BoundingInfo;
  61797. /**
  61798. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61799. */
  61800. _pcs: PointsCloudSystem;
  61801. /**
  61802. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61803. */
  61804. _stillInvisible: boolean;
  61805. /**
  61806. * @hidden Last computed particle rotation matrix
  61807. */
  61808. _rotationMatrix: number[];
  61809. /**
  61810. * Parent particle Id, if any.
  61811. * Default null.
  61812. */
  61813. parentId: Nullable<number>;
  61814. /**
  61815. * @hidden Internal global position in the PCS.
  61816. */
  61817. _globalPosition: Vector3;
  61818. /**
  61819. * Creates a Point Cloud object.
  61820. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61821. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61822. * @param group (PointsGroup) is the group the particle belongs to
  61823. * @param groupId (integer) is the group identifier in the PCS.
  61824. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61825. * @param pcs defines the PCS it is associated to
  61826. */
  61827. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61828. /**
  61829. * get point size
  61830. */
  61831. /**
  61832. * Set point size
  61833. */
  61834. size: Vector3;
  61835. /**
  61836. * Legacy support, changed quaternion to rotationQuaternion
  61837. */
  61838. /**
  61839. * Legacy support, changed quaternion to rotationQuaternion
  61840. */
  61841. quaternion: Nullable<Quaternion>;
  61842. /**
  61843. * Returns a boolean. True if the particle intersects a mesh, else false
  61844. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61845. * @param target is the object (point or mesh) what the intersection is computed against
  61846. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61847. * @returns true if it intersects
  61848. */
  61849. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61850. /**
  61851. * get the rotation matrix of the particle
  61852. * @hidden
  61853. */
  61854. getRotationMatrix(m: Matrix): void;
  61855. }
  61856. /**
  61857. * Represents a group of points in a points cloud system
  61858. * * PCS internal tool, don't use it manually.
  61859. */
  61860. export class PointsGroup {
  61861. /**
  61862. * The group id
  61863. * @hidden
  61864. */
  61865. groupID: number;
  61866. /**
  61867. * image data for group (internal use)
  61868. * @hidden
  61869. */
  61870. _groupImageData: Nullable<ArrayBufferView>;
  61871. /**
  61872. * Image Width (internal use)
  61873. * @hidden
  61874. */
  61875. _groupImgWidth: number;
  61876. /**
  61877. * Image Height (internal use)
  61878. * @hidden
  61879. */
  61880. _groupImgHeight: number;
  61881. /**
  61882. * Custom position function (internal use)
  61883. * @hidden
  61884. */
  61885. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61886. /**
  61887. * density per facet for surface points
  61888. * @hidden
  61889. */
  61890. _groupDensity: number[];
  61891. /**
  61892. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61893. * PCS internal tool, don't use it manually.
  61894. * @hidden
  61895. */
  61896. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61897. }
  61898. }
  61899. declare module "babylonjs/Particles/index" {
  61900. export * from "babylonjs/Particles/baseParticleSystem";
  61901. export * from "babylonjs/Particles/EmitterTypes/index";
  61902. export * from "babylonjs/Particles/gpuParticleSystem";
  61903. export * from "babylonjs/Particles/IParticleSystem";
  61904. export * from "babylonjs/Particles/particle";
  61905. export * from "babylonjs/Particles/particleHelper";
  61906. export * from "babylonjs/Particles/particleSystem";
  61907. export * from "babylonjs/Particles/particleSystemComponent";
  61908. export * from "babylonjs/Particles/particleSystemSet";
  61909. export * from "babylonjs/Particles/solidParticle";
  61910. export * from "babylonjs/Particles/solidParticleSystem";
  61911. export * from "babylonjs/Particles/cloudPoint";
  61912. export * from "babylonjs/Particles/pointsCloudSystem";
  61913. export * from "babylonjs/Particles/subEmitter";
  61914. }
  61915. declare module "babylonjs/Physics/physicsEngineComponent" {
  61916. import { Nullable } from "babylonjs/types";
  61917. import { Observable, Observer } from "babylonjs/Misc/observable";
  61918. import { Vector3 } from "babylonjs/Maths/math.vector";
  61919. import { Mesh } from "babylonjs/Meshes/mesh";
  61920. import { ISceneComponent } from "babylonjs/sceneComponent";
  61921. import { Scene } from "babylonjs/scene";
  61922. import { Node } from "babylonjs/node";
  61923. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61924. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61925. module "babylonjs/scene" {
  61926. interface Scene {
  61927. /** @hidden (Backing field) */
  61928. _physicsEngine: Nullable<IPhysicsEngine>;
  61929. /**
  61930. * Gets the current physics engine
  61931. * @returns a IPhysicsEngine or null if none attached
  61932. */
  61933. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61934. /**
  61935. * Enables physics to the current scene
  61936. * @param gravity defines the scene's gravity for the physics engine
  61937. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61938. * @return a boolean indicating if the physics engine was initialized
  61939. */
  61940. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61941. /**
  61942. * Disables and disposes the physics engine associated with the scene
  61943. */
  61944. disablePhysicsEngine(): void;
  61945. /**
  61946. * Gets a boolean indicating if there is an active physics engine
  61947. * @returns a boolean indicating if there is an active physics engine
  61948. */
  61949. isPhysicsEnabled(): boolean;
  61950. /**
  61951. * Deletes a physics compound impostor
  61952. * @param compound defines the compound to delete
  61953. */
  61954. deleteCompoundImpostor(compound: any): void;
  61955. /**
  61956. * An event triggered when physic simulation is about to be run
  61957. */
  61958. onBeforePhysicsObservable: Observable<Scene>;
  61959. /**
  61960. * An event triggered when physic simulation has been done
  61961. */
  61962. onAfterPhysicsObservable: Observable<Scene>;
  61963. }
  61964. }
  61965. module "babylonjs/Meshes/abstractMesh" {
  61966. interface AbstractMesh {
  61967. /** @hidden */
  61968. _physicsImpostor: Nullable<PhysicsImpostor>;
  61969. /**
  61970. * Gets or sets impostor used for physic simulation
  61971. * @see http://doc.babylonjs.com/features/physics_engine
  61972. */
  61973. physicsImpostor: Nullable<PhysicsImpostor>;
  61974. /**
  61975. * Gets the current physics impostor
  61976. * @see http://doc.babylonjs.com/features/physics_engine
  61977. * @returns a physics impostor or null
  61978. */
  61979. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61980. /** Apply a physic impulse to the mesh
  61981. * @param force defines the force to apply
  61982. * @param contactPoint defines where to apply the force
  61983. * @returns the current mesh
  61984. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61985. */
  61986. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61987. /**
  61988. * Creates a physic joint between two meshes
  61989. * @param otherMesh defines the other mesh to use
  61990. * @param pivot1 defines the pivot to use on this mesh
  61991. * @param pivot2 defines the pivot to use on the other mesh
  61992. * @param options defines additional options (can be plugin dependent)
  61993. * @returns the current mesh
  61994. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61995. */
  61996. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61997. /** @hidden */
  61998. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61999. }
  62000. }
  62001. /**
  62002. * Defines the physics engine scene component responsible to manage a physics engine
  62003. */
  62004. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62005. /**
  62006. * The component name helpful to identify the component in the list of scene components.
  62007. */
  62008. readonly name: string;
  62009. /**
  62010. * The scene the component belongs to.
  62011. */
  62012. scene: Scene;
  62013. /**
  62014. * Creates a new instance of the component for the given scene
  62015. * @param scene Defines the scene to register the component in
  62016. */
  62017. constructor(scene: Scene);
  62018. /**
  62019. * Registers the component in a given scene
  62020. */
  62021. register(): void;
  62022. /**
  62023. * Rebuilds the elements related to this component in case of
  62024. * context lost for instance.
  62025. */
  62026. rebuild(): void;
  62027. /**
  62028. * Disposes the component and the associated ressources
  62029. */
  62030. dispose(): void;
  62031. }
  62032. }
  62033. declare module "babylonjs/Physics/physicsHelper" {
  62034. import { Nullable } from "babylonjs/types";
  62035. import { Vector3 } from "babylonjs/Maths/math.vector";
  62036. import { Mesh } from "babylonjs/Meshes/mesh";
  62037. import { Scene } from "babylonjs/scene";
  62038. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62039. /**
  62040. * A helper for physics simulations
  62041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62042. */
  62043. export class PhysicsHelper {
  62044. private _scene;
  62045. private _physicsEngine;
  62046. /**
  62047. * Initializes the Physics helper
  62048. * @param scene Babylon.js scene
  62049. */
  62050. constructor(scene: Scene);
  62051. /**
  62052. * Applies a radial explosion impulse
  62053. * @param origin the origin of the explosion
  62054. * @param radiusOrEventOptions the radius or the options of radial explosion
  62055. * @param strength the explosion strength
  62056. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62057. * @returns A physics radial explosion event, or null
  62058. */
  62059. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62060. /**
  62061. * Applies a radial explosion force
  62062. * @param origin the origin of the explosion
  62063. * @param radiusOrEventOptions the radius or the options of radial explosion
  62064. * @param strength the explosion strength
  62065. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62066. * @returns A physics radial explosion event, or null
  62067. */
  62068. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62069. /**
  62070. * Creates a gravitational field
  62071. * @param origin the origin of the explosion
  62072. * @param radiusOrEventOptions the radius or the options of radial explosion
  62073. * @param strength the explosion strength
  62074. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62075. * @returns A physics gravitational field event, or null
  62076. */
  62077. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62078. /**
  62079. * Creates a physics updraft event
  62080. * @param origin the origin of the updraft
  62081. * @param radiusOrEventOptions the radius or the options of the updraft
  62082. * @param strength the strength of the updraft
  62083. * @param height the height of the updraft
  62084. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62085. * @returns A physics updraft event, or null
  62086. */
  62087. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62088. /**
  62089. * Creates a physics vortex event
  62090. * @param origin the of the vortex
  62091. * @param radiusOrEventOptions the radius or the options of the vortex
  62092. * @param strength the strength of the vortex
  62093. * @param height the height of the vortex
  62094. * @returns a Physics vortex event, or null
  62095. * A physics vortex event or null
  62096. */
  62097. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62098. }
  62099. /**
  62100. * Represents a physics radial explosion event
  62101. */
  62102. class PhysicsRadialExplosionEvent {
  62103. private _scene;
  62104. private _options;
  62105. private _sphere;
  62106. private _dataFetched;
  62107. /**
  62108. * Initializes a radial explosioin event
  62109. * @param _scene BabylonJS scene
  62110. * @param _options The options for the vortex event
  62111. */
  62112. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62113. /**
  62114. * Returns the data related to the radial explosion event (sphere).
  62115. * @returns The radial explosion event data
  62116. */
  62117. getData(): PhysicsRadialExplosionEventData;
  62118. /**
  62119. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62120. * @param impostor A physics imposter
  62121. * @param origin the origin of the explosion
  62122. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62123. */
  62124. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62125. /**
  62126. * Triggers affecterd impostors callbacks
  62127. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62128. */
  62129. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62130. /**
  62131. * Disposes the sphere.
  62132. * @param force Specifies if the sphere should be disposed by force
  62133. */
  62134. dispose(force?: boolean): void;
  62135. /*** Helpers ***/
  62136. private _prepareSphere;
  62137. private _intersectsWithSphere;
  62138. }
  62139. /**
  62140. * Represents a gravitational field event
  62141. */
  62142. class PhysicsGravitationalFieldEvent {
  62143. private _physicsHelper;
  62144. private _scene;
  62145. private _origin;
  62146. private _options;
  62147. private _tickCallback;
  62148. private _sphere;
  62149. private _dataFetched;
  62150. /**
  62151. * Initializes the physics gravitational field event
  62152. * @param _physicsHelper A physics helper
  62153. * @param _scene BabylonJS scene
  62154. * @param _origin The origin position of the gravitational field event
  62155. * @param _options The options for the vortex event
  62156. */
  62157. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62158. /**
  62159. * Returns the data related to the gravitational field event (sphere).
  62160. * @returns A gravitational field event
  62161. */
  62162. getData(): PhysicsGravitationalFieldEventData;
  62163. /**
  62164. * Enables the gravitational field.
  62165. */
  62166. enable(): void;
  62167. /**
  62168. * Disables the gravitational field.
  62169. */
  62170. disable(): void;
  62171. /**
  62172. * Disposes the sphere.
  62173. * @param force The force to dispose from the gravitational field event
  62174. */
  62175. dispose(force?: boolean): void;
  62176. private _tick;
  62177. }
  62178. /**
  62179. * Represents a physics updraft event
  62180. */
  62181. class PhysicsUpdraftEvent {
  62182. private _scene;
  62183. private _origin;
  62184. private _options;
  62185. private _physicsEngine;
  62186. private _originTop;
  62187. private _originDirection;
  62188. private _tickCallback;
  62189. private _cylinder;
  62190. private _cylinderPosition;
  62191. private _dataFetched;
  62192. /**
  62193. * Initializes the physics updraft event
  62194. * @param _scene BabylonJS scene
  62195. * @param _origin The origin position of the updraft
  62196. * @param _options The options for the updraft event
  62197. */
  62198. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62199. /**
  62200. * Returns the data related to the updraft event (cylinder).
  62201. * @returns A physics updraft event
  62202. */
  62203. getData(): PhysicsUpdraftEventData;
  62204. /**
  62205. * Enables the updraft.
  62206. */
  62207. enable(): void;
  62208. /**
  62209. * Disables the updraft.
  62210. */
  62211. disable(): void;
  62212. /**
  62213. * Disposes the cylinder.
  62214. * @param force Specifies if the updraft should be disposed by force
  62215. */
  62216. dispose(force?: boolean): void;
  62217. private getImpostorHitData;
  62218. private _tick;
  62219. /*** Helpers ***/
  62220. private _prepareCylinder;
  62221. private _intersectsWithCylinder;
  62222. }
  62223. /**
  62224. * Represents a physics vortex event
  62225. */
  62226. class PhysicsVortexEvent {
  62227. private _scene;
  62228. private _origin;
  62229. private _options;
  62230. private _physicsEngine;
  62231. private _originTop;
  62232. private _tickCallback;
  62233. private _cylinder;
  62234. private _cylinderPosition;
  62235. private _dataFetched;
  62236. /**
  62237. * Initializes the physics vortex event
  62238. * @param _scene The BabylonJS scene
  62239. * @param _origin The origin position of the vortex
  62240. * @param _options The options for the vortex event
  62241. */
  62242. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62243. /**
  62244. * Returns the data related to the vortex event (cylinder).
  62245. * @returns The physics vortex event data
  62246. */
  62247. getData(): PhysicsVortexEventData;
  62248. /**
  62249. * Enables the vortex.
  62250. */
  62251. enable(): void;
  62252. /**
  62253. * Disables the cortex.
  62254. */
  62255. disable(): void;
  62256. /**
  62257. * Disposes the sphere.
  62258. * @param force
  62259. */
  62260. dispose(force?: boolean): void;
  62261. private getImpostorHitData;
  62262. private _tick;
  62263. /*** Helpers ***/
  62264. private _prepareCylinder;
  62265. private _intersectsWithCylinder;
  62266. }
  62267. /**
  62268. * Options fot the radial explosion event
  62269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62270. */
  62271. export class PhysicsRadialExplosionEventOptions {
  62272. /**
  62273. * The radius of the sphere for the radial explosion.
  62274. */
  62275. radius: number;
  62276. /**
  62277. * The strenth of the explosion.
  62278. */
  62279. strength: number;
  62280. /**
  62281. * The strenght of the force in correspondence to the distance of the affected object
  62282. */
  62283. falloff: PhysicsRadialImpulseFalloff;
  62284. /**
  62285. * Sphere options for the radial explosion.
  62286. */
  62287. sphere: {
  62288. segments: number;
  62289. diameter: number;
  62290. };
  62291. /**
  62292. * Sphere options for the radial explosion.
  62293. */
  62294. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62295. }
  62296. /**
  62297. * Options fot the updraft event
  62298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62299. */
  62300. export class PhysicsUpdraftEventOptions {
  62301. /**
  62302. * The radius of the cylinder for the vortex
  62303. */
  62304. radius: number;
  62305. /**
  62306. * The strenth of the updraft.
  62307. */
  62308. strength: number;
  62309. /**
  62310. * The height of the cylinder for the updraft.
  62311. */
  62312. height: number;
  62313. /**
  62314. * The mode for the the updraft.
  62315. */
  62316. updraftMode: PhysicsUpdraftMode;
  62317. }
  62318. /**
  62319. * Options fot the vortex event
  62320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62321. */
  62322. export class PhysicsVortexEventOptions {
  62323. /**
  62324. * The radius of the cylinder for the vortex
  62325. */
  62326. radius: number;
  62327. /**
  62328. * The strenth of the vortex.
  62329. */
  62330. strength: number;
  62331. /**
  62332. * The height of the cylinder for the vortex.
  62333. */
  62334. height: number;
  62335. /**
  62336. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62337. */
  62338. centripetalForceThreshold: number;
  62339. /**
  62340. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62341. */
  62342. centripetalForceMultiplier: number;
  62343. /**
  62344. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62345. */
  62346. centrifugalForceMultiplier: number;
  62347. /**
  62348. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62349. */
  62350. updraftForceMultiplier: number;
  62351. }
  62352. /**
  62353. * The strenght of the force in correspondence to the distance of the affected object
  62354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62355. */
  62356. export enum PhysicsRadialImpulseFalloff {
  62357. /** Defines that impulse is constant in strength across it's whole radius */
  62358. Constant = 0,
  62359. /** Defines that impulse gets weaker if it's further from the origin */
  62360. Linear = 1
  62361. }
  62362. /**
  62363. * The strength of the force in correspondence to the distance of the affected object
  62364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62365. */
  62366. export enum PhysicsUpdraftMode {
  62367. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62368. Center = 0,
  62369. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62370. Perpendicular = 1
  62371. }
  62372. /**
  62373. * Interface for a physics hit data
  62374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62375. */
  62376. export interface PhysicsHitData {
  62377. /**
  62378. * The force applied at the contact point
  62379. */
  62380. force: Vector3;
  62381. /**
  62382. * The contact point
  62383. */
  62384. contactPoint: Vector3;
  62385. /**
  62386. * The distance from the origin to the contact point
  62387. */
  62388. distanceFromOrigin: number;
  62389. }
  62390. /**
  62391. * Interface for radial explosion event data
  62392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62393. */
  62394. export interface PhysicsRadialExplosionEventData {
  62395. /**
  62396. * A sphere used for the radial explosion event
  62397. */
  62398. sphere: Mesh;
  62399. }
  62400. /**
  62401. * Interface for gravitational field event data
  62402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62403. */
  62404. export interface PhysicsGravitationalFieldEventData {
  62405. /**
  62406. * A sphere mesh used for the gravitational field event
  62407. */
  62408. sphere: Mesh;
  62409. }
  62410. /**
  62411. * Interface for updraft event data
  62412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62413. */
  62414. export interface PhysicsUpdraftEventData {
  62415. /**
  62416. * A cylinder used for the updraft event
  62417. */
  62418. cylinder: Mesh;
  62419. }
  62420. /**
  62421. * Interface for vortex event data
  62422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62423. */
  62424. export interface PhysicsVortexEventData {
  62425. /**
  62426. * A cylinder used for the vortex event
  62427. */
  62428. cylinder: Mesh;
  62429. }
  62430. /**
  62431. * Interface for an affected physics impostor
  62432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62433. */
  62434. export interface PhysicsAffectedImpostorWithData {
  62435. /**
  62436. * The impostor affected by the effect
  62437. */
  62438. impostor: PhysicsImpostor;
  62439. /**
  62440. * The data about the hit/horce from the explosion
  62441. */
  62442. hitData: PhysicsHitData;
  62443. }
  62444. }
  62445. declare module "babylonjs/Physics/Plugins/index" {
  62446. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62447. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62448. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62449. }
  62450. declare module "babylonjs/Physics/index" {
  62451. export * from "babylonjs/Physics/IPhysicsEngine";
  62452. export * from "babylonjs/Physics/physicsEngine";
  62453. export * from "babylonjs/Physics/physicsEngineComponent";
  62454. export * from "babylonjs/Physics/physicsHelper";
  62455. export * from "babylonjs/Physics/physicsImpostor";
  62456. export * from "babylonjs/Physics/physicsJoint";
  62457. export * from "babylonjs/Physics/Plugins/index";
  62458. }
  62459. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62460. /** @hidden */
  62461. export var blackAndWhitePixelShader: {
  62462. name: string;
  62463. shader: string;
  62464. };
  62465. }
  62466. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62467. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62468. import { Camera } from "babylonjs/Cameras/camera";
  62469. import { Engine } from "babylonjs/Engines/engine";
  62470. import "babylonjs/Shaders/blackAndWhite.fragment";
  62471. /**
  62472. * Post process used to render in black and white
  62473. */
  62474. export class BlackAndWhitePostProcess extends PostProcess {
  62475. /**
  62476. * Linear about to convert he result to black and white (default: 1)
  62477. */
  62478. degree: number;
  62479. /**
  62480. * Creates a black and white post process
  62481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  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: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62490. }
  62491. }
  62492. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  62493. import { Nullable } from "babylonjs/types";
  62494. import { Camera } from "babylonjs/Cameras/camera";
  62495. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62496. import { Engine } from "babylonjs/Engines/engine";
  62497. /**
  62498. * This represents a set of one or more post processes in Babylon.
  62499. * A post process can be used to apply a shader to a texture after it is rendered.
  62500. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62501. */
  62502. export class PostProcessRenderEffect {
  62503. private _postProcesses;
  62504. private _getPostProcesses;
  62505. private _singleInstance;
  62506. private _cameras;
  62507. private _indicesForCamera;
  62508. /**
  62509. * Name of the effect
  62510. * @hidden
  62511. */
  62512. _name: string;
  62513. /**
  62514. * Instantiates a post process render effect.
  62515. * A post process can be used to apply a shader to a texture after it is rendered.
  62516. * @param engine The engine the effect is tied to
  62517. * @param name The name of the effect
  62518. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62519. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62520. */
  62521. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62522. /**
  62523. * Checks if all the post processes in the effect are supported.
  62524. */
  62525. readonly isSupported: boolean;
  62526. /**
  62527. * Updates the current state of the effect
  62528. * @hidden
  62529. */
  62530. _update(): void;
  62531. /**
  62532. * Attaches the effect on cameras
  62533. * @param cameras The camera to attach to.
  62534. * @hidden
  62535. */
  62536. _attachCameras(cameras: Camera): void;
  62537. /**
  62538. * Attaches the effect on cameras
  62539. * @param cameras The camera to attach to.
  62540. * @hidden
  62541. */
  62542. _attachCameras(cameras: Camera[]): void;
  62543. /**
  62544. * Detaches the effect on cameras
  62545. * @param cameras The camera to detatch from.
  62546. * @hidden
  62547. */
  62548. _detachCameras(cameras: Camera): void;
  62549. /**
  62550. * Detatches the effect on cameras
  62551. * @param cameras The camera to detatch from.
  62552. * @hidden
  62553. */
  62554. _detachCameras(cameras: Camera[]): void;
  62555. /**
  62556. * Enables the effect on given cameras
  62557. * @param cameras The camera to enable.
  62558. * @hidden
  62559. */
  62560. _enable(cameras: Camera): void;
  62561. /**
  62562. * Enables the effect on given cameras
  62563. * @param cameras The camera to enable.
  62564. * @hidden
  62565. */
  62566. _enable(cameras: Nullable<Camera[]>): void;
  62567. /**
  62568. * Disables the effect on the given cameras
  62569. * @param cameras The camera to disable.
  62570. * @hidden
  62571. */
  62572. _disable(cameras: Camera): void;
  62573. /**
  62574. * Disables the effect on the given cameras
  62575. * @param cameras The camera to disable.
  62576. * @hidden
  62577. */
  62578. _disable(cameras: Nullable<Camera[]>): void;
  62579. /**
  62580. * Gets a list of the post processes contained in the effect.
  62581. * @param camera The camera to get the post processes on.
  62582. * @returns The list of the post processes in the effect.
  62583. */
  62584. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62585. }
  62586. }
  62587. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  62588. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62589. /** @hidden */
  62590. export var extractHighlightsPixelShader: {
  62591. name: string;
  62592. shader: string;
  62593. };
  62594. }
  62595. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62596. import { Nullable } from "babylonjs/types";
  62597. import { Camera } from "babylonjs/Cameras/camera";
  62598. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62599. import { Engine } from "babylonjs/Engines/engine";
  62600. import "babylonjs/Shaders/extractHighlights.fragment";
  62601. /**
  62602. * 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.
  62603. */
  62604. export class ExtractHighlightsPostProcess extends PostProcess {
  62605. /**
  62606. * The luminance threshold, pixels below this value will be set to black.
  62607. */
  62608. threshold: number;
  62609. /** @hidden */
  62610. _exposure: number;
  62611. /**
  62612. * Post process which has the input texture to be used when performing highlight extraction
  62613. * @hidden
  62614. */
  62615. _inputPostProcess: Nullable<PostProcess>;
  62616. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62617. }
  62618. }
  62619. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62620. /** @hidden */
  62621. export var bloomMergePixelShader: {
  62622. name: string;
  62623. shader: string;
  62624. };
  62625. }
  62626. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62627. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62628. import { Nullable } from "babylonjs/types";
  62629. import { Engine } from "babylonjs/Engines/engine";
  62630. import { Camera } from "babylonjs/Cameras/camera";
  62631. import "babylonjs/Shaders/bloomMerge.fragment";
  62632. /**
  62633. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62634. */
  62635. export class BloomMergePostProcess extends PostProcess {
  62636. /** Weight of the bloom to be added to the original input. */
  62637. weight: number;
  62638. /**
  62639. * Creates a new instance of @see BloomMergePostProcess
  62640. * @param name The name of the effect.
  62641. * @param originalFromInput Post process which's input will be used for the merge.
  62642. * @param blurred Blurred highlights post process which's output will be used.
  62643. * @param weight Weight of the bloom to be added to the original input.
  62644. * @param options The required width/height ratio to downsize to before computing the render pass.
  62645. * @param camera The camera to apply the render pass to.
  62646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62647. * @param engine The engine which the post process will be applied. (default: current engine)
  62648. * @param reusable If the post process can be reused on the same frame. (default: false)
  62649. * @param textureType Type of textures used when performing the post process. (default: 0)
  62650. * @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)
  62651. */
  62652. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62653. /** Weight of the bloom to be added to the original input. */
  62654. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62655. }
  62656. }
  62657. declare module "babylonjs/PostProcesses/bloomEffect" {
  62658. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62659. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62660. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62661. import { Camera } from "babylonjs/Cameras/camera";
  62662. import { Scene } from "babylonjs/scene";
  62663. /**
  62664. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62665. */
  62666. export class BloomEffect extends PostProcessRenderEffect {
  62667. private bloomScale;
  62668. /**
  62669. * @hidden Internal
  62670. */
  62671. _effects: Array<PostProcess>;
  62672. /**
  62673. * @hidden Internal
  62674. */
  62675. _downscale: ExtractHighlightsPostProcess;
  62676. private _blurX;
  62677. private _blurY;
  62678. private _merge;
  62679. /**
  62680. * The luminance threshold to find bright areas of the image to bloom.
  62681. */
  62682. threshold: number;
  62683. /**
  62684. * The strength of the bloom.
  62685. */
  62686. weight: number;
  62687. /**
  62688. * Specifies the size of the bloom blur kernel, relative to the final output size
  62689. */
  62690. kernel: number;
  62691. /**
  62692. * Creates a new instance of @see BloomEffect
  62693. * @param scene The scene the effect belongs to.
  62694. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62695. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62696. * @param bloomWeight The the strength of bloom.
  62697. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62698. * @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)
  62699. */
  62700. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62701. /**
  62702. * Disposes each of the internal effects for a given camera.
  62703. * @param camera The camera to dispose the effect on.
  62704. */
  62705. disposeEffects(camera: Camera): void;
  62706. /**
  62707. * @hidden Internal
  62708. */
  62709. _updateEffects(): void;
  62710. /**
  62711. * Internal
  62712. * @returns if all the contained post processes are ready.
  62713. * @hidden
  62714. */
  62715. _isReady(): boolean;
  62716. }
  62717. }
  62718. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62719. /** @hidden */
  62720. export var chromaticAberrationPixelShader: {
  62721. name: string;
  62722. shader: string;
  62723. };
  62724. }
  62725. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62726. import { Vector2 } from "babylonjs/Maths/math.vector";
  62727. import { Nullable } from "babylonjs/types";
  62728. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62729. import { Camera } from "babylonjs/Cameras/camera";
  62730. import { Engine } from "babylonjs/Engines/engine";
  62731. import "babylonjs/Shaders/chromaticAberration.fragment";
  62732. /**
  62733. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62734. */
  62735. export class ChromaticAberrationPostProcess extends PostProcess {
  62736. /**
  62737. * The amount of seperation of rgb channels (default: 30)
  62738. */
  62739. aberrationAmount: number;
  62740. /**
  62741. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62742. */
  62743. radialIntensity: number;
  62744. /**
  62745. * 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))
  62746. */
  62747. direction: Vector2;
  62748. /**
  62749. * 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))
  62750. */
  62751. centerPosition: Vector2;
  62752. /**
  62753. * Creates a new instance ChromaticAberrationPostProcess
  62754. * @param name The name of the effect.
  62755. * @param screenWidth The width of the screen to apply the effect on.
  62756. * @param screenHeight The height of the screen to apply the effect on.
  62757. * @param options The required width/height ratio to downsize to before computing the render pass.
  62758. * @param camera The camera to apply the render pass to.
  62759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62760. * @param engine The engine which the post process will be applied. (default: current engine)
  62761. * @param reusable If the post process can be reused on the same frame. (default: false)
  62762. * @param textureType Type of textures used when performing the post process. (default: 0)
  62763. * @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)
  62764. */
  62765. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62766. }
  62767. }
  62768. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62769. /** @hidden */
  62770. export var circleOfConfusionPixelShader: {
  62771. name: string;
  62772. shader: string;
  62773. };
  62774. }
  62775. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62776. import { Nullable } from "babylonjs/types";
  62777. import { Engine } from "babylonjs/Engines/engine";
  62778. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62779. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62780. import { Camera } from "babylonjs/Cameras/camera";
  62781. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62782. /**
  62783. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62784. */
  62785. export class CircleOfConfusionPostProcess extends PostProcess {
  62786. /**
  62787. * 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.
  62788. */
  62789. lensSize: number;
  62790. /**
  62791. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62792. */
  62793. fStop: number;
  62794. /**
  62795. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62796. */
  62797. focusDistance: number;
  62798. /**
  62799. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62800. */
  62801. focalLength: number;
  62802. private _depthTexture;
  62803. /**
  62804. * Creates a new instance CircleOfConfusionPostProcess
  62805. * @param name The name of the effect.
  62806. * @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.
  62807. * @param options The required width/height ratio to downsize to before computing the render pass.
  62808. * @param camera The camera to apply the render pass to.
  62809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62810. * @param engine The engine which the post process will be applied. (default: current engine)
  62811. * @param reusable If the post process can be reused on the same frame. (default: false)
  62812. * @param textureType Type of textures used when performing the post process. (default: 0)
  62813. * @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)
  62814. */
  62815. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62816. /**
  62817. * 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.
  62818. */
  62819. depthTexture: RenderTargetTexture;
  62820. }
  62821. }
  62822. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62823. /** @hidden */
  62824. export var colorCorrectionPixelShader: {
  62825. name: string;
  62826. shader: string;
  62827. };
  62828. }
  62829. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62830. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62831. import { Engine } from "babylonjs/Engines/engine";
  62832. import { Camera } from "babylonjs/Cameras/camera";
  62833. import "babylonjs/Shaders/colorCorrection.fragment";
  62834. /**
  62835. *
  62836. * This post-process allows the modification of rendered colors by using
  62837. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62838. *
  62839. * The object needs to be provided an url to a texture containing the color
  62840. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62841. * Use an image editing software to tweak the LUT to match your needs.
  62842. *
  62843. * For an example of a color LUT, see here:
  62844. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62845. * For explanations on color grading, see here:
  62846. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62847. *
  62848. */
  62849. export class ColorCorrectionPostProcess extends PostProcess {
  62850. private _colorTableTexture;
  62851. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62852. }
  62853. }
  62854. declare module "babylonjs/Shaders/convolution.fragment" {
  62855. /** @hidden */
  62856. export var convolutionPixelShader: {
  62857. name: string;
  62858. shader: string;
  62859. };
  62860. }
  62861. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62862. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62863. import { Nullable } from "babylonjs/types";
  62864. import { Camera } from "babylonjs/Cameras/camera";
  62865. import { Engine } from "babylonjs/Engines/engine";
  62866. import "babylonjs/Shaders/convolution.fragment";
  62867. /**
  62868. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62869. * input texture to perform effects such as edge detection or sharpening
  62870. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62871. */
  62872. export class ConvolutionPostProcess extends PostProcess {
  62873. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62874. kernel: number[];
  62875. /**
  62876. * Creates a new instance ConvolutionPostProcess
  62877. * @param name The name of the effect.
  62878. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62879. * @param options The required width/height ratio to downsize to before computing the render pass.
  62880. * @param camera The camera to apply the render pass to.
  62881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62882. * @param engine The engine which the post process will be applied. (default: current engine)
  62883. * @param reusable If the post process can be reused on the same frame. (default: false)
  62884. * @param textureType Type of textures used when performing the post process. (default: 0)
  62885. */
  62886. constructor(name: string,
  62887. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62888. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62889. /**
  62890. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62891. */
  62892. static EdgeDetect0Kernel: number[];
  62893. /**
  62894. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62895. */
  62896. static EdgeDetect1Kernel: number[];
  62897. /**
  62898. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62899. */
  62900. static EdgeDetect2Kernel: number[];
  62901. /**
  62902. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62903. */
  62904. static SharpenKernel: number[];
  62905. /**
  62906. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62907. */
  62908. static EmbossKernel: number[];
  62909. /**
  62910. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62911. */
  62912. static GaussianKernel: number[];
  62913. }
  62914. }
  62915. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62916. import { Nullable } from "babylonjs/types";
  62917. import { Vector2 } from "babylonjs/Maths/math.vector";
  62918. import { Camera } from "babylonjs/Cameras/camera";
  62919. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62920. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62921. import { Engine } from "babylonjs/Engines/engine";
  62922. import { Scene } from "babylonjs/scene";
  62923. /**
  62924. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62925. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62926. * based on samples that have a large difference in distance than the center pixel.
  62927. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62928. */
  62929. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62930. direction: Vector2;
  62931. /**
  62932. * Creates a new instance CircleOfConfusionPostProcess
  62933. * @param name The name of the effect.
  62934. * @param scene The scene the effect belongs to.
  62935. * @param direction The direction the blur should be applied.
  62936. * @param kernel The size of the kernel used to blur.
  62937. * @param options The required width/height ratio to downsize to before computing the render pass.
  62938. * @param camera The camera to apply the render pass to.
  62939. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62940. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62942. * @param engine The engine which the post process will be applied. (default: current engine)
  62943. * @param reusable If the post process can be reused on the same frame. (default: false)
  62944. * @param textureType Type of textures used when performing the post process. (default: 0)
  62945. * @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)
  62946. */
  62947. 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);
  62948. }
  62949. }
  62950. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62951. /** @hidden */
  62952. export var depthOfFieldMergePixelShader: {
  62953. name: string;
  62954. shader: string;
  62955. };
  62956. }
  62957. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62958. import { Nullable } from "babylonjs/types";
  62959. import { Camera } from "babylonjs/Cameras/camera";
  62960. import { Effect } from "babylonjs/Materials/effect";
  62961. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62962. import { Engine } from "babylonjs/Engines/engine";
  62963. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62964. /**
  62965. * Options to be set when merging outputs from the default pipeline.
  62966. */
  62967. export class DepthOfFieldMergePostProcessOptions {
  62968. /**
  62969. * The original image to merge on top of
  62970. */
  62971. originalFromInput: PostProcess;
  62972. /**
  62973. * Parameters to perform the merge of the depth of field effect
  62974. */
  62975. depthOfField?: {
  62976. circleOfConfusion: PostProcess;
  62977. blurSteps: Array<PostProcess>;
  62978. };
  62979. /**
  62980. * Parameters to perform the merge of bloom effect
  62981. */
  62982. bloom?: {
  62983. blurred: PostProcess;
  62984. weight: number;
  62985. };
  62986. }
  62987. /**
  62988. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62989. */
  62990. export class DepthOfFieldMergePostProcess extends PostProcess {
  62991. private blurSteps;
  62992. /**
  62993. * Creates a new instance of DepthOfFieldMergePostProcess
  62994. * @param name The name of the effect.
  62995. * @param originalFromInput Post process which's input will be used for the merge.
  62996. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62997. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62998. * @param options The required width/height ratio to downsize to before computing the render pass.
  62999. * @param camera The camera to apply the render pass to.
  63000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63001. * @param engine The engine which the post process will be applied. (default: current engine)
  63002. * @param reusable If the post process can be reused on the same frame. (default: false)
  63003. * @param textureType Type of textures used when performing the post process. (default: 0)
  63004. * @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)
  63005. */
  63006. 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);
  63007. /**
  63008. * Updates the effect with the current post process compile time values and recompiles the shader.
  63009. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63010. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63011. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63012. * @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
  63013. * @param onCompiled Called when the shader has been compiled.
  63014. * @param onError Called if there is an error when compiling a shader.
  63015. */
  63016. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63017. }
  63018. }
  63019. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63020. import { Nullable } from "babylonjs/types";
  63021. import { Camera } from "babylonjs/Cameras/camera";
  63022. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63023. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63024. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63025. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63026. import { Scene } from "babylonjs/scene";
  63027. /**
  63028. * Specifies the level of max blur that should be applied when using the depth of field effect
  63029. */
  63030. export enum DepthOfFieldEffectBlurLevel {
  63031. /**
  63032. * Subtle blur
  63033. */
  63034. Low = 0,
  63035. /**
  63036. * Medium blur
  63037. */
  63038. Medium = 1,
  63039. /**
  63040. * Large blur
  63041. */
  63042. High = 2
  63043. }
  63044. /**
  63045. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63046. */
  63047. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63048. private _circleOfConfusion;
  63049. /**
  63050. * @hidden Internal, blurs from high to low
  63051. */
  63052. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63053. private _depthOfFieldBlurY;
  63054. private _dofMerge;
  63055. /**
  63056. * @hidden Internal post processes in depth of field effect
  63057. */
  63058. _effects: Array<PostProcess>;
  63059. /**
  63060. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63061. */
  63062. focalLength: number;
  63063. /**
  63064. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63065. */
  63066. fStop: number;
  63067. /**
  63068. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63069. */
  63070. focusDistance: number;
  63071. /**
  63072. * 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.
  63073. */
  63074. lensSize: number;
  63075. /**
  63076. * Creates a new instance DepthOfFieldEffect
  63077. * @param scene The scene the effect belongs to.
  63078. * @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.
  63079. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63080. * @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)
  63081. */
  63082. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63083. /**
  63084. * Get the current class name of the current effet
  63085. * @returns "DepthOfFieldEffect"
  63086. */
  63087. getClassName(): string;
  63088. /**
  63089. * 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.
  63090. */
  63091. depthTexture: RenderTargetTexture;
  63092. /**
  63093. * Disposes each of the internal effects for a given camera.
  63094. * @param camera The camera to dispose the effect on.
  63095. */
  63096. disposeEffects(camera: Camera): void;
  63097. /**
  63098. * @hidden Internal
  63099. */
  63100. _updateEffects(): void;
  63101. /**
  63102. * Internal
  63103. * @returns if all the contained post processes are ready.
  63104. * @hidden
  63105. */
  63106. _isReady(): boolean;
  63107. }
  63108. }
  63109. declare module "babylonjs/Shaders/displayPass.fragment" {
  63110. /** @hidden */
  63111. export var displayPassPixelShader: {
  63112. name: string;
  63113. shader: string;
  63114. };
  63115. }
  63116. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63117. import { Nullable } from "babylonjs/types";
  63118. import { Camera } from "babylonjs/Cameras/camera";
  63119. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63120. import { Engine } from "babylonjs/Engines/engine";
  63121. import "babylonjs/Shaders/displayPass.fragment";
  63122. /**
  63123. * DisplayPassPostProcess which produces an output the same as it's input
  63124. */
  63125. export class DisplayPassPostProcess extends PostProcess {
  63126. /**
  63127. * Creates the DisplayPassPostProcess
  63128. * @param name The name of the effect.
  63129. * @param options The required width/height ratio to downsize to before computing the render pass.
  63130. * @param camera The camera to apply the render pass to.
  63131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63132. * @param engine The engine which the post process will be applied. (default: current engine)
  63133. * @param reusable If the post process can be reused on the same frame. (default: false)
  63134. */
  63135. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63136. }
  63137. }
  63138. declare module "babylonjs/Shaders/filter.fragment" {
  63139. /** @hidden */
  63140. export var filterPixelShader: {
  63141. name: string;
  63142. shader: string;
  63143. };
  63144. }
  63145. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63146. import { Nullable } from "babylonjs/types";
  63147. import { Matrix } from "babylonjs/Maths/math.vector";
  63148. import { Camera } from "babylonjs/Cameras/camera";
  63149. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63150. import { Engine } from "babylonjs/Engines/engine";
  63151. import "babylonjs/Shaders/filter.fragment";
  63152. /**
  63153. * Applies a kernel filter to the image
  63154. */
  63155. export class FilterPostProcess extends PostProcess {
  63156. /** The matrix to be applied to the image */
  63157. kernelMatrix: Matrix;
  63158. /**
  63159. *
  63160. * @param name The name of the effect.
  63161. * @param kernelMatrix The matrix to be applied to the image
  63162. * @param options The required width/height ratio to downsize to before computing the render pass.
  63163. * @param camera The camera to apply the render pass to.
  63164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63165. * @param engine The engine which the post process will be applied. (default: current engine)
  63166. * @param reusable If the post process can be reused on the same frame. (default: false)
  63167. */
  63168. constructor(name: string,
  63169. /** The matrix to be applied to the image */
  63170. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63171. }
  63172. }
  63173. declare module "babylonjs/Shaders/fxaa.fragment" {
  63174. /** @hidden */
  63175. export var fxaaPixelShader: {
  63176. name: string;
  63177. shader: string;
  63178. };
  63179. }
  63180. declare module "babylonjs/Shaders/fxaa.vertex" {
  63181. /** @hidden */
  63182. export var fxaaVertexShader: {
  63183. name: string;
  63184. shader: string;
  63185. };
  63186. }
  63187. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63188. import { Nullable } from "babylonjs/types";
  63189. import { Camera } from "babylonjs/Cameras/camera";
  63190. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63191. import { Engine } from "babylonjs/Engines/engine";
  63192. import "babylonjs/Shaders/fxaa.fragment";
  63193. import "babylonjs/Shaders/fxaa.vertex";
  63194. /**
  63195. * Fxaa post process
  63196. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63197. */
  63198. export class FxaaPostProcess extends PostProcess {
  63199. /** @hidden */
  63200. texelWidth: number;
  63201. /** @hidden */
  63202. texelHeight: number;
  63203. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63204. private _getDefines;
  63205. }
  63206. }
  63207. declare module "babylonjs/Shaders/grain.fragment" {
  63208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63209. /** @hidden */
  63210. export var grainPixelShader: {
  63211. name: string;
  63212. shader: string;
  63213. };
  63214. }
  63215. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63216. import { Nullable } from "babylonjs/types";
  63217. import { Camera } from "babylonjs/Cameras/camera";
  63218. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63219. import { Engine } from "babylonjs/Engines/engine";
  63220. import "babylonjs/Shaders/grain.fragment";
  63221. /**
  63222. * The GrainPostProcess adds noise to the image at mid luminance levels
  63223. */
  63224. export class GrainPostProcess extends PostProcess {
  63225. /**
  63226. * The intensity of the grain added (default: 30)
  63227. */
  63228. intensity: number;
  63229. /**
  63230. * If the grain should be randomized on every frame
  63231. */
  63232. animated: boolean;
  63233. /**
  63234. * Creates a new instance of @see GrainPostProcess
  63235. * @param name The name of the effect.
  63236. * @param options The required width/height ratio to downsize to before computing the render pass.
  63237. * @param camera The camera to apply the render pass to.
  63238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63239. * @param engine The engine which the post process will be applied. (default: current engine)
  63240. * @param reusable If the post process can be reused on the same frame. (default: false)
  63241. * @param textureType Type of textures used when performing the post process. (default: 0)
  63242. * @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)
  63243. */
  63244. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63245. }
  63246. }
  63247. declare module "babylonjs/Shaders/highlights.fragment" {
  63248. /** @hidden */
  63249. export var highlightsPixelShader: {
  63250. name: string;
  63251. shader: string;
  63252. };
  63253. }
  63254. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63255. import { Nullable } from "babylonjs/types";
  63256. import { Camera } from "babylonjs/Cameras/camera";
  63257. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63258. import { Engine } from "babylonjs/Engines/engine";
  63259. import "babylonjs/Shaders/highlights.fragment";
  63260. /**
  63261. * Extracts highlights from the image
  63262. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63263. */
  63264. export class HighlightsPostProcess extends PostProcess {
  63265. /**
  63266. * Extracts highlights from the image
  63267. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63268. * @param name The name of the effect.
  63269. * @param options The required width/height ratio to downsize to before computing the render pass.
  63270. * @param camera The camera to apply the render pass to.
  63271. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63272. * @param engine The engine which the post process will be applied. (default: current engine)
  63273. * @param reusable If the post process can be reused on the same frame. (default: false)
  63274. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63275. */
  63276. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63277. }
  63278. }
  63279. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63280. /** @hidden */
  63281. export var mrtFragmentDeclaration: {
  63282. name: string;
  63283. shader: string;
  63284. };
  63285. }
  63286. declare module "babylonjs/Shaders/geometry.fragment" {
  63287. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63288. /** @hidden */
  63289. export var geometryPixelShader: {
  63290. name: string;
  63291. shader: string;
  63292. };
  63293. }
  63294. declare module "babylonjs/Shaders/geometry.vertex" {
  63295. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63296. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63297. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63298. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63299. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63300. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63301. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63302. /** @hidden */
  63303. export var geometryVertexShader: {
  63304. name: string;
  63305. shader: string;
  63306. };
  63307. }
  63308. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63309. import { Matrix } from "babylonjs/Maths/math.vector";
  63310. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63311. import { Mesh } from "babylonjs/Meshes/mesh";
  63312. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63313. import { Effect } from "babylonjs/Materials/effect";
  63314. import { Scene } from "babylonjs/scene";
  63315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63316. import "babylonjs/Shaders/geometry.fragment";
  63317. import "babylonjs/Shaders/geometry.vertex";
  63318. /** @hidden */
  63319. interface ISavedTransformationMatrix {
  63320. world: Matrix;
  63321. viewProjection: Matrix;
  63322. }
  63323. /**
  63324. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63325. */
  63326. export class GeometryBufferRenderer {
  63327. /**
  63328. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63329. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63330. */
  63331. static readonly POSITION_TEXTURE_TYPE: number;
  63332. /**
  63333. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63334. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63335. */
  63336. static readonly VELOCITY_TEXTURE_TYPE: number;
  63337. /**
  63338. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63339. * in order to compute objects velocities when enableVelocity is set to "true"
  63340. * @hidden
  63341. */
  63342. _previousTransformationMatrices: {
  63343. [index: number]: ISavedTransformationMatrix;
  63344. };
  63345. /**
  63346. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63347. * in order to compute objects velocities when enableVelocity is set to "true"
  63348. * @hidden
  63349. */
  63350. _previousBonesTransformationMatrices: {
  63351. [index: number]: Float32Array;
  63352. };
  63353. /**
  63354. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63355. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63356. */
  63357. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63358. private _scene;
  63359. private _multiRenderTarget;
  63360. private _ratio;
  63361. private _enablePosition;
  63362. private _enableVelocity;
  63363. private _positionIndex;
  63364. private _velocityIndex;
  63365. protected _effect: Effect;
  63366. protected _cachedDefines: string;
  63367. /**
  63368. * Set the render list (meshes to be rendered) used in the G buffer.
  63369. */
  63370. renderList: Mesh[];
  63371. /**
  63372. * Gets wether or not G buffer are supported by the running hardware.
  63373. * This requires draw buffer supports
  63374. */
  63375. readonly isSupported: boolean;
  63376. /**
  63377. * Returns the index of the given texture type in the G-Buffer textures array
  63378. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63379. * @returns the index of the given texture type in the G-Buffer textures array
  63380. */
  63381. getTextureIndex(textureType: number): number;
  63382. /**
  63383. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63384. */
  63385. /**
  63386. * Sets whether or not objects positions are enabled for the G buffer.
  63387. */
  63388. enablePosition: boolean;
  63389. /**
  63390. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63391. */
  63392. /**
  63393. * Sets wether or not objects velocities are enabled for the G buffer.
  63394. */
  63395. enableVelocity: boolean;
  63396. /**
  63397. * Gets the scene associated with the buffer.
  63398. */
  63399. readonly scene: Scene;
  63400. /**
  63401. * Gets the ratio used by the buffer during its creation.
  63402. * How big is the buffer related to the main canvas.
  63403. */
  63404. readonly ratio: number;
  63405. /** @hidden */
  63406. static _SceneComponentInitialization: (scene: Scene) => void;
  63407. /**
  63408. * Creates a new G Buffer for the scene
  63409. * @param scene The scene the buffer belongs to
  63410. * @param ratio How big is the buffer related to the main canvas.
  63411. */
  63412. constructor(scene: Scene, ratio?: number);
  63413. /**
  63414. * Checks wether everything is ready to render a submesh to the G buffer.
  63415. * @param subMesh the submesh to check readiness for
  63416. * @param useInstances is the mesh drawn using instance or not
  63417. * @returns true if ready otherwise false
  63418. */
  63419. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63420. /**
  63421. * Gets the current underlying G Buffer.
  63422. * @returns the buffer
  63423. */
  63424. getGBuffer(): MultiRenderTarget;
  63425. /**
  63426. * Gets the number of samples used to render the buffer (anti aliasing).
  63427. */
  63428. /**
  63429. * Sets the number of samples used to render the buffer (anti aliasing).
  63430. */
  63431. samples: number;
  63432. /**
  63433. * Disposes the renderer and frees up associated resources.
  63434. */
  63435. dispose(): void;
  63436. protected _createRenderTargets(): void;
  63437. private _copyBonesTransformationMatrices;
  63438. }
  63439. }
  63440. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63441. import { Nullable } from "babylonjs/types";
  63442. import { Scene } from "babylonjs/scene";
  63443. import { ISceneComponent } from "babylonjs/sceneComponent";
  63444. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63445. module "babylonjs/scene" {
  63446. interface Scene {
  63447. /** @hidden (Backing field) */
  63448. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63449. /**
  63450. * Gets or Sets the current geometry buffer associated to the scene.
  63451. */
  63452. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63453. /**
  63454. * Enables a GeometryBufferRender and associates it with the scene
  63455. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63456. * @returns the GeometryBufferRenderer
  63457. */
  63458. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63459. /**
  63460. * Disables the GeometryBufferRender associated with the scene
  63461. */
  63462. disableGeometryBufferRenderer(): void;
  63463. }
  63464. }
  63465. /**
  63466. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63467. * in several rendering techniques.
  63468. */
  63469. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63470. /**
  63471. * The component name helpful to identify the component in the list of scene components.
  63472. */
  63473. readonly name: string;
  63474. /**
  63475. * The scene the component belongs to.
  63476. */
  63477. scene: Scene;
  63478. /**
  63479. * Creates a new instance of the component for the given scene
  63480. * @param scene Defines the scene to register the component in
  63481. */
  63482. constructor(scene: Scene);
  63483. /**
  63484. * Registers the component in a given scene
  63485. */
  63486. register(): void;
  63487. /**
  63488. * Rebuilds the elements related to this component in case of
  63489. * context lost for instance.
  63490. */
  63491. rebuild(): void;
  63492. /**
  63493. * Disposes the component and the associated ressources
  63494. */
  63495. dispose(): void;
  63496. private _gatherRenderTargets;
  63497. }
  63498. }
  63499. declare module "babylonjs/Shaders/motionBlur.fragment" {
  63500. /** @hidden */
  63501. export var motionBlurPixelShader: {
  63502. name: string;
  63503. shader: string;
  63504. };
  63505. }
  63506. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  63507. import { Nullable } from "babylonjs/types";
  63508. import { Camera } from "babylonjs/Cameras/camera";
  63509. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63510. import { Scene } from "babylonjs/scene";
  63511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63512. import "babylonjs/Animations/animatable";
  63513. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63514. import "babylonjs/Shaders/motionBlur.fragment";
  63515. import { Engine } from "babylonjs/Engines/engine";
  63516. /**
  63517. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63518. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63519. * As an example, all you have to do is to create the post-process:
  63520. * var mb = new BABYLON.MotionBlurPostProcess(
  63521. * 'mb', // The name of the effect.
  63522. * scene, // The scene containing the objects to blur according to their velocity.
  63523. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63524. * camera // The camera to apply the render pass to.
  63525. * );
  63526. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63527. */
  63528. export class MotionBlurPostProcess extends PostProcess {
  63529. /**
  63530. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63531. */
  63532. motionStrength: number;
  63533. /**
  63534. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63535. */
  63536. /**
  63537. * Sets the number of iterations to be used for motion blur quality
  63538. */
  63539. motionBlurSamples: number;
  63540. private _motionBlurSamples;
  63541. private _geometryBufferRenderer;
  63542. /**
  63543. * Creates a new instance MotionBlurPostProcess
  63544. * @param name The name of the effect.
  63545. * @param scene The scene containing the objects to blur according to their velocity.
  63546. * @param options The required width/height ratio to downsize to before computing the render pass.
  63547. * @param camera The camera to apply the render pass to.
  63548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63549. * @param engine The engine which the post process will be applied. (default: current engine)
  63550. * @param reusable If the post process can be reused on the same frame. (default: false)
  63551. * @param textureType Type of textures used when performing the post process. (default: 0)
  63552. * @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)
  63553. */
  63554. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63555. /**
  63556. * Excludes the given skinned mesh from computing bones velocities.
  63557. * 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.
  63558. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63559. */
  63560. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63561. /**
  63562. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63563. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63564. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63565. */
  63566. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63567. /**
  63568. * Disposes the post process.
  63569. * @param camera The camera to dispose the post process on.
  63570. */
  63571. dispose(camera?: Camera): void;
  63572. }
  63573. }
  63574. declare module "babylonjs/Shaders/refraction.fragment" {
  63575. /** @hidden */
  63576. export var refractionPixelShader: {
  63577. name: string;
  63578. shader: string;
  63579. };
  63580. }
  63581. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  63582. import { Color3 } from "babylonjs/Maths/math.color";
  63583. import { Camera } from "babylonjs/Cameras/camera";
  63584. import { Texture } from "babylonjs/Materials/Textures/texture";
  63585. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63586. import { Engine } from "babylonjs/Engines/engine";
  63587. import "babylonjs/Shaders/refraction.fragment";
  63588. /**
  63589. * Post process which applies a refractin texture
  63590. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63591. */
  63592. export class RefractionPostProcess extends PostProcess {
  63593. /** the base color of the refraction (used to taint the rendering) */
  63594. color: Color3;
  63595. /** simulated refraction depth */
  63596. depth: number;
  63597. /** the coefficient of the base color (0 to remove base color tainting) */
  63598. colorLevel: number;
  63599. private _refTexture;
  63600. private _ownRefractionTexture;
  63601. /**
  63602. * Gets or sets the refraction texture
  63603. * Please note that you are responsible for disposing the texture if you set it manually
  63604. */
  63605. refractionTexture: Texture;
  63606. /**
  63607. * Initializes the RefractionPostProcess
  63608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63609. * @param name The name of the effect.
  63610. * @param refractionTextureUrl Url of the refraction texture to use
  63611. * @param color the base color of the refraction (used to taint the rendering)
  63612. * @param depth simulated refraction depth
  63613. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63614. * @param camera The camera to apply the render pass to.
  63615. * @param options The required width/height ratio to downsize to before computing the render pass.
  63616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63617. * @param engine The engine which the post process will be applied. (default: current engine)
  63618. * @param reusable If the post process can be reused on the same frame. (default: false)
  63619. */
  63620. constructor(name: string, refractionTextureUrl: string,
  63621. /** the base color of the refraction (used to taint the rendering) */
  63622. color: Color3,
  63623. /** simulated refraction depth */
  63624. depth: number,
  63625. /** the coefficient of the base color (0 to remove base color tainting) */
  63626. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63627. /**
  63628. * Disposes of the post process
  63629. * @param camera Camera to dispose post process on
  63630. */
  63631. dispose(camera: Camera): void;
  63632. }
  63633. }
  63634. declare module "babylonjs/Shaders/sharpen.fragment" {
  63635. /** @hidden */
  63636. export var sharpenPixelShader: {
  63637. name: string;
  63638. shader: string;
  63639. };
  63640. }
  63641. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63642. import { Nullable } from "babylonjs/types";
  63643. import { Camera } from "babylonjs/Cameras/camera";
  63644. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63645. import "babylonjs/Shaders/sharpen.fragment";
  63646. import { Engine } from "babylonjs/Engines/engine";
  63647. /**
  63648. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63649. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63650. */
  63651. export class SharpenPostProcess extends PostProcess {
  63652. /**
  63653. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63654. */
  63655. colorAmount: number;
  63656. /**
  63657. * How much sharpness should be applied (default: 0.3)
  63658. */
  63659. edgeAmount: number;
  63660. /**
  63661. * Creates a new instance ConvolutionPostProcess
  63662. * @param name The name of the effect.
  63663. * @param options The required width/height ratio to downsize to before computing the render pass.
  63664. * @param camera The camera to apply the render pass to.
  63665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63666. * @param engine The engine which the post process will be applied. (default: current engine)
  63667. * @param reusable If the post process can be reused on the same frame. (default: false)
  63668. * @param textureType Type of textures used when performing the post process. (default: 0)
  63669. * @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)
  63670. */
  63671. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63672. }
  63673. }
  63674. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63675. import { Nullable } from "babylonjs/types";
  63676. import { Camera } from "babylonjs/Cameras/camera";
  63677. import { Engine } from "babylonjs/Engines/engine";
  63678. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63679. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63680. /**
  63681. * PostProcessRenderPipeline
  63682. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63683. */
  63684. export class PostProcessRenderPipeline {
  63685. private engine;
  63686. private _renderEffects;
  63687. private _renderEffectsForIsolatedPass;
  63688. /**
  63689. * List of inspectable custom properties (used by the Inspector)
  63690. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63691. */
  63692. inspectableCustomProperties: IInspectable[];
  63693. /**
  63694. * @hidden
  63695. */
  63696. protected _cameras: Camera[];
  63697. /** @hidden */
  63698. _name: string;
  63699. /**
  63700. * Gets pipeline name
  63701. */
  63702. readonly name: string;
  63703. /**
  63704. * Initializes a PostProcessRenderPipeline
  63705. * @param engine engine to add the pipeline to
  63706. * @param name name of the pipeline
  63707. */
  63708. constructor(engine: Engine, name: string);
  63709. /**
  63710. * Gets the class name
  63711. * @returns "PostProcessRenderPipeline"
  63712. */
  63713. getClassName(): string;
  63714. /**
  63715. * If all the render effects in the pipeline are supported
  63716. */
  63717. readonly isSupported: boolean;
  63718. /**
  63719. * Adds an effect to the pipeline
  63720. * @param renderEffect the effect to add
  63721. */
  63722. addEffect(renderEffect: PostProcessRenderEffect): void;
  63723. /** @hidden */
  63724. _rebuild(): void;
  63725. /** @hidden */
  63726. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63727. /** @hidden */
  63728. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63729. /** @hidden */
  63730. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63731. /** @hidden */
  63732. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63733. /** @hidden */
  63734. _attachCameras(cameras: Camera, unique: boolean): void;
  63735. /** @hidden */
  63736. _attachCameras(cameras: Camera[], unique: boolean): void;
  63737. /** @hidden */
  63738. _detachCameras(cameras: Camera): void;
  63739. /** @hidden */
  63740. _detachCameras(cameras: Nullable<Camera[]>): void;
  63741. /** @hidden */
  63742. _update(): void;
  63743. /** @hidden */
  63744. _reset(): void;
  63745. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63746. /**
  63747. * Disposes of the pipeline
  63748. */
  63749. dispose(): void;
  63750. }
  63751. }
  63752. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63753. import { Camera } from "babylonjs/Cameras/camera";
  63754. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63755. /**
  63756. * PostProcessRenderPipelineManager class
  63757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63758. */
  63759. export class PostProcessRenderPipelineManager {
  63760. private _renderPipelines;
  63761. /**
  63762. * Initializes a PostProcessRenderPipelineManager
  63763. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63764. */
  63765. constructor();
  63766. /**
  63767. * Gets the list of supported render pipelines
  63768. */
  63769. readonly supportedPipelines: PostProcessRenderPipeline[];
  63770. /**
  63771. * Adds a pipeline to the manager
  63772. * @param renderPipeline The pipeline to add
  63773. */
  63774. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63775. /**
  63776. * Attaches a camera to the pipeline
  63777. * @param renderPipelineName The name of the pipeline to attach to
  63778. * @param cameras the camera to attach
  63779. * @param unique if the camera can be attached multiple times to the pipeline
  63780. */
  63781. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63782. /**
  63783. * Detaches a camera from the pipeline
  63784. * @param renderPipelineName The name of the pipeline to detach from
  63785. * @param cameras the camera to detach
  63786. */
  63787. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63788. /**
  63789. * Enables an effect by name on a pipeline
  63790. * @param renderPipelineName the name of the pipeline to enable the effect in
  63791. * @param renderEffectName the name of the effect to enable
  63792. * @param cameras the cameras that the effect should be enabled on
  63793. */
  63794. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63795. /**
  63796. * Disables an effect by name on a pipeline
  63797. * @param renderPipelineName the name of the pipeline to disable the effect in
  63798. * @param renderEffectName the name of the effect to disable
  63799. * @param cameras the cameras that the effect should be disabled on
  63800. */
  63801. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63802. /**
  63803. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63804. */
  63805. update(): void;
  63806. /** @hidden */
  63807. _rebuild(): void;
  63808. /**
  63809. * Disposes of the manager and pipelines
  63810. */
  63811. dispose(): void;
  63812. }
  63813. }
  63814. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63815. import { ISceneComponent } from "babylonjs/sceneComponent";
  63816. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63817. import { Scene } from "babylonjs/scene";
  63818. module "babylonjs/scene" {
  63819. interface Scene {
  63820. /** @hidden (Backing field) */
  63821. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63822. /**
  63823. * Gets the postprocess render pipeline manager
  63824. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63825. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63826. */
  63827. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63828. }
  63829. }
  63830. /**
  63831. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63832. */
  63833. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63834. /**
  63835. * The component name helpfull to identify the component in the list of scene components.
  63836. */
  63837. readonly name: string;
  63838. /**
  63839. * The scene the component belongs to.
  63840. */
  63841. scene: Scene;
  63842. /**
  63843. * Creates a new instance of the component for the given scene
  63844. * @param scene Defines the scene to register the component in
  63845. */
  63846. constructor(scene: Scene);
  63847. /**
  63848. * Registers the component in a given scene
  63849. */
  63850. register(): void;
  63851. /**
  63852. * Rebuilds the elements related to this component in case of
  63853. * context lost for instance.
  63854. */
  63855. rebuild(): void;
  63856. /**
  63857. * Disposes the component and the associated ressources
  63858. */
  63859. dispose(): void;
  63860. private _gatherRenderTargets;
  63861. }
  63862. }
  63863. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63864. import { Nullable } from "babylonjs/types";
  63865. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63866. import { Camera } from "babylonjs/Cameras/camera";
  63867. import { IDisposable } from "babylonjs/scene";
  63868. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63869. import { Scene } from "babylonjs/scene";
  63870. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63871. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63872. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63873. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63874. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63875. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63876. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63877. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63878. import { Animation } from "babylonjs/Animations/animation";
  63879. /**
  63880. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63881. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63882. */
  63883. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63884. private _scene;
  63885. private _camerasToBeAttached;
  63886. /**
  63887. * ID of the sharpen post process,
  63888. */
  63889. private readonly SharpenPostProcessId;
  63890. /**
  63891. * @ignore
  63892. * ID of the image processing post process;
  63893. */
  63894. readonly ImageProcessingPostProcessId: string;
  63895. /**
  63896. * @ignore
  63897. * ID of the Fast Approximate Anti-Aliasing post process;
  63898. */
  63899. readonly FxaaPostProcessId: string;
  63900. /**
  63901. * ID of the chromatic aberration post process,
  63902. */
  63903. private readonly ChromaticAberrationPostProcessId;
  63904. /**
  63905. * ID of the grain post process
  63906. */
  63907. private readonly GrainPostProcessId;
  63908. /**
  63909. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63910. */
  63911. sharpen: SharpenPostProcess;
  63912. private _sharpenEffect;
  63913. private bloom;
  63914. /**
  63915. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63916. */
  63917. depthOfField: DepthOfFieldEffect;
  63918. /**
  63919. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63920. */
  63921. fxaa: FxaaPostProcess;
  63922. /**
  63923. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63924. */
  63925. imageProcessing: ImageProcessingPostProcess;
  63926. /**
  63927. * Chromatic aberration post process which will shift rgb colors in the image
  63928. */
  63929. chromaticAberration: ChromaticAberrationPostProcess;
  63930. private _chromaticAberrationEffect;
  63931. /**
  63932. * Grain post process which add noise to the image
  63933. */
  63934. grain: GrainPostProcess;
  63935. private _grainEffect;
  63936. /**
  63937. * Glow post process which adds a glow to emissive areas of the image
  63938. */
  63939. private _glowLayer;
  63940. /**
  63941. * Animations which can be used to tweak settings over a period of time
  63942. */
  63943. animations: Animation[];
  63944. private _imageProcessingConfigurationObserver;
  63945. private _sharpenEnabled;
  63946. private _bloomEnabled;
  63947. private _depthOfFieldEnabled;
  63948. private _depthOfFieldBlurLevel;
  63949. private _fxaaEnabled;
  63950. private _imageProcessingEnabled;
  63951. private _defaultPipelineTextureType;
  63952. private _bloomScale;
  63953. private _chromaticAberrationEnabled;
  63954. private _grainEnabled;
  63955. private _buildAllowed;
  63956. /**
  63957. * Gets active scene
  63958. */
  63959. readonly scene: Scene;
  63960. /**
  63961. * Enable or disable the sharpen process from the pipeline
  63962. */
  63963. sharpenEnabled: boolean;
  63964. private _resizeObserver;
  63965. private _hardwareScaleLevel;
  63966. private _bloomKernel;
  63967. /**
  63968. * Specifies the size of the bloom blur kernel, relative to the final output size
  63969. */
  63970. bloomKernel: number;
  63971. /**
  63972. * Specifies the weight of the bloom in the final rendering
  63973. */
  63974. private _bloomWeight;
  63975. /**
  63976. * Specifies the luma threshold for the area that will be blurred by the bloom
  63977. */
  63978. private _bloomThreshold;
  63979. private _hdr;
  63980. /**
  63981. * The strength of the bloom.
  63982. */
  63983. bloomWeight: number;
  63984. /**
  63985. * The strength of the bloom.
  63986. */
  63987. bloomThreshold: number;
  63988. /**
  63989. * The scale of the bloom, lower value will provide better performance.
  63990. */
  63991. bloomScale: number;
  63992. /**
  63993. * Enable or disable the bloom from the pipeline
  63994. */
  63995. bloomEnabled: boolean;
  63996. private _rebuildBloom;
  63997. /**
  63998. * If the depth of field is enabled.
  63999. */
  64000. depthOfFieldEnabled: boolean;
  64001. /**
  64002. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64003. */
  64004. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64005. /**
  64006. * If the anti aliasing is enabled.
  64007. */
  64008. fxaaEnabled: boolean;
  64009. private _samples;
  64010. /**
  64011. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64012. */
  64013. samples: number;
  64014. /**
  64015. * If image processing is enabled.
  64016. */
  64017. imageProcessingEnabled: boolean;
  64018. /**
  64019. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64020. */
  64021. glowLayerEnabled: boolean;
  64022. /**
  64023. * Gets the glow layer (or null if not defined)
  64024. */
  64025. readonly glowLayer: Nullable<GlowLayer>;
  64026. /**
  64027. * Enable or disable the chromaticAberration process from the pipeline
  64028. */
  64029. chromaticAberrationEnabled: boolean;
  64030. /**
  64031. * Enable or disable the grain process from the pipeline
  64032. */
  64033. grainEnabled: boolean;
  64034. /**
  64035. * @constructor
  64036. * @param name - The rendering pipeline name (default: "")
  64037. * @param hdr - If high dynamic range textures should be used (default: true)
  64038. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64039. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64040. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64041. */
  64042. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64043. /**
  64044. * Get the class name
  64045. * @returns "DefaultRenderingPipeline"
  64046. */
  64047. getClassName(): string;
  64048. /**
  64049. * Force the compilation of the entire pipeline.
  64050. */
  64051. prepare(): void;
  64052. private _hasCleared;
  64053. private _prevPostProcess;
  64054. private _prevPrevPostProcess;
  64055. private _setAutoClearAndTextureSharing;
  64056. private _depthOfFieldSceneObserver;
  64057. private _buildPipeline;
  64058. private _disposePostProcesses;
  64059. /**
  64060. * Adds a camera to the pipeline
  64061. * @param camera the camera to be added
  64062. */
  64063. addCamera(camera: Camera): void;
  64064. /**
  64065. * Removes a camera from the pipeline
  64066. * @param camera the camera to remove
  64067. */
  64068. removeCamera(camera: Camera): void;
  64069. /**
  64070. * Dispose of the pipeline and stop all post processes
  64071. */
  64072. dispose(): void;
  64073. /**
  64074. * Serialize the rendering pipeline (Used when exporting)
  64075. * @returns the serialized object
  64076. */
  64077. serialize(): any;
  64078. /**
  64079. * Parse the serialized pipeline
  64080. * @param source Source pipeline.
  64081. * @param scene The scene to load the pipeline to.
  64082. * @param rootUrl The URL of the serialized pipeline.
  64083. * @returns An instantiated pipeline from the serialized object.
  64084. */
  64085. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64086. }
  64087. }
  64088. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64089. /** @hidden */
  64090. export var lensHighlightsPixelShader: {
  64091. name: string;
  64092. shader: string;
  64093. };
  64094. }
  64095. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64096. /** @hidden */
  64097. export var depthOfFieldPixelShader: {
  64098. name: string;
  64099. shader: string;
  64100. };
  64101. }
  64102. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64103. import { Camera } from "babylonjs/Cameras/camera";
  64104. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64105. import { Scene } from "babylonjs/scene";
  64106. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64107. import "babylonjs/Shaders/chromaticAberration.fragment";
  64108. import "babylonjs/Shaders/lensHighlights.fragment";
  64109. import "babylonjs/Shaders/depthOfField.fragment";
  64110. /**
  64111. * BABYLON.JS Chromatic Aberration GLSL Shader
  64112. * Author: Olivier Guyot
  64113. * Separates very slightly R, G and B colors on the edges of the screen
  64114. * Inspired by Francois Tarlier & Martins Upitis
  64115. */
  64116. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64117. /**
  64118. * @ignore
  64119. * The chromatic aberration PostProcess id in the pipeline
  64120. */
  64121. LensChromaticAberrationEffect: string;
  64122. /**
  64123. * @ignore
  64124. * The highlights enhancing PostProcess id in the pipeline
  64125. */
  64126. HighlightsEnhancingEffect: string;
  64127. /**
  64128. * @ignore
  64129. * The depth-of-field PostProcess id in the pipeline
  64130. */
  64131. LensDepthOfFieldEffect: string;
  64132. private _scene;
  64133. private _depthTexture;
  64134. private _grainTexture;
  64135. private _chromaticAberrationPostProcess;
  64136. private _highlightsPostProcess;
  64137. private _depthOfFieldPostProcess;
  64138. private _edgeBlur;
  64139. private _grainAmount;
  64140. private _chromaticAberration;
  64141. private _distortion;
  64142. private _highlightsGain;
  64143. private _highlightsThreshold;
  64144. private _dofDistance;
  64145. private _dofAperture;
  64146. private _dofDarken;
  64147. private _dofPentagon;
  64148. private _blurNoise;
  64149. /**
  64150. * @constructor
  64151. *
  64152. * Effect parameters are as follow:
  64153. * {
  64154. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64155. * edge_blur: number; // from 0 to x (1 for realism)
  64156. * distortion: number; // from 0 to x (1 for realism)
  64157. * grain_amount: number; // from 0 to 1
  64158. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64159. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64160. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64161. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64162. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64163. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64164. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64165. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64166. * }
  64167. * Note: if an effect parameter is unset, effect is disabled
  64168. *
  64169. * @param name The rendering pipeline name
  64170. * @param parameters - An object containing all parameters (see above)
  64171. * @param scene The scene linked to this pipeline
  64172. * @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)
  64173. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64174. */
  64175. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64176. /**
  64177. * Get the class name
  64178. * @returns "LensRenderingPipeline"
  64179. */
  64180. getClassName(): string;
  64181. /**
  64182. * Gets associated scene
  64183. */
  64184. readonly scene: Scene;
  64185. /**
  64186. * Gets or sets the edge blur
  64187. */
  64188. edgeBlur: number;
  64189. /**
  64190. * Gets or sets the grain amount
  64191. */
  64192. grainAmount: number;
  64193. /**
  64194. * Gets or sets the chromatic aberration amount
  64195. */
  64196. chromaticAberration: number;
  64197. /**
  64198. * Gets or sets the depth of field aperture
  64199. */
  64200. dofAperture: number;
  64201. /**
  64202. * Gets or sets the edge distortion
  64203. */
  64204. edgeDistortion: number;
  64205. /**
  64206. * Gets or sets the depth of field distortion
  64207. */
  64208. dofDistortion: number;
  64209. /**
  64210. * Gets or sets the darken out of focus amount
  64211. */
  64212. darkenOutOfFocus: number;
  64213. /**
  64214. * Gets or sets a boolean indicating if blur noise is enabled
  64215. */
  64216. blurNoise: boolean;
  64217. /**
  64218. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64219. */
  64220. pentagonBokeh: boolean;
  64221. /**
  64222. * Gets or sets the highlight grain amount
  64223. */
  64224. highlightsGain: number;
  64225. /**
  64226. * Gets or sets the highlight threshold
  64227. */
  64228. highlightsThreshold: number;
  64229. /**
  64230. * Sets the amount of blur at the edges
  64231. * @param amount blur amount
  64232. */
  64233. setEdgeBlur(amount: number): void;
  64234. /**
  64235. * Sets edge blur to 0
  64236. */
  64237. disableEdgeBlur(): void;
  64238. /**
  64239. * Sets the amout of grain
  64240. * @param amount Amount of grain
  64241. */
  64242. setGrainAmount(amount: number): void;
  64243. /**
  64244. * Set grain amount to 0
  64245. */
  64246. disableGrain(): void;
  64247. /**
  64248. * Sets the chromatic aberration amount
  64249. * @param amount amount of chromatic aberration
  64250. */
  64251. setChromaticAberration(amount: number): void;
  64252. /**
  64253. * Sets chromatic aberration amount to 0
  64254. */
  64255. disableChromaticAberration(): void;
  64256. /**
  64257. * Sets the EdgeDistortion amount
  64258. * @param amount amount of EdgeDistortion
  64259. */
  64260. setEdgeDistortion(amount: number): void;
  64261. /**
  64262. * Sets edge distortion to 0
  64263. */
  64264. disableEdgeDistortion(): void;
  64265. /**
  64266. * Sets the FocusDistance amount
  64267. * @param amount amount of FocusDistance
  64268. */
  64269. setFocusDistance(amount: number): void;
  64270. /**
  64271. * Disables depth of field
  64272. */
  64273. disableDepthOfField(): void;
  64274. /**
  64275. * Sets the Aperture amount
  64276. * @param amount amount of Aperture
  64277. */
  64278. setAperture(amount: number): void;
  64279. /**
  64280. * Sets the DarkenOutOfFocus amount
  64281. * @param amount amount of DarkenOutOfFocus
  64282. */
  64283. setDarkenOutOfFocus(amount: number): void;
  64284. private _pentagonBokehIsEnabled;
  64285. /**
  64286. * Creates a pentagon bokeh effect
  64287. */
  64288. enablePentagonBokeh(): void;
  64289. /**
  64290. * Disables the pentagon bokeh effect
  64291. */
  64292. disablePentagonBokeh(): void;
  64293. /**
  64294. * Enables noise blur
  64295. */
  64296. enableNoiseBlur(): void;
  64297. /**
  64298. * Disables noise blur
  64299. */
  64300. disableNoiseBlur(): void;
  64301. /**
  64302. * Sets the HighlightsGain amount
  64303. * @param amount amount of HighlightsGain
  64304. */
  64305. setHighlightsGain(amount: number): void;
  64306. /**
  64307. * Sets the HighlightsThreshold amount
  64308. * @param amount amount of HighlightsThreshold
  64309. */
  64310. setHighlightsThreshold(amount: number): void;
  64311. /**
  64312. * Disables highlights
  64313. */
  64314. disableHighlights(): void;
  64315. /**
  64316. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64317. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64318. */
  64319. dispose(disableDepthRender?: boolean): void;
  64320. private _createChromaticAberrationPostProcess;
  64321. private _createHighlightsPostProcess;
  64322. private _createDepthOfFieldPostProcess;
  64323. private _createGrainTexture;
  64324. }
  64325. }
  64326. declare module "babylonjs/Shaders/ssao2.fragment" {
  64327. /** @hidden */
  64328. export var ssao2PixelShader: {
  64329. name: string;
  64330. shader: string;
  64331. };
  64332. }
  64333. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64334. /** @hidden */
  64335. export var ssaoCombinePixelShader: {
  64336. name: string;
  64337. shader: string;
  64338. };
  64339. }
  64340. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64341. import { Camera } from "babylonjs/Cameras/camera";
  64342. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64343. import { Scene } from "babylonjs/scene";
  64344. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64345. import "babylonjs/Shaders/ssao2.fragment";
  64346. import "babylonjs/Shaders/ssaoCombine.fragment";
  64347. /**
  64348. * Render pipeline to produce ssao effect
  64349. */
  64350. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64351. /**
  64352. * @ignore
  64353. * The PassPostProcess id in the pipeline that contains the original scene color
  64354. */
  64355. SSAOOriginalSceneColorEffect: string;
  64356. /**
  64357. * @ignore
  64358. * The SSAO PostProcess id in the pipeline
  64359. */
  64360. SSAORenderEffect: string;
  64361. /**
  64362. * @ignore
  64363. * The horizontal blur PostProcess id in the pipeline
  64364. */
  64365. SSAOBlurHRenderEffect: string;
  64366. /**
  64367. * @ignore
  64368. * The vertical blur PostProcess id in the pipeline
  64369. */
  64370. SSAOBlurVRenderEffect: string;
  64371. /**
  64372. * @ignore
  64373. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64374. */
  64375. SSAOCombineRenderEffect: string;
  64376. /**
  64377. * The output strength of the SSAO post-process. Default value is 1.0.
  64378. */
  64379. totalStrength: number;
  64380. /**
  64381. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64382. */
  64383. maxZ: number;
  64384. /**
  64385. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64386. */
  64387. minZAspect: number;
  64388. private _samples;
  64389. /**
  64390. * Number of samples used for the SSAO calculations. Default value is 8
  64391. */
  64392. samples: number;
  64393. private _textureSamples;
  64394. /**
  64395. * Number of samples to use for antialiasing
  64396. */
  64397. textureSamples: number;
  64398. /**
  64399. * Ratio object used for SSAO ratio and blur ratio
  64400. */
  64401. private _ratio;
  64402. /**
  64403. * Dynamically generated sphere sampler.
  64404. */
  64405. private _sampleSphere;
  64406. /**
  64407. * Blur filter offsets
  64408. */
  64409. private _samplerOffsets;
  64410. private _expensiveBlur;
  64411. /**
  64412. * If bilateral blur should be used
  64413. */
  64414. expensiveBlur: boolean;
  64415. /**
  64416. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64417. */
  64418. radius: number;
  64419. /**
  64420. * The base color of the SSAO post-process
  64421. * The final result is "base + ssao" between [0, 1]
  64422. */
  64423. base: number;
  64424. /**
  64425. * Support test.
  64426. */
  64427. static readonly IsSupported: boolean;
  64428. private _scene;
  64429. private _depthTexture;
  64430. private _normalTexture;
  64431. private _randomTexture;
  64432. private _originalColorPostProcess;
  64433. private _ssaoPostProcess;
  64434. private _blurHPostProcess;
  64435. private _blurVPostProcess;
  64436. private _ssaoCombinePostProcess;
  64437. private _firstUpdate;
  64438. /**
  64439. * Gets active scene
  64440. */
  64441. readonly scene: Scene;
  64442. /**
  64443. * @constructor
  64444. * @param name The rendering pipeline name
  64445. * @param scene The scene linked to this pipeline
  64446. * @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 }
  64447. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64448. */
  64449. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64450. /**
  64451. * Get the class name
  64452. * @returns "SSAO2RenderingPipeline"
  64453. */
  64454. getClassName(): string;
  64455. /**
  64456. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64457. */
  64458. dispose(disableGeometryBufferRenderer?: boolean): void;
  64459. private _createBlurPostProcess;
  64460. /** @hidden */
  64461. _rebuild(): void;
  64462. private _bits;
  64463. private _radicalInverse_VdC;
  64464. private _hammersley;
  64465. private _hemisphereSample_uniform;
  64466. private _generateHemisphere;
  64467. private _createSSAOPostProcess;
  64468. private _createSSAOCombinePostProcess;
  64469. private _createRandomTexture;
  64470. /**
  64471. * Serialize the rendering pipeline (Used when exporting)
  64472. * @returns the serialized object
  64473. */
  64474. serialize(): any;
  64475. /**
  64476. * Parse the serialized pipeline
  64477. * @param source Source pipeline.
  64478. * @param scene The scene to load the pipeline to.
  64479. * @param rootUrl The URL of the serialized pipeline.
  64480. * @returns An instantiated pipeline from the serialized object.
  64481. */
  64482. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  64483. }
  64484. }
  64485. declare module "babylonjs/Shaders/ssao.fragment" {
  64486. /** @hidden */
  64487. export var ssaoPixelShader: {
  64488. name: string;
  64489. shader: string;
  64490. };
  64491. }
  64492. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  64493. import { Camera } from "babylonjs/Cameras/camera";
  64494. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64495. import { Scene } from "babylonjs/scene";
  64496. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64497. import "babylonjs/Shaders/ssao.fragment";
  64498. import "babylonjs/Shaders/ssaoCombine.fragment";
  64499. /**
  64500. * Render pipeline to produce ssao effect
  64501. */
  64502. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  64503. /**
  64504. * @ignore
  64505. * The PassPostProcess id in the pipeline that contains the original scene color
  64506. */
  64507. SSAOOriginalSceneColorEffect: string;
  64508. /**
  64509. * @ignore
  64510. * The SSAO PostProcess id in the pipeline
  64511. */
  64512. SSAORenderEffect: string;
  64513. /**
  64514. * @ignore
  64515. * The horizontal blur PostProcess id in the pipeline
  64516. */
  64517. SSAOBlurHRenderEffect: string;
  64518. /**
  64519. * @ignore
  64520. * The vertical blur PostProcess id in the pipeline
  64521. */
  64522. SSAOBlurVRenderEffect: string;
  64523. /**
  64524. * @ignore
  64525. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64526. */
  64527. SSAOCombineRenderEffect: string;
  64528. /**
  64529. * The output strength of the SSAO post-process. Default value is 1.0.
  64530. */
  64531. totalStrength: number;
  64532. /**
  64533. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64534. */
  64535. radius: number;
  64536. /**
  64537. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64538. * Must not be equal to fallOff and superior to fallOff.
  64539. * Default value is 0.0075
  64540. */
  64541. area: number;
  64542. /**
  64543. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64544. * Must not be equal to area and inferior to area.
  64545. * Default value is 0.000001
  64546. */
  64547. fallOff: number;
  64548. /**
  64549. * The base color of the SSAO post-process
  64550. * The final result is "base + ssao" between [0, 1]
  64551. */
  64552. base: number;
  64553. private _scene;
  64554. private _depthTexture;
  64555. private _randomTexture;
  64556. private _originalColorPostProcess;
  64557. private _ssaoPostProcess;
  64558. private _blurHPostProcess;
  64559. private _blurVPostProcess;
  64560. private _ssaoCombinePostProcess;
  64561. private _firstUpdate;
  64562. /**
  64563. * Gets active scene
  64564. */
  64565. readonly scene: Scene;
  64566. /**
  64567. * @constructor
  64568. * @param name - The rendering pipeline name
  64569. * @param scene - The scene linked to this pipeline
  64570. * @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 }
  64571. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64572. */
  64573. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64574. /**
  64575. * Get the class name
  64576. * @returns "SSAORenderingPipeline"
  64577. */
  64578. getClassName(): string;
  64579. /**
  64580. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64581. */
  64582. dispose(disableDepthRender?: boolean): void;
  64583. private _createBlurPostProcess;
  64584. /** @hidden */
  64585. _rebuild(): void;
  64586. private _createSSAOPostProcess;
  64587. private _createSSAOCombinePostProcess;
  64588. private _createRandomTexture;
  64589. }
  64590. }
  64591. declare module "babylonjs/Shaders/standard.fragment" {
  64592. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64593. /** @hidden */
  64594. export var standardPixelShader: {
  64595. name: string;
  64596. shader: string;
  64597. };
  64598. }
  64599. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64600. import { Nullable } from "babylonjs/types";
  64601. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64602. import { Camera } from "babylonjs/Cameras/camera";
  64603. import { Texture } from "babylonjs/Materials/Textures/texture";
  64604. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64605. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64606. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64607. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64608. import { IDisposable } from "babylonjs/scene";
  64609. import { SpotLight } from "babylonjs/Lights/spotLight";
  64610. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64611. import { Scene } from "babylonjs/scene";
  64612. import { Animation } from "babylonjs/Animations/animation";
  64613. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64614. import "babylonjs/Shaders/standard.fragment";
  64615. /**
  64616. * Standard rendering pipeline
  64617. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64618. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64619. */
  64620. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64621. /**
  64622. * Public members
  64623. */
  64624. /**
  64625. * Post-process which contains the original scene color before the pipeline applies all the effects
  64626. */
  64627. originalPostProcess: Nullable<PostProcess>;
  64628. /**
  64629. * Post-process used to down scale an image x4
  64630. */
  64631. downSampleX4PostProcess: Nullable<PostProcess>;
  64632. /**
  64633. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64634. */
  64635. brightPassPostProcess: Nullable<PostProcess>;
  64636. /**
  64637. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64638. */
  64639. blurHPostProcesses: PostProcess[];
  64640. /**
  64641. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64642. */
  64643. blurVPostProcesses: PostProcess[];
  64644. /**
  64645. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64646. */
  64647. textureAdderPostProcess: Nullable<PostProcess>;
  64648. /**
  64649. * Post-process used to create volumetric lighting effect
  64650. */
  64651. volumetricLightPostProcess: Nullable<PostProcess>;
  64652. /**
  64653. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64654. */
  64655. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64656. /**
  64657. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64658. */
  64659. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64660. /**
  64661. * Post-process used to merge the volumetric light effect and the real scene color
  64662. */
  64663. volumetricLightMergePostProces: Nullable<PostProcess>;
  64664. /**
  64665. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64666. */
  64667. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64668. /**
  64669. * Base post-process used to calculate the average luminance of the final image for HDR
  64670. */
  64671. luminancePostProcess: Nullable<PostProcess>;
  64672. /**
  64673. * Post-processes used to create down sample post-processes in order to get
  64674. * the average luminance of the final image for HDR
  64675. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64676. */
  64677. luminanceDownSamplePostProcesses: PostProcess[];
  64678. /**
  64679. * Post-process used to create a HDR effect (light adaptation)
  64680. */
  64681. hdrPostProcess: Nullable<PostProcess>;
  64682. /**
  64683. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64684. */
  64685. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64686. /**
  64687. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64688. */
  64689. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64690. /**
  64691. * Post-process used to merge the final HDR post-process and the real scene color
  64692. */
  64693. hdrFinalPostProcess: Nullable<PostProcess>;
  64694. /**
  64695. * Post-process used to create a lens flare effect
  64696. */
  64697. lensFlarePostProcess: Nullable<PostProcess>;
  64698. /**
  64699. * Post-process that merges the result of the lens flare post-process and the real scene color
  64700. */
  64701. lensFlareComposePostProcess: Nullable<PostProcess>;
  64702. /**
  64703. * Post-process used to create a motion blur effect
  64704. */
  64705. motionBlurPostProcess: Nullable<PostProcess>;
  64706. /**
  64707. * Post-process used to create a depth of field effect
  64708. */
  64709. depthOfFieldPostProcess: Nullable<PostProcess>;
  64710. /**
  64711. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64712. */
  64713. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64714. /**
  64715. * Represents the brightness threshold in order to configure the illuminated surfaces
  64716. */
  64717. brightThreshold: number;
  64718. /**
  64719. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64720. */
  64721. blurWidth: number;
  64722. /**
  64723. * Sets if the blur for highlighted surfaces must be only horizontal
  64724. */
  64725. horizontalBlur: boolean;
  64726. /**
  64727. * Gets the overall exposure used by the pipeline
  64728. */
  64729. /**
  64730. * Sets the overall exposure used by the pipeline
  64731. */
  64732. exposure: number;
  64733. /**
  64734. * Texture used typically to simulate "dirty" on camera lens
  64735. */
  64736. lensTexture: Nullable<Texture>;
  64737. /**
  64738. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64739. */
  64740. volumetricLightCoefficient: number;
  64741. /**
  64742. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64743. */
  64744. volumetricLightPower: number;
  64745. /**
  64746. * Used the set the blur intensity to smooth the volumetric lights
  64747. */
  64748. volumetricLightBlurScale: number;
  64749. /**
  64750. * Light (spot or directional) used to generate the volumetric lights rays
  64751. * The source light must have a shadow generate so the pipeline can get its
  64752. * depth map
  64753. */
  64754. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64755. /**
  64756. * For eye adaptation, represents the minimum luminance the eye can see
  64757. */
  64758. hdrMinimumLuminance: number;
  64759. /**
  64760. * For eye adaptation, represents the decrease luminance speed
  64761. */
  64762. hdrDecreaseRate: number;
  64763. /**
  64764. * For eye adaptation, represents the increase luminance speed
  64765. */
  64766. hdrIncreaseRate: number;
  64767. /**
  64768. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64769. */
  64770. /**
  64771. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64772. */
  64773. hdrAutoExposure: boolean;
  64774. /**
  64775. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64776. */
  64777. lensColorTexture: Nullable<Texture>;
  64778. /**
  64779. * The overall strengh for the lens flare effect
  64780. */
  64781. lensFlareStrength: number;
  64782. /**
  64783. * Dispersion coefficient for lens flare ghosts
  64784. */
  64785. lensFlareGhostDispersal: number;
  64786. /**
  64787. * Main lens flare halo width
  64788. */
  64789. lensFlareHaloWidth: number;
  64790. /**
  64791. * Based on the lens distortion effect, defines how much the lens flare result
  64792. * is distorted
  64793. */
  64794. lensFlareDistortionStrength: number;
  64795. /**
  64796. * Configures the blur intensity used for for lens flare (halo)
  64797. */
  64798. lensFlareBlurWidth: number;
  64799. /**
  64800. * Lens star texture must be used to simulate rays on the flares and is available
  64801. * in the documentation
  64802. */
  64803. lensStarTexture: Nullable<Texture>;
  64804. /**
  64805. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64806. * flare effect by taking account of the dirt texture
  64807. */
  64808. lensFlareDirtTexture: Nullable<Texture>;
  64809. /**
  64810. * Represents the focal length for the depth of field effect
  64811. */
  64812. depthOfFieldDistance: number;
  64813. /**
  64814. * Represents the blur intensity for the blurred part of the depth of field effect
  64815. */
  64816. depthOfFieldBlurWidth: number;
  64817. /**
  64818. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64819. */
  64820. /**
  64821. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64822. */
  64823. motionStrength: number;
  64824. /**
  64825. * Gets wether or not the motion blur post-process is object based or screen based.
  64826. */
  64827. /**
  64828. * Sets wether or not the motion blur post-process should be object based or screen based
  64829. */
  64830. objectBasedMotionBlur: boolean;
  64831. /**
  64832. * List of animations for the pipeline (IAnimatable implementation)
  64833. */
  64834. animations: Animation[];
  64835. /**
  64836. * Private members
  64837. */
  64838. private _scene;
  64839. private _currentDepthOfFieldSource;
  64840. private _basePostProcess;
  64841. private _fixedExposure;
  64842. private _currentExposure;
  64843. private _hdrAutoExposure;
  64844. private _hdrCurrentLuminance;
  64845. private _motionStrength;
  64846. private _isObjectBasedMotionBlur;
  64847. private _floatTextureType;
  64848. private _camerasToBeAttached;
  64849. private _ratio;
  64850. private _bloomEnabled;
  64851. private _depthOfFieldEnabled;
  64852. private _vlsEnabled;
  64853. private _lensFlareEnabled;
  64854. private _hdrEnabled;
  64855. private _motionBlurEnabled;
  64856. private _fxaaEnabled;
  64857. private _motionBlurSamples;
  64858. private _volumetricLightStepsCount;
  64859. private _samples;
  64860. /**
  64861. * @ignore
  64862. * Specifies if the bloom pipeline is enabled
  64863. */
  64864. BloomEnabled: boolean;
  64865. /**
  64866. * @ignore
  64867. * Specifies if the depth of field pipeline is enabed
  64868. */
  64869. DepthOfFieldEnabled: boolean;
  64870. /**
  64871. * @ignore
  64872. * Specifies if the lens flare pipeline is enabed
  64873. */
  64874. LensFlareEnabled: boolean;
  64875. /**
  64876. * @ignore
  64877. * Specifies if the HDR pipeline is enabled
  64878. */
  64879. HDREnabled: boolean;
  64880. /**
  64881. * @ignore
  64882. * Specifies if the volumetric lights scattering effect is enabled
  64883. */
  64884. VLSEnabled: boolean;
  64885. /**
  64886. * @ignore
  64887. * Specifies if the motion blur effect is enabled
  64888. */
  64889. MotionBlurEnabled: boolean;
  64890. /**
  64891. * Specifies if anti-aliasing is enabled
  64892. */
  64893. fxaaEnabled: boolean;
  64894. /**
  64895. * Specifies the number of steps used to calculate the volumetric lights
  64896. * Typically in interval [50, 200]
  64897. */
  64898. volumetricLightStepsCount: number;
  64899. /**
  64900. * Specifies the number of samples used for the motion blur effect
  64901. * Typically in interval [16, 64]
  64902. */
  64903. motionBlurSamples: number;
  64904. /**
  64905. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64906. */
  64907. samples: number;
  64908. /**
  64909. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64910. * @constructor
  64911. * @param name The rendering pipeline name
  64912. * @param scene The scene linked to this pipeline
  64913. * @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)
  64914. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64915. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64916. */
  64917. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64918. private _buildPipeline;
  64919. private _createDownSampleX4PostProcess;
  64920. private _createBrightPassPostProcess;
  64921. private _createBlurPostProcesses;
  64922. private _createTextureAdderPostProcess;
  64923. private _createVolumetricLightPostProcess;
  64924. private _createLuminancePostProcesses;
  64925. private _createHdrPostProcess;
  64926. private _createLensFlarePostProcess;
  64927. private _createDepthOfFieldPostProcess;
  64928. private _createMotionBlurPostProcess;
  64929. private _getDepthTexture;
  64930. private _disposePostProcesses;
  64931. /**
  64932. * Dispose of the pipeline and stop all post processes
  64933. */
  64934. dispose(): void;
  64935. /**
  64936. * Serialize the rendering pipeline (Used when exporting)
  64937. * @returns the serialized object
  64938. */
  64939. serialize(): any;
  64940. /**
  64941. * Parse the serialized pipeline
  64942. * @param source Source pipeline.
  64943. * @param scene The scene to load the pipeline to.
  64944. * @param rootUrl The URL of the serialized pipeline.
  64945. * @returns An instantiated pipeline from the serialized object.
  64946. */
  64947. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64948. /**
  64949. * Luminance steps
  64950. */
  64951. static LuminanceSteps: number;
  64952. }
  64953. }
  64954. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64955. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64956. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64957. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64958. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64959. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64960. }
  64961. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64962. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64963. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64964. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64965. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64966. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64967. }
  64968. declare module "babylonjs/Shaders/tonemap.fragment" {
  64969. /** @hidden */
  64970. export var tonemapPixelShader: {
  64971. name: string;
  64972. shader: string;
  64973. };
  64974. }
  64975. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64976. import { Camera } from "babylonjs/Cameras/camera";
  64977. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64978. import "babylonjs/Shaders/tonemap.fragment";
  64979. import { Engine } from "babylonjs/Engines/engine";
  64980. /** Defines operator used for tonemapping */
  64981. export enum TonemappingOperator {
  64982. /** Hable */
  64983. Hable = 0,
  64984. /** Reinhard */
  64985. Reinhard = 1,
  64986. /** HejiDawson */
  64987. HejiDawson = 2,
  64988. /** Photographic */
  64989. Photographic = 3
  64990. }
  64991. /**
  64992. * Defines a post process to apply tone mapping
  64993. */
  64994. export class TonemapPostProcess extends PostProcess {
  64995. private _operator;
  64996. /** Defines the required exposure adjustement */
  64997. exposureAdjustment: number;
  64998. /**
  64999. * Creates a new TonemapPostProcess
  65000. * @param name defines the name of the postprocess
  65001. * @param _operator defines the operator to use
  65002. * @param exposureAdjustment defines the required exposure adjustement
  65003. * @param camera defines the camera to use (can be null)
  65004. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65005. * @param engine defines the hosting engine (can be ignore if camera is set)
  65006. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65007. */
  65008. constructor(name: string, _operator: TonemappingOperator,
  65009. /** Defines the required exposure adjustement */
  65010. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65011. }
  65012. }
  65013. declare module "babylonjs/Shaders/depth.vertex" {
  65014. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65015. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65016. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65017. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65018. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65019. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65020. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65021. /** @hidden */
  65022. export var depthVertexShader: {
  65023. name: string;
  65024. shader: string;
  65025. };
  65026. }
  65027. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65028. /** @hidden */
  65029. export var volumetricLightScatteringPixelShader: {
  65030. name: string;
  65031. shader: string;
  65032. };
  65033. }
  65034. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65035. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65036. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65037. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65038. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65039. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65040. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65041. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65042. /** @hidden */
  65043. export var volumetricLightScatteringPassVertexShader: {
  65044. name: string;
  65045. shader: string;
  65046. };
  65047. }
  65048. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65049. /** @hidden */
  65050. export var volumetricLightScatteringPassPixelShader: {
  65051. name: string;
  65052. shader: string;
  65053. };
  65054. }
  65055. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65056. import { Vector3 } from "babylonjs/Maths/math.vector";
  65057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65058. import { Mesh } from "babylonjs/Meshes/mesh";
  65059. import { Camera } from "babylonjs/Cameras/camera";
  65060. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65061. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65062. import { Scene } from "babylonjs/scene";
  65063. import "babylonjs/Meshes/Builders/planeBuilder";
  65064. import "babylonjs/Shaders/depth.vertex";
  65065. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65066. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65067. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65068. import { Engine } from "babylonjs/Engines/engine";
  65069. /**
  65070. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65071. */
  65072. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65073. private _volumetricLightScatteringPass;
  65074. private _volumetricLightScatteringRTT;
  65075. private _viewPort;
  65076. private _screenCoordinates;
  65077. private _cachedDefines;
  65078. /**
  65079. * If not undefined, the mesh position is computed from the attached node position
  65080. */
  65081. attachedNode: {
  65082. position: Vector3;
  65083. };
  65084. /**
  65085. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65086. */
  65087. customMeshPosition: Vector3;
  65088. /**
  65089. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65090. */
  65091. useCustomMeshPosition: boolean;
  65092. /**
  65093. * If the post-process should inverse the light scattering direction
  65094. */
  65095. invert: boolean;
  65096. /**
  65097. * The internal mesh used by the post-process
  65098. */
  65099. mesh: Mesh;
  65100. /**
  65101. * @hidden
  65102. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65103. */
  65104. useDiffuseColor: boolean;
  65105. /**
  65106. * Array containing the excluded meshes not rendered in the internal pass
  65107. */
  65108. excludedMeshes: AbstractMesh[];
  65109. /**
  65110. * Controls the overall intensity of the post-process
  65111. */
  65112. exposure: number;
  65113. /**
  65114. * Dissipates each sample's contribution in range [0, 1]
  65115. */
  65116. decay: number;
  65117. /**
  65118. * Controls the overall intensity of each sample
  65119. */
  65120. weight: number;
  65121. /**
  65122. * Controls the density of each sample
  65123. */
  65124. density: number;
  65125. /**
  65126. * @constructor
  65127. * @param name The post-process name
  65128. * @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)
  65129. * @param camera The camera that the post-process will be attached to
  65130. * @param mesh The mesh used to create the light scattering
  65131. * @param samples The post-process quality, default 100
  65132. * @param samplingModeThe post-process filtering mode
  65133. * @param engine The babylon engine
  65134. * @param reusable If the post-process is reusable
  65135. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65136. */
  65137. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65138. /**
  65139. * Returns the string "VolumetricLightScatteringPostProcess"
  65140. * @returns "VolumetricLightScatteringPostProcess"
  65141. */
  65142. getClassName(): string;
  65143. private _isReady;
  65144. /**
  65145. * Sets the new light position for light scattering effect
  65146. * @param position The new custom light position
  65147. */
  65148. setCustomMeshPosition(position: Vector3): void;
  65149. /**
  65150. * Returns the light position for light scattering effect
  65151. * @return Vector3 The custom light position
  65152. */
  65153. getCustomMeshPosition(): Vector3;
  65154. /**
  65155. * Disposes the internal assets and detaches the post-process from the camera
  65156. */
  65157. dispose(camera: Camera): void;
  65158. /**
  65159. * Returns the render target texture used by the post-process
  65160. * @return the render target texture used by the post-process
  65161. */
  65162. getPass(): RenderTargetTexture;
  65163. private _meshExcluded;
  65164. private _createPass;
  65165. private _updateMeshScreenCoordinates;
  65166. /**
  65167. * Creates a default mesh for the Volumeric Light Scattering post-process
  65168. * @param name The mesh name
  65169. * @param scene The scene where to create the mesh
  65170. * @return the default mesh
  65171. */
  65172. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65173. }
  65174. }
  65175. declare module "babylonjs/PostProcesses/index" {
  65176. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65177. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65178. export * from "babylonjs/PostProcesses/bloomEffect";
  65179. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65180. export * from "babylonjs/PostProcesses/blurPostProcess";
  65181. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65182. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65183. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65184. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65185. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65186. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65187. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65188. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65189. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65190. export * from "babylonjs/PostProcesses/filterPostProcess";
  65191. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65192. export * from "babylonjs/PostProcesses/grainPostProcess";
  65193. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65194. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65195. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65196. export * from "babylonjs/PostProcesses/passPostProcess";
  65197. export * from "babylonjs/PostProcesses/postProcess";
  65198. export * from "babylonjs/PostProcesses/postProcessManager";
  65199. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65200. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65201. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65202. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65203. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65204. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65205. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65206. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65207. }
  65208. declare module "babylonjs/Probes/index" {
  65209. export * from "babylonjs/Probes/reflectionProbe";
  65210. }
  65211. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65212. import { Scene } from "babylonjs/scene";
  65213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65214. import { SmartArray } from "babylonjs/Misc/smartArray";
  65215. import { ISceneComponent } from "babylonjs/sceneComponent";
  65216. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65217. import "babylonjs/Meshes/Builders/boxBuilder";
  65218. import "babylonjs/Shaders/color.fragment";
  65219. import "babylonjs/Shaders/color.vertex";
  65220. import { Color3 } from "babylonjs/Maths/math.color";
  65221. module "babylonjs/scene" {
  65222. interface Scene {
  65223. /** @hidden (Backing field) */
  65224. _boundingBoxRenderer: BoundingBoxRenderer;
  65225. /** @hidden (Backing field) */
  65226. _forceShowBoundingBoxes: boolean;
  65227. /**
  65228. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65229. */
  65230. forceShowBoundingBoxes: boolean;
  65231. /**
  65232. * Gets the bounding box renderer associated with the scene
  65233. * @returns a BoundingBoxRenderer
  65234. */
  65235. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65236. }
  65237. }
  65238. module "babylonjs/Meshes/abstractMesh" {
  65239. interface AbstractMesh {
  65240. /** @hidden (Backing field) */
  65241. _showBoundingBox: boolean;
  65242. /**
  65243. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65244. */
  65245. showBoundingBox: boolean;
  65246. }
  65247. }
  65248. /**
  65249. * Component responsible of rendering the bounding box of the meshes in a scene.
  65250. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65251. */
  65252. export class BoundingBoxRenderer implements ISceneComponent {
  65253. /**
  65254. * The component name helpfull to identify the component in the list of scene components.
  65255. */
  65256. readonly name: string;
  65257. /**
  65258. * The scene the component belongs to.
  65259. */
  65260. scene: Scene;
  65261. /**
  65262. * Color of the bounding box lines placed in front of an object
  65263. */
  65264. frontColor: Color3;
  65265. /**
  65266. * Color of the bounding box lines placed behind an object
  65267. */
  65268. backColor: Color3;
  65269. /**
  65270. * Defines if the renderer should show the back lines or not
  65271. */
  65272. showBackLines: boolean;
  65273. /**
  65274. * @hidden
  65275. */
  65276. renderList: SmartArray<BoundingBox>;
  65277. private _colorShader;
  65278. private _vertexBuffers;
  65279. private _indexBuffer;
  65280. private _fillIndexBuffer;
  65281. private _fillIndexData;
  65282. /**
  65283. * Instantiates a new bounding box renderer in a scene.
  65284. * @param scene the scene the renderer renders in
  65285. */
  65286. constructor(scene: Scene);
  65287. /**
  65288. * Registers the component in a given scene
  65289. */
  65290. register(): void;
  65291. private _evaluateSubMesh;
  65292. private _activeMesh;
  65293. private _prepareRessources;
  65294. private _createIndexBuffer;
  65295. /**
  65296. * Rebuilds the elements related to this component in case of
  65297. * context lost for instance.
  65298. */
  65299. rebuild(): void;
  65300. /**
  65301. * @hidden
  65302. */
  65303. reset(): void;
  65304. /**
  65305. * Render the bounding boxes of a specific rendering group
  65306. * @param renderingGroupId defines the rendering group to render
  65307. */
  65308. render(renderingGroupId: number): void;
  65309. /**
  65310. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65311. * @param mesh Define the mesh to render the occlusion bounding box for
  65312. */
  65313. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65314. /**
  65315. * Dispose and release the resources attached to this renderer.
  65316. */
  65317. dispose(): void;
  65318. }
  65319. }
  65320. declare module "babylonjs/Shaders/depth.fragment" {
  65321. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65322. /** @hidden */
  65323. export var depthPixelShader: {
  65324. name: string;
  65325. shader: string;
  65326. };
  65327. }
  65328. declare module "babylonjs/Rendering/depthRenderer" {
  65329. import { Nullable } from "babylonjs/types";
  65330. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65331. import { Scene } from "babylonjs/scene";
  65332. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65333. import { Camera } from "babylonjs/Cameras/camera";
  65334. import "babylonjs/Shaders/depth.fragment";
  65335. import "babylonjs/Shaders/depth.vertex";
  65336. /**
  65337. * This represents a depth renderer in Babylon.
  65338. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65339. */
  65340. export class DepthRenderer {
  65341. private _scene;
  65342. private _depthMap;
  65343. private _effect;
  65344. private readonly _storeNonLinearDepth;
  65345. private readonly _clearColor;
  65346. /** Get if the depth renderer is using packed depth or not */
  65347. readonly isPacked: boolean;
  65348. private _cachedDefines;
  65349. private _camera;
  65350. /**
  65351. * Specifiess that the depth renderer will only be used within
  65352. * the camera it is created for.
  65353. * This can help forcing its rendering during the camera processing.
  65354. */
  65355. useOnlyInActiveCamera: boolean;
  65356. /** @hidden */
  65357. static _SceneComponentInitialization: (scene: Scene) => void;
  65358. /**
  65359. * Instantiates a depth renderer
  65360. * @param scene The scene the renderer belongs to
  65361. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65362. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65363. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65364. */
  65365. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65366. /**
  65367. * Creates the depth rendering effect and checks if the effect is ready.
  65368. * @param subMesh The submesh to be used to render the depth map of
  65369. * @param useInstances If multiple world instances should be used
  65370. * @returns if the depth renderer is ready to render the depth map
  65371. */
  65372. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65373. /**
  65374. * Gets the texture which the depth map will be written to.
  65375. * @returns The depth map texture
  65376. */
  65377. getDepthMap(): RenderTargetTexture;
  65378. /**
  65379. * Disposes of the depth renderer.
  65380. */
  65381. dispose(): void;
  65382. }
  65383. }
  65384. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65385. import { Nullable } from "babylonjs/types";
  65386. import { Scene } from "babylonjs/scene";
  65387. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65388. import { Camera } from "babylonjs/Cameras/camera";
  65389. import { ISceneComponent } from "babylonjs/sceneComponent";
  65390. module "babylonjs/scene" {
  65391. interface Scene {
  65392. /** @hidden (Backing field) */
  65393. _depthRenderer: {
  65394. [id: string]: DepthRenderer;
  65395. };
  65396. /**
  65397. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65398. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65399. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65400. * @returns the created depth renderer
  65401. */
  65402. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65403. /**
  65404. * Disables a depth renderer for a given camera
  65405. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65406. */
  65407. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65408. }
  65409. }
  65410. /**
  65411. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65412. * in several rendering techniques.
  65413. */
  65414. export class DepthRendererSceneComponent implements ISceneComponent {
  65415. /**
  65416. * The component name helpfull to identify the component in the list of scene components.
  65417. */
  65418. readonly name: string;
  65419. /**
  65420. * The scene the component belongs to.
  65421. */
  65422. scene: Scene;
  65423. /**
  65424. * Creates a new instance of the component for the given scene
  65425. * @param scene Defines the scene to register the component in
  65426. */
  65427. constructor(scene: Scene);
  65428. /**
  65429. * Registers the component in a given scene
  65430. */
  65431. register(): void;
  65432. /**
  65433. * Rebuilds the elements related to this component in case of
  65434. * context lost for instance.
  65435. */
  65436. rebuild(): void;
  65437. /**
  65438. * Disposes the component and the associated ressources
  65439. */
  65440. dispose(): void;
  65441. private _gatherRenderTargets;
  65442. private _gatherActiveCameraRenderTargets;
  65443. }
  65444. }
  65445. declare module "babylonjs/Shaders/outline.fragment" {
  65446. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65447. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65448. /** @hidden */
  65449. export var outlinePixelShader: {
  65450. name: string;
  65451. shader: string;
  65452. };
  65453. }
  65454. declare module "babylonjs/Shaders/outline.vertex" {
  65455. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65456. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65458. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65459. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65461. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65462. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65463. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65464. /** @hidden */
  65465. export var outlineVertexShader: {
  65466. name: string;
  65467. shader: string;
  65468. };
  65469. }
  65470. declare module "babylonjs/Rendering/outlineRenderer" {
  65471. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65472. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  65473. import { Scene } from "babylonjs/scene";
  65474. import { ISceneComponent } from "babylonjs/sceneComponent";
  65475. import "babylonjs/Shaders/outline.fragment";
  65476. import "babylonjs/Shaders/outline.vertex";
  65477. module "babylonjs/scene" {
  65478. interface Scene {
  65479. /** @hidden */
  65480. _outlineRenderer: OutlineRenderer;
  65481. /**
  65482. * Gets the outline renderer associated with the scene
  65483. * @returns a OutlineRenderer
  65484. */
  65485. getOutlineRenderer(): OutlineRenderer;
  65486. }
  65487. }
  65488. module "babylonjs/Meshes/abstractMesh" {
  65489. interface AbstractMesh {
  65490. /** @hidden (Backing field) */
  65491. _renderOutline: boolean;
  65492. /**
  65493. * Gets or sets a boolean indicating if the outline must be rendered as well
  65494. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  65495. */
  65496. renderOutline: boolean;
  65497. /** @hidden (Backing field) */
  65498. _renderOverlay: boolean;
  65499. /**
  65500. * Gets or sets a boolean indicating if the overlay must be rendered as well
  65501. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  65502. */
  65503. renderOverlay: boolean;
  65504. }
  65505. }
  65506. /**
  65507. * This class is responsible to draw bothe outline/overlay of meshes.
  65508. * It should not be used directly but through the available method on mesh.
  65509. */
  65510. export class OutlineRenderer implements ISceneComponent {
  65511. /**
  65512. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  65513. */
  65514. private static _StencilReference;
  65515. /**
  65516. * The name of the component. Each component must have a unique name.
  65517. */
  65518. name: string;
  65519. /**
  65520. * The scene the component belongs to.
  65521. */
  65522. scene: Scene;
  65523. /**
  65524. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  65525. */
  65526. zOffset: number;
  65527. private _engine;
  65528. private _effect;
  65529. private _cachedDefines;
  65530. private _savedDepthWrite;
  65531. /**
  65532. * Instantiates a new outline renderer. (There could be only one per scene).
  65533. * @param scene Defines the scene it belongs to
  65534. */
  65535. constructor(scene: Scene);
  65536. /**
  65537. * Register the component to one instance of a scene.
  65538. */
  65539. register(): void;
  65540. /**
  65541. * Rebuilds the elements related to this component in case of
  65542. * context lost for instance.
  65543. */
  65544. rebuild(): void;
  65545. /**
  65546. * Disposes the component and the associated ressources.
  65547. */
  65548. dispose(): void;
  65549. /**
  65550. * Renders the outline in the canvas.
  65551. * @param subMesh Defines the sumesh to render
  65552. * @param batch Defines the batch of meshes in case of instances
  65553. * @param useOverlay Defines if the rendering is for the overlay or the outline
  65554. */
  65555. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  65556. /**
  65557. * Returns whether or not the outline renderer is ready for a given submesh.
  65558. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  65559. * @param subMesh Defines the submesh to check readyness for
  65560. * @param useInstances Defines wheter wee are trying to render instances or not
  65561. * @returns true if ready otherwise false
  65562. */
  65563. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65564. private _beforeRenderingMesh;
  65565. private _afterRenderingMesh;
  65566. }
  65567. }
  65568. declare module "babylonjs/Rendering/index" {
  65569. export * from "babylonjs/Rendering/boundingBoxRenderer";
  65570. export * from "babylonjs/Rendering/depthRenderer";
  65571. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  65572. export * from "babylonjs/Rendering/edgesRenderer";
  65573. export * from "babylonjs/Rendering/geometryBufferRenderer";
  65574. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65575. export * from "babylonjs/Rendering/outlineRenderer";
  65576. export * from "babylonjs/Rendering/renderingGroup";
  65577. export * from "babylonjs/Rendering/renderingManager";
  65578. export * from "babylonjs/Rendering/utilityLayerRenderer";
  65579. }
  65580. declare module "babylonjs/Sprites/spritePackedManager" {
  65581. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  65582. import { Scene } from "babylonjs/scene";
  65583. /**
  65584. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65585. * @see http://doc.babylonjs.com/babylon101/sprites
  65586. */
  65587. export class SpritePackedManager extends SpriteManager {
  65588. /** defines the packed manager's name */
  65589. name: string;
  65590. /**
  65591. * Creates a new sprite manager from a packed sprite sheet
  65592. * @param name defines the manager's name
  65593. * @param imgUrl defines the sprite sheet url
  65594. * @param capacity defines the maximum allowed number of sprites
  65595. * @param scene defines the hosting scene
  65596. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65597. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65598. * @param samplingMode defines the smapling mode to use with spritesheet
  65599. * @param fromPacked set to true; do not alter
  65600. */
  65601. constructor(
  65602. /** defines the packed manager's name */
  65603. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65604. }
  65605. }
  65606. declare module "babylonjs/Sprites/index" {
  65607. export * from "babylonjs/Sprites/sprite";
  65608. export * from "babylonjs/Sprites/spriteManager";
  65609. export * from "babylonjs/Sprites/spritePackedManager";
  65610. export * from "babylonjs/Sprites/spriteSceneComponent";
  65611. }
  65612. declare module "babylonjs/States/index" {
  65613. export * from "babylonjs/States/alphaCullingState";
  65614. export * from "babylonjs/States/depthCullingState";
  65615. export * from "babylonjs/States/stencilState";
  65616. }
  65617. declare module "babylonjs/Misc/assetsManager" {
  65618. import { Scene } from "babylonjs/scene";
  65619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65620. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65621. import { Skeleton } from "babylonjs/Bones/skeleton";
  65622. import { Observable } from "babylonjs/Misc/observable";
  65623. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65624. import { Texture } from "babylonjs/Materials/Textures/texture";
  65625. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65626. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65627. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65628. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65629. /**
  65630. * Defines the list of states available for a task inside a AssetsManager
  65631. */
  65632. export enum AssetTaskState {
  65633. /**
  65634. * Initialization
  65635. */
  65636. INIT = 0,
  65637. /**
  65638. * Running
  65639. */
  65640. RUNNING = 1,
  65641. /**
  65642. * Done
  65643. */
  65644. DONE = 2,
  65645. /**
  65646. * Error
  65647. */
  65648. ERROR = 3
  65649. }
  65650. /**
  65651. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65652. */
  65653. export abstract class AbstractAssetTask {
  65654. /**
  65655. * Task name
  65656. */ name: string;
  65657. /**
  65658. * Callback called when the task is successful
  65659. */
  65660. onSuccess: (task: any) => void;
  65661. /**
  65662. * Callback called when the task is not successful
  65663. */
  65664. onError: (task: any, message?: string, exception?: any) => void;
  65665. /**
  65666. * Creates a new AssetsManager
  65667. * @param name defines the name of the task
  65668. */
  65669. constructor(
  65670. /**
  65671. * Task name
  65672. */ name: string);
  65673. private _isCompleted;
  65674. private _taskState;
  65675. private _errorObject;
  65676. /**
  65677. * Get if the task is completed
  65678. */
  65679. readonly isCompleted: boolean;
  65680. /**
  65681. * Gets the current state of the task
  65682. */
  65683. readonly taskState: AssetTaskState;
  65684. /**
  65685. * Gets the current error object (if task is in error)
  65686. */
  65687. readonly errorObject: {
  65688. message?: string;
  65689. exception?: any;
  65690. };
  65691. /**
  65692. * Internal only
  65693. * @hidden
  65694. */
  65695. _setErrorObject(message?: string, exception?: any): void;
  65696. /**
  65697. * Execute the current task
  65698. * @param scene defines the scene where you want your assets to be loaded
  65699. * @param onSuccess is a callback called when the task is successfully executed
  65700. * @param onError is a callback called if an error occurs
  65701. */
  65702. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65703. /**
  65704. * Execute the current task
  65705. * @param scene defines the scene where you want your assets to be loaded
  65706. * @param onSuccess is a callback called when the task is successfully executed
  65707. * @param onError is a callback called if an error occurs
  65708. */
  65709. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65710. /**
  65711. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65712. * This can be used with failed tasks that have the reason for failure fixed.
  65713. */
  65714. reset(): void;
  65715. private onErrorCallback;
  65716. private onDoneCallback;
  65717. }
  65718. /**
  65719. * Define the interface used by progress events raised during assets loading
  65720. */
  65721. export interface IAssetsProgressEvent {
  65722. /**
  65723. * Defines the number of remaining tasks to process
  65724. */
  65725. remainingCount: number;
  65726. /**
  65727. * Defines the total number of tasks
  65728. */
  65729. totalCount: number;
  65730. /**
  65731. * Defines the task that was just processed
  65732. */
  65733. task: AbstractAssetTask;
  65734. }
  65735. /**
  65736. * Class used to share progress information about assets loading
  65737. */
  65738. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65739. /**
  65740. * Defines the number of remaining tasks to process
  65741. */
  65742. remainingCount: number;
  65743. /**
  65744. * Defines the total number of tasks
  65745. */
  65746. totalCount: number;
  65747. /**
  65748. * Defines the task that was just processed
  65749. */
  65750. task: AbstractAssetTask;
  65751. /**
  65752. * Creates a AssetsProgressEvent
  65753. * @param remainingCount defines the number of remaining tasks to process
  65754. * @param totalCount defines the total number of tasks
  65755. * @param task defines the task that was just processed
  65756. */
  65757. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65758. }
  65759. /**
  65760. * Define a task used by AssetsManager to load meshes
  65761. */
  65762. export class MeshAssetTask extends AbstractAssetTask {
  65763. /**
  65764. * Defines the name of the task
  65765. */
  65766. name: string;
  65767. /**
  65768. * Defines the list of mesh's names you want to load
  65769. */
  65770. meshesNames: any;
  65771. /**
  65772. * Defines the root url to use as a base to load your meshes and associated resources
  65773. */
  65774. rootUrl: string;
  65775. /**
  65776. * Defines the filename of the scene to load from
  65777. */
  65778. sceneFilename: string;
  65779. /**
  65780. * Gets the list of loaded meshes
  65781. */
  65782. loadedMeshes: Array<AbstractMesh>;
  65783. /**
  65784. * Gets the list of loaded particle systems
  65785. */
  65786. loadedParticleSystems: Array<IParticleSystem>;
  65787. /**
  65788. * Gets the list of loaded skeletons
  65789. */
  65790. loadedSkeletons: Array<Skeleton>;
  65791. /**
  65792. * Gets the list of loaded animation groups
  65793. */
  65794. loadedAnimationGroups: Array<AnimationGroup>;
  65795. /**
  65796. * Callback called when the task is successful
  65797. */
  65798. onSuccess: (task: MeshAssetTask) => void;
  65799. /**
  65800. * Callback called when the task is successful
  65801. */
  65802. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65803. /**
  65804. * Creates a new MeshAssetTask
  65805. * @param name defines the name of the task
  65806. * @param meshesNames defines the list of mesh's names you want to load
  65807. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65808. * @param sceneFilename defines the filename of the scene to load from
  65809. */
  65810. constructor(
  65811. /**
  65812. * Defines the name of the task
  65813. */
  65814. name: string,
  65815. /**
  65816. * Defines the list of mesh's names you want to load
  65817. */
  65818. meshesNames: any,
  65819. /**
  65820. * Defines the root url to use as a base to load your meshes and associated resources
  65821. */
  65822. rootUrl: string,
  65823. /**
  65824. * Defines the filename of the scene to load from
  65825. */
  65826. sceneFilename: string);
  65827. /**
  65828. * Execute the current task
  65829. * @param scene defines the scene where you want your assets to be loaded
  65830. * @param onSuccess is a callback called when the task is successfully executed
  65831. * @param onError is a callback called if an error occurs
  65832. */
  65833. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65834. }
  65835. /**
  65836. * Define a task used by AssetsManager to load text content
  65837. */
  65838. export class TextFileAssetTask extends AbstractAssetTask {
  65839. /**
  65840. * Defines the name of the task
  65841. */
  65842. name: string;
  65843. /**
  65844. * Defines the location of the file to load
  65845. */
  65846. url: string;
  65847. /**
  65848. * Gets the loaded text string
  65849. */
  65850. text: string;
  65851. /**
  65852. * Callback called when the task is successful
  65853. */
  65854. onSuccess: (task: TextFileAssetTask) => void;
  65855. /**
  65856. * Callback called when the task is successful
  65857. */
  65858. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65859. /**
  65860. * Creates a new TextFileAssetTask object
  65861. * @param name defines the name of the task
  65862. * @param url defines the location of the file to load
  65863. */
  65864. constructor(
  65865. /**
  65866. * Defines the name of the task
  65867. */
  65868. name: string,
  65869. /**
  65870. * Defines the location of the file to load
  65871. */
  65872. url: string);
  65873. /**
  65874. * Execute the current task
  65875. * @param scene defines the scene where you want your assets to be loaded
  65876. * @param onSuccess is a callback called when the task is successfully executed
  65877. * @param onError is a callback called if an error occurs
  65878. */
  65879. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65880. }
  65881. /**
  65882. * Define a task used by AssetsManager to load binary data
  65883. */
  65884. export class BinaryFileAssetTask extends AbstractAssetTask {
  65885. /**
  65886. * Defines the name of the task
  65887. */
  65888. name: string;
  65889. /**
  65890. * Defines the location of the file to load
  65891. */
  65892. url: string;
  65893. /**
  65894. * Gets the lodaded data (as an array buffer)
  65895. */
  65896. data: ArrayBuffer;
  65897. /**
  65898. * Callback called when the task is successful
  65899. */
  65900. onSuccess: (task: BinaryFileAssetTask) => void;
  65901. /**
  65902. * Callback called when the task is successful
  65903. */
  65904. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65905. /**
  65906. * Creates a new BinaryFileAssetTask object
  65907. * @param name defines the name of the new task
  65908. * @param url defines the location of the file to load
  65909. */
  65910. constructor(
  65911. /**
  65912. * Defines the name of the task
  65913. */
  65914. name: string,
  65915. /**
  65916. * Defines the location of the file to load
  65917. */
  65918. url: string);
  65919. /**
  65920. * Execute the current task
  65921. * @param scene defines the scene where you want your assets to be loaded
  65922. * @param onSuccess is a callback called when the task is successfully executed
  65923. * @param onError is a callback called if an error occurs
  65924. */
  65925. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65926. }
  65927. /**
  65928. * Define a task used by AssetsManager to load images
  65929. */
  65930. export class ImageAssetTask extends AbstractAssetTask {
  65931. /**
  65932. * Defines the name of the task
  65933. */
  65934. name: string;
  65935. /**
  65936. * Defines the location of the image to load
  65937. */
  65938. url: string;
  65939. /**
  65940. * Gets the loaded images
  65941. */
  65942. image: HTMLImageElement;
  65943. /**
  65944. * Callback called when the task is successful
  65945. */
  65946. onSuccess: (task: ImageAssetTask) => void;
  65947. /**
  65948. * Callback called when the task is successful
  65949. */
  65950. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65951. /**
  65952. * Creates a new ImageAssetTask
  65953. * @param name defines the name of the task
  65954. * @param url defines the location of the image to load
  65955. */
  65956. constructor(
  65957. /**
  65958. * Defines the name of the task
  65959. */
  65960. name: string,
  65961. /**
  65962. * Defines the location of the image to load
  65963. */
  65964. url: string);
  65965. /**
  65966. * Execute the current task
  65967. * @param scene defines the scene where you want your assets to be loaded
  65968. * @param onSuccess is a callback called when the task is successfully executed
  65969. * @param onError is a callback called if an error occurs
  65970. */
  65971. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65972. }
  65973. /**
  65974. * Defines the interface used by texture loading tasks
  65975. */
  65976. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65977. /**
  65978. * Gets the loaded texture
  65979. */
  65980. texture: TEX;
  65981. }
  65982. /**
  65983. * Define a task used by AssetsManager to load 2D textures
  65984. */
  65985. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65986. /**
  65987. * Defines the name of the task
  65988. */
  65989. name: string;
  65990. /**
  65991. * Defines the location of the file to load
  65992. */
  65993. url: string;
  65994. /**
  65995. * Defines if mipmap should not be generated (default is false)
  65996. */
  65997. noMipmap?: boolean | undefined;
  65998. /**
  65999. * Defines if texture must be inverted on Y axis (default is false)
  66000. */
  66001. invertY?: boolean | undefined;
  66002. /**
  66003. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66004. */
  66005. samplingMode: number;
  66006. /**
  66007. * Gets the loaded texture
  66008. */
  66009. texture: Texture;
  66010. /**
  66011. * Callback called when the task is successful
  66012. */
  66013. onSuccess: (task: TextureAssetTask) => void;
  66014. /**
  66015. * Callback called when the task is successful
  66016. */
  66017. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66018. /**
  66019. * Creates a new TextureAssetTask object
  66020. * @param name defines the name of the task
  66021. * @param url defines the location of the file to load
  66022. * @param noMipmap defines if mipmap should not be generated (default is false)
  66023. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66024. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66025. */
  66026. constructor(
  66027. /**
  66028. * Defines the name of the task
  66029. */
  66030. name: string,
  66031. /**
  66032. * Defines the location of the file to load
  66033. */
  66034. url: string,
  66035. /**
  66036. * Defines if mipmap should not be generated (default is false)
  66037. */
  66038. noMipmap?: boolean | undefined,
  66039. /**
  66040. * Defines if texture must be inverted on Y axis (default is false)
  66041. */
  66042. invertY?: boolean | undefined,
  66043. /**
  66044. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66045. */
  66046. samplingMode?: number);
  66047. /**
  66048. * Execute the current task
  66049. * @param scene defines the scene where you want your assets to be loaded
  66050. * @param onSuccess is a callback called when the task is successfully executed
  66051. * @param onError is a callback called if an error occurs
  66052. */
  66053. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66054. }
  66055. /**
  66056. * Define a task used by AssetsManager to load cube textures
  66057. */
  66058. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66059. /**
  66060. * Defines the name of the task
  66061. */
  66062. name: string;
  66063. /**
  66064. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66065. */
  66066. url: string;
  66067. /**
  66068. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66069. */
  66070. extensions?: string[] | undefined;
  66071. /**
  66072. * Defines if mipmaps should not be generated (default is false)
  66073. */
  66074. noMipmap?: boolean | undefined;
  66075. /**
  66076. * Defines the explicit list of files (undefined by default)
  66077. */
  66078. files?: string[] | undefined;
  66079. /**
  66080. * Gets the loaded texture
  66081. */
  66082. texture: CubeTexture;
  66083. /**
  66084. * Callback called when the task is successful
  66085. */
  66086. onSuccess: (task: CubeTextureAssetTask) => void;
  66087. /**
  66088. * Callback called when the task is successful
  66089. */
  66090. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66091. /**
  66092. * Creates a new CubeTextureAssetTask
  66093. * @param name defines the name of the task
  66094. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66095. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66096. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66097. * @param files defines the explicit list of files (undefined by default)
  66098. */
  66099. constructor(
  66100. /**
  66101. * Defines the name of the task
  66102. */
  66103. name: string,
  66104. /**
  66105. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66106. */
  66107. url: string,
  66108. /**
  66109. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66110. */
  66111. extensions?: string[] | undefined,
  66112. /**
  66113. * Defines if mipmaps should not be generated (default is false)
  66114. */
  66115. noMipmap?: boolean | undefined,
  66116. /**
  66117. * Defines the explicit list of files (undefined by default)
  66118. */
  66119. files?: string[] | undefined);
  66120. /**
  66121. * Execute the current task
  66122. * @param scene defines the scene where you want your assets to be loaded
  66123. * @param onSuccess is a callback called when the task is successfully executed
  66124. * @param onError is a callback called if an error occurs
  66125. */
  66126. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66127. }
  66128. /**
  66129. * Define a task used by AssetsManager to load HDR cube textures
  66130. */
  66131. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66132. /**
  66133. * Defines the name of the task
  66134. */
  66135. name: string;
  66136. /**
  66137. * Defines the location of the file to load
  66138. */
  66139. url: string;
  66140. /**
  66141. * Defines the desired size (the more it increases the longer the generation will be)
  66142. */
  66143. size: number;
  66144. /**
  66145. * Defines if mipmaps should not be generated (default is false)
  66146. */
  66147. noMipmap: boolean;
  66148. /**
  66149. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66150. */
  66151. generateHarmonics: boolean;
  66152. /**
  66153. * 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)
  66154. */
  66155. gammaSpace: boolean;
  66156. /**
  66157. * Internal Use Only
  66158. */
  66159. reserved: boolean;
  66160. /**
  66161. * Gets the loaded texture
  66162. */
  66163. texture: HDRCubeTexture;
  66164. /**
  66165. * Callback called when the task is successful
  66166. */
  66167. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66168. /**
  66169. * Callback called when the task is successful
  66170. */
  66171. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66172. /**
  66173. * Creates a new HDRCubeTextureAssetTask object
  66174. * @param name defines the name of the task
  66175. * @param url defines the location of the file to load
  66176. * @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.
  66177. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66178. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66179. * @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)
  66180. * @param reserved Internal use only
  66181. */
  66182. constructor(
  66183. /**
  66184. * Defines the name of the task
  66185. */
  66186. name: string,
  66187. /**
  66188. * Defines the location of the file to load
  66189. */
  66190. url: string,
  66191. /**
  66192. * Defines the desired size (the more it increases the longer the generation will be)
  66193. */
  66194. size: number,
  66195. /**
  66196. * Defines if mipmaps should not be generated (default is false)
  66197. */
  66198. noMipmap?: boolean,
  66199. /**
  66200. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66201. */
  66202. generateHarmonics?: boolean,
  66203. /**
  66204. * 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)
  66205. */
  66206. gammaSpace?: boolean,
  66207. /**
  66208. * Internal Use Only
  66209. */
  66210. reserved?: boolean);
  66211. /**
  66212. * Execute the current task
  66213. * @param scene defines the scene where you want your assets to be loaded
  66214. * @param onSuccess is a callback called when the task is successfully executed
  66215. * @param onError is a callback called if an error occurs
  66216. */
  66217. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66218. }
  66219. /**
  66220. * Define a task used by AssetsManager to load Equirectangular cube textures
  66221. */
  66222. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66223. /**
  66224. * Defines the name of the task
  66225. */
  66226. name: string;
  66227. /**
  66228. * Defines the location of the file to load
  66229. */
  66230. url: string;
  66231. /**
  66232. * Defines the desired size (the more it increases the longer the generation will be)
  66233. */
  66234. size: number;
  66235. /**
  66236. * Defines if mipmaps should not be generated (default is false)
  66237. */
  66238. noMipmap: boolean;
  66239. /**
  66240. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66241. * but the standard material would require them in Gamma space) (default is true)
  66242. */
  66243. gammaSpace: boolean;
  66244. /**
  66245. * Gets the loaded texture
  66246. */
  66247. texture: EquiRectangularCubeTexture;
  66248. /**
  66249. * Callback called when the task is successful
  66250. */
  66251. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66252. /**
  66253. * Callback called when the task is successful
  66254. */
  66255. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66256. /**
  66257. * Creates a new EquiRectangularCubeTextureAssetTask object
  66258. * @param name defines the name of the task
  66259. * @param url defines the location of the file to load
  66260. * @param size defines the desired size (the more it increases the longer the generation will be)
  66261. * If the size is omitted this implies you are using a preprocessed cubemap.
  66262. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66263. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66264. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66265. * (default is true)
  66266. */
  66267. constructor(
  66268. /**
  66269. * Defines the name of the task
  66270. */
  66271. name: string,
  66272. /**
  66273. * Defines the location of the file to load
  66274. */
  66275. url: string,
  66276. /**
  66277. * Defines the desired size (the more it increases the longer the generation will be)
  66278. */
  66279. size: number,
  66280. /**
  66281. * Defines if mipmaps should not be generated (default is false)
  66282. */
  66283. noMipmap?: boolean,
  66284. /**
  66285. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66286. * but the standard material would require them in Gamma space) (default is true)
  66287. */
  66288. gammaSpace?: boolean);
  66289. /**
  66290. * Execute the current task
  66291. * @param scene defines the scene where you want your assets to be loaded
  66292. * @param onSuccess is a callback called when the task is successfully executed
  66293. * @param onError is a callback called if an error occurs
  66294. */
  66295. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66296. }
  66297. /**
  66298. * This class can be used to easily import assets into a scene
  66299. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66300. */
  66301. export class AssetsManager {
  66302. private _scene;
  66303. private _isLoading;
  66304. protected _tasks: AbstractAssetTask[];
  66305. protected _waitingTasksCount: number;
  66306. protected _totalTasksCount: number;
  66307. /**
  66308. * Callback called when all tasks are processed
  66309. */
  66310. onFinish: (tasks: AbstractAssetTask[]) => void;
  66311. /**
  66312. * Callback called when a task is successful
  66313. */
  66314. onTaskSuccess: (task: AbstractAssetTask) => void;
  66315. /**
  66316. * Callback called when a task had an error
  66317. */
  66318. onTaskError: (task: AbstractAssetTask) => void;
  66319. /**
  66320. * Callback called when a task is done (whatever the result is)
  66321. */
  66322. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66323. /**
  66324. * Observable called when all tasks are processed
  66325. */
  66326. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66327. /**
  66328. * Observable called when a task had an error
  66329. */
  66330. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66331. /**
  66332. * Observable called when all tasks were executed
  66333. */
  66334. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66335. /**
  66336. * Observable called when a task is done (whatever the result is)
  66337. */
  66338. onProgressObservable: Observable<IAssetsProgressEvent>;
  66339. /**
  66340. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66341. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66342. */
  66343. useDefaultLoadingScreen: boolean;
  66344. /**
  66345. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66346. * when all assets have been downloaded.
  66347. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66348. */
  66349. autoHideLoadingUI: boolean;
  66350. /**
  66351. * Creates a new AssetsManager
  66352. * @param scene defines the scene to work on
  66353. */
  66354. constructor(scene: Scene);
  66355. /**
  66356. * Add a MeshAssetTask to the list of active tasks
  66357. * @param taskName defines the name of the new task
  66358. * @param meshesNames defines the name of meshes to load
  66359. * @param rootUrl defines the root url to use to locate files
  66360. * @param sceneFilename defines the filename of the scene file
  66361. * @returns a new MeshAssetTask object
  66362. */
  66363. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66364. /**
  66365. * Add a TextFileAssetTask to the list of active tasks
  66366. * @param taskName defines the name of the new task
  66367. * @param url defines the url of the file to load
  66368. * @returns a new TextFileAssetTask object
  66369. */
  66370. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66371. /**
  66372. * Add a BinaryFileAssetTask to the list of active tasks
  66373. * @param taskName defines the name of the new task
  66374. * @param url defines the url of the file to load
  66375. * @returns a new BinaryFileAssetTask object
  66376. */
  66377. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66378. /**
  66379. * Add a ImageAssetTask to the list of active tasks
  66380. * @param taskName defines the name of the new task
  66381. * @param url defines the url of the file to load
  66382. * @returns a new ImageAssetTask object
  66383. */
  66384. addImageTask(taskName: string, url: string): ImageAssetTask;
  66385. /**
  66386. * Add a TextureAssetTask to the list of active tasks
  66387. * @param taskName defines the name of the new task
  66388. * @param url defines the url of the file to load
  66389. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66390. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66391. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66392. * @returns a new TextureAssetTask object
  66393. */
  66394. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66395. /**
  66396. * Add a CubeTextureAssetTask to the list of active tasks
  66397. * @param taskName defines the name of the new task
  66398. * @param url defines the url of the file to load
  66399. * @param extensions defines the extension to use to load the cube map (can be null)
  66400. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66401. * @param files defines the list of files to load (can be null)
  66402. * @returns a new CubeTextureAssetTask object
  66403. */
  66404. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66405. /**
  66406. *
  66407. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66408. * @param taskName defines the name of the new task
  66409. * @param url defines the url of the file to load
  66410. * @param size defines the size you want for the cubemap (can be null)
  66411. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66412. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66413. * @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)
  66414. * @param reserved Internal use only
  66415. * @returns a new HDRCubeTextureAssetTask object
  66416. */
  66417. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66418. /**
  66419. *
  66420. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66421. * @param taskName defines the name of the new task
  66422. * @param url defines the url of the file to load
  66423. * @param size defines the size you want for the cubemap (can be null)
  66424. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66425. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66426. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66427. * @returns a new EquiRectangularCubeTextureAssetTask object
  66428. */
  66429. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66430. /**
  66431. * Remove a task from the assets manager.
  66432. * @param task the task to remove
  66433. */
  66434. removeTask(task: AbstractAssetTask): void;
  66435. private _decreaseWaitingTasksCount;
  66436. private _runTask;
  66437. /**
  66438. * Reset the AssetsManager and remove all tasks
  66439. * @return the current instance of the AssetsManager
  66440. */
  66441. reset(): AssetsManager;
  66442. /**
  66443. * Start the loading process
  66444. * @return the current instance of the AssetsManager
  66445. */
  66446. load(): AssetsManager;
  66447. /**
  66448. * Start the loading process as an async operation
  66449. * @return a promise returning the list of failed tasks
  66450. */
  66451. loadAsync(): Promise<void>;
  66452. }
  66453. }
  66454. declare module "babylonjs/Misc/deferred" {
  66455. /**
  66456. * Wrapper class for promise with external resolve and reject.
  66457. */
  66458. export class Deferred<T> {
  66459. /**
  66460. * The promise associated with this deferred object.
  66461. */
  66462. readonly promise: Promise<T>;
  66463. private _resolve;
  66464. private _reject;
  66465. /**
  66466. * The resolve method of the promise associated with this deferred object.
  66467. */
  66468. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66469. /**
  66470. * The reject method of the promise associated with this deferred object.
  66471. */
  66472. readonly reject: (reason?: any) => void;
  66473. /**
  66474. * Constructor for this deferred object.
  66475. */
  66476. constructor();
  66477. }
  66478. }
  66479. declare module "babylonjs/Misc/meshExploder" {
  66480. import { Mesh } from "babylonjs/Meshes/mesh";
  66481. /**
  66482. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66483. */
  66484. export class MeshExploder {
  66485. private _centerMesh;
  66486. private _meshes;
  66487. private _meshesOrigins;
  66488. private _toCenterVectors;
  66489. private _scaledDirection;
  66490. private _newPosition;
  66491. private _centerPosition;
  66492. /**
  66493. * Explodes meshes from a center mesh.
  66494. * @param meshes The meshes to explode.
  66495. * @param centerMesh The mesh to be center of explosion.
  66496. */
  66497. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66498. private _setCenterMesh;
  66499. /**
  66500. * Get class name
  66501. * @returns "MeshExploder"
  66502. */
  66503. getClassName(): string;
  66504. /**
  66505. * "Exploded meshes"
  66506. * @returns Array of meshes with the centerMesh at index 0.
  66507. */
  66508. getMeshes(): Array<Mesh>;
  66509. /**
  66510. * Explodes meshes giving a specific direction
  66511. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66512. */
  66513. explode(direction?: number): void;
  66514. }
  66515. }
  66516. declare module "babylonjs/Misc/filesInput" {
  66517. import { Engine } from "babylonjs/Engines/engine";
  66518. import { Scene } from "babylonjs/scene";
  66519. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  66520. /**
  66521. * Class used to help managing file picking and drag'n'drop
  66522. */
  66523. export class FilesInput {
  66524. /**
  66525. * List of files ready to be loaded
  66526. */
  66527. static readonly FilesToLoad: {
  66528. [key: string]: File;
  66529. };
  66530. /**
  66531. * Callback called when a file is processed
  66532. */
  66533. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66534. private _engine;
  66535. private _currentScene;
  66536. private _sceneLoadedCallback;
  66537. private _progressCallback;
  66538. private _additionalRenderLoopLogicCallback;
  66539. private _textureLoadingCallback;
  66540. private _startingProcessingFilesCallback;
  66541. private _onReloadCallback;
  66542. private _errorCallback;
  66543. private _elementToMonitor;
  66544. private _sceneFileToLoad;
  66545. private _filesToLoad;
  66546. /**
  66547. * Creates a new FilesInput
  66548. * @param engine defines the rendering engine
  66549. * @param scene defines the hosting scene
  66550. * @param sceneLoadedCallback callback called when scene is loaded
  66551. * @param progressCallback callback called to track progress
  66552. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66553. * @param textureLoadingCallback callback called when a texture is loading
  66554. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66555. * @param onReloadCallback callback called when a reload is requested
  66556. * @param errorCallback callback call if an error occurs
  66557. */
  66558. 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);
  66559. private _dragEnterHandler;
  66560. private _dragOverHandler;
  66561. private _dropHandler;
  66562. /**
  66563. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66564. * @param elementToMonitor defines the DOM element to track
  66565. */
  66566. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66567. /**
  66568. * Release all associated resources
  66569. */
  66570. dispose(): void;
  66571. private renderFunction;
  66572. private drag;
  66573. private drop;
  66574. private _traverseFolder;
  66575. private _processFiles;
  66576. /**
  66577. * Load files from a drop event
  66578. * @param event defines the drop event to use as source
  66579. */
  66580. loadFiles(event: any): void;
  66581. private _processReload;
  66582. /**
  66583. * Reload the current scene from the loaded files
  66584. */
  66585. reload(): void;
  66586. }
  66587. }
  66588. declare module "babylonjs/Misc/HighDynamicRange/index" {
  66589. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  66590. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  66591. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  66592. }
  66593. declare module "babylonjs/Misc/sceneOptimizer" {
  66594. import { Scene, IDisposable } from "babylonjs/scene";
  66595. import { Observable } from "babylonjs/Misc/observable";
  66596. /**
  66597. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66599. */
  66600. export class SceneOptimization {
  66601. /**
  66602. * Defines the priority of this optimization (0 by default which means first in the list)
  66603. */
  66604. priority: number;
  66605. /**
  66606. * Gets a string describing the action executed by the current optimization
  66607. * @returns description string
  66608. */
  66609. getDescription(): string;
  66610. /**
  66611. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66612. * @param scene defines the current scene where to apply this optimization
  66613. * @param optimizer defines the current optimizer
  66614. * @returns true if everything that can be done was applied
  66615. */
  66616. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66617. /**
  66618. * Creates the SceneOptimization object
  66619. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66620. * @param desc defines the description associated with the optimization
  66621. */
  66622. constructor(
  66623. /**
  66624. * Defines the priority of this optimization (0 by default which means first in the list)
  66625. */
  66626. priority?: number);
  66627. }
  66628. /**
  66629. * Defines an optimization used to reduce the size of render target textures
  66630. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66631. */
  66632. export class TextureOptimization extends SceneOptimization {
  66633. /**
  66634. * Defines the priority of this optimization (0 by default which means first in the list)
  66635. */
  66636. priority: number;
  66637. /**
  66638. * 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
  66639. */
  66640. maximumSize: number;
  66641. /**
  66642. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66643. */
  66644. step: number;
  66645. /**
  66646. * Gets a string describing the action executed by the current optimization
  66647. * @returns description string
  66648. */
  66649. getDescription(): string;
  66650. /**
  66651. * Creates the TextureOptimization object
  66652. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66653. * @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
  66654. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66655. */
  66656. constructor(
  66657. /**
  66658. * Defines the priority of this optimization (0 by default which means first in the list)
  66659. */
  66660. priority?: number,
  66661. /**
  66662. * 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
  66663. */
  66664. maximumSize?: number,
  66665. /**
  66666. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66667. */
  66668. step?: number);
  66669. /**
  66670. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66671. * @param scene defines the current scene where to apply this optimization
  66672. * @param optimizer defines the current optimizer
  66673. * @returns true if everything that can be done was applied
  66674. */
  66675. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66676. }
  66677. /**
  66678. * Defines an optimization used to increase or decrease the rendering resolution
  66679. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66680. */
  66681. export class HardwareScalingOptimization extends SceneOptimization {
  66682. /**
  66683. * Defines the priority of this optimization (0 by default which means first in the list)
  66684. */
  66685. priority: number;
  66686. /**
  66687. * Defines the maximum scale to use (2 by default)
  66688. */
  66689. maximumScale: number;
  66690. /**
  66691. * Defines the step to use between two passes (0.5 by default)
  66692. */
  66693. step: number;
  66694. private _currentScale;
  66695. private _directionOffset;
  66696. /**
  66697. * Gets a string describing the action executed by the current optimization
  66698. * @return description string
  66699. */
  66700. getDescription(): string;
  66701. /**
  66702. * Creates the HardwareScalingOptimization object
  66703. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66704. * @param maximumScale defines the maximum scale to use (2 by default)
  66705. * @param step defines the step to use between two passes (0.5 by default)
  66706. */
  66707. constructor(
  66708. /**
  66709. * Defines the priority of this optimization (0 by default which means first in the list)
  66710. */
  66711. priority?: number,
  66712. /**
  66713. * Defines the maximum scale to use (2 by default)
  66714. */
  66715. maximumScale?: number,
  66716. /**
  66717. * Defines the step to use between two passes (0.5 by default)
  66718. */
  66719. step?: number);
  66720. /**
  66721. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66722. * @param scene defines the current scene where to apply this optimization
  66723. * @param optimizer defines the current optimizer
  66724. * @returns true if everything that can be done was applied
  66725. */
  66726. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66727. }
  66728. /**
  66729. * Defines an optimization used to remove shadows
  66730. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66731. */
  66732. export class ShadowsOptimization extends SceneOptimization {
  66733. /**
  66734. * Gets a string describing the action executed by the current optimization
  66735. * @return description string
  66736. */
  66737. getDescription(): string;
  66738. /**
  66739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66740. * @param scene defines the current scene where to apply this optimization
  66741. * @param optimizer defines the current optimizer
  66742. * @returns true if everything that can be done was applied
  66743. */
  66744. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66745. }
  66746. /**
  66747. * Defines an optimization used to turn post-processes off
  66748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66749. */
  66750. export class PostProcessesOptimization extends SceneOptimization {
  66751. /**
  66752. * Gets a string describing the action executed by the current optimization
  66753. * @return description string
  66754. */
  66755. getDescription(): string;
  66756. /**
  66757. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66758. * @param scene defines the current scene where to apply this optimization
  66759. * @param optimizer defines the current optimizer
  66760. * @returns true if everything that can be done was applied
  66761. */
  66762. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66763. }
  66764. /**
  66765. * Defines an optimization used to turn lens flares off
  66766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66767. */
  66768. export class LensFlaresOptimization extends SceneOptimization {
  66769. /**
  66770. * Gets a string describing the action executed by the current optimization
  66771. * @return description string
  66772. */
  66773. getDescription(): string;
  66774. /**
  66775. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66776. * @param scene defines the current scene where to apply this optimization
  66777. * @param optimizer defines the current optimizer
  66778. * @returns true if everything that can be done was applied
  66779. */
  66780. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66781. }
  66782. /**
  66783. * Defines an optimization based on user defined callback.
  66784. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66785. */
  66786. export class CustomOptimization extends SceneOptimization {
  66787. /**
  66788. * Callback called to apply the custom optimization.
  66789. */
  66790. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66791. /**
  66792. * Callback called to get custom description
  66793. */
  66794. onGetDescription: () => string;
  66795. /**
  66796. * Gets a string describing the action executed by the current optimization
  66797. * @returns description string
  66798. */
  66799. getDescription(): string;
  66800. /**
  66801. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66802. * @param scene defines the current scene where to apply this optimization
  66803. * @param optimizer defines the current optimizer
  66804. * @returns true if everything that can be done was applied
  66805. */
  66806. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66807. }
  66808. /**
  66809. * Defines an optimization used to turn particles off
  66810. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66811. */
  66812. export class ParticlesOptimization extends SceneOptimization {
  66813. /**
  66814. * Gets a string describing the action executed by the current optimization
  66815. * @return description string
  66816. */
  66817. getDescription(): string;
  66818. /**
  66819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66820. * @param scene defines the current scene where to apply this optimization
  66821. * @param optimizer defines the current optimizer
  66822. * @returns true if everything that can be done was applied
  66823. */
  66824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66825. }
  66826. /**
  66827. * Defines an optimization used to turn render targets off
  66828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66829. */
  66830. export class RenderTargetsOptimization extends SceneOptimization {
  66831. /**
  66832. * Gets a string describing the action executed by the current optimization
  66833. * @return description string
  66834. */
  66835. getDescription(): string;
  66836. /**
  66837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66838. * @param scene defines the current scene where to apply this optimization
  66839. * @param optimizer defines the current optimizer
  66840. * @returns true if everything that can be done was applied
  66841. */
  66842. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66843. }
  66844. /**
  66845. * Defines an optimization used to merge meshes with compatible materials
  66846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66847. */
  66848. export class MergeMeshesOptimization extends SceneOptimization {
  66849. private static _UpdateSelectionTree;
  66850. /**
  66851. * Gets or sets a boolean which defines if optimization octree has to be updated
  66852. */
  66853. /**
  66854. * Gets or sets a boolean which defines if optimization octree has to be updated
  66855. */
  66856. static UpdateSelectionTree: boolean;
  66857. /**
  66858. * Gets a string describing the action executed by the current optimization
  66859. * @return description string
  66860. */
  66861. getDescription(): string;
  66862. private _canBeMerged;
  66863. /**
  66864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66865. * @param scene defines the current scene where to apply this optimization
  66866. * @param optimizer defines the current optimizer
  66867. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66868. * @returns true if everything that can be done was applied
  66869. */
  66870. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66871. }
  66872. /**
  66873. * Defines a list of options used by SceneOptimizer
  66874. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66875. */
  66876. export class SceneOptimizerOptions {
  66877. /**
  66878. * Defines the target frame rate to reach (60 by default)
  66879. */
  66880. targetFrameRate: number;
  66881. /**
  66882. * Defines the interval between two checkes (2000ms by default)
  66883. */
  66884. trackerDuration: number;
  66885. /**
  66886. * Gets the list of optimizations to apply
  66887. */
  66888. optimizations: SceneOptimization[];
  66889. /**
  66890. * Creates a new list of options used by SceneOptimizer
  66891. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66892. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66893. */
  66894. constructor(
  66895. /**
  66896. * Defines the target frame rate to reach (60 by default)
  66897. */
  66898. targetFrameRate?: number,
  66899. /**
  66900. * Defines the interval between two checkes (2000ms by default)
  66901. */
  66902. trackerDuration?: number);
  66903. /**
  66904. * Add a new optimization
  66905. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66906. * @returns the current SceneOptimizerOptions
  66907. */
  66908. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66909. /**
  66910. * Add a new custom optimization
  66911. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66912. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66913. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66914. * @returns the current SceneOptimizerOptions
  66915. */
  66916. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66917. /**
  66918. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66919. * @param targetFrameRate defines the target frame rate (60 by default)
  66920. * @returns a SceneOptimizerOptions object
  66921. */
  66922. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66923. /**
  66924. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66925. * @param targetFrameRate defines the target frame rate (60 by default)
  66926. * @returns a SceneOptimizerOptions object
  66927. */
  66928. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66929. /**
  66930. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66931. * @param targetFrameRate defines the target frame rate (60 by default)
  66932. * @returns a SceneOptimizerOptions object
  66933. */
  66934. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66935. }
  66936. /**
  66937. * Class used to run optimizations in order to reach a target frame rate
  66938. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66939. */
  66940. export class SceneOptimizer implements IDisposable {
  66941. private _isRunning;
  66942. private _options;
  66943. private _scene;
  66944. private _currentPriorityLevel;
  66945. private _targetFrameRate;
  66946. private _trackerDuration;
  66947. private _currentFrameRate;
  66948. private _sceneDisposeObserver;
  66949. private _improvementMode;
  66950. /**
  66951. * Defines an observable called when the optimizer reaches the target frame rate
  66952. */
  66953. onSuccessObservable: Observable<SceneOptimizer>;
  66954. /**
  66955. * Defines an observable called when the optimizer enables an optimization
  66956. */
  66957. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66958. /**
  66959. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66960. */
  66961. onFailureObservable: Observable<SceneOptimizer>;
  66962. /**
  66963. * Gets a boolean indicating if the optimizer is in improvement mode
  66964. */
  66965. readonly isInImprovementMode: boolean;
  66966. /**
  66967. * Gets the current priority level (0 at start)
  66968. */
  66969. readonly currentPriorityLevel: number;
  66970. /**
  66971. * Gets the current frame rate checked by the SceneOptimizer
  66972. */
  66973. readonly currentFrameRate: number;
  66974. /**
  66975. * Gets or sets the current target frame rate (60 by default)
  66976. */
  66977. /**
  66978. * Gets or sets the current target frame rate (60 by default)
  66979. */
  66980. targetFrameRate: number;
  66981. /**
  66982. * Gets or sets the current interval between two checks (every 2000ms by default)
  66983. */
  66984. /**
  66985. * Gets or sets the current interval between two checks (every 2000ms by default)
  66986. */
  66987. trackerDuration: number;
  66988. /**
  66989. * Gets the list of active optimizations
  66990. */
  66991. readonly optimizations: SceneOptimization[];
  66992. /**
  66993. * Creates a new SceneOptimizer
  66994. * @param scene defines the scene to work on
  66995. * @param options defines the options to use with the SceneOptimizer
  66996. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66997. * @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)
  66998. */
  66999. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67000. /**
  67001. * Stops the current optimizer
  67002. */
  67003. stop(): void;
  67004. /**
  67005. * Reset the optimizer to initial step (current priority level = 0)
  67006. */
  67007. reset(): void;
  67008. /**
  67009. * Start the optimizer. By default it will try to reach a specific framerate
  67010. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67011. */
  67012. start(): void;
  67013. private _checkCurrentState;
  67014. /**
  67015. * Release all resources
  67016. */
  67017. dispose(): void;
  67018. /**
  67019. * Helper function to create a SceneOptimizer with one single line of code
  67020. * @param scene defines the scene to work on
  67021. * @param options defines the options to use with the SceneOptimizer
  67022. * @param onSuccess defines a callback to call on success
  67023. * @param onFailure defines a callback to call on failure
  67024. * @returns the new SceneOptimizer object
  67025. */
  67026. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67027. }
  67028. }
  67029. declare module "babylonjs/Misc/sceneSerializer" {
  67030. import { Scene } from "babylonjs/scene";
  67031. /**
  67032. * Class used to serialize a scene into a string
  67033. */
  67034. export class SceneSerializer {
  67035. /**
  67036. * Clear cache used by a previous serialization
  67037. */
  67038. static ClearCache(): void;
  67039. /**
  67040. * Serialize a scene into a JSON compatible object
  67041. * @param scene defines the scene to serialize
  67042. * @returns a JSON compatible object
  67043. */
  67044. static Serialize(scene: Scene): any;
  67045. /**
  67046. * Serialize a mesh into a JSON compatible object
  67047. * @param toSerialize defines the mesh to serialize
  67048. * @param withParents defines if parents must be serialized as well
  67049. * @param withChildren defines if children must be serialized as well
  67050. * @returns a JSON compatible object
  67051. */
  67052. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67053. }
  67054. }
  67055. declare module "babylonjs/Misc/textureTools" {
  67056. import { Texture } from "babylonjs/Materials/Textures/texture";
  67057. /**
  67058. * Class used to host texture specific utilities
  67059. */
  67060. export class TextureTools {
  67061. /**
  67062. * Uses the GPU to create a copy texture rescaled at a given size
  67063. * @param texture Texture to copy from
  67064. * @param width defines the desired width
  67065. * @param height defines the desired height
  67066. * @param useBilinearMode defines if bilinear mode has to be used
  67067. * @return the generated texture
  67068. */
  67069. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67070. }
  67071. }
  67072. declare module "babylonjs/Misc/videoRecorder" {
  67073. import { Nullable } from "babylonjs/types";
  67074. import { Engine } from "babylonjs/Engines/engine";
  67075. /**
  67076. * This represents the different options available for the video capture.
  67077. */
  67078. export interface VideoRecorderOptions {
  67079. /** Defines the mime type of the video. */
  67080. mimeType: string;
  67081. /** Defines the FPS the video should be recorded at. */
  67082. fps: number;
  67083. /** Defines the chunk size for the recording data. */
  67084. recordChunckSize: number;
  67085. /** The audio tracks to attach to the recording. */
  67086. audioTracks?: MediaStreamTrack[];
  67087. }
  67088. /**
  67089. * This can help with recording videos from BabylonJS.
  67090. * This is based on the available WebRTC functionalities of the browser.
  67091. *
  67092. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67093. */
  67094. export class VideoRecorder {
  67095. private static readonly _defaultOptions;
  67096. /**
  67097. * Returns whether or not the VideoRecorder is available in your browser.
  67098. * @param engine Defines the Babylon Engine.
  67099. * @returns true if supported otherwise false.
  67100. */
  67101. static IsSupported(engine: Engine): boolean;
  67102. private readonly _options;
  67103. private _canvas;
  67104. private _mediaRecorder;
  67105. private _recordedChunks;
  67106. private _fileName;
  67107. private _resolve;
  67108. private _reject;
  67109. /**
  67110. * True when a recording is already in progress.
  67111. */
  67112. readonly isRecording: boolean;
  67113. /**
  67114. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67115. * @param engine Defines the BabylonJS Engine you wish to record.
  67116. * @param options Defines options that can be used to customize the capture.
  67117. */
  67118. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67119. /**
  67120. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67121. */
  67122. stopRecording(): void;
  67123. /**
  67124. * Starts recording the canvas for a max duration specified in parameters.
  67125. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67126. * If null no automatic download will start and you can rely on the promise to get the data back.
  67127. * @param maxDuration Defines the maximum recording time in seconds.
  67128. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67129. * @return A promise callback at the end of the recording with the video data in Blob.
  67130. */
  67131. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67132. /**
  67133. * Releases internal resources used during the recording.
  67134. */
  67135. dispose(): void;
  67136. private _handleDataAvailable;
  67137. private _handleError;
  67138. private _handleStop;
  67139. }
  67140. }
  67141. declare module "babylonjs/Misc/screenshotTools" {
  67142. import { Camera } from "babylonjs/Cameras/camera";
  67143. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67144. import { Engine } from "babylonjs/Engines/engine";
  67145. /**
  67146. * Class containing a set of static utilities functions for screenshots
  67147. */
  67148. export class ScreenshotTools {
  67149. /**
  67150. * Captures a screenshot of the current rendering
  67151. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67152. * @param engine defines the rendering engine
  67153. * @param camera defines the source camera
  67154. * @param size This parameter can be set to a single number or to an object with the
  67155. * following (optional) properties: precision, width, height. If a single number is passed,
  67156. * it will be used for both width and height. If an object is passed, the screenshot size
  67157. * will be derived from the parameters. The precision property is a multiplier allowing
  67158. * rendering at a higher or lower resolution
  67159. * @param successCallback defines the callback receives a single parameter which contains the
  67160. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67161. * src parameter of an <img> to display it
  67162. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67163. * Check your browser for supported MIME types
  67164. */
  67165. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67166. /**
  67167. * Captures a screenshot of the current rendering
  67168. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67169. * @param engine defines the rendering engine
  67170. * @param camera defines the source camera
  67171. * @param size This parameter can be set to a single number or to an object with the
  67172. * following (optional) properties: precision, width, height. If a single number is passed,
  67173. * it will be used for both width and height. If an object is passed, the screenshot size
  67174. * will be derived from the parameters. The precision property is a multiplier allowing
  67175. * rendering at a higher or lower resolution
  67176. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67177. * Check your browser for supported MIME types
  67178. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67179. * to the src parameter of an <img> to display it
  67180. */
  67181. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67182. /**
  67183. * Generates an image screenshot from the specified camera.
  67184. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67185. * @param engine The engine to use for rendering
  67186. * @param camera The camera to use for rendering
  67187. * @param size This parameter can be set to a single number or to an object with the
  67188. * following (optional) properties: precision, width, height. If a single number is passed,
  67189. * it will be used for both width and height. If an object is passed, the screenshot size
  67190. * will be derived from the parameters. The precision property is a multiplier allowing
  67191. * rendering at a higher or lower resolution
  67192. * @param successCallback The callback receives a single parameter which contains the
  67193. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67194. * src parameter of an <img> to display it
  67195. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67196. * Check your browser for supported MIME types
  67197. * @param samples Texture samples (default: 1)
  67198. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67199. * @param fileName A name for for the downloaded file.
  67200. */
  67201. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67202. /**
  67203. * Generates an image screenshot from the specified camera.
  67204. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67205. * @param engine The engine to use for rendering
  67206. * @param camera The camera to use for rendering
  67207. * @param size This parameter can be set to a single number or to an object with the
  67208. * following (optional) properties: precision, width, height. If a single number is passed,
  67209. * it will be used for both width and height. If an object is passed, the screenshot size
  67210. * will be derived from the parameters. The precision property is a multiplier allowing
  67211. * rendering at a higher or lower resolution
  67212. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67213. * Check your browser for supported MIME types
  67214. * @param samples Texture samples (default: 1)
  67215. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67216. * @param fileName A name for for the downloaded file.
  67217. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67218. * to the src parameter of an <img> to display it
  67219. */
  67220. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67221. /**
  67222. * Gets height and width for screenshot size
  67223. * @private
  67224. */
  67225. private static _getScreenshotSize;
  67226. }
  67227. }
  67228. declare module "babylonjs/Misc/index" {
  67229. export * from "babylonjs/Misc/andOrNotEvaluator";
  67230. export * from "babylonjs/Misc/assetsManager";
  67231. export * from "babylonjs/Misc/dds";
  67232. export * from "babylonjs/Misc/decorators";
  67233. export * from "babylonjs/Misc/deferred";
  67234. export * from "babylonjs/Misc/environmentTextureTools";
  67235. export * from "babylonjs/Misc/meshExploder";
  67236. export * from "babylonjs/Misc/filesInput";
  67237. export * from "babylonjs/Misc/HighDynamicRange/index";
  67238. export * from "babylonjs/Misc/khronosTextureContainer";
  67239. export * from "babylonjs/Misc/observable";
  67240. export * from "babylonjs/Misc/performanceMonitor";
  67241. export * from "babylonjs/Misc/promise";
  67242. export * from "babylonjs/Misc/sceneOptimizer";
  67243. export * from "babylonjs/Misc/sceneSerializer";
  67244. export * from "babylonjs/Misc/smartArray";
  67245. export * from "babylonjs/Misc/stringDictionary";
  67246. export * from "babylonjs/Misc/tags";
  67247. export * from "babylonjs/Misc/textureTools";
  67248. export * from "babylonjs/Misc/tga";
  67249. export * from "babylonjs/Misc/tools";
  67250. export * from "babylonjs/Misc/videoRecorder";
  67251. export * from "babylonjs/Misc/virtualJoystick";
  67252. export * from "babylonjs/Misc/workerPool";
  67253. export * from "babylonjs/Misc/logger";
  67254. export * from "babylonjs/Misc/typeStore";
  67255. export * from "babylonjs/Misc/filesInputStore";
  67256. export * from "babylonjs/Misc/deepCopier";
  67257. export * from "babylonjs/Misc/pivotTools";
  67258. export * from "babylonjs/Misc/precisionDate";
  67259. export * from "babylonjs/Misc/screenshotTools";
  67260. export * from "babylonjs/Misc/typeStore";
  67261. export * from "babylonjs/Misc/webRequest";
  67262. export * from "babylonjs/Misc/iInspectable";
  67263. export * from "babylonjs/Misc/brdfTextureTools";
  67264. export * from "babylonjs/Misc/rgbdTextureTools";
  67265. export * from "babylonjs/Misc/gradients";
  67266. export * from "babylonjs/Misc/perfCounter";
  67267. export * from "babylonjs/Misc/fileRequest";
  67268. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67269. export * from "babylonjs/Misc/retryStrategy";
  67270. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67271. export * from "babylonjs/Misc/canvasGenerator";
  67272. export * from "babylonjs/Misc/fileTools";
  67273. export * from "babylonjs/Misc/stringTools";
  67274. }
  67275. declare module "babylonjs/index" {
  67276. export * from "babylonjs/abstractScene";
  67277. export * from "babylonjs/Actions/index";
  67278. export * from "babylonjs/Animations/index";
  67279. export * from "babylonjs/assetContainer";
  67280. export * from "babylonjs/Audio/index";
  67281. export * from "babylonjs/Behaviors/index";
  67282. export * from "babylonjs/Bones/index";
  67283. export * from "babylonjs/Cameras/index";
  67284. export * from "babylonjs/Collisions/index";
  67285. export * from "babylonjs/Culling/index";
  67286. export * from "babylonjs/Debug/index";
  67287. export * from "babylonjs/Engines/index";
  67288. export * from "babylonjs/Events/index";
  67289. export * from "babylonjs/Gamepads/index";
  67290. export * from "babylonjs/Gizmos/index";
  67291. export * from "babylonjs/Helpers/index";
  67292. export * from "babylonjs/Instrumentation/index";
  67293. export * from "babylonjs/Layers/index";
  67294. export * from "babylonjs/LensFlares/index";
  67295. export * from "babylonjs/Lights/index";
  67296. export * from "babylonjs/Loading/index";
  67297. export * from "babylonjs/Materials/index";
  67298. export * from "babylonjs/Maths/index";
  67299. export * from "babylonjs/Meshes/index";
  67300. export * from "babylonjs/Morph/index";
  67301. export * from "babylonjs/Navigation/index";
  67302. export * from "babylonjs/node";
  67303. export * from "babylonjs/Offline/index";
  67304. export * from "babylonjs/Particles/index";
  67305. export * from "babylonjs/Physics/index";
  67306. export * from "babylonjs/PostProcesses/index";
  67307. export * from "babylonjs/Probes/index";
  67308. export * from "babylonjs/Rendering/index";
  67309. export * from "babylonjs/scene";
  67310. export * from "babylonjs/sceneComponent";
  67311. export * from "babylonjs/Sprites/index";
  67312. export * from "babylonjs/States/index";
  67313. export * from "babylonjs/Misc/index";
  67314. export * from "babylonjs/types";
  67315. }
  67316. declare module "babylonjs/Animations/pathCursor" {
  67317. import { Vector3 } from "babylonjs/Maths/math.vector";
  67318. import { Path2 } from "babylonjs/Maths/math.path";
  67319. /**
  67320. * A cursor which tracks a point on a path
  67321. */
  67322. export class PathCursor {
  67323. private path;
  67324. /**
  67325. * Stores path cursor callbacks for when an onchange event is triggered
  67326. */
  67327. private _onchange;
  67328. /**
  67329. * The value of the path cursor
  67330. */
  67331. value: number;
  67332. /**
  67333. * The animation array of the path cursor
  67334. */
  67335. animations: Animation[];
  67336. /**
  67337. * Initializes the path cursor
  67338. * @param path The path to track
  67339. */
  67340. constructor(path: Path2);
  67341. /**
  67342. * Gets the cursor point on the path
  67343. * @returns A point on the path cursor at the cursor location
  67344. */
  67345. getPoint(): Vector3;
  67346. /**
  67347. * Moves the cursor ahead by the step amount
  67348. * @param step The amount to move the cursor forward
  67349. * @returns This path cursor
  67350. */
  67351. moveAhead(step?: number): PathCursor;
  67352. /**
  67353. * Moves the cursor behind by the step amount
  67354. * @param step The amount to move the cursor back
  67355. * @returns This path cursor
  67356. */
  67357. moveBack(step?: number): PathCursor;
  67358. /**
  67359. * Moves the cursor by the step amount
  67360. * If the step amount is greater than one, an exception is thrown
  67361. * @param step The amount to move the cursor
  67362. * @returns This path cursor
  67363. */
  67364. move(step: number): PathCursor;
  67365. /**
  67366. * Ensures that the value is limited between zero and one
  67367. * @returns This path cursor
  67368. */
  67369. private ensureLimits;
  67370. /**
  67371. * Runs onchange callbacks on change (used by the animation engine)
  67372. * @returns This path cursor
  67373. */
  67374. private raiseOnChange;
  67375. /**
  67376. * Executes a function on change
  67377. * @param f A path cursor onchange callback
  67378. * @returns This path cursor
  67379. */
  67380. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67381. }
  67382. }
  67383. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67384. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67385. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67386. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67387. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67388. }
  67389. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67390. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67391. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67392. }
  67393. declare module "babylonjs/Engines/Processors/index" {
  67394. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67395. export * from "babylonjs/Engines/Processors/Expressions/index";
  67396. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67397. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67398. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67399. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67400. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67401. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67402. }
  67403. declare module "babylonjs/Legacy/legacy" {
  67404. import * as Babylon from "babylonjs/index";
  67405. export * from "babylonjs/index";
  67406. }
  67407. declare module "babylonjs/Shaders/blur.fragment" {
  67408. /** @hidden */
  67409. export var blurPixelShader: {
  67410. name: string;
  67411. shader: string;
  67412. };
  67413. }
  67414. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  67415. /** @hidden */
  67416. export var pointCloudVertexDeclaration: {
  67417. name: string;
  67418. shader: string;
  67419. };
  67420. }
  67421. declare module "babylonjs" {
  67422. export * from "babylonjs/Legacy/legacy";
  67423. }
  67424. declare module BABYLON {
  67425. /** Alias type for value that can be null */
  67426. export type Nullable<T> = T | null;
  67427. /**
  67428. * Alias type for number that are floats
  67429. * @ignorenaming
  67430. */
  67431. export type float = number;
  67432. /**
  67433. * Alias type for number that are doubles.
  67434. * @ignorenaming
  67435. */
  67436. export type double = number;
  67437. /**
  67438. * Alias type for number that are integer
  67439. * @ignorenaming
  67440. */
  67441. export type int = number;
  67442. /** Alias type for number array or Float32Array */
  67443. export type FloatArray = number[] | Float32Array;
  67444. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  67445. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  67446. /**
  67447. * Alias for types that can be used by a Buffer or VertexBuffer.
  67448. */
  67449. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  67450. /**
  67451. * Alias type for primitive types
  67452. * @ignorenaming
  67453. */
  67454. type Primitive = undefined | null | boolean | string | number | Function;
  67455. /**
  67456. * Type modifier to make all the properties of an object Readonly
  67457. */
  67458. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  67459. /**
  67460. * Type modifier to make all the properties of an object Readonly recursively
  67461. */
  67462. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  67463. /**
  67464. * Type modifier to make object properties readonly.
  67465. */
  67466. export type DeepImmutableObject<T> = {
  67467. readonly [K in keyof T]: DeepImmutable<T[K]>;
  67468. };
  67469. /** @hidden */
  67470. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  67471. }
  67472. }
  67473. declare module BABYLON {
  67474. /**
  67475. * A class serves as a medium between the observable and its observers
  67476. */
  67477. export class EventState {
  67478. /**
  67479. * Create a new EventState
  67480. * @param mask defines the mask associated with this state
  67481. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67482. * @param target defines the original target of the state
  67483. * @param currentTarget defines the current target of the state
  67484. */
  67485. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67486. /**
  67487. * Initialize the current event state
  67488. * @param mask defines the mask associated with this state
  67489. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67490. * @param target defines the original target of the state
  67491. * @param currentTarget defines the current target of the state
  67492. * @returns the current event state
  67493. */
  67494. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67495. /**
  67496. * An Observer can set this property to true to prevent subsequent observers of being notified
  67497. */
  67498. skipNextObservers: boolean;
  67499. /**
  67500. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67501. */
  67502. mask: number;
  67503. /**
  67504. * The object that originally notified the event
  67505. */
  67506. target?: any;
  67507. /**
  67508. * The current object in the bubbling phase
  67509. */
  67510. currentTarget?: any;
  67511. /**
  67512. * This will be populated with the return value of the last function that was executed.
  67513. * If it is the first function in the callback chain it will be the event data.
  67514. */
  67515. lastReturnValue?: any;
  67516. }
  67517. /**
  67518. * Represent an Observer registered to a given Observable object.
  67519. */
  67520. export class Observer<T> {
  67521. /**
  67522. * Defines the callback to call when the observer is notified
  67523. */
  67524. callback: (eventData: T, eventState: EventState) => void;
  67525. /**
  67526. * Defines the mask of the observer (used to filter notifications)
  67527. */
  67528. mask: number;
  67529. /**
  67530. * Defines the current scope used to restore the JS context
  67531. */
  67532. scope: any;
  67533. /** @hidden */
  67534. _willBeUnregistered: boolean;
  67535. /**
  67536. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67537. */
  67538. unregisterOnNextCall: boolean;
  67539. /**
  67540. * Creates a new observer
  67541. * @param callback defines the callback to call when the observer is notified
  67542. * @param mask defines the mask of the observer (used to filter notifications)
  67543. * @param scope defines the current scope used to restore the JS context
  67544. */
  67545. constructor(
  67546. /**
  67547. * Defines the callback to call when the observer is notified
  67548. */
  67549. callback: (eventData: T, eventState: EventState) => void,
  67550. /**
  67551. * Defines the mask of the observer (used to filter notifications)
  67552. */
  67553. mask: number,
  67554. /**
  67555. * Defines the current scope used to restore the JS context
  67556. */
  67557. scope?: any);
  67558. }
  67559. /**
  67560. * Represent a list of observers registered to multiple Observables object.
  67561. */
  67562. export class MultiObserver<T> {
  67563. private _observers;
  67564. private _observables;
  67565. /**
  67566. * Release associated resources
  67567. */
  67568. dispose(): void;
  67569. /**
  67570. * Raise a callback when one of the observable will notify
  67571. * @param observables defines a list of observables to watch
  67572. * @param callback defines the callback to call on notification
  67573. * @param mask defines the mask used to filter notifications
  67574. * @param scope defines the current scope used to restore the JS context
  67575. * @returns the new MultiObserver
  67576. */
  67577. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67578. }
  67579. /**
  67580. * The Observable class is a simple implementation of the Observable pattern.
  67581. *
  67582. * 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.
  67583. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67584. * 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).
  67585. * 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.
  67586. */
  67587. export class Observable<T> {
  67588. private _observers;
  67589. private _eventState;
  67590. private _onObserverAdded;
  67591. /**
  67592. * Gets the list of observers
  67593. */
  67594. readonly observers: Array<Observer<T>>;
  67595. /**
  67596. * Creates a new observable
  67597. * @param onObserverAdded defines a callback to call when a new observer is added
  67598. */
  67599. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67600. /**
  67601. * Create a new Observer with the specified callback
  67602. * @param callback the callback that will be executed for that Observer
  67603. * @param mask the mask used to filter observers
  67604. * @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.
  67605. * @param scope optional scope for the callback to be called from
  67606. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67607. * @returns the new observer created for the callback
  67608. */
  67609. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67610. /**
  67611. * Create a new Observer with the specified callback and unregisters after the next notification
  67612. * @param callback the callback that will be executed for that Observer
  67613. * @returns the new observer created for the callback
  67614. */
  67615. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67616. /**
  67617. * Remove an Observer from the Observable object
  67618. * @param observer the instance of the Observer to remove
  67619. * @returns false if it doesn't belong to this Observable
  67620. */
  67621. remove(observer: Nullable<Observer<T>>): boolean;
  67622. /**
  67623. * Remove a callback from the Observable object
  67624. * @param callback the callback to remove
  67625. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67626. * @returns false if it doesn't belong to this Observable
  67627. */
  67628. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67629. private _deferUnregister;
  67630. private _remove;
  67631. /**
  67632. * Moves the observable to the top of the observer list making it get called first when notified
  67633. * @param observer the observer to move
  67634. */
  67635. makeObserverTopPriority(observer: Observer<T>): void;
  67636. /**
  67637. * Moves the observable to the bottom of the observer list making it get called last when notified
  67638. * @param observer the observer to move
  67639. */
  67640. makeObserverBottomPriority(observer: Observer<T>): void;
  67641. /**
  67642. * Notify all Observers by calling their respective callback with the given data
  67643. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67644. * @param eventData defines the data to send to all observers
  67645. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67646. * @param target defines the original target of the state
  67647. * @param currentTarget defines the current target of the state
  67648. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67649. */
  67650. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67651. /**
  67652. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67653. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67654. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67655. * and it is crucial that all callbacks will be executed.
  67656. * The order of the callbacks is kept, callbacks are not executed parallel.
  67657. *
  67658. * @param eventData The data to be sent to each callback
  67659. * @param mask is used to filter observers defaults to -1
  67660. * @param target defines the callback target (see EventState)
  67661. * @param currentTarget defines he current object in the bubbling phase
  67662. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67663. */
  67664. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67665. /**
  67666. * Notify a specific observer
  67667. * @param observer defines the observer to notify
  67668. * @param eventData defines the data to be sent to each callback
  67669. * @param mask is used to filter observers defaults to -1
  67670. */
  67671. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67672. /**
  67673. * Gets a boolean indicating if the observable has at least one observer
  67674. * @returns true is the Observable has at least one Observer registered
  67675. */
  67676. hasObservers(): boolean;
  67677. /**
  67678. * Clear the list of observers
  67679. */
  67680. clear(): void;
  67681. /**
  67682. * Clone the current observable
  67683. * @returns a new observable
  67684. */
  67685. clone(): Observable<T>;
  67686. /**
  67687. * Does this observable handles observer registered with a given mask
  67688. * @param mask defines the mask to be tested
  67689. * @return whether or not one observer registered with the given mask is handeled
  67690. **/
  67691. hasSpecificMask(mask?: number): boolean;
  67692. }
  67693. }
  67694. declare module BABYLON {
  67695. /**
  67696. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67697. * Babylon.js
  67698. */
  67699. export class DomManagement {
  67700. /**
  67701. * Checks if the window object exists
  67702. * @returns true if the window object exists
  67703. */
  67704. static IsWindowObjectExist(): boolean;
  67705. /**
  67706. * Checks if the navigator object exists
  67707. * @returns true if the navigator object exists
  67708. */
  67709. static IsNavigatorAvailable(): boolean;
  67710. /**
  67711. * Extracts text content from a DOM element hierarchy
  67712. * @param element defines the root element
  67713. * @returns a string
  67714. */
  67715. static GetDOMTextContent(element: HTMLElement): string;
  67716. }
  67717. }
  67718. declare module BABYLON {
  67719. /**
  67720. * Logger used througouht the application to allow configuration of
  67721. * the log level required for the messages.
  67722. */
  67723. export class Logger {
  67724. /**
  67725. * No log
  67726. */
  67727. static readonly NoneLogLevel: number;
  67728. /**
  67729. * Only message logs
  67730. */
  67731. static readonly MessageLogLevel: number;
  67732. /**
  67733. * Only warning logs
  67734. */
  67735. static readonly WarningLogLevel: number;
  67736. /**
  67737. * Only error logs
  67738. */
  67739. static readonly ErrorLogLevel: number;
  67740. /**
  67741. * All logs
  67742. */
  67743. static readonly AllLogLevel: number;
  67744. private static _LogCache;
  67745. /**
  67746. * Gets a value indicating the number of loading errors
  67747. * @ignorenaming
  67748. */
  67749. static errorsCount: number;
  67750. /**
  67751. * Callback called when a new log is added
  67752. */
  67753. static OnNewCacheEntry: (entry: string) => void;
  67754. private static _AddLogEntry;
  67755. private static _FormatMessage;
  67756. private static _LogDisabled;
  67757. private static _LogEnabled;
  67758. private static _WarnDisabled;
  67759. private static _WarnEnabled;
  67760. private static _ErrorDisabled;
  67761. private static _ErrorEnabled;
  67762. /**
  67763. * Log a message to the console
  67764. */
  67765. static Log: (message: string) => void;
  67766. /**
  67767. * Write a warning message to the console
  67768. */
  67769. static Warn: (message: string) => void;
  67770. /**
  67771. * Write an error message to the console
  67772. */
  67773. static Error: (message: string) => void;
  67774. /**
  67775. * Gets current log cache (list of logs)
  67776. */
  67777. static readonly LogCache: string;
  67778. /**
  67779. * Clears the log cache
  67780. */
  67781. static ClearLogCache(): void;
  67782. /**
  67783. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67784. */
  67785. static LogLevels: number;
  67786. }
  67787. }
  67788. declare module BABYLON {
  67789. /** @hidden */
  67790. export class _TypeStore {
  67791. /** @hidden */
  67792. static RegisteredTypes: {
  67793. [key: string]: Object;
  67794. };
  67795. /** @hidden */
  67796. static GetClass(fqdn: string): any;
  67797. }
  67798. }
  67799. declare module BABYLON {
  67800. /**
  67801. * Class containing a set of static utilities functions for deep copy.
  67802. */
  67803. export class DeepCopier {
  67804. /**
  67805. * Tries to copy an object by duplicating every property
  67806. * @param source defines the source object
  67807. * @param destination defines the target object
  67808. * @param doNotCopyList defines a list of properties to avoid
  67809. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67810. */
  67811. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67812. }
  67813. }
  67814. declare module BABYLON {
  67815. /**
  67816. * Class containing a set of static utilities functions for precision date
  67817. */
  67818. export class PrecisionDate {
  67819. /**
  67820. * Gets either window.performance.now() if supported or Date.now() else
  67821. */
  67822. static readonly Now: number;
  67823. }
  67824. }
  67825. declare module BABYLON {
  67826. /** @hidden */
  67827. export class _DevTools {
  67828. static WarnImport(name: string): string;
  67829. }
  67830. }
  67831. declare module BABYLON {
  67832. /**
  67833. * Interface used to define the mechanism to get data from the network
  67834. */
  67835. export interface IWebRequest {
  67836. /**
  67837. * Returns client's response url
  67838. */
  67839. responseURL: string;
  67840. /**
  67841. * Returns client's status
  67842. */
  67843. status: number;
  67844. /**
  67845. * Returns client's status as a text
  67846. */
  67847. statusText: string;
  67848. }
  67849. }
  67850. declare module BABYLON {
  67851. /**
  67852. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67853. */
  67854. export class WebRequest implements IWebRequest {
  67855. private _xhr;
  67856. /**
  67857. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67858. * i.e. when loading files, where the server/service expects an Authorization header
  67859. */
  67860. static CustomRequestHeaders: {
  67861. [key: string]: string;
  67862. };
  67863. /**
  67864. * Add callback functions in this array to update all the requests before they get sent to the network
  67865. */
  67866. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67867. private _injectCustomRequestHeaders;
  67868. /**
  67869. * Gets or sets a function to be called when loading progress changes
  67870. */
  67871. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67872. /**
  67873. * Returns client's state
  67874. */
  67875. readonly readyState: number;
  67876. /**
  67877. * Returns client's status
  67878. */
  67879. readonly status: number;
  67880. /**
  67881. * Returns client's status as a text
  67882. */
  67883. readonly statusText: string;
  67884. /**
  67885. * Returns client's response
  67886. */
  67887. readonly response: any;
  67888. /**
  67889. * Returns client's response url
  67890. */
  67891. readonly responseURL: string;
  67892. /**
  67893. * Returns client's response as text
  67894. */
  67895. readonly responseText: string;
  67896. /**
  67897. * Gets or sets the expected response type
  67898. */
  67899. responseType: XMLHttpRequestResponseType;
  67900. /** @hidden */
  67901. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67902. /** @hidden */
  67903. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67904. /**
  67905. * Cancels any network activity
  67906. */
  67907. abort(): void;
  67908. /**
  67909. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67910. * @param body defines an optional request body
  67911. */
  67912. send(body?: Document | BodyInit | null): void;
  67913. /**
  67914. * Sets the request method, request URL
  67915. * @param method defines the method to use (GET, POST, etc..)
  67916. * @param url defines the url to connect with
  67917. */
  67918. open(method: string, url: string): void;
  67919. /**
  67920. * Sets the value of a request header.
  67921. * @param name The name of the header whose value is to be set
  67922. * @param value The value to set as the body of the header
  67923. */
  67924. setRequestHeader(name: string, value: string): void;
  67925. /**
  67926. * Get the string containing the text of a particular header's value.
  67927. * @param name The name of the header
  67928. * @returns The string containing the text of the given header name
  67929. */
  67930. getResponseHeader(name: string): Nullable<string>;
  67931. }
  67932. }
  67933. declare module BABYLON {
  67934. /**
  67935. * File request interface
  67936. */
  67937. export interface IFileRequest {
  67938. /**
  67939. * Raised when the request is complete (success or error).
  67940. */
  67941. onCompleteObservable: Observable<IFileRequest>;
  67942. /**
  67943. * Aborts the request for a file.
  67944. */
  67945. abort: () => void;
  67946. }
  67947. }
  67948. declare module BABYLON {
  67949. /**
  67950. * Define options used to create a render target texture
  67951. */
  67952. export class RenderTargetCreationOptions {
  67953. /**
  67954. * Specifies is mipmaps must be generated
  67955. */
  67956. generateMipMaps?: boolean;
  67957. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67958. generateDepthBuffer?: boolean;
  67959. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67960. generateStencilBuffer?: boolean;
  67961. /** Defines texture type (int by default) */
  67962. type?: number;
  67963. /** Defines sampling mode (trilinear by default) */
  67964. samplingMode?: number;
  67965. /** Defines format (RGBA by default) */
  67966. format?: number;
  67967. }
  67968. }
  67969. declare module BABYLON {
  67970. /**
  67971. * @hidden
  67972. **/
  67973. export class _TimeToken {
  67974. _startTimeQuery: Nullable<WebGLQuery>;
  67975. _endTimeQuery: Nullable<WebGLQuery>;
  67976. _timeElapsedQuery: Nullable<WebGLQuery>;
  67977. _timeElapsedQueryEnded: boolean;
  67978. }
  67979. }
  67980. declare module BABYLON {
  67981. /** Defines the cross module used constants to avoid circular dependncies */
  67982. export class Constants {
  67983. /** Defines that alpha blending is disabled */
  67984. static readonly ALPHA_DISABLE: number;
  67985. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67986. static readonly ALPHA_ADD: number;
  67987. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67988. static readonly ALPHA_COMBINE: number;
  67989. /** Defines that alpha blending to DEST - SRC * DEST */
  67990. static readonly ALPHA_SUBTRACT: number;
  67991. /** Defines that alpha blending to SRC * DEST */
  67992. static readonly ALPHA_MULTIPLY: number;
  67993. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67994. static readonly ALPHA_MAXIMIZED: number;
  67995. /** Defines that alpha blending to SRC + DEST */
  67996. static readonly ALPHA_ONEONE: number;
  67997. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67998. static readonly ALPHA_PREMULTIPLIED: number;
  67999. /**
  68000. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68001. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68002. */
  68003. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68004. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68005. static readonly ALPHA_INTERPOLATE: number;
  68006. /**
  68007. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68008. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68009. */
  68010. static readonly ALPHA_SCREENMODE: number;
  68011. /**
  68012. * Defines that alpha blending to SRC + DST
  68013. * Alpha will be set to SRC ALPHA + DST ALPHA
  68014. */
  68015. static readonly ALPHA_ONEONE_ONEONE: number;
  68016. /**
  68017. * Defines that alpha blending to SRC * DST ALPHA + DST
  68018. * Alpha will be set to 0
  68019. */
  68020. static readonly ALPHA_ALPHATOCOLOR: number;
  68021. /**
  68022. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68023. */
  68024. static readonly ALPHA_REVERSEONEMINUS: number;
  68025. /**
  68026. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68027. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68028. */
  68029. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68030. /**
  68031. * Defines that alpha blending to SRC + DST
  68032. * Alpha will be set to SRC ALPHA
  68033. */
  68034. static readonly ALPHA_ONEONE_ONEZERO: number;
  68035. /** Defines that alpha blending equation a SUM */
  68036. static readonly ALPHA_EQUATION_ADD: number;
  68037. /** Defines that alpha blending equation a SUBSTRACTION */
  68038. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68039. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68040. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68041. /** Defines that alpha blending equation a MAX operation */
  68042. static readonly ALPHA_EQUATION_MAX: number;
  68043. /** Defines that alpha blending equation a MIN operation */
  68044. static readonly ALPHA_EQUATION_MIN: number;
  68045. /**
  68046. * Defines that alpha blending equation a DARKEN operation:
  68047. * It takes the min of the src and sums the alpha channels.
  68048. */
  68049. static readonly ALPHA_EQUATION_DARKEN: number;
  68050. /** Defines that the ressource is not delayed*/
  68051. static readonly DELAYLOADSTATE_NONE: number;
  68052. /** Defines that the ressource was successfully delay loaded */
  68053. static readonly DELAYLOADSTATE_LOADED: number;
  68054. /** Defines that the ressource is currently delay loading */
  68055. static readonly DELAYLOADSTATE_LOADING: number;
  68056. /** Defines that the ressource is delayed and has not started loading */
  68057. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68058. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68059. static readonly NEVER: number;
  68060. /** 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 */
  68061. static readonly ALWAYS: number;
  68062. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68063. static readonly LESS: number;
  68064. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68065. static readonly EQUAL: number;
  68066. /** 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 */
  68067. static readonly LEQUAL: number;
  68068. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68069. static readonly GREATER: number;
  68070. /** 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 */
  68071. static readonly GEQUAL: number;
  68072. /** 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 */
  68073. static readonly NOTEQUAL: number;
  68074. /** Passed to stencilOperation to specify that stencil value must be kept */
  68075. static readonly KEEP: number;
  68076. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68077. static readonly REPLACE: number;
  68078. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68079. static readonly INCR: number;
  68080. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68081. static readonly DECR: number;
  68082. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68083. static readonly INVERT: number;
  68084. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68085. static readonly INCR_WRAP: number;
  68086. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68087. static readonly DECR_WRAP: number;
  68088. /** Texture is not repeating outside of 0..1 UVs */
  68089. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68090. /** Texture is repeating outside of 0..1 UVs */
  68091. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68092. /** Texture is repeating and mirrored */
  68093. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68094. /** ALPHA */
  68095. static readonly TEXTUREFORMAT_ALPHA: number;
  68096. /** LUMINANCE */
  68097. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68098. /** LUMINANCE_ALPHA */
  68099. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68100. /** RGB */
  68101. static readonly TEXTUREFORMAT_RGB: number;
  68102. /** RGBA */
  68103. static readonly TEXTUREFORMAT_RGBA: number;
  68104. /** RED */
  68105. static readonly TEXTUREFORMAT_RED: number;
  68106. /** RED (2nd reference) */
  68107. static readonly TEXTUREFORMAT_R: number;
  68108. /** RG */
  68109. static readonly TEXTUREFORMAT_RG: number;
  68110. /** RED_INTEGER */
  68111. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68112. /** RED_INTEGER (2nd reference) */
  68113. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68114. /** RG_INTEGER */
  68115. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68116. /** RGB_INTEGER */
  68117. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68118. /** RGBA_INTEGER */
  68119. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68120. /** UNSIGNED_BYTE */
  68121. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68122. /** UNSIGNED_BYTE (2nd reference) */
  68123. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68124. /** FLOAT */
  68125. static readonly TEXTURETYPE_FLOAT: number;
  68126. /** HALF_FLOAT */
  68127. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68128. /** BYTE */
  68129. static readonly TEXTURETYPE_BYTE: number;
  68130. /** SHORT */
  68131. static readonly TEXTURETYPE_SHORT: number;
  68132. /** UNSIGNED_SHORT */
  68133. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68134. /** INT */
  68135. static readonly TEXTURETYPE_INT: number;
  68136. /** UNSIGNED_INT */
  68137. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68138. /** UNSIGNED_SHORT_4_4_4_4 */
  68139. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68140. /** UNSIGNED_SHORT_5_5_5_1 */
  68141. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68142. /** UNSIGNED_SHORT_5_6_5 */
  68143. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68144. /** UNSIGNED_INT_2_10_10_10_REV */
  68145. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68146. /** UNSIGNED_INT_24_8 */
  68147. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68148. /** UNSIGNED_INT_10F_11F_11F_REV */
  68149. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68150. /** UNSIGNED_INT_5_9_9_9_REV */
  68151. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68152. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68153. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68154. /** nearest is mag = nearest and min = nearest and mip = linear */
  68155. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68156. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68157. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68158. /** Trilinear is mag = linear and min = linear and mip = linear */
  68159. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68160. /** nearest is mag = nearest and min = nearest and mip = linear */
  68161. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68162. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68163. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68164. /** Trilinear is mag = linear and min = linear and mip = linear */
  68165. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68166. /** mag = nearest and min = nearest and mip = nearest */
  68167. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68168. /** mag = nearest and min = linear and mip = nearest */
  68169. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68170. /** mag = nearest and min = linear and mip = linear */
  68171. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68172. /** mag = nearest and min = linear and mip = none */
  68173. static readonly TEXTURE_NEAREST_LINEAR: number;
  68174. /** mag = nearest and min = nearest and mip = none */
  68175. static readonly TEXTURE_NEAREST_NEAREST: number;
  68176. /** mag = linear and min = nearest and mip = nearest */
  68177. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68178. /** mag = linear and min = nearest and mip = linear */
  68179. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68180. /** mag = linear and min = linear and mip = none */
  68181. static readonly TEXTURE_LINEAR_LINEAR: number;
  68182. /** mag = linear and min = nearest and mip = none */
  68183. static readonly TEXTURE_LINEAR_NEAREST: number;
  68184. /** Explicit coordinates mode */
  68185. static readonly TEXTURE_EXPLICIT_MODE: number;
  68186. /** Spherical coordinates mode */
  68187. static readonly TEXTURE_SPHERICAL_MODE: number;
  68188. /** Planar coordinates mode */
  68189. static readonly TEXTURE_PLANAR_MODE: number;
  68190. /** Cubic coordinates mode */
  68191. static readonly TEXTURE_CUBIC_MODE: number;
  68192. /** Projection coordinates mode */
  68193. static readonly TEXTURE_PROJECTION_MODE: number;
  68194. /** Skybox coordinates mode */
  68195. static readonly TEXTURE_SKYBOX_MODE: number;
  68196. /** Inverse Cubic coordinates mode */
  68197. static readonly TEXTURE_INVCUBIC_MODE: number;
  68198. /** Equirectangular coordinates mode */
  68199. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68200. /** Equirectangular Fixed coordinates mode */
  68201. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68202. /** Equirectangular Fixed Mirrored coordinates mode */
  68203. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68204. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68205. static readonly SCALEMODE_FLOOR: number;
  68206. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68207. static readonly SCALEMODE_NEAREST: number;
  68208. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68209. static readonly SCALEMODE_CEILING: number;
  68210. /**
  68211. * The dirty texture flag value
  68212. */
  68213. static readonly MATERIAL_TextureDirtyFlag: number;
  68214. /**
  68215. * The dirty light flag value
  68216. */
  68217. static readonly MATERIAL_LightDirtyFlag: number;
  68218. /**
  68219. * The dirty fresnel flag value
  68220. */
  68221. static readonly MATERIAL_FresnelDirtyFlag: number;
  68222. /**
  68223. * The dirty attribute flag value
  68224. */
  68225. static readonly MATERIAL_AttributesDirtyFlag: number;
  68226. /**
  68227. * The dirty misc flag value
  68228. */
  68229. static readonly MATERIAL_MiscDirtyFlag: number;
  68230. /**
  68231. * The all dirty flag value
  68232. */
  68233. static readonly MATERIAL_AllDirtyFlag: number;
  68234. /**
  68235. * Returns the triangle fill mode
  68236. */
  68237. static readonly MATERIAL_TriangleFillMode: number;
  68238. /**
  68239. * Returns the wireframe mode
  68240. */
  68241. static readonly MATERIAL_WireFrameFillMode: number;
  68242. /**
  68243. * Returns the point fill mode
  68244. */
  68245. static readonly MATERIAL_PointFillMode: number;
  68246. /**
  68247. * Returns the point list draw mode
  68248. */
  68249. static readonly MATERIAL_PointListDrawMode: number;
  68250. /**
  68251. * Returns the line list draw mode
  68252. */
  68253. static readonly MATERIAL_LineListDrawMode: number;
  68254. /**
  68255. * Returns the line loop draw mode
  68256. */
  68257. static readonly MATERIAL_LineLoopDrawMode: number;
  68258. /**
  68259. * Returns the line strip draw mode
  68260. */
  68261. static readonly MATERIAL_LineStripDrawMode: number;
  68262. /**
  68263. * Returns the triangle strip draw mode
  68264. */
  68265. static readonly MATERIAL_TriangleStripDrawMode: number;
  68266. /**
  68267. * Returns the triangle fan draw mode
  68268. */
  68269. static readonly MATERIAL_TriangleFanDrawMode: number;
  68270. /**
  68271. * Stores the clock-wise side orientation
  68272. */
  68273. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68274. /**
  68275. * Stores the counter clock-wise side orientation
  68276. */
  68277. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68278. /**
  68279. * Nothing
  68280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68281. */
  68282. static readonly ACTION_NothingTrigger: number;
  68283. /**
  68284. * On pick
  68285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68286. */
  68287. static readonly ACTION_OnPickTrigger: number;
  68288. /**
  68289. * On left pick
  68290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68291. */
  68292. static readonly ACTION_OnLeftPickTrigger: number;
  68293. /**
  68294. * On right pick
  68295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68296. */
  68297. static readonly ACTION_OnRightPickTrigger: number;
  68298. /**
  68299. * On center pick
  68300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68301. */
  68302. static readonly ACTION_OnCenterPickTrigger: number;
  68303. /**
  68304. * On pick down
  68305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68306. */
  68307. static readonly ACTION_OnPickDownTrigger: number;
  68308. /**
  68309. * On double pick
  68310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68311. */
  68312. static readonly ACTION_OnDoublePickTrigger: number;
  68313. /**
  68314. * On pick up
  68315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68316. */
  68317. static readonly ACTION_OnPickUpTrigger: number;
  68318. /**
  68319. * On pick out.
  68320. * This trigger will only be raised if you also declared a OnPickDown
  68321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68322. */
  68323. static readonly ACTION_OnPickOutTrigger: number;
  68324. /**
  68325. * On long press
  68326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68327. */
  68328. static readonly ACTION_OnLongPressTrigger: number;
  68329. /**
  68330. * On pointer over
  68331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68332. */
  68333. static readonly ACTION_OnPointerOverTrigger: number;
  68334. /**
  68335. * On pointer out
  68336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68337. */
  68338. static readonly ACTION_OnPointerOutTrigger: number;
  68339. /**
  68340. * On every frame
  68341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68342. */
  68343. static readonly ACTION_OnEveryFrameTrigger: number;
  68344. /**
  68345. * On intersection enter
  68346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68347. */
  68348. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68349. /**
  68350. * On intersection exit
  68351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68352. */
  68353. static readonly ACTION_OnIntersectionExitTrigger: number;
  68354. /**
  68355. * On key down
  68356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68357. */
  68358. static readonly ACTION_OnKeyDownTrigger: number;
  68359. /**
  68360. * On key up
  68361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68362. */
  68363. static readonly ACTION_OnKeyUpTrigger: number;
  68364. /**
  68365. * Billboard mode will only apply to Y axis
  68366. */
  68367. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68368. /**
  68369. * Billboard mode will apply to all axes
  68370. */
  68371. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68372. /**
  68373. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68374. */
  68375. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68376. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68377. * Test order :
  68378. * Is the bounding sphere outside the frustum ?
  68379. * If not, are the bounding box vertices outside the frustum ?
  68380. * It not, then the cullable object is in the frustum.
  68381. */
  68382. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68383. /** Culling strategy : Bounding Sphere Only.
  68384. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68385. * It's also less accurate than the standard because some not visible objects can still be selected.
  68386. * Test : is the bounding sphere outside the frustum ?
  68387. * If not, then the cullable object is in the frustum.
  68388. */
  68389. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68390. /** Culling strategy : Optimistic Inclusion.
  68391. * This in an inclusion test first, then the standard exclusion test.
  68392. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68393. * 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.
  68394. * Anyway, it's as accurate as the standard strategy.
  68395. * Test :
  68396. * Is the cullable object bounding sphere center in the frustum ?
  68397. * If not, apply the default culling strategy.
  68398. */
  68399. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68400. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68401. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68402. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68403. * 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.
  68404. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68405. * Test :
  68406. * Is the cullable object bounding sphere center in the frustum ?
  68407. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68408. */
  68409. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68410. /**
  68411. * No logging while loading
  68412. */
  68413. static readonly SCENELOADER_NO_LOGGING: number;
  68414. /**
  68415. * Minimal logging while loading
  68416. */
  68417. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68418. /**
  68419. * Summary logging while loading
  68420. */
  68421. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68422. /**
  68423. * Detailled logging while loading
  68424. */
  68425. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68426. }
  68427. }
  68428. declare module BABYLON {
  68429. /**
  68430. * This represents the required contract to create a new type of texture loader.
  68431. */
  68432. export interface IInternalTextureLoader {
  68433. /**
  68434. * Defines wether the loader supports cascade loading the different faces.
  68435. */
  68436. supportCascades: boolean;
  68437. /**
  68438. * This returns if the loader support the current file information.
  68439. * @param extension defines the file extension of the file being loaded
  68440. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68441. * @param fallback defines the fallback internal texture if any
  68442. * @param isBase64 defines whether the texture is encoded as a base64
  68443. * @param isBuffer defines whether the texture data are stored as a buffer
  68444. * @returns true if the loader can load the specified file
  68445. */
  68446. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68447. /**
  68448. * Transform the url before loading if required.
  68449. * @param rootUrl the url of the texture
  68450. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68451. * @returns the transformed texture
  68452. */
  68453. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68454. /**
  68455. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68456. * @param rootUrl the url of the texture
  68457. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68458. * @returns the fallback texture
  68459. */
  68460. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68461. /**
  68462. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68463. * @param data contains the texture data
  68464. * @param texture defines the BabylonJS internal texture
  68465. * @param createPolynomials will be true if polynomials have been requested
  68466. * @param onLoad defines the callback to trigger once the texture is ready
  68467. * @param onError defines the callback to trigger in case of error
  68468. */
  68469. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68470. /**
  68471. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68472. * @param data contains the texture data
  68473. * @param texture defines the BabylonJS internal texture
  68474. * @param callback defines the method to call once ready to upload
  68475. */
  68476. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68477. }
  68478. }
  68479. declare module BABYLON {
  68480. /**
  68481. * Class used to store and describe the pipeline context associated with an effect
  68482. */
  68483. export interface IPipelineContext {
  68484. /**
  68485. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68486. */
  68487. isAsync: boolean;
  68488. /**
  68489. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68490. */
  68491. isReady: boolean;
  68492. /** @hidden */
  68493. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68494. }
  68495. }
  68496. declare module BABYLON {
  68497. /**
  68498. * Class used to store gfx data (like WebGLBuffer)
  68499. */
  68500. export class DataBuffer {
  68501. /**
  68502. * Gets or sets the number of objects referencing this buffer
  68503. */
  68504. references: number;
  68505. /** Gets or sets the size of the underlying buffer */
  68506. capacity: number;
  68507. /**
  68508. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68509. */
  68510. is32Bits: boolean;
  68511. /**
  68512. * Gets the underlying buffer
  68513. */
  68514. readonly underlyingResource: any;
  68515. }
  68516. }
  68517. declare module BABYLON {
  68518. /** @hidden */
  68519. export interface IShaderProcessor {
  68520. attributeProcessor?: (attribute: string) => string;
  68521. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68522. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68523. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68524. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68525. lineProcessor?: (line: string, isFragment: boolean) => string;
  68526. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68527. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68528. }
  68529. }
  68530. declare module BABYLON {
  68531. /** @hidden */
  68532. export interface ProcessingOptions {
  68533. defines: string[];
  68534. indexParameters: any;
  68535. isFragment: boolean;
  68536. shouldUseHighPrecisionShader: boolean;
  68537. supportsUniformBuffers: boolean;
  68538. shadersRepository: string;
  68539. includesShadersStore: {
  68540. [key: string]: string;
  68541. };
  68542. processor?: IShaderProcessor;
  68543. version: string;
  68544. platformName: string;
  68545. lookForClosingBracketForUniformBuffer?: boolean;
  68546. }
  68547. }
  68548. declare module BABYLON {
  68549. /**
  68550. * Helper to manipulate strings
  68551. */
  68552. export class StringTools {
  68553. /**
  68554. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68555. * @param str Source string
  68556. * @param suffix Suffix to search for in the source string
  68557. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68558. */
  68559. static EndsWith(str: string, suffix: string): boolean;
  68560. /**
  68561. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68562. * @param str Source string
  68563. * @param suffix Suffix to search for in the source string
  68564. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68565. */
  68566. static StartsWith(str: string, suffix: string): boolean;
  68567. /**
  68568. * Decodes a buffer into a string
  68569. * @param buffer The buffer to decode
  68570. * @returns The decoded string
  68571. */
  68572. static Decode(buffer: Uint8Array | Uint16Array): string;
  68573. }
  68574. }
  68575. declare module BABYLON {
  68576. /** @hidden */
  68577. export class ShaderCodeNode {
  68578. line: string;
  68579. children: ShaderCodeNode[];
  68580. additionalDefineKey?: string;
  68581. additionalDefineValue?: string;
  68582. isValid(preprocessors: {
  68583. [key: string]: string;
  68584. }): boolean;
  68585. process(preprocessors: {
  68586. [key: string]: string;
  68587. }, options: ProcessingOptions): string;
  68588. }
  68589. }
  68590. declare module BABYLON {
  68591. /** @hidden */
  68592. export class ShaderCodeCursor {
  68593. private _lines;
  68594. lineIndex: number;
  68595. readonly currentLine: string;
  68596. readonly canRead: boolean;
  68597. lines: string[];
  68598. }
  68599. }
  68600. declare module BABYLON {
  68601. /** @hidden */
  68602. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68603. process(preprocessors: {
  68604. [key: string]: string;
  68605. }, options: ProcessingOptions): string;
  68606. }
  68607. }
  68608. declare module BABYLON {
  68609. /** @hidden */
  68610. export class ShaderDefineExpression {
  68611. isTrue(preprocessors: {
  68612. [key: string]: string;
  68613. }): boolean;
  68614. }
  68615. }
  68616. declare module BABYLON {
  68617. /** @hidden */
  68618. export class ShaderCodeTestNode extends ShaderCodeNode {
  68619. testExpression: ShaderDefineExpression;
  68620. isValid(preprocessors: {
  68621. [key: string]: string;
  68622. }): boolean;
  68623. }
  68624. }
  68625. declare module BABYLON {
  68626. /** @hidden */
  68627. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68628. define: string;
  68629. not: boolean;
  68630. constructor(define: string, not?: boolean);
  68631. isTrue(preprocessors: {
  68632. [key: string]: string;
  68633. }): boolean;
  68634. }
  68635. }
  68636. declare module BABYLON {
  68637. /** @hidden */
  68638. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68639. leftOperand: ShaderDefineExpression;
  68640. rightOperand: ShaderDefineExpression;
  68641. isTrue(preprocessors: {
  68642. [key: string]: string;
  68643. }): boolean;
  68644. }
  68645. }
  68646. declare module BABYLON {
  68647. /** @hidden */
  68648. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68649. leftOperand: ShaderDefineExpression;
  68650. rightOperand: ShaderDefineExpression;
  68651. isTrue(preprocessors: {
  68652. [key: string]: string;
  68653. }): boolean;
  68654. }
  68655. }
  68656. declare module BABYLON {
  68657. /** @hidden */
  68658. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68659. define: string;
  68660. operand: string;
  68661. testValue: string;
  68662. constructor(define: string, operand: string, testValue: string);
  68663. isTrue(preprocessors: {
  68664. [key: string]: string;
  68665. }): boolean;
  68666. }
  68667. }
  68668. declare module BABYLON {
  68669. /**
  68670. * Class used to enable access to offline support
  68671. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68672. */
  68673. export interface IOfflineProvider {
  68674. /**
  68675. * Gets a boolean indicating if scene must be saved in the database
  68676. */
  68677. enableSceneOffline: boolean;
  68678. /**
  68679. * Gets a boolean indicating if textures must be saved in the database
  68680. */
  68681. enableTexturesOffline: boolean;
  68682. /**
  68683. * Open the offline support and make it available
  68684. * @param successCallback defines the callback to call on success
  68685. * @param errorCallback defines the callback to call on error
  68686. */
  68687. open(successCallback: () => void, errorCallback: () => void): void;
  68688. /**
  68689. * Loads an image from the offline support
  68690. * @param url defines the url to load from
  68691. * @param image defines the target DOM image
  68692. */
  68693. loadImage(url: string, image: HTMLImageElement): void;
  68694. /**
  68695. * Loads a file from offline support
  68696. * @param url defines the URL to load from
  68697. * @param sceneLoaded defines a callback to call on success
  68698. * @param progressCallBack defines a callback to call when progress changed
  68699. * @param errorCallback defines a callback to call on error
  68700. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68701. */
  68702. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68703. }
  68704. }
  68705. declare module BABYLON {
  68706. /**
  68707. * Class used to help managing file picking and drag'n'drop
  68708. * File Storage
  68709. */
  68710. export class FilesInputStore {
  68711. /**
  68712. * List of files ready to be loaded
  68713. */
  68714. static FilesToLoad: {
  68715. [key: string]: File;
  68716. };
  68717. }
  68718. }
  68719. declare module BABYLON {
  68720. /**
  68721. * Class used to define a retry strategy when error happens while loading assets
  68722. */
  68723. export class RetryStrategy {
  68724. /**
  68725. * Function used to defines an exponential back off strategy
  68726. * @param maxRetries defines the maximum number of retries (3 by default)
  68727. * @param baseInterval defines the interval between retries
  68728. * @returns the strategy function to use
  68729. */
  68730. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68731. }
  68732. }
  68733. declare module BABYLON {
  68734. /**
  68735. * @ignore
  68736. * Application error to support additional information when loading a file
  68737. */
  68738. export abstract class BaseError extends Error {
  68739. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  68740. }
  68741. }
  68742. declare module BABYLON {
  68743. /** @ignore */
  68744. export class LoadFileError extends BaseError {
  68745. request?: WebRequest;
  68746. file?: File;
  68747. /**
  68748. * Creates a new LoadFileError
  68749. * @param message defines the message of the error
  68750. * @param request defines the optional web request
  68751. * @param file defines the optional file
  68752. */
  68753. constructor(message: string, object?: WebRequest | File);
  68754. }
  68755. /** @ignore */
  68756. export class RequestFileError extends BaseError {
  68757. request: WebRequest;
  68758. /**
  68759. * Creates a new LoadFileError
  68760. * @param message defines the message of the error
  68761. * @param request defines the optional web request
  68762. */
  68763. constructor(message: string, request: WebRequest);
  68764. }
  68765. /** @ignore */
  68766. export class ReadFileError extends BaseError {
  68767. file: File;
  68768. /**
  68769. * Creates a new ReadFileError
  68770. * @param message defines the message of the error
  68771. * @param file defines the optional file
  68772. */
  68773. constructor(message: string, file: File);
  68774. }
  68775. /**
  68776. * @hidden
  68777. */
  68778. export class FileTools {
  68779. /**
  68780. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68781. */
  68782. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68783. /**
  68784. * Gets or sets the base URL to use to load assets
  68785. */
  68786. static BaseUrl: string;
  68787. /**
  68788. * Default behaviour for cors in the application.
  68789. * It can be a string if the expected behavior is identical in the entire app.
  68790. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68791. */
  68792. static CorsBehavior: string | ((url: string | string[]) => string);
  68793. /**
  68794. * Gets or sets a function used to pre-process url before using them to load assets
  68795. */
  68796. static PreprocessUrl: (url: string) => string;
  68797. /**
  68798. * Removes unwanted characters from an url
  68799. * @param url defines the url to clean
  68800. * @returns the cleaned url
  68801. */
  68802. private static _CleanUrl;
  68803. /**
  68804. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68805. * @param url define the url we are trying
  68806. * @param element define the dom element where to configure the cors policy
  68807. */
  68808. static SetCorsBehavior(url: string | string[], element: {
  68809. crossOrigin: string | null;
  68810. }): void;
  68811. /**
  68812. * Encode an array buffer into a base64 string
  68813. * @param buffer defines the buffer to encode
  68814. * @returns a string containing the base64 version of the buffer
  68815. */
  68816. static ArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68817. /**
  68818. * Loads an image as an HTMLImageElement.
  68819. * @param input url string, ArrayBuffer, or Blob to load
  68820. * @param onLoad callback called when the image successfully loads
  68821. * @param onError callback called when the image fails to load
  68822. * @param offlineProvider offline provider for caching
  68823. * @param mimeType optional mime type
  68824. * @returns the HTMLImageElement of the loaded image
  68825. */
  68826. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  68827. /**
  68828. * Reads a file from a File object
  68829. * @param file defines the file to load
  68830. * @param onSuccess defines the callback to call when data is loaded
  68831. * @param onProgress defines the callback to call during loading process
  68832. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68833. * @param onError defines the callback to call when an error occurs
  68834. * @returns a file request object
  68835. */
  68836. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  68837. /**
  68838. * Loads a file from a url
  68839. * @param url url to load
  68840. * @param onSuccess callback called when the file successfully loads
  68841. * @param onProgress callback called while file is loading (if the server supports this mode)
  68842. * @param offlineProvider defines the offline provider for caching
  68843. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68844. * @param onError callback called when the file fails to load
  68845. * @returns a file request object
  68846. */
  68847. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  68848. /**
  68849. * Loads a file
  68850. * @param url url to load
  68851. * @param onSuccess callback called when the file successfully loads
  68852. * @param onProgress callback called while file is loading (if the server supports this mode)
  68853. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68854. * @param onError callback called when the file fails to load
  68855. * @param onOpened callback called when the web request is opened
  68856. * @returns a file request object
  68857. */
  68858. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  68859. /**
  68860. * Checks if the loaded document was accessed via `file:`-Protocol.
  68861. * @returns boolean
  68862. */
  68863. static IsFileURL(): boolean;
  68864. }
  68865. }
  68866. declare module BABYLON {
  68867. /** @hidden */
  68868. export class ShaderProcessor {
  68869. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68870. private static _ProcessPrecision;
  68871. private static _ExtractOperation;
  68872. private static _BuildSubExpression;
  68873. private static _BuildExpression;
  68874. private static _MoveCursorWithinIf;
  68875. private static _MoveCursor;
  68876. private static _EvaluatePreProcessors;
  68877. private static _PreparePreProcessors;
  68878. private static _ProcessShaderConversion;
  68879. private static _ProcessIncludes;
  68880. }
  68881. }
  68882. declare module BABYLON {
  68883. /**
  68884. * @hidden
  68885. */
  68886. export interface IColor4Like {
  68887. r: float;
  68888. g: float;
  68889. b: float;
  68890. a: float;
  68891. }
  68892. /**
  68893. * @hidden
  68894. */
  68895. export interface IColor3Like {
  68896. r: float;
  68897. g: float;
  68898. b: float;
  68899. }
  68900. /**
  68901. * @hidden
  68902. */
  68903. export interface IVector4Like {
  68904. x: float;
  68905. y: float;
  68906. z: float;
  68907. w: float;
  68908. }
  68909. /**
  68910. * @hidden
  68911. */
  68912. export interface IVector3Like {
  68913. x: float;
  68914. y: float;
  68915. z: float;
  68916. }
  68917. /**
  68918. * @hidden
  68919. */
  68920. export interface IVector2Like {
  68921. x: float;
  68922. y: float;
  68923. }
  68924. /**
  68925. * @hidden
  68926. */
  68927. export interface IMatrixLike {
  68928. toArray(): DeepImmutable<Float32Array>;
  68929. updateFlag: int;
  68930. }
  68931. /**
  68932. * @hidden
  68933. */
  68934. export interface IViewportLike {
  68935. x: float;
  68936. y: float;
  68937. width: float;
  68938. height: float;
  68939. }
  68940. /**
  68941. * @hidden
  68942. */
  68943. export interface IPlaneLike {
  68944. normal: IVector3Like;
  68945. d: float;
  68946. normalize(): void;
  68947. }
  68948. }
  68949. declare module BABYLON {
  68950. /**
  68951. * Interface used to define common properties for effect fallbacks
  68952. */
  68953. export interface IEffectFallbacks {
  68954. /**
  68955. * Removes the defines that should be removed when falling back.
  68956. * @param currentDefines defines the current define statements for the shader.
  68957. * @param effect defines the current effect we try to compile
  68958. * @returns The resulting defines with defines of the current rank removed.
  68959. */
  68960. reduce(currentDefines: string, effect: Effect): string;
  68961. /**
  68962. * Removes the fallback from the bound mesh.
  68963. */
  68964. unBindMesh(): void;
  68965. /**
  68966. * Checks to see if more fallbacks are still availible.
  68967. */
  68968. hasMoreFallbacks: boolean;
  68969. }
  68970. }
  68971. declare module BABYLON {
  68972. /**
  68973. * Class used to evalaute queries containing `and` and `or` operators
  68974. */
  68975. export class AndOrNotEvaluator {
  68976. /**
  68977. * Evaluate a query
  68978. * @param query defines the query to evaluate
  68979. * @param evaluateCallback defines the callback used to filter result
  68980. * @returns true if the query matches
  68981. */
  68982. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68983. private static _HandleParenthesisContent;
  68984. private static _SimplifyNegation;
  68985. }
  68986. }
  68987. declare module BABYLON {
  68988. /**
  68989. * Class used to store custom tags
  68990. */
  68991. export class Tags {
  68992. /**
  68993. * Adds support for tags on the given object
  68994. * @param obj defines the object to use
  68995. */
  68996. static EnableFor(obj: any): void;
  68997. /**
  68998. * Removes tags support
  68999. * @param obj defines the object to use
  69000. */
  69001. static DisableFor(obj: any): void;
  69002. /**
  69003. * Gets a boolean indicating if the given object has tags
  69004. * @param obj defines the object to use
  69005. * @returns a boolean
  69006. */
  69007. static HasTags(obj: any): boolean;
  69008. /**
  69009. * Gets the tags available on a given object
  69010. * @param obj defines the object to use
  69011. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69012. * @returns the tags
  69013. */
  69014. static GetTags(obj: any, asString?: boolean): any;
  69015. /**
  69016. * Adds tags to an object
  69017. * @param obj defines the object to use
  69018. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69019. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69020. */
  69021. static AddTagsTo(obj: any, tagsString: string): void;
  69022. /**
  69023. * @hidden
  69024. */
  69025. static _AddTagTo(obj: any, tag: string): void;
  69026. /**
  69027. * Removes specific tags from a specific object
  69028. * @param obj defines the object to use
  69029. * @param tagsString defines the tags to remove
  69030. */
  69031. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69032. /**
  69033. * @hidden
  69034. */
  69035. static _RemoveTagFrom(obj: any, tag: string): void;
  69036. /**
  69037. * Defines if tags hosted on an object match a given query
  69038. * @param obj defines the object to use
  69039. * @param tagsQuery defines the tag query
  69040. * @returns a boolean
  69041. */
  69042. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69043. }
  69044. }
  69045. declare module BABYLON {
  69046. /**
  69047. * Scalar computation library
  69048. */
  69049. export class Scalar {
  69050. /**
  69051. * Two pi constants convenient for computation.
  69052. */
  69053. static TwoPi: number;
  69054. /**
  69055. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69056. * @param a number
  69057. * @param b number
  69058. * @param epsilon (default = 1.401298E-45)
  69059. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69060. */
  69061. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69062. /**
  69063. * Returns a string : the upper case translation of the number i to hexadecimal.
  69064. * @param i number
  69065. * @returns the upper case translation of the number i to hexadecimal.
  69066. */
  69067. static ToHex(i: number): string;
  69068. /**
  69069. * Returns -1 if value is negative and +1 is value is positive.
  69070. * @param value the value
  69071. * @returns the value itself if it's equal to zero.
  69072. */
  69073. static Sign(value: number): number;
  69074. /**
  69075. * Returns the value itself if it's between min and max.
  69076. * Returns min if the value is lower than min.
  69077. * Returns max if the value is greater than max.
  69078. * @param value the value to clmap
  69079. * @param min the min value to clamp to (default: 0)
  69080. * @param max the max value to clamp to (default: 1)
  69081. * @returns the clamped value
  69082. */
  69083. static Clamp(value: number, min?: number, max?: number): number;
  69084. /**
  69085. * the log2 of value.
  69086. * @param value the value to compute log2 of
  69087. * @returns the log2 of value.
  69088. */
  69089. static Log2(value: number): number;
  69090. /**
  69091. * Loops the value, so that it is never larger than length and never smaller than 0.
  69092. *
  69093. * This is similar to the modulo operator but it works with floating point numbers.
  69094. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69095. * With t = 5 and length = 2.5, the result would be 0.0.
  69096. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69097. * @param value the value
  69098. * @param length the length
  69099. * @returns the looped value
  69100. */
  69101. static Repeat(value: number, length: number): number;
  69102. /**
  69103. * Normalize the value between 0.0 and 1.0 using min and max values
  69104. * @param value value to normalize
  69105. * @param min max to normalize between
  69106. * @param max min to normalize between
  69107. * @returns the normalized value
  69108. */
  69109. static Normalize(value: number, min: number, max: number): number;
  69110. /**
  69111. * Denormalize the value from 0.0 and 1.0 using min and max values
  69112. * @param normalized value to denormalize
  69113. * @param min max to denormalize between
  69114. * @param max min to denormalize between
  69115. * @returns the denormalized value
  69116. */
  69117. static Denormalize(normalized: number, min: number, max: number): number;
  69118. /**
  69119. * Calculates the shortest difference between two given angles given in degrees.
  69120. * @param current current angle in degrees
  69121. * @param target target angle in degrees
  69122. * @returns the delta
  69123. */
  69124. static DeltaAngle(current: number, target: number): number;
  69125. /**
  69126. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69127. * @param tx value
  69128. * @param length length
  69129. * @returns The returned value will move back and forth between 0 and length
  69130. */
  69131. static PingPong(tx: number, length: number): number;
  69132. /**
  69133. * Interpolates between min and max with smoothing at the limits.
  69134. *
  69135. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69136. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69137. * @param from from
  69138. * @param to to
  69139. * @param tx value
  69140. * @returns the smooth stepped value
  69141. */
  69142. static SmoothStep(from: number, to: number, tx: number): number;
  69143. /**
  69144. * Moves a value current towards target.
  69145. *
  69146. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69147. * Negative values of maxDelta pushes the value away from target.
  69148. * @param current current value
  69149. * @param target target value
  69150. * @param maxDelta max distance to move
  69151. * @returns resulting value
  69152. */
  69153. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69154. /**
  69155. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69156. *
  69157. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69158. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69159. * @param current current value
  69160. * @param target target value
  69161. * @param maxDelta max distance to move
  69162. * @returns resulting angle
  69163. */
  69164. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69165. /**
  69166. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69167. * @param start start value
  69168. * @param end target value
  69169. * @param amount amount to lerp between
  69170. * @returns the lerped value
  69171. */
  69172. static Lerp(start: number, end: number, amount: number): number;
  69173. /**
  69174. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69175. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69176. * @param start start value
  69177. * @param end target value
  69178. * @param amount amount to lerp between
  69179. * @returns the lerped value
  69180. */
  69181. static LerpAngle(start: number, end: number, amount: number): number;
  69182. /**
  69183. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69184. * @param a start value
  69185. * @param b target value
  69186. * @param value value between a and b
  69187. * @returns the inverseLerp value
  69188. */
  69189. static InverseLerp(a: number, b: number, value: number): number;
  69190. /**
  69191. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69192. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69193. * @param value1 spline value
  69194. * @param tangent1 spline value
  69195. * @param value2 spline value
  69196. * @param tangent2 spline value
  69197. * @param amount input value
  69198. * @returns hermite result
  69199. */
  69200. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69201. /**
  69202. * Returns a random float number between and min and max values
  69203. * @param min min value of random
  69204. * @param max max value of random
  69205. * @returns random value
  69206. */
  69207. static RandomRange(min: number, max: number): number;
  69208. /**
  69209. * This function returns percentage of a number in a given range.
  69210. *
  69211. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69212. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69213. * @param number to convert to percentage
  69214. * @param min min range
  69215. * @param max max range
  69216. * @returns the percentage
  69217. */
  69218. static RangeToPercent(number: number, min: number, max: number): number;
  69219. /**
  69220. * This function returns number that corresponds to the percentage in a given range.
  69221. *
  69222. * PercentToRange(0.34,0,100) will return 34.
  69223. * @param percent to convert to number
  69224. * @param min min range
  69225. * @param max max range
  69226. * @returns the number
  69227. */
  69228. static PercentToRange(percent: number, min: number, max: number): number;
  69229. /**
  69230. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69231. * @param angle The angle to normalize in radian.
  69232. * @return The converted angle.
  69233. */
  69234. static NormalizeRadians(angle: number): number;
  69235. }
  69236. }
  69237. declare module BABYLON {
  69238. /**
  69239. * Constant used to convert a value to gamma space
  69240. * @ignorenaming
  69241. */
  69242. export const ToGammaSpace: number;
  69243. /**
  69244. * Constant used to convert a value to linear space
  69245. * @ignorenaming
  69246. */
  69247. export const ToLinearSpace = 2.2;
  69248. /**
  69249. * Constant used to define the minimal number value in Babylon.js
  69250. * @ignorenaming
  69251. */
  69252. let Epsilon: number;
  69253. }
  69254. declare module BABYLON {
  69255. /**
  69256. * Class used to represent a viewport on screen
  69257. */
  69258. export class Viewport {
  69259. /** viewport left coordinate */
  69260. x: number;
  69261. /** viewport top coordinate */
  69262. y: number;
  69263. /**viewport width */
  69264. width: number;
  69265. /** viewport height */
  69266. height: number;
  69267. /**
  69268. * Creates a Viewport object located at (x, y) and sized (width, height)
  69269. * @param x defines viewport left coordinate
  69270. * @param y defines viewport top coordinate
  69271. * @param width defines the viewport width
  69272. * @param height defines the viewport height
  69273. */
  69274. constructor(
  69275. /** viewport left coordinate */
  69276. x: number,
  69277. /** viewport top coordinate */
  69278. y: number,
  69279. /**viewport width */
  69280. width: number,
  69281. /** viewport height */
  69282. height: number);
  69283. /**
  69284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69285. * @param renderWidth defines the rendering width
  69286. * @param renderHeight defines the rendering height
  69287. * @returns a new Viewport
  69288. */
  69289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69290. /**
  69291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69292. * @param renderWidth defines the rendering width
  69293. * @param renderHeight defines the rendering height
  69294. * @param ref defines the target viewport
  69295. * @returns the current viewport
  69296. */
  69297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69298. /**
  69299. * Returns a new Viewport copied from the current one
  69300. * @returns a new Viewport
  69301. */
  69302. clone(): Viewport;
  69303. }
  69304. }
  69305. declare module BABYLON {
  69306. /**
  69307. * Class containing a set of static utilities functions for arrays.
  69308. */
  69309. export class ArrayTools {
  69310. /**
  69311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69312. * @param size the number of element to construct and put in the array
  69313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69314. * @returns a new array filled with new objects
  69315. */
  69316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69317. }
  69318. }
  69319. declare module BABYLON {
  69320. /**
  69321. * Class representing a vector containing 2 coordinates
  69322. */
  69323. export class Vector2 {
  69324. /** defines the first coordinate */
  69325. x: number;
  69326. /** defines the second coordinate */
  69327. y: number;
  69328. /**
  69329. * Creates a new Vector2 from the given x and y coordinates
  69330. * @param x defines the first coordinate
  69331. * @param y defines the second coordinate
  69332. */
  69333. constructor(
  69334. /** defines the first coordinate */
  69335. x?: number,
  69336. /** defines the second coordinate */
  69337. y?: number);
  69338. /**
  69339. * Gets a string with the Vector2 coordinates
  69340. * @returns a string with the Vector2 coordinates
  69341. */
  69342. toString(): string;
  69343. /**
  69344. * Gets class name
  69345. * @returns the string "Vector2"
  69346. */
  69347. getClassName(): string;
  69348. /**
  69349. * Gets current vector hash code
  69350. * @returns the Vector2 hash code as a number
  69351. */
  69352. getHashCode(): number;
  69353. /**
  69354. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69355. * @param array defines the source array
  69356. * @param index defines the offset in source array
  69357. * @returns the current Vector2
  69358. */
  69359. toArray(array: FloatArray, index?: number): Vector2;
  69360. /**
  69361. * Copy the current vector to an array
  69362. * @returns a new array with 2 elements: the Vector2 coordinates.
  69363. */
  69364. asArray(): number[];
  69365. /**
  69366. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69367. * @param source defines the source Vector2
  69368. * @returns the current updated Vector2
  69369. */
  69370. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69371. /**
  69372. * Sets the Vector2 coordinates with the given floats
  69373. * @param x defines the first coordinate
  69374. * @param y defines the second coordinate
  69375. * @returns the current updated Vector2
  69376. */
  69377. copyFromFloats(x: number, y: number): Vector2;
  69378. /**
  69379. * Sets the Vector2 coordinates with the given floats
  69380. * @param x defines the first coordinate
  69381. * @param y defines the second coordinate
  69382. * @returns the current updated Vector2
  69383. */
  69384. set(x: number, y: number): Vector2;
  69385. /**
  69386. * Add another vector with the current one
  69387. * @param otherVector defines the other vector
  69388. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69389. */
  69390. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69391. /**
  69392. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69393. * @param otherVector defines the other vector
  69394. * @param result defines the target vector
  69395. * @returns the unmodified current Vector2
  69396. */
  69397. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69398. /**
  69399. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69400. * @param otherVector defines the other vector
  69401. * @returns the current updated Vector2
  69402. */
  69403. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69404. /**
  69405. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69406. * @param otherVector defines the other vector
  69407. * @returns a new Vector2
  69408. */
  69409. addVector3(otherVector: Vector3): Vector2;
  69410. /**
  69411. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  69412. * @param otherVector defines the other vector
  69413. * @returns a new Vector2
  69414. */
  69415. subtract(otherVector: Vector2): Vector2;
  69416. /**
  69417. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  69418. * @param otherVector defines the other vector
  69419. * @param result defines the target vector
  69420. * @returns the unmodified current Vector2
  69421. */
  69422. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69423. /**
  69424. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  69425. * @param otherVector defines the other vector
  69426. * @returns the current updated Vector2
  69427. */
  69428. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69429. /**
  69430. * Multiplies in place the current Vector2 coordinates by the given ones
  69431. * @param otherVector defines the other vector
  69432. * @returns the current updated Vector2
  69433. */
  69434. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69435. /**
  69436. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  69437. * @param otherVector defines the other vector
  69438. * @returns a new Vector2
  69439. */
  69440. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  69441. /**
  69442. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  69443. * @param otherVector defines the other vector
  69444. * @param result defines the target vector
  69445. * @returns the unmodified current Vector2
  69446. */
  69447. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69448. /**
  69449. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  69450. * @param x defines the first coordinate
  69451. * @param y defines the second coordinate
  69452. * @returns a new Vector2
  69453. */
  69454. multiplyByFloats(x: number, y: number): Vector2;
  69455. /**
  69456. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  69457. * @param otherVector defines the other vector
  69458. * @returns a new Vector2
  69459. */
  69460. divide(otherVector: Vector2): Vector2;
  69461. /**
  69462. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  69463. * @param otherVector defines the other vector
  69464. * @param result defines the target vector
  69465. * @returns the unmodified current Vector2
  69466. */
  69467. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69468. /**
  69469. * Divides the current Vector2 coordinates by the given ones
  69470. * @param otherVector defines the other vector
  69471. * @returns the current updated Vector2
  69472. */
  69473. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69474. /**
  69475. * Gets a new Vector2 with current Vector2 negated coordinates
  69476. * @returns a new Vector2
  69477. */
  69478. negate(): Vector2;
  69479. /**
  69480. * Multiply the Vector2 coordinates by scale
  69481. * @param scale defines the scaling factor
  69482. * @returns the current updated Vector2
  69483. */
  69484. scaleInPlace(scale: number): Vector2;
  69485. /**
  69486. * Returns a new Vector2 scaled by "scale" from the current Vector2
  69487. * @param scale defines the scaling factor
  69488. * @returns a new Vector2
  69489. */
  69490. scale(scale: number): Vector2;
  69491. /**
  69492. * Scale the current Vector2 values by a factor to a given Vector2
  69493. * @param scale defines the scale factor
  69494. * @param result defines the Vector2 object where to store the result
  69495. * @returns the unmodified current Vector2
  69496. */
  69497. scaleToRef(scale: number, result: Vector2): Vector2;
  69498. /**
  69499. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  69500. * @param scale defines the scale factor
  69501. * @param result defines the Vector2 object where to store the result
  69502. * @returns the unmodified current Vector2
  69503. */
  69504. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  69505. /**
  69506. * Gets a boolean if two vectors are equals
  69507. * @param otherVector defines the other vector
  69508. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  69509. */
  69510. equals(otherVector: DeepImmutable<Vector2>): boolean;
  69511. /**
  69512. * Gets a boolean if two vectors are equals (using an epsilon value)
  69513. * @param otherVector defines the other vector
  69514. * @param epsilon defines the minimal distance to consider equality
  69515. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  69516. */
  69517. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  69518. /**
  69519. * Gets a new Vector2 from current Vector2 floored values
  69520. * @returns a new Vector2
  69521. */
  69522. floor(): Vector2;
  69523. /**
  69524. * Gets a new Vector2 from current Vector2 floored values
  69525. * @returns a new Vector2
  69526. */
  69527. fract(): Vector2;
  69528. /**
  69529. * Gets the length of the vector
  69530. * @returns the vector length (float)
  69531. */
  69532. length(): number;
  69533. /**
  69534. * Gets the vector squared length
  69535. * @returns the vector squared length (float)
  69536. */
  69537. lengthSquared(): number;
  69538. /**
  69539. * Normalize the vector
  69540. * @returns the current updated Vector2
  69541. */
  69542. normalize(): Vector2;
  69543. /**
  69544. * Gets a new Vector2 copied from the Vector2
  69545. * @returns a new Vector2
  69546. */
  69547. clone(): Vector2;
  69548. /**
  69549. * Gets a new Vector2(0, 0)
  69550. * @returns a new Vector2
  69551. */
  69552. static Zero(): Vector2;
  69553. /**
  69554. * Gets a new Vector2(1, 1)
  69555. * @returns a new Vector2
  69556. */
  69557. static One(): Vector2;
  69558. /**
  69559. * Gets a new Vector2 set from the given index element of the given array
  69560. * @param array defines the data source
  69561. * @param offset defines the offset in the data source
  69562. * @returns a new Vector2
  69563. */
  69564. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  69565. /**
  69566. * Sets "result" from the given index element of the given array
  69567. * @param array defines the data source
  69568. * @param offset defines the offset in the data source
  69569. * @param result defines the target vector
  69570. */
  69571. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  69572. /**
  69573. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69574. * @param value1 defines 1st point of control
  69575. * @param value2 defines 2nd point of control
  69576. * @param value3 defines 3rd point of control
  69577. * @param value4 defines 4th point of control
  69578. * @param amount defines the interpolation factor
  69579. * @returns a new Vector2
  69580. */
  69581. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  69582. /**
  69583. * 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".
  69584. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69585. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69586. * @param value defines the value to clamp
  69587. * @param min defines the lower limit
  69588. * @param max defines the upper limit
  69589. * @returns a new Vector2
  69590. */
  69591. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  69592. /**
  69593. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69594. * @param value1 defines the 1st control point
  69595. * @param tangent1 defines the outgoing tangent
  69596. * @param value2 defines the 2nd control point
  69597. * @param tangent2 defines the incoming tangent
  69598. * @param amount defines the interpolation factor
  69599. * @returns a new Vector2
  69600. */
  69601. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  69602. /**
  69603. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69604. * @param start defines the start vector
  69605. * @param end defines the end vector
  69606. * @param amount defines the interpolation factor
  69607. * @returns a new Vector2
  69608. */
  69609. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  69610. /**
  69611. * Gets the dot product of the vector "left" and the vector "right"
  69612. * @param left defines first vector
  69613. * @param right defines second vector
  69614. * @returns the dot product (float)
  69615. */
  69616. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  69617. /**
  69618. * Returns a new Vector2 equal to the normalized given vector
  69619. * @param vector defines the vector to normalize
  69620. * @returns a new Vector2
  69621. */
  69622. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  69623. /**
  69624. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69625. * @param left defines 1st vector
  69626. * @param right defines 2nd vector
  69627. * @returns a new Vector2
  69628. */
  69629. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69630. /**
  69631. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69632. * @param left defines 1st vector
  69633. * @param right defines 2nd vector
  69634. * @returns a new Vector2
  69635. */
  69636. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69637. /**
  69638. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69639. * @param vector defines the vector to transform
  69640. * @param transformation defines the matrix to apply
  69641. * @returns a new Vector2
  69642. */
  69643. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  69644. /**
  69645. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69646. * @param vector defines the vector to transform
  69647. * @param transformation defines the matrix to apply
  69648. * @param result defines the target vector
  69649. */
  69650. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  69651. /**
  69652. * Determines if a given vector is included in a triangle
  69653. * @param p defines the vector to test
  69654. * @param p0 defines 1st triangle point
  69655. * @param p1 defines 2nd triangle point
  69656. * @param p2 defines 3rd triangle point
  69657. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69658. */
  69659. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69660. /**
  69661. * Gets the distance between the vectors "value1" and "value2"
  69662. * @param value1 defines first vector
  69663. * @param value2 defines second vector
  69664. * @returns the distance between vectors
  69665. */
  69666. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69667. /**
  69668. * Returns the squared distance between the vectors "value1" and "value2"
  69669. * @param value1 defines first vector
  69670. * @param value2 defines second vector
  69671. * @returns the squared distance between vectors
  69672. */
  69673. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69674. /**
  69675. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69676. * @param value1 defines first vector
  69677. * @param value2 defines second vector
  69678. * @returns a new Vector2
  69679. */
  69680. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69681. /**
  69682. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69683. * @param p defines the middle point
  69684. * @param segA defines one point of the segment
  69685. * @param segB defines the other point of the segment
  69686. * @returns the shortest distance
  69687. */
  69688. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69689. }
  69690. /**
  69691. * Classed used to store (x,y,z) vector representation
  69692. * A Vector3 is the main object used in 3D geometry
  69693. * It can represent etiher the coordinates of a point the space, either a direction
  69694. * Reminder: js uses a left handed forward facing system
  69695. */
  69696. export class Vector3 {
  69697. /**
  69698. * Defines the first coordinates (on X axis)
  69699. */
  69700. x: number;
  69701. /**
  69702. * Defines the second coordinates (on Y axis)
  69703. */
  69704. y: number;
  69705. /**
  69706. * Defines the third coordinates (on Z axis)
  69707. */
  69708. z: number;
  69709. private static _UpReadOnly;
  69710. private static _ZeroReadOnly;
  69711. /**
  69712. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69713. * @param x defines the first coordinates (on X axis)
  69714. * @param y defines the second coordinates (on Y axis)
  69715. * @param z defines the third coordinates (on Z axis)
  69716. */
  69717. constructor(
  69718. /**
  69719. * Defines the first coordinates (on X axis)
  69720. */
  69721. x?: number,
  69722. /**
  69723. * Defines the second coordinates (on Y axis)
  69724. */
  69725. y?: number,
  69726. /**
  69727. * Defines the third coordinates (on Z axis)
  69728. */
  69729. z?: number);
  69730. /**
  69731. * Creates a string representation of the Vector3
  69732. * @returns a string with the Vector3 coordinates.
  69733. */
  69734. toString(): string;
  69735. /**
  69736. * Gets the class name
  69737. * @returns the string "Vector3"
  69738. */
  69739. getClassName(): string;
  69740. /**
  69741. * Creates the Vector3 hash code
  69742. * @returns a number which tends to be unique between Vector3 instances
  69743. */
  69744. getHashCode(): number;
  69745. /**
  69746. * Creates an array containing three elements : the coordinates of the Vector3
  69747. * @returns a new array of numbers
  69748. */
  69749. asArray(): number[];
  69750. /**
  69751. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69752. * @param array defines the destination array
  69753. * @param index defines the offset in the destination array
  69754. * @returns the current Vector3
  69755. */
  69756. toArray(array: FloatArray, index?: number): Vector3;
  69757. /**
  69758. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69759. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69760. */
  69761. toQuaternion(): Quaternion;
  69762. /**
  69763. * Adds the given vector to the current Vector3
  69764. * @param otherVector defines the second operand
  69765. * @returns the current updated Vector3
  69766. */
  69767. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69768. /**
  69769. * Adds the given coordinates to the current Vector3
  69770. * @param x defines the x coordinate of the operand
  69771. * @param y defines the y coordinate of the operand
  69772. * @param z defines the z coordinate of the operand
  69773. * @returns the current updated Vector3
  69774. */
  69775. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69776. /**
  69777. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69778. * @param otherVector defines the second operand
  69779. * @returns the resulting Vector3
  69780. */
  69781. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69782. /**
  69783. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69784. * @param otherVector defines the second operand
  69785. * @param result defines the Vector3 object where to store the result
  69786. * @returns the current Vector3
  69787. */
  69788. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69789. /**
  69790. * Subtract the given vector from the current Vector3
  69791. * @param otherVector defines the second operand
  69792. * @returns the current updated Vector3
  69793. */
  69794. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69795. /**
  69796. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69797. * @param otherVector defines the second operand
  69798. * @returns the resulting Vector3
  69799. */
  69800. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69801. /**
  69802. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69803. * @param otherVector defines the second operand
  69804. * @param result defines the Vector3 object where to store the result
  69805. * @returns the current Vector3
  69806. */
  69807. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69808. /**
  69809. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69810. * @param x defines the x coordinate of the operand
  69811. * @param y defines the y coordinate of the operand
  69812. * @param z defines the z coordinate of the operand
  69813. * @returns the resulting Vector3
  69814. */
  69815. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69816. /**
  69817. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69818. * @param x defines the x coordinate of the operand
  69819. * @param y defines the y coordinate of the operand
  69820. * @param z defines the z coordinate of the operand
  69821. * @param result defines the Vector3 object where to store the result
  69822. * @returns the current Vector3
  69823. */
  69824. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69825. /**
  69826. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69827. * @returns a new Vector3
  69828. */
  69829. negate(): Vector3;
  69830. /**
  69831. * Multiplies the Vector3 coordinates by the float "scale"
  69832. * @param scale defines the multiplier factor
  69833. * @returns the current updated Vector3
  69834. */
  69835. scaleInPlace(scale: number): Vector3;
  69836. /**
  69837. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69838. * @param scale defines the multiplier factor
  69839. * @returns a new Vector3
  69840. */
  69841. scale(scale: number): Vector3;
  69842. /**
  69843. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69844. * @param scale defines the multiplier factor
  69845. * @param result defines the Vector3 object where to store the result
  69846. * @returns the current Vector3
  69847. */
  69848. scaleToRef(scale: number, result: Vector3): Vector3;
  69849. /**
  69850. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69851. * @param scale defines the scale factor
  69852. * @param result defines the Vector3 object where to store the result
  69853. * @returns the unmodified current Vector3
  69854. */
  69855. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69856. /**
  69857. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69858. * @param otherVector defines the second operand
  69859. * @returns true if both vectors are equals
  69860. */
  69861. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69862. /**
  69863. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69864. * @param otherVector defines the second operand
  69865. * @param epsilon defines the minimal distance to define values as equals
  69866. * @returns true if both vectors are distant less than epsilon
  69867. */
  69868. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69869. /**
  69870. * Returns true if the current Vector3 coordinates equals the given floats
  69871. * @param x defines the x coordinate of the operand
  69872. * @param y defines the y coordinate of the operand
  69873. * @param z defines the z coordinate of the operand
  69874. * @returns true if both vectors are equals
  69875. */
  69876. equalsToFloats(x: number, y: number, z: number): boolean;
  69877. /**
  69878. * Multiplies the current Vector3 coordinates by the given ones
  69879. * @param otherVector defines the second operand
  69880. * @returns the current updated Vector3
  69881. */
  69882. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69883. /**
  69884. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69885. * @param otherVector defines the second operand
  69886. * @returns the new Vector3
  69887. */
  69888. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69889. /**
  69890. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69891. * @param otherVector defines the second operand
  69892. * @param result defines the Vector3 object where to store the result
  69893. * @returns the current Vector3
  69894. */
  69895. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69896. /**
  69897. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69898. * @param x defines the x coordinate of the operand
  69899. * @param y defines the y coordinate of the operand
  69900. * @param z defines the z coordinate of the operand
  69901. * @returns the new Vector3
  69902. */
  69903. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69904. /**
  69905. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69906. * @param otherVector defines the second operand
  69907. * @returns the new Vector3
  69908. */
  69909. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69910. /**
  69911. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69912. * @param otherVector defines the second operand
  69913. * @param result defines the Vector3 object where to store the result
  69914. * @returns the current Vector3
  69915. */
  69916. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69917. /**
  69918. * Divides the current Vector3 coordinates by the given ones.
  69919. * @param otherVector defines the second operand
  69920. * @returns the current updated Vector3
  69921. */
  69922. divideInPlace(otherVector: Vector3): Vector3;
  69923. /**
  69924. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69925. * @param other defines the second operand
  69926. * @returns the current updated Vector3
  69927. */
  69928. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69929. /**
  69930. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69931. * @param other defines the second operand
  69932. * @returns the current updated Vector3
  69933. */
  69934. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69935. /**
  69936. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69937. * @param x defines the x coordinate of the operand
  69938. * @param y defines the y coordinate of the operand
  69939. * @param z defines the z coordinate of the operand
  69940. * @returns the current updated Vector3
  69941. */
  69942. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69943. /**
  69944. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69945. * @param x defines the x coordinate of the operand
  69946. * @param y defines the y coordinate of the operand
  69947. * @param z defines the z coordinate of the operand
  69948. * @returns the current updated Vector3
  69949. */
  69950. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69951. /**
  69952. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69953. * Check if is non uniform within a certain amount of decimal places to account for this
  69954. * @param epsilon the amount the values can differ
  69955. * @returns if the the vector is non uniform to a certain number of decimal places
  69956. */
  69957. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69958. /**
  69959. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69960. */
  69961. readonly isNonUniform: boolean;
  69962. /**
  69963. * Gets a new Vector3 from current Vector3 floored values
  69964. * @returns a new Vector3
  69965. */
  69966. floor(): Vector3;
  69967. /**
  69968. * Gets a new Vector3 from current Vector3 floored values
  69969. * @returns a new Vector3
  69970. */
  69971. fract(): Vector3;
  69972. /**
  69973. * Gets the length of the Vector3
  69974. * @returns the length of the Vector3
  69975. */
  69976. length(): number;
  69977. /**
  69978. * Gets the squared length of the Vector3
  69979. * @returns squared length of the Vector3
  69980. */
  69981. lengthSquared(): number;
  69982. /**
  69983. * Normalize the current Vector3.
  69984. * Please note that this is an in place operation.
  69985. * @returns the current updated Vector3
  69986. */
  69987. normalize(): Vector3;
  69988. /**
  69989. * Reorders the x y z properties of the vector in place
  69990. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69991. * @returns the current updated vector
  69992. */
  69993. reorderInPlace(order: string): this;
  69994. /**
  69995. * Rotates the vector around 0,0,0 by a quaternion
  69996. * @param quaternion the rotation quaternion
  69997. * @param result vector to store the result
  69998. * @returns the resulting vector
  69999. */
  70000. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70001. /**
  70002. * Rotates a vector around a given point
  70003. * @param quaternion the rotation quaternion
  70004. * @param point the point to rotate around
  70005. * @param result vector to store the result
  70006. * @returns the resulting vector
  70007. */
  70008. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70009. /**
  70010. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70011. * The cross product is then orthogonal to both current and "other"
  70012. * @param other defines the right operand
  70013. * @returns the cross product
  70014. */
  70015. cross(other: Vector3): Vector3;
  70016. /**
  70017. * Normalize the current Vector3 with the given input length.
  70018. * Please note that this is an in place operation.
  70019. * @param len the length of the vector
  70020. * @returns the current updated Vector3
  70021. */
  70022. normalizeFromLength(len: number): Vector3;
  70023. /**
  70024. * Normalize the current Vector3 to a new vector
  70025. * @returns the new Vector3
  70026. */
  70027. normalizeToNew(): Vector3;
  70028. /**
  70029. * Normalize the current Vector3 to the reference
  70030. * @param reference define the Vector3 to update
  70031. * @returns the updated Vector3
  70032. */
  70033. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70034. /**
  70035. * Creates a new Vector3 copied from the current Vector3
  70036. * @returns the new Vector3
  70037. */
  70038. clone(): Vector3;
  70039. /**
  70040. * Copies the given vector coordinates to the current Vector3 ones
  70041. * @param source defines the source Vector3
  70042. * @returns the current updated Vector3
  70043. */
  70044. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70045. /**
  70046. * Copies the given floats to the current Vector3 coordinates
  70047. * @param x defines the x coordinate of the operand
  70048. * @param y defines the y coordinate of the operand
  70049. * @param z defines the z coordinate of the operand
  70050. * @returns the current updated Vector3
  70051. */
  70052. copyFromFloats(x: number, y: number, z: number): Vector3;
  70053. /**
  70054. * Copies the given floats to the current Vector3 coordinates
  70055. * @param x defines the x coordinate of the operand
  70056. * @param y defines the y coordinate of the operand
  70057. * @param z defines the z coordinate of the operand
  70058. * @returns the current updated Vector3
  70059. */
  70060. set(x: number, y: number, z: number): Vector3;
  70061. /**
  70062. * Copies the given float to the current Vector3 coordinates
  70063. * @param v defines the x, y and z coordinates of the operand
  70064. * @returns the current updated Vector3
  70065. */
  70066. setAll(v: number): Vector3;
  70067. /**
  70068. * Get the clip factor between two vectors
  70069. * @param vector0 defines the first operand
  70070. * @param vector1 defines the second operand
  70071. * @param axis defines the axis to use
  70072. * @param size defines the size along the axis
  70073. * @returns the clip factor
  70074. */
  70075. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70076. /**
  70077. * Get angle between two vectors
  70078. * @param vector0 angle between vector0 and vector1
  70079. * @param vector1 angle between vector0 and vector1
  70080. * @param normal direction of the normal
  70081. * @return the angle between vector0 and vector1
  70082. */
  70083. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70084. /**
  70085. * Returns a new Vector3 set from the index "offset" of the given array
  70086. * @param array defines the source array
  70087. * @param offset defines the offset in the source array
  70088. * @returns the new Vector3
  70089. */
  70090. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70091. /**
  70092. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70093. * This function is deprecated. Use FromArray instead
  70094. * @param array defines the source array
  70095. * @param offset defines the offset in the source array
  70096. * @returns the new Vector3
  70097. */
  70098. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70099. /**
  70100. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70101. * @param array defines the source array
  70102. * @param offset defines the offset in the source array
  70103. * @param result defines the Vector3 where to store the result
  70104. */
  70105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70106. /**
  70107. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70108. * This function is deprecated. Use FromArrayToRef instead.
  70109. * @param array defines the source array
  70110. * @param offset defines the offset in the source array
  70111. * @param result defines the Vector3 where to store the result
  70112. */
  70113. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70114. /**
  70115. * Sets the given vector "result" with the given floats.
  70116. * @param x defines the x coordinate of the source
  70117. * @param y defines the y coordinate of the source
  70118. * @param z defines the z coordinate of the source
  70119. * @param result defines the Vector3 where to store the result
  70120. */
  70121. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70122. /**
  70123. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70124. * @returns a new empty Vector3
  70125. */
  70126. static Zero(): Vector3;
  70127. /**
  70128. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70129. * @returns a new unit Vector3
  70130. */
  70131. static One(): Vector3;
  70132. /**
  70133. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70134. * @returns a new up Vector3
  70135. */
  70136. static Up(): Vector3;
  70137. /**
  70138. * Gets a up Vector3 that must not be updated
  70139. */
  70140. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70141. /**
  70142. * Gets a zero Vector3 that must not be updated
  70143. */
  70144. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70145. /**
  70146. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70147. * @returns a new down Vector3
  70148. */
  70149. static Down(): Vector3;
  70150. /**
  70151. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70152. * @returns a new forward Vector3
  70153. */
  70154. static Forward(): Vector3;
  70155. /**
  70156. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70157. * @returns a new forward Vector3
  70158. */
  70159. static Backward(): Vector3;
  70160. /**
  70161. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70162. * @returns a new right Vector3
  70163. */
  70164. static Right(): Vector3;
  70165. /**
  70166. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70167. * @returns a new left Vector3
  70168. */
  70169. static Left(): Vector3;
  70170. /**
  70171. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70172. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70173. * @param vector defines the Vector3 to transform
  70174. * @param transformation defines the transformation matrix
  70175. * @returns the transformed Vector3
  70176. */
  70177. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70178. /**
  70179. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70180. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70181. * @param vector defines the Vector3 to transform
  70182. * @param transformation defines the transformation matrix
  70183. * @param result defines the Vector3 where to store the result
  70184. */
  70185. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70186. /**
  70187. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70188. * This method computes tranformed coordinates only, not transformed direction vectors
  70189. * @param x define the x coordinate of the source vector
  70190. * @param y define the y coordinate of the source vector
  70191. * @param z define the z coordinate of the source vector
  70192. * @param transformation defines the transformation matrix
  70193. * @param result defines the Vector3 where to store the result
  70194. */
  70195. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70196. /**
  70197. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70198. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70199. * @param vector defines the Vector3 to transform
  70200. * @param transformation defines the transformation matrix
  70201. * @returns the new Vector3
  70202. */
  70203. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70204. /**
  70205. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70206. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70207. * @param vector defines the Vector3 to transform
  70208. * @param transformation defines the transformation matrix
  70209. * @param result defines the Vector3 where to store the result
  70210. */
  70211. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70212. /**
  70213. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70214. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70215. * @param x define the x coordinate of the source vector
  70216. * @param y define the y coordinate of the source vector
  70217. * @param z define the z coordinate of the source vector
  70218. * @param transformation defines the transformation matrix
  70219. * @param result defines the Vector3 where to store the result
  70220. */
  70221. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70222. /**
  70223. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70224. * @param value1 defines the first control point
  70225. * @param value2 defines the second control point
  70226. * @param value3 defines the third control point
  70227. * @param value4 defines the fourth control point
  70228. * @param amount defines the amount on the spline to use
  70229. * @returns the new Vector3
  70230. */
  70231. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70232. /**
  70233. * 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"
  70234. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70235. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70236. * @param value defines the current value
  70237. * @param min defines the lower range value
  70238. * @param max defines the upper range value
  70239. * @returns the new Vector3
  70240. */
  70241. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70242. /**
  70243. * 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"
  70244. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70245. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70246. * @param value defines the current value
  70247. * @param min defines the lower range value
  70248. * @param max defines the upper range value
  70249. * @param result defines the Vector3 where to store the result
  70250. */
  70251. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70252. /**
  70253. * Checks if a given vector is inside a specific range
  70254. * @param v defines the vector to test
  70255. * @param min defines the minimum range
  70256. * @param max defines the maximum range
  70257. */
  70258. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70259. /**
  70260. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70261. * @param value1 defines the first control point
  70262. * @param tangent1 defines the first tangent vector
  70263. * @param value2 defines the second control point
  70264. * @param tangent2 defines the second tangent vector
  70265. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70266. * @returns the new Vector3
  70267. */
  70268. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70269. /**
  70270. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70271. * @param start defines the start value
  70272. * @param end defines the end value
  70273. * @param amount max defines amount between both (between 0 and 1)
  70274. * @returns the new Vector3
  70275. */
  70276. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70277. /**
  70278. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70279. * @param start defines the start value
  70280. * @param end defines the end value
  70281. * @param amount max defines amount between both (between 0 and 1)
  70282. * @param result defines the Vector3 where to store the result
  70283. */
  70284. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70285. /**
  70286. * Returns the dot product (float) between the vectors "left" and "right"
  70287. * @param left defines the left operand
  70288. * @param right defines the right operand
  70289. * @returns the dot product
  70290. */
  70291. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70292. /**
  70293. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70294. * The cross product is then orthogonal to both "left" and "right"
  70295. * @param left defines the left operand
  70296. * @param right defines the right operand
  70297. * @returns the cross product
  70298. */
  70299. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70300. /**
  70301. * Sets the given vector "result" with the cross product of "left" and "right"
  70302. * The cross product is then orthogonal to both "left" and "right"
  70303. * @param left defines the left operand
  70304. * @param right defines the right operand
  70305. * @param result defines the Vector3 where to store the result
  70306. */
  70307. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70308. /**
  70309. * Returns a new Vector3 as the normalization of the given vector
  70310. * @param vector defines the Vector3 to normalize
  70311. * @returns the new Vector3
  70312. */
  70313. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70314. /**
  70315. * Sets the given vector "result" with the normalization of the given first vector
  70316. * @param vector defines the Vector3 to normalize
  70317. * @param result defines the Vector3 where to store the result
  70318. */
  70319. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70320. /**
  70321. * Project a Vector3 onto screen space
  70322. * @param vector defines the Vector3 to project
  70323. * @param world defines the world matrix to use
  70324. * @param transform defines the transform (view x projection) matrix to use
  70325. * @param viewport defines the screen viewport to use
  70326. * @returns the new Vector3
  70327. */
  70328. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70329. /** @hidden */
  70330. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70331. /**
  70332. * Unproject from screen space to object space
  70333. * @param source defines the screen space Vector3 to use
  70334. * @param viewportWidth defines the current width of the viewport
  70335. * @param viewportHeight defines the current height of the viewport
  70336. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70337. * @param transform defines the transform (view x projection) matrix to use
  70338. * @returns the new Vector3
  70339. */
  70340. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70341. /**
  70342. * Unproject from screen space to object space
  70343. * @param source defines the screen space Vector3 to use
  70344. * @param viewportWidth defines the current width of the viewport
  70345. * @param viewportHeight defines the current height of the viewport
  70346. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70347. * @param view defines the view matrix to use
  70348. * @param projection defines the projection matrix to use
  70349. * @returns the new Vector3
  70350. */
  70351. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70352. /**
  70353. * Unproject from screen space to object space
  70354. * @param source defines the screen space Vector3 to use
  70355. * @param viewportWidth defines the current width of the viewport
  70356. * @param viewportHeight defines the current height of the viewport
  70357. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70358. * @param view defines the view matrix to use
  70359. * @param projection defines the projection matrix to use
  70360. * @param result defines the Vector3 where to store the result
  70361. */
  70362. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70363. /**
  70364. * Unproject from screen space to object space
  70365. * @param sourceX defines the screen space x coordinate to use
  70366. * @param sourceY defines the screen space y coordinate to use
  70367. * @param sourceZ defines the screen space z coordinate to use
  70368. * @param viewportWidth defines the current width of the viewport
  70369. * @param viewportHeight defines the current height of the viewport
  70370. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70371. * @param view defines the view matrix to use
  70372. * @param projection defines the projection matrix to use
  70373. * @param result defines the Vector3 where to store the result
  70374. */
  70375. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70376. /**
  70377. * Gets the minimal coordinate values between two Vector3
  70378. * @param left defines the first operand
  70379. * @param right defines the second operand
  70380. * @returns the new Vector3
  70381. */
  70382. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70383. /**
  70384. * Gets the maximal coordinate values between two Vector3
  70385. * @param left defines the first operand
  70386. * @param right defines the second operand
  70387. * @returns the new Vector3
  70388. */
  70389. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70390. /**
  70391. * Returns the distance between the vectors "value1" and "value2"
  70392. * @param value1 defines the first operand
  70393. * @param value2 defines the second operand
  70394. * @returns the distance
  70395. */
  70396. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70397. /**
  70398. * Returns the squared distance between the vectors "value1" and "value2"
  70399. * @param value1 defines the first operand
  70400. * @param value2 defines the second operand
  70401. * @returns the squared distance
  70402. */
  70403. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70404. /**
  70405. * Returns a new Vector3 located at the center between "value1" and "value2"
  70406. * @param value1 defines the first operand
  70407. * @param value2 defines the second operand
  70408. * @returns the new Vector3
  70409. */
  70410. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  70411. /**
  70412. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70413. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70414. * to something in order to rotate it from its local system to the given target system
  70415. * Note: axis1, axis2 and axis3 are normalized during this operation
  70416. * @param axis1 defines the first axis
  70417. * @param axis2 defines the second axis
  70418. * @param axis3 defines the third axis
  70419. * @returns a new Vector3
  70420. */
  70421. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  70422. /**
  70423. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70424. * @param axis1 defines the first axis
  70425. * @param axis2 defines the second axis
  70426. * @param axis3 defines the third axis
  70427. * @param ref defines the Vector3 where to store the result
  70428. */
  70429. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  70430. }
  70431. /**
  70432. * Vector4 class created for EulerAngle class conversion to Quaternion
  70433. */
  70434. export class Vector4 {
  70435. /** x value of the vector */
  70436. x: number;
  70437. /** y value of the vector */
  70438. y: number;
  70439. /** z value of the vector */
  70440. z: number;
  70441. /** w value of the vector */
  70442. w: number;
  70443. /**
  70444. * Creates a Vector4 object from the given floats.
  70445. * @param x x value of the vector
  70446. * @param y y value of the vector
  70447. * @param z z value of the vector
  70448. * @param w w value of the vector
  70449. */
  70450. constructor(
  70451. /** x value of the vector */
  70452. x: number,
  70453. /** y value of the vector */
  70454. y: number,
  70455. /** z value of the vector */
  70456. z: number,
  70457. /** w value of the vector */
  70458. w: number);
  70459. /**
  70460. * Returns the string with the Vector4 coordinates.
  70461. * @returns a string containing all the vector values
  70462. */
  70463. toString(): string;
  70464. /**
  70465. * Returns the string "Vector4".
  70466. * @returns "Vector4"
  70467. */
  70468. getClassName(): string;
  70469. /**
  70470. * Returns the Vector4 hash code.
  70471. * @returns a unique hash code
  70472. */
  70473. getHashCode(): number;
  70474. /**
  70475. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70476. * @returns the resulting array
  70477. */
  70478. asArray(): number[];
  70479. /**
  70480. * Populates the given array from the given index with the Vector4 coordinates.
  70481. * @param array array to populate
  70482. * @param index index of the array to start at (default: 0)
  70483. * @returns the Vector4.
  70484. */
  70485. toArray(array: FloatArray, index?: number): Vector4;
  70486. /**
  70487. * Adds the given vector to the current Vector4.
  70488. * @param otherVector the vector to add
  70489. * @returns the updated Vector4.
  70490. */
  70491. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70492. /**
  70493. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70494. * @param otherVector the vector to add
  70495. * @returns the resulting vector
  70496. */
  70497. add(otherVector: DeepImmutable<Vector4>): Vector4;
  70498. /**
  70499. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70500. * @param otherVector the vector to add
  70501. * @param result the vector to store the result
  70502. * @returns the current Vector4.
  70503. */
  70504. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70505. /**
  70506. * Subtract in place the given vector from the current Vector4.
  70507. * @param otherVector the vector to subtract
  70508. * @returns the updated Vector4.
  70509. */
  70510. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70511. /**
  70512. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70513. * @param otherVector the vector to add
  70514. * @returns the new vector with the result
  70515. */
  70516. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  70517. /**
  70518. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70519. * @param otherVector the vector to subtract
  70520. * @param result the vector to store the result
  70521. * @returns the current Vector4.
  70522. */
  70523. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70524. /**
  70525. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70526. */
  70527. /**
  70528. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70529. * @param x value to subtract
  70530. * @param y value to subtract
  70531. * @param z value to subtract
  70532. * @param w value to subtract
  70533. * @returns new vector containing the result
  70534. */
  70535. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70536. /**
  70537. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70538. * @param x value to subtract
  70539. * @param y value to subtract
  70540. * @param z value to subtract
  70541. * @param w value to subtract
  70542. * @param result the vector to store the result in
  70543. * @returns the current Vector4.
  70544. */
  70545. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  70546. /**
  70547. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70548. * @returns a new vector with the negated values
  70549. */
  70550. negate(): Vector4;
  70551. /**
  70552. * Multiplies the current Vector4 coordinates by scale (float).
  70553. * @param scale the number to scale with
  70554. * @returns the updated Vector4.
  70555. */
  70556. scaleInPlace(scale: number): Vector4;
  70557. /**
  70558. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70559. * @param scale the number to scale with
  70560. * @returns a new vector with the result
  70561. */
  70562. scale(scale: number): Vector4;
  70563. /**
  70564. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70565. * @param scale the number to scale with
  70566. * @param result a vector to store the result in
  70567. * @returns the current Vector4.
  70568. */
  70569. scaleToRef(scale: number, result: Vector4): Vector4;
  70570. /**
  70571. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70572. * @param scale defines the scale factor
  70573. * @param result defines the Vector4 object where to store the result
  70574. * @returns the unmodified current Vector4
  70575. */
  70576. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  70577. /**
  70578. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70579. * @param otherVector the vector to compare against
  70580. * @returns true if they are equal
  70581. */
  70582. equals(otherVector: DeepImmutable<Vector4>): boolean;
  70583. /**
  70584. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70585. * @param otherVector vector to compare against
  70586. * @param epsilon (Default: very small number)
  70587. * @returns true if they are equal
  70588. */
  70589. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  70590. /**
  70591. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70592. * @param x x value to compare against
  70593. * @param y y value to compare against
  70594. * @param z z value to compare against
  70595. * @param w w value to compare against
  70596. * @returns true if equal
  70597. */
  70598. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  70599. /**
  70600. * Multiplies in place the current Vector4 by the given one.
  70601. * @param otherVector vector to multiple with
  70602. * @returns the updated Vector4.
  70603. */
  70604. multiplyInPlace(otherVector: Vector4): Vector4;
  70605. /**
  70606. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70607. * @param otherVector vector to multiple with
  70608. * @returns resulting new vector
  70609. */
  70610. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  70611. /**
  70612. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70613. * @param otherVector vector to multiple with
  70614. * @param result vector to store the result
  70615. * @returns the current Vector4.
  70616. */
  70617. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70618. /**
  70619. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70620. * @param x x value multiply with
  70621. * @param y y value multiply with
  70622. * @param z z value multiply with
  70623. * @param w w value multiply with
  70624. * @returns resulting new vector
  70625. */
  70626. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  70627. /**
  70628. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70629. * @param otherVector vector to devide with
  70630. * @returns resulting new vector
  70631. */
  70632. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  70633. /**
  70634. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70635. * @param otherVector vector to devide with
  70636. * @param result vector to store the result
  70637. * @returns the current Vector4.
  70638. */
  70639. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70640. /**
  70641. * Divides the current Vector3 coordinates by the given ones.
  70642. * @param otherVector vector to devide with
  70643. * @returns the updated Vector3.
  70644. */
  70645. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70646. /**
  70647. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70648. * @param other defines the second operand
  70649. * @returns the current updated Vector4
  70650. */
  70651. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70652. /**
  70653. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70654. * @param other defines the second operand
  70655. * @returns the current updated Vector4
  70656. */
  70657. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70658. /**
  70659. * Gets a new Vector4 from current Vector4 floored values
  70660. * @returns a new Vector4
  70661. */
  70662. floor(): Vector4;
  70663. /**
  70664. * Gets a new Vector4 from current Vector3 floored values
  70665. * @returns a new Vector4
  70666. */
  70667. fract(): Vector4;
  70668. /**
  70669. * Returns the Vector4 length (float).
  70670. * @returns the length
  70671. */
  70672. length(): number;
  70673. /**
  70674. * Returns the Vector4 squared length (float).
  70675. * @returns the length squared
  70676. */
  70677. lengthSquared(): number;
  70678. /**
  70679. * Normalizes in place the Vector4.
  70680. * @returns the updated Vector4.
  70681. */
  70682. normalize(): Vector4;
  70683. /**
  70684. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70685. * @returns this converted to a new vector3
  70686. */
  70687. toVector3(): Vector3;
  70688. /**
  70689. * Returns a new Vector4 copied from the current one.
  70690. * @returns the new cloned vector
  70691. */
  70692. clone(): Vector4;
  70693. /**
  70694. * Updates the current Vector4 with the given one coordinates.
  70695. * @param source the source vector to copy from
  70696. * @returns the updated Vector4.
  70697. */
  70698. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70699. /**
  70700. * Updates the current Vector4 coordinates with the given floats.
  70701. * @param x float to copy from
  70702. * @param y float to copy from
  70703. * @param z float to copy from
  70704. * @param w float to copy from
  70705. * @returns the updated Vector4.
  70706. */
  70707. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70708. /**
  70709. * Updates the current Vector4 coordinates with the given floats.
  70710. * @param x float to set from
  70711. * @param y float to set from
  70712. * @param z float to set from
  70713. * @param w float to set from
  70714. * @returns the updated Vector4.
  70715. */
  70716. set(x: number, y: number, z: number, w: number): Vector4;
  70717. /**
  70718. * Copies the given float to the current Vector3 coordinates
  70719. * @param v defines the x, y, z and w coordinates of the operand
  70720. * @returns the current updated Vector3
  70721. */
  70722. setAll(v: number): Vector4;
  70723. /**
  70724. * Returns a new Vector4 set from the starting index of the given array.
  70725. * @param array the array to pull values from
  70726. * @param offset the offset into the array to start at
  70727. * @returns the new vector
  70728. */
  70729. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70730. /**
  70731. * Updates the given vector "result" from the starting index of the given array.
  70732. * @param array the array to pull values from
  70733. * @param offset the offset into the array to start at
  70734. * @param result the vector to store the result in
  70735. */
  70736. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70737. /**
  70738. * Updates the given vector "result" from the starting index of the given Float32Array.
  70739. * @param array the array to pull values from
  70740. * @param offset the offset into the array to start at
  70741. * @param result the vector to store the result in
  70742. */
  70743. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70744. /**
  70745. * Updates the given vector "result" coordinates from the given floats.
  70746. * @param x float to set from
  70747. * @param y float to set from
  70748. * @param z float to set from
  70749. * @param w float to set from
  70750. * @param result the vector to the floats in
  70751. */
  70752. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70753. /**
  70754. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70755. * @returns the new vector
  70756. */
  70757. static Zero(): Vector4;
  70758. /**
  70759. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70760. * @returns the new vector
  70761. */
  70762. static One(): Vector4;
  70763. /**
  70764. * Returns a new normalized Vector4 from the given one.
  70765. * @param vector the vector to normalize
  70766. * @returns the vector
  70767. */
  70768. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70769. /**
  70770. * Updates the given vector "result" from the normalization of the given one.
  70771. * @param vector the vector to normalize
  70772. * @param result the vector to store the result in
  70773. */
  70774. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70775. /**
  70776. * Returns a vector with the minimum values from the left and right vectors
  70777. * @param left left vector to minimize
  70778. * @param right right vector to minimize
  70779. * @returns a new vector with the minimum of the left and right vector values
  70780. */
  70781. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70782. /**
  70783. * Returns a vector with the maximum values from the left and right vectors
  70784. * @param left left vector to maximize
  70785. * @param right right vector to maximize
  70786. * @returns a new vector with the maximum of the left and right vector values
  70787. */
  70788. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70789. /**
  70790. * Returns the distance (float) between the vectors "value1" and "value2".
  70791. * @param value1 value to calulate the distance between
  70792. * @param value2 value to calulate the distance between
  70793. * @return the distance between the two vectors
  70794. */
  70795. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70796. /**
  70797. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70798. * @param value1 value to calulate the distance between
  70799. * @param value2 value to calulate the distance between
  70800. * @return the distance between the two vectors squared
  70801. */
  70802. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70803. /**
  70804. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70805. * @param value1 value to calulate the center between
  70806. * @param value2 value to calulate the center between
  70807. * @return the center between the two vectors
  70808. */
  70809. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70810. /**
  70811. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70812. * This methods computes transformed normalized direction vectors only.
  70813. * @param vector the vector to transform
  70814. * @param transformation the transformation matrix to apply
  70815. * @returns the new vector
  70816. */
  70817. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70818. /**
  70819. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70820. * This methods computes transformed normalized direction vectors only.
  70821. * @param vector the vector to transform
  70822. * @param transformation the transformation matrix to apply
  70823. * @param result the vector to store the result in
  70824. */
  70825. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70826. /**
  70827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70828. * This methods computes transformed normalized direction vectors only.
  70829. * @param x value to transform
  70830. * @param y value to transform
  70831. * @param z value to transform
  70832. * @param w value to transform
  70833. * @param transformation the transformation matrix to apply
  70834. * @param result the vector to store the results in
  70835. */
  70836. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70837. /**
  70838. * Creates a new Vector4 from a Vector3
  70839. * @param source defines the source data
  70840. * @param w defines the 4th component (default is 0)
  70841. * @returns a new Vector4
  70842. */
  70843. static FromVector3(source: Vector3, w?: number): Vector4;
  70844. }
  70845. /**
  70846. * Class used to store quaternion data
  70847. * @see https://en.wikipedia.org/wiki/Quaternion
  70848. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70849. */
  70850. export class Quaternion {
  70851. /** defines the first component (0 by default) */
  70852. x: number;
  70853. /** defines the second component (0 by default) */
  70854. y: number;
  70855. /** defines the third component (0 by default) */
  70856. z: number;
  70857. /** defines the fourth component (1.0 by default) */
  70858. w: number;
  70859. /**
  70860. * Creates a new Quaternion from the given floats
  70861. * @param x defines the first component (0 by default)
  70862. * @param y defines the second component (0 by default)
  70863. * @param z defines the third component (0 by default)
  70864. * @param w defines the fourth component (1.0 by default)
  70865. */
  70866. constructor(
  70867. /** defines the first component (0 by default) */
  70868. x?: number,
  70869. /** defines the second component (0 by default) */
  70870. y?: number,
  70871. /** defines the third component (0 by default) */
  70872. z?: number,
  70873. /** defines the fourth component (1.0 by default) */
  70874. w?: number);
  70875. /**
  70876. * Gets a string representation for the current quaternion
  70877. * @returns a string with the Quaternion coordinates
  70878. */
  70879. toString(): string;
  70880. /**
  70881. * Gets the class name of the quaternion
  70882. * @returns the string "Quaternion"
  70883. */
  70884. getClassName(): string;
  70885. /**
  70886. * Gets a hash code for this quaternion
  70887. * @returns the quaternion hash code
  70888. */
  70889. getHashCode(): number;
  70890. /**
  70891. * Copy the quaternion to an array
  70892. * @returns a new array populated with 4 elements from the quaternion coordinates
  70893. */
  70894. asArray(): number[];
  70895. /**
  70896. * Check if two quaternions are equals
  70897. * @param otherQuaternion defines the second operand
  70898. * @return true if the current quaternion and the given one coordinates are strictly equals
  70899. */
  70900. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70901. /**
  70902. * Clone the current quaternion
  70903. * @returns a new quaternion copied from the current one
  70904. */
  70905. clone(): Quaternion;
  70906. /**
  70907. * Copy a quaternion to the current one
  70908. * @param other defines the other quaternion
  70909. * @returns the updated current quaternion
  70910. */
  70911. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70912. /**
  70913. * Updates the current quaternion with the given float coordinates
  70914. * @param x defines the x coordinate
  70915. * @param y defines the y coordinate
  70916. * @param z defines the z coordinate
  70917. * @param w defines the w coordinate
  70918. * @returns the updated current quaternion
  70919. */
  70920. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70921. /**
  70922. * Updates the current quaternion from the given float coordinates
  70923. * @param x defines the x coordinate
  70924. * @param y defines the y coordinate
  70925. * @param z defines the z coordinate
  70926. * @param w defines the w coordinate
  70927. * @returns the updated current quaternion
  70928. */
  70929. set(x: number, y: number, z: number, w: number): Quaternion;
  70930. /**
  70931. * Adds two quaternions
  70932. * @param other defines the second operand
  70933. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70934. */
  70935. add(other: DeepImmutable<Quaternion>): Quaternion;
  70936. /**
  70937. * Add a quaternion to the current one
  70938. * @param other defines the quaternion to add
  70939. * @returns the current quaternion
  70940. */
  70941. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70942. /**
  70943. * Subtract two quaternions
  70944. * @param other defines the second operand
  70945. * @returns a new quaternion as the subtraction result of the given one from the current one
  70946. */
  70947. subtract(other: Quaternion): Quaternion;
  70948. /**
  70949. * Multiplies the current quaternion by a scale factor
  70950. * @param value defines the scale factor
  70951. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70952. */
  70953. scale(value: number): Quaternion;
  70954. /**
  70955. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70956. * @param scale defines the scale factor
  70957. * @param result defines the Quaternion object where to store the result
  70958. * @returns the unmodified current quaternion
  70959. */
  70960. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70961. /**
  70962. * Multiplies in place the current quaternion by a scale factor
  70963. * @param value defines the scale factor
  70964. * @returns the current modified quaternion
  70965. */
  70966. scaleInPlace(value: number): Quaternion;
  70967. /**
  70968. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70969. * @param scale defines the scale factor
  70970. * @param result defines the Quaternion object where to store the result
  70971. * @returns the unmodified current quaternion
  70972. */
  70973. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70974. /**
  70975. * Multiplies two quaternions
  70976. * @param q1 defines the second operand
  70977. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70978. */
  70979. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70980. /**
  70981. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70982. * @param q1 defines the second operand
  70983. * @param result defines the target quaternion
  70984. * @returns the current quaternion
  70985. */
  70986. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  70987. /**
  70988. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70989. * @param q1 defines the second operand
  70990. * @returns the currentupdated quaternion
  70991. */
  70992. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  70993. /**
  70994. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70995. * @param ref defines the target quaternion
  70996. * @returns the current quaternion
  70997. */
  70998. conjugateToRef(ref: Quaternion): Quaternion;
  70999. /**
  71000. * Conjugates in place (1-q) the current quaternion
  71001. * @returns the current updated quaternion
  71002. */
  71003. conjugateInPlace(): Quaternion;
  71004. /**
  71005. * Conjugates in place (1-q) the current quaternion
  71006. * @returns a new quaternion
  71007. */
  71008. conjugate(): Quaternion;
  71009. /**
  71010. * Gets length of current quaternion
  71011. * @returns the quaternion length (float)
  71012. */
  71013. length(): number;
  71014. /**
  71015. * Normalize in place the current quaternion
  71016. * @returns the current updated quaternion
  71017. */
  71018. normalize(): Quaternion;
  71019. /**
  71020. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71021. * @param order is a reserved parameter and is ignore for now
  71022. * @returns a new Vector3 containing the Euler angles
  71023. */
  71024. toEulerAngles(order?: string): Vector3;
  71025. /**
  71026. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71027. * @param result defines the vector which will be filled with the Euler angles
  71028. * @param order is a reserved parameter and is ignore for now
  71029. * @returns the current unchanged quaternion
  71030. */
  71031. toEulerAnglesToRef(result: Vector3): Quaternion;
  71032. /**
  71033. * Updates the given rotation matrix with the current quaternion values
  71034. * @param result defines the target matrix
  71035. * @returns the current unchanged quaternion
  71036. */
  71037. toRotationMatrix(result: Matrix): Quaternion;
  71038. /**
  71039. * Updates the current quaternion from the given rotation matrix values
  71040. * @param matrix defines the source matrix
  71041. * @returns the current updated quaternion
  71042. */
  71043. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71044. /**
  71045. * Creates a new quaternion from a rotation matrix
  71046. * @param matrix defines the source matrix
  71047. * @returns a new quaternion created from the given rotation matrix values
  71048. */
  71049. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71050. /**
  71051. * Updates the given quaternion with the given rotation matrix values
  71052. * @param matrix defines the source matrix
  71053. * @param result defines the target quaternion
  71054. */
  71055. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71056. /**
  71057. * Returns the dot product (float) between the quaternions "left" and "right"
  71058. * @param left defines the left operand
  71059. * @param right defines the right operand
  71060. * @returns the dot product
  71061. */
  71062. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71063. /**
  71064. * Checks if the two quaternions are close to each other
  71065. * @param quat0 defines the first quaternion to check
  71066. * @param quat1 defines the second quaternion to check
  71067. * @returns true if the two quaternions are close to each other
  71068. */
  71069. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71070. /**
  71071. * Creates an empty quaternion
  71072. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71073. */
  71074. static Zero(): Quaternion;
  71075. /**
  71076. * Inverse a given quaternion
  71077. * @param q defines the source quaternion
  71078. * @returns a new quaternion as the inverted current quaternion
  71079. */
  71080. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71081. /**
  71082. * Inverse a given quaternion
  71083. * @param q defines the source quaternion
  71084. * @param result the quaternion the result will be stored in
  71085. * @returns the result quaternion
  71086. */
  71087. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71088. /**
  71089. * Creates an identity quaternion
  71090. * @returns the identity quaternion
  71091. */
  71092. static Identity(): Quaternion;
  71093. /**
  71094. * Gets a boolean indicating if the given quaternion is identity
  71095. * @param quaternion defines the quaternion to check
  71096. * @returns true if the quaternion is identity
  71097. */
  71098. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71099. /**
  71100. * Creates a quaternion from a rotation around an axis
  71101. * @param axis defines the axis to use
  71102. * @param angle defines the angle to use
  71103. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71104. */
  71105. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71106. /**
  71107. * Creates a rotation around an axis and stores it into the given quaternion
  71108. * @param axis defines the axis to use
  71109. * @param angle defines the angle to use
  71110. * @param result defines the target quaternion
  71111. * @returns the target quaternion
  71112. */
  71113. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71114. /**
  71115. * Creates a new quaternion from data stored into an array
  71116. * @param array defines the data source
  71117. * @param offset defines the offset in the source array where the data starts
  71118. * @returns a new quaternion
  71119. */
  71120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71121. /**
  71122. * Create a quaternion from Euler rotation angles
  71123. * @param x Pitch
  71124. * @param y Yaw
  71125. * @param z Roll
  71126. * @returns the new Quaternion
  71127. */
  71128. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71129. /**
  71130. * Updates a quaternion from Euler rotation angles
  71131. * @param x Pitch
  71132. * @param y Yaw
  71133. * @param z Roll
  71134. * @param result the quaternion to store the result
  71135. * @returns the updated quaternion
  71136. */
  71137. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71138. /**
  71139. * Create a quaternion from Euler rotation vector
  71140. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71141. * @returns the new Quaternion
  71142. */
  71143. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71144. /**
  71145. * Updates a quaternion from Euler rotation vector
  71146. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71147. * @param result the quaternion to store the result
  71148. * @returns the updated quaternion
  71149. */
  71150. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71151. /**
  71152. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71153. * @param yaw defines the rotation around Y axis
  71154. * @param pitch defines the rotation around X axis
  71155. * @param roll defines the rotation around Z axis
  71156. * @returns the new quaternion
  71157. */
  71158. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71159. /**
  71160. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71161. * @param yaw defines the rotation around Y axis
  71162. * @param pitch defines the rotation around X axis
  71163. * @param roll defines the rotation around Z axis
  71164. * @param result defines the target quaternion
  71165. */
  71166. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71167. /**
  71168. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71169. * @param alpha defines the rotation around first axis
  71170. * @param beta defines the rotation around second axis
  71171. * @param gamma defines the rotation around third axis
  71172. * @returns the new quaternion
  71173. */
  71174. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71175. /**
  71176. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71177. * @param alpha defines the rotation around first axis
  71178. * @param beta defines the rotation around second axis
  71179. * @param gamma defines the rotation around third axis
  71180. * @param result defines the target quaternion
  71181. */
  71182. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71183. /**
  71184. * 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)
  71185. * @param axis1 defines the first axis
  71186. * @param axis2 defines the second axis
  71187. * @param axis3 defines the third axis
  71188. * @returns the new quaternion
  71189. */
  71190. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71191. /**
  71192. * 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
  71193. * @param axis1 defines the first axis
  71194. * @param axis2 defines the second axis
  71195. * @param axis3 defines the third axis
  71196. * @param ref defines the target quaternion
  71197. */
  71198. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71199. /**
  71200. * Interpolates between two quaternions
  71201. * @param left defines first quaternion
  71202. * @param right defines second quaternion
  71203. * @param amount defines the gradient to use
  71204. * @returns the new interpolated quaternion
  71205. */
  71206. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71207. /**
  71208. * Interpolates between two quaternions and stores it into a target quaternion
  71209. * @param left defines first quaternion
  71210. * @param right defines second quaternion
  71211. * @param amount defines the gradient to use
  71212. * @param result defines the target quaternion
  71213. */
  71214. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71215. /**
  71216. * Interpolate between two quaternions using Hermite interpolation
  71217. * @param value1 defines first quaternion
  71218. * @param tangent1 defines the incoming tangent
  71219. * @param value2 defines second quaternion
  71220. * @param tangent2 defines the outgoing tangent
  71221. * @param amount defines the target quaternion
  71222. * @returns the new interpolated quaternion
  71223. */
  71224. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71225. }
  71226. /**
  71227. * Class used to store matrix data (4x4)
  71228. */
  71229. export class Matrix {
  71230. private static _updateFlagSeed;
  71231. private static _identityReadOnly;
  71232. private _isIdentity;
  71233. private _isIdentityDirty;
  71234. private _isIdentity3x2;
  71235. private _isIdentity3x2Dirty;
  71236. /**
  71237. * Gets the update flag of the matrix which is an unique number for the matrix.
  71238. * It will be incremented every time the matrix data change.
  71239. * You can use it to speed the comparison between two versions of the same matrix.
  71240. */
  71241. updateFlag: number;
  71242. private readonly _m;
  71243. /**
  71244. * Gets the internal data of the matrix
  71245. */
  71246. readonly m: DeepImmutable<Float32Array>;
  71247. /** @hidden */
  71248. _markAsUpdated(): void;
  71249. /** @hidden */
  71250. private _updateIdentityStatus;
  71251. /**
  71252. * Creates an empty matrix (filled with zeros)
  71253. */
  71254. constructor();
  71255. /**
  71256. * Check if the current matrix is identity
  71257. * @returns true is the matrix is the identity matrix
  71258. */
  71259. isIdentity(): boolean;
  71260. /**
  71261. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71262. * @returns true is the matrix is the identity matrix
  71263. */
  71264. isIdentityAs3x2(): boolean;
  71265. /**
  71266. * Gets the determinant of the matrix
  71267. * @returns the matrix determinant
  71268. */
  71269. determinant(): number;
  71270. /**
  71271. * Returns the matrix as a Float32Array
  71272. * @returns the matrix underlying array
  71273. */
  71274. toArray(): DeepImmutable<Float32Array>;
  71275. /**
  71276. * Returns the matrix as a Float32Array
  71277. * @returns the matrix underlying array.
  71278. */
  71279. asArray(): DeepImmutable<Float32Array>;
  71280. /**
  71281. * Inverts the current matrix in place
  71282. * @returns the current inverted matrix
  71283. */
  71284. invert(): Matrix;
  71285. /**
  71286. * Sets all the matrix elements to zero
  71287. * @returns the current matrix
  71288. */
  71289. reset(): Matrix;
  71290. /**
  71291. * Adds the current matrix with a second one
  71292. * @param other defines the matrix to add
  71293. * @returns a new matrix as the addition of the current matrix and the given one
  71294. */
  71295. add(other: DeepImmutable<Matrix>): Matrix;
  71296. /**
  71297. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71298. * @param other defines the matrix to add
  71299. * @param result defines the target matrix
  71300. * @returns the current matrix
  71301. */
  71302. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71303. /**
  71304. * Adds in place the given matrix to the current matrix
  71305. * @param other defines the second operand
  71306. * @returns the current updated matrix
  71307. */
  71308. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71309. /**
  71310. * Sets the given matrix to the current inverted Matrix
  71311. * @param other defines the target matrix
  71312. * @returns the unmodified current matrix
  71313. */
  71314. invertToRef(other: Matrix): Matrix;
  71315. /**
  71316. * add a value at the specified position in the current Matrix
  71317. * @param index the index of the value within the matrix. between 0 and 15.
  71318. * @param value the value to be added
  71319. * @returns the current updated matrix
  71320. */
  71321. addAtIndex(index: number, value: number): Matrix;
  71322. /**
  71323. * mutiply the specified position in the current Matrix by a value
  71324. * @param index the index of the value within the matrix. between 0 and 15.
  71325. * @param value the value to be added
  71326. * @returns the current updated matrix
  71327. */
  71328. multiplyAtIndex(index: number, value: number): Matrix;
  71329. /**
  71330. * Inserts the translation vector (using 3 floats) in the current matrix
  71331. * @param x defines the 1st component of the translation
  71332. * @param y defines the 2nd component of the translation
  71333. * @param z defines the 3rd component of the translation
  71334. * @returns the current updated matrix
  71335. */
  71336. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71337. /**
  71338. * Adds the translation vector (using 3 floats) in the current matrix
  71339. * @param x defines the 1st component of the translation
  71340. * @param y defines the 2nd component of the translation
  71341. * @param z defines the 3rd component of the translation
  71342. * @returns the current updated matrix
  71343. */
  71344. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71345. /**
  71346. * Inserts the translation vector in the current matrix
  71347. * @param vector3 defines the translation to insert
  71348. * @returns the current updated matrix
  71349. */
  71350. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71351. /**
  71352. * Gets the translation value of the current matrix
  71353. * @returns a new Vector3 as the extracted translation from the matrix
  71354. */
  71355. getTranslation(): Vector3;
  71356. /**
  71357. * Fill a Vector3 with the extracted translation from the matrix
  71358. * @param result defines the Vector3 where to store the translation
  71359. * @returns the current matrix
  71360. */
  71361. getTranslationToRef(result: Vector3): Matrix;
  71362. /**
  71363. * Remove rotation and scaling part from the matrix
  71364. * @returns the updated matrix
  71365. */
  71366. removeRotationAndScaling(): Matrix;
  71367. /**
  71368. * Multiply two matrices
  71369. * @param other defines the second operand
  71370. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71371. */
  71372. multiply(other: DeepImmutable<Matrix>): Matrix;
  71373. /**
  71374. * Copy the current matrix from the given one
  71375. * @param other defines the source matrix
  71376. * @returns the current updated matrix
  71377. */
  71378. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71379. /**
  71380. * Populates the given array from the starting index with the current matrix values
  71381. * @param array defines the target array
  71382. * @param offset defines the offset in the target array where to start storing values
  71383. * @returns the current matrix
  71384. */
  71385. copyToArray(array: Float32Array, offset?: number): Matrix;
  71386. /**
  71387. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71388. * @param other defines the second operand
  71389. * @param result defines the matrix where to store the multiplication
  71390. * @returns the current matrix
  71391. */
  71392. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71393. /**
  71394. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71395. * @param other defines the second operand
  71396. * @param result defines the array where to store the multiplication
  71397. * @param offset defines the offset in the target array where to start storing values
  71398. * @returns the current matrix
  71399. */
  71400. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71401. /**
  71402. * Check equality between this matrix and a second one
  71403. * @param value defines the second matrix to compare
  71404. * @returns true is the current matrix and the given one values are strictly equal
  71405. */
  71406. equals(value: DeepImmutable<Matrix>): boolean;
  71407. /**
  71408. * Clone the current matrix
  71409. * @returns a new matrix from the current matrix
  71410. */
  71411. clone(): Matrix;
  71412. /**
  71413. * Returns the name of the current matrix class
  71414. * @returns the string "Matrix"
  71415. */
  71416. getClassName(): string;
  71417. /**
  71418. * Gets the hash code of the current matrix
  71419. * @returns the hash code
  71420. */
  71421. getHashCode(): number;
  71422. /**
  71423. * Decomposes the current Matrix into a translation, rotation and scaling components
  71424. * @param scale defines the scale vector3 given as a reference to update
  71425. * @param rotation defines the rotation quaternion given as a reference to update
  71426. * @param translation defines the translation vector3 given as a reference to update
  71427. * @returns true if operation was successful
  71428. */
  71429. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  71430. /**
  71431. * Gets specific row of the matrix
  71432. * @param index defines the number of the row to get
  71433. * @returns the index-th row of the current matrix as a new Vector4
  71434. */
  71435. getRow(index: number): Nullable<Vector4>;
  71436. /**
  71437. * Sets the index-th row of the current matrix to the vector4 values
  71438. * @param index defines the number of the row to set
  71439. * @param row defines the target vector4
  71440. * @returns the updated current matrix
  71441. */
  71442. setRow(index: number, row: Vector4): Matrix;
  71443. /**
  71444. * Compute the transpose of the matrix
  71445. * @returns the new transposed matrix
  71446. */
  71447. transpose(): Matrix;
  71448. /**
  71449. * Compute the transpose of the matrix and store it in a given matrix
  71450. * @param result defines the target matrix
  71451. * @returns the current matrix
  71452. */
  71453. transposeToRef(result: Matrix): Matrix;
  71454. /**
  71455. * Sets the index-th row of the current matrix with the given 4 x float values
  71456. * @param index defines the row index
  71457. * @param x defines the x component to set
  71458. * @param y defines the y component to set
  71459. * @param z defines the z component to set
  71460. * @param w defines the w component to set
  71461. * @returns the updated current matrix
  71462. */
  71463. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  71464. /**
  71465. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71466. * @param scale defines the scale factor
  71467. * @returns a new matrix
  71468. */
  71469. scale(scale: number): Matrix;
  71470. /**
  71471. * Scale the current matrix values by a factor to a given result matrix
  71472. * @param scale defines the scale factor
  71473. * @param result defines the matrix to store the result
  71474. * @returns the current matrix
  71475. */
  71476. scaleToRef(scale: number, result: Matrix): Matrix;
  71477. /**
  71478. * Scale the current matrix values by a factor and add the result to a given matrix
  71479. * @param scale defines the scale factor
  71480. * @param result defines the Matrix to store the result
  71481. * @returns the current matrix
  71482. */
  71483. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  71484. /**
  71485. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71486. * @param ref matrix to store the result
  71487. */
  71488. toNormalMatrix(ref: Matrix): void;
  71489. /**
  71490. * Gets only rotation part of the current matrix
  71491. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71492. */
  71493. getRotationMatrix(): Matrix;
  71494. /**
  71495. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71496. * @param result defines the target matrix to store data to
  71497. * @returns the current matrix
  71498. */
  71499. getRotationMatrixToRef(result: Matrix): Matrix;
  71500. /**
  71501. * Toggles model matrix from being right handed to left handed in place and vice versa
  71502. */
  71503. toggleModelMatrixHandInPlace(): void;
  71504. /**
  71505. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71506. */
  71507. toggleProjectionMatrixHandInPlace(): void;
  71508. /**
  71509. * Creates a matrix from an array
  71510. * @param array defines the source array
  71511. * @param offset defines an offset in the source array
  71512. * @returns a new Matrix set from the starting index of the given array
  71513. */
  71514. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  71515. /**
  71516. * Copy the content of an array into a given matrix
  71517. * @param array defines the source array
  71518. * @param offset defines an offset in the source array
  71519. * @param result defines the target matrix
  71520. */
  71521. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  71522. /**
  71523. * Stores an array into a matrix after having multiplied each component by a given factor
  71524. * @param array defines the source array
  71525. * @param offset defines the offset in the source array
  71526. * @param scale defines the scaling factor
  71527. * @param result defines the target matrix
  71528. */
  71529. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  71530. /**
  71531. * Gets an identity matrix that must not be updated
  71532. */
  71533. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  71534. /**
  71535. * Stores a list of values (16) inside a given matrix
  71536. * @param initialM11 defines 1st value of 1st row
  71537. * @param initialM12 defines 2nd value of 1st row
  71538. * @param initialM13 defines 3rd value of 1st row
  71539. * @param initialM14 defines 4th value of 1st row
  71540. * @param initialM21 defines 1st value of 2nd row
  71541. * @param initialM22 defines 2nd value of 2nd row
  71542. * @param initialM23 defines 3rd value of 2nd row
  71543. * @param initialM24 defines 4th value of 2nd row
  71544. * @param initialM31 defines 1st value of 3rd row
  71545. * @param initialM32 defines 2nd value of 3rd row
  71546. * @param initialM33 defines 3rd value of 3rd row
  71547. * @param initialM34 defines 4th value of 3rd row
  71548. * @param initialM41 defines 1st value of 4th row
  71549. * @param initialM42 defines 2nd value of 4th row
  71550. * @param initialM43 defines 3rd value of 4th row
  71551. * @param initialM44 defines 4th value of 4th row
  71552. * @param result defines the target matrix
  71553. */
  71554. 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;
  71555. /**
  71556. * Creates new matrix from a list of values (16)
  71557. * @param initialM11 defines 1st value of 1st row
  71558. * @param initialM12 defines 2nd value of 1st row
  71559. * @param initialM13 defines 3rd value of 1st row
  71560. * @param initialM14 defines 4th value of 1st row
  71561. * @param initialM21 defines 1st value of 2nd row
  71562. * @param initialM22 defines 2nd value of 2nd row
  71563. * @param initialM23 defines 3rd value of 2nd row
  71564. * @param initialM24 defines 4th value of 2nd row
  71565. * @param initialM31 defines 1st value of 3rd row
  71566. * @param initialM32 defines 2nd value of 3rd row
  71567. * @param initialM33 defines 3rd value of 3rd row
  71568. * @param initialM34 defines 4th value of 3rd row
  71569. * @param initialM41 defines 1st value of 4th row
  71570. * @param initialM42 defines 2nd value of 4th row
  71571. * @param initialM43 defines 3rd value of 4th row
  71572. * @param initialM44 defines 4th value of 4th row
  71573. * @returns the new matrix
  71574. */
  71575. 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;
  71576. /**
  71577. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71578. * @param scale defines the scale vector3
  71579. * @param rotation defines the rotation quaternion
  71580. * @param translation defines the translation vector3
  71581. * @returns a new matrix
  71582. */
  71583. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  71584. /**
  71585. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71586. * @param scale defines the scale vector3
  71587. * @param rotation defines the rotation quaternion
  71588. * @param translation defines the translation vector3
  71589. * @param result defines the target matrix
  71590. */
  71591. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  71592. /**
  71593. * Creates a new identity matrix
  71594. * @returns a new identity matrix
  71595. */
  71596. static Identity(): Matrix;
  71597. /**
  71598. * Creates a new identity matrix and stores the result in a given matrix
  71599. * @param result defines the target matrix
  71600. */
  71601. static IdentityToRef(result: Matrix): void;
  71602. /**
  71603. * Creates a new zero matrix
  71604. * @returns a new zero matrix
  71605. */
  71606. static Zero(): Matrix;
  71607. /**
  71608. * Creates a new rotation matrix for "angle" radians around the X axis
  71609. * @param angle defines the angle (in radians) to use
  71610. * @return the new matrix
  71611. */
  71612. static RotationX(angle: number): Matrix;
  71613. /**
  71614. * Creates a new matrix as the invert of a given matrix
  71615. * @param source defines the source matrix
  71616. * @returns the new matrix
  71617. */
  71618. static Invert(source: DeepImmutable<Matrix>): Matrix;
  71619. /**
  71620. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  71621. * @param angle defines the angle (in radians) to use
  71622. * @param result defines the target matrix
  71623. */
  71624. static RotationXToRef(angle: number, result: Matrix): void;
  71625. /**
  71626. * Creates a new rotation matrix for "angle" radians around the Y axis
  71627. * @param angle defines the angle (in radians) to use
  71628. * @return the new matrix
  71629. */
  71630. static RotationY(angle: number): Matrix;
  71631. /**
  71632. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  71633. * @param angle defines the angle (in radians) to use
  71634. * @param result defines the target matrix
  71635. */
  71636. static RotationYToRef(angle: number, result: Matrix): void;
  71637. /**
  71638. * Creates a new rotation matrix for "angle" radians around the Z axis
  71639. * @param angle defines the angle (in radians) to use
  71640. * @return the new matrix
  71641. */
  71642. static RotationZ(angle: number): Matrix;
  71643. /**
  71644. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  71645. * @param angle defines the angle (in radians) to use
  71646. * @param result defines the target matrix
  71647. */
  71648. static RotationZToRef(angle: number, result: Matrix): void;
  71649. /**
  71650. * Creates a new rotation matrix for "angle" radians around the given axis
  71651. * @param axis defines the axis to use
  71652. * @param angle defines the angle (in radians) to use
  71653. * @return the new matrix
  71654. */
  71655. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71656. /**
  71657. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71658. * @param axis defines the axis to use
  71659. * @param angle defines the angle (in radians) to use
  71660. * @param result defines the target matrix
  71661. */
  71662. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71663. /**
  71664. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71665. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71666. * @param from defines the vector to align
  71667. * @param to defines the vector to align to
  71668. * @param result defines the target matrix
  71669. */
  71670. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71671. /**
  71672. * Creates a rotation matrix
  71673. * @param yaw defines the yaw angle in radians (Y axis)
  71674. * @param pitch defines the pitch angle in radians (X axis)
  71675. * @param roll defines the roll angle in radians (X axis)
  71676. * @returns the new rotation matrix
  71677. */
  71678. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71679. /**
  71680. * Creates a rotation matrix and stores it in a given matrix
  71681. * @param yaw defines the yaw angle in radians (Y axis)
  71682. * @param pitch defines the pitch angle in radians (X axis)
  71683. * @param roll defines the roll angle in radians (X axis)
  71684. * @param result defines the target matrix
  71685. */
  71686. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71687. /**
  71688. * Creates a scaling matrix
  71689. * @param x defines the scale factor on X axis
  71690. * @param y defines the scale factor on Y axis
  71691. * @param z defines the scale factor on Z axis
  71692. * @returns the new matrix
  71693. */
  71694. static Scaling(x: number, y: number, z: number): Matrix;
  71695. /**
  71696. * Creates a scaling matrix and stores it in a given matrix
  71697. * @param x defines the scale factor on X axis
  71698. * @param y defines the scale factor on Y axis
  71699. * @param z defines the scale factor on Z axis
  71700. * @param result defines the target matrix
  71701. */
  71702. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71703. /**
  71704. * Creates a translation matrix
  71705. * @param x defines the translation on X axis
  71706. * @param y defines the translation on Y axis
  71707. * @param z defines the translationon Z axis
  71708. * @returns the new matrix
  71709. */
  71710. static Translation(x: number, y: number, z: number): Matrix;
  71711. /**
  71712. * Creates a translation matrix and stores it in a given matrix
  71713. * @param x defines the translation on X axis
  71714. * @param y defines the translation on Y axis
  71715. * @param z defines the translationon Z axis
  71716. * @param result defines the target matrix
  71717. */
  71718. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71719. /**
  71720. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71721. * @param startValue defines the start value
  71722. * @param endValue defines the end value
  71723. * @param gradient defines the gradient factor
  71724. * @returns the new matrix
  71725. */
  71726. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71727. /**
  71728. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71729. * @param startValue defines the start value
  71730. * @param endValue defines the end value
  71731. * @param gradient defines the gradient factor
  71732. * @param result defines the Matrix object where to store data
  71733. */
  71734. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71735. /**
  71736. * Builds a new matrix whose values are computed by:
  71737. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71738. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71739. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71740. * @param startValue defines the first matrix
  71741. * @param endValue defines the second matrix
  71742. * @param gradient defines the gradient between the two matrices
  71743. * @returns the new matrix
  71744. */
  71745. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71746. /**
  71747. * Update a matrix to values which are computed by:
  71748. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71749. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71750. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71751. * @param startValue defines the first matrix
  71752. * @param endValue defines the second matrix
  71753. * @param gradient defines the gradient between the two matrices
  71754. * @param result defines the target matrix
  71755. */
  71756. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71757. /**
  71758. * 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"
  71759. * This function works in left handed mode
  71760. * @param eye defines the final position of the entity
  71761. * @param target defines where the entity should look at
  71762. * @param up defines the up vector for the entity
  71763. * @returns the new matrix
  71764. */
  71765. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71766. /**
  71767. * 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".
  71768. * This function works in left handed mode
  71769. * @param eye defines the final position of the entity
  71770. * @param target defines where the entity should look at
  71771. * @param up defines the up vector for the entity
  71772. * @param result defines the target matrix
  71773. */
  71774. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71775. /**
  71776. * 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"
  71777. * This function works in right handed mode
  71778. * @param eye defines the final position of the entity
  71779. * @param target defines where the entity should look at
  71780. * @param up defines the up vector for the entity
  71781. * @returns the new matrix
  71782. */
  71783. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71784. /**
  71785. * 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".
  71786. * This function works in right handed mode
  71787. * @param eye defines the final position of the entity
  71788. * @param target defines where the entity should look at
  71789. * @param up defines the up vector for the entity
  71790. * @param result defines the target matrix
  71791. */
  71792. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71793. /**
  71794. * Create a left-handed orthographic projection matrix
  71795. * @param width defines the viewport width
  71796. * @param height defines the viewport height
  71797. * @param znear defines the near clip plane
  71798. * @param zfar defines the far clip plane
  71799. * @returns a new matrix as a left-handed orthographic projection matrix
  71800. */
  71801. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71802. /**
  71803. * Store a left-handed orthographic projection to a given matrix
  71804. * @param width defines the viewport width
  71805. * @param height defines the viewport height
  71806. * @param znear defines the near clip plane
  71807. * @param zfar defines the far clip plane
  71808. * @param result defines the target matrix
  71809. */
  71810. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71811. /**
  71812. * Create a left-handed orthographic projection matrix
  71813. * @param left defines the viewport left coordinate
  71814. * @param right defines the viewport right coordinate
  71815. * @param bottom defines the viewport bottom coordinate
  71816. * @param top defines the viewport top coordinate
  71817. * @param znear defines the near clip plane
  71818. * @param zfar defines the far clip plane
  71819. * @returns a new matrix as a left-handed orthographic projection matrix
  71820. */
  71821. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71822. /**
  71823. * Stores a left-handed orthographic projection into a given matrix
  71824. * @param left defines the viewport left coordinate
  71825. * @param right defines the viewport right coordinate
  71826. * @param bottom defines the viewport bottom coordinate
  71827. * @param top defines the viewport top coordinate
  71828. * @param znear defines the near clip plane
  71829. * @param zfar defines the far clip plane
  71830. * @param result defines the target matrix
  71831. */
  71832. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71833. /**
  71834. * Creates a right-handed orthographic projection matrix
  71835. * @param left defines the viewport left coordinate
  71836. * @param right defines the viewport right coordinate
  71837. * @param bottom defines the viewport bottom coordinate
  71838. * @param top defines the viewport top coordinate
  71839. * @param znear defines the near clip plane
  71840. * @param zfar defines the far clip plane
  71841. * @returns a new matrix as a right-handed orthographic projection matrix
  71842. */
  71843. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71844. /**
  71845. * Stores a right-handed orthographic projection into a given matrix
  71846. * @param left defines the viewport left coordinate
  71847. * @param right defines the viewport right coordinate
  71848. * @param bottom defines the viewport bottom coordinate
  71849. * @param top defines the viewport top coordinate
  71850. * @param znear defines the near clip plane
  71851. * @param zfar defines the far clip plane
  71852. * @param result defines the target matrix
  71853. */
  71854. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71855. /**
  71856. * Creates a left-handed perspective projection matrix
  71857. * @param width defines the viewport width
  71858. * @param height defines the viewport height
  71859. * @param znear defines the near clip plane
  71860. * @param zfar defines the far clip plane
  71861. * @returns a new matrix as a left-handed perspective projection matrix
  71862. */
  71863. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71864. /**
  71865. * Creates a left-handed perspective projection matrix
  71866. * @param fov defines the horizontal field of view
  71867. * @param aspect defines the aspect ratio
  71868. * @param znear defines the near clip plane
  71869. * @param zfar defines the far clip plane
  71870. * @returns a new matrix as a left-handed perspective projection matrix
  71871. */
  71872. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71873. /**
  71874. * Stores a left-handed perspective projection into a given matrix
  71875. * @param fov defines the horizontal field of view
  71876. * @param aspect defines the aspect ratio
  71877. * @param znear defines the near clip plane
  71878. * @param zfar defines the far clip plane
  71879. * @param result defines the target matrix
  71880. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71881. */
  71882. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71883. /**
  71884. * Creates a right-handed perspective projection matrix
  71885. * @param fov defines the horizontal field of view
  71886. * @param aspect defines the aspect ratio
  71887. * @param znear defines the near clip plane
  71888. * @param zfar defines the far clip plane
  71889. * @returns a new matrix as a right-handed perspective projection matrix
  71890. */
  71891. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71892. /**
  71893. * Stores a right-handed perspective projection into a given matrix
  71894. * @param fov defines the horizontal field of view
  71895. * @param aspect defines the aspect ratio
  71896. * @param znear defines the near clip plane
  71897. * @param zfar defines the far clip plane
  71898. * @param result defines the target matrix
  71899. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71900. */
  71901. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71902. /**
  71903. * Stores a perspective projection for WebVR info a given matrix
  71904. * @param fov defines the field of view
  71905. * @param znear defines the near clip plane
  71906. * @param zfar defines the far clip plane
  71907. * @param result defines the target matrix
  71908. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71909. */
  71910. static PerspectiveFovWebVRToRef(fov: {
  71911. upDegrees: number;
  71912. downDegrees: number;
  71913. leftDegrees: number;
  71914. rightDegrees: number;
  71915. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71916. /**
  71917. * Computes a complete transformation matrix
  71918. * @param viewport defines the viewport to use
  71919. * @param world defines the world matrix
  71920. * @param view defines the view matrix
  71921. * @param projection defines the projection matrix
  71922. * @param zmin defines the near clip plane
  71923. * @param zmax defines the far clip plane
  71924. * @returns the transformation matrix
  71925. */
  71926. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71927. /**
  71928. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71929. * @param matrix defines the matrix to use
  71930. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71931. */
  71932. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71933. /**
  71934. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71935. * @param matrix defines the matrix to use
  71936. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71937. */
  71938. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71939. /**
  71940. * Compute the transpose of a given matrix
  71941. * @param matrix defines the matrix to transpose
  71942. * @returns the new matrix
  71943. */
  71944. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71945. /**
  71946. * Compute the transpose of a matrix and store it in a target matrix
  71947. * @param matrix defines the matrix to transpose
  71948. * @param result defines the target matrix
  71949. */
  71950. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71951. /**
  71952. * Computes a reflection matrix from a plane
  71953. * @param plane defines the reflection plane
  71954. * @returns a new matrix
  71955. */
  71956. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71957. /**
  71958. * Computes a reflection matrix from a plane
  71959. * @param plane defines the reflection plane
  71960. * @param result defines the target matrix
  71961. */
  71962. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71963. /**
  71964. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71965. * @param xaxis defines the value of the 1st axis
  71966. * @param yaxis defines the value of the 2nd axis
  71967. * @param zaxis defines the value of the 3rd axis
  71968. * @param result defines the target matrix
  71969. */
  71970. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71971. /**
  71972. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71973. * @param quat defines the quaternion to use
  71974. * @param result defines the target matrix
  71975. */
  71976. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71977. }
  71978. /**
  71979. * @hidden
  71980. */
  71981. export class TmpVectors {
  71982. static Vector2: Vector2[];
  71983. static Vector3: Vector3[];
  71984. static Vector4: Vector4[];
  71985. static Quaternion: Quaternion[];
  71986. static Matrix: Matrix[];
  71987. }
  71988. }
  71989. declare module BABYLON {
  71990. /**
  71991. * Defines potential orientation for back face culling
  71992. */
  71993. export enum Orientation {
  71994. /**
  71995. * Clockwise
  71996. */
  71997. CW = 0,
  71998. /** Counter clockwise */
  71999. CCW = 1
  72000. }
  72001. /** Class used to represent a Bezier curve */
  72002. export class BezierCurve {
  72003. /**
  72004. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72005. * @param t defines the time
  72006. * @param x1 defines the left coordinate on X axis
  72007. * @param y1 defines the left coordinate on Y axis
  72008. * @param x2 defines the right coordinate on X axis
  72009. * @param y2 defines the right coordinate on Y axis
  72010. * @returns the interpolated value
  72011. */
  72012. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72013. }
  72014. /**
  72015. * Defines angle representation
  72016. */
  72017. export class Angle {
  72018. private _radians;
  72019. /**
  72020. * Creates an Angle object of "radians" radians (float).
  72021. * @param radians the angle in radians
  72022. */
  72023. constructor(radians: number);
  72024. /**
  72025. * Get value in degrees
  72026. * @returns the Angle value in degrees (float)
  72027. */
  72028. degrees(): number;
  72029. /**
  72030. * Get value in radians
  72031. * @returns the Angle value in radians (float)
  72032. */
  72033. radians(): number;
  72034. /**
  72035. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72036. * @param a defines first vector
  72037. * @param b defines second vector
  72038. * @returns a new Angle
  72039. */
  72040. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72041. /**
  72042. * Gets a new Angle object from the given float in radians
  72043. * @param radians defines the angle value in radians
  72044. * @returns a new Angle
  72045. */
  72046. static FromRadians(radians: number): Angle;
  72047. /**
  72048. * Gets a new Angle object from the given float in degrees
  72049. * @param degrees defines the angle value in degrees
  72050. * @returns a new Angle
  72051. */
  72052. static FromDegrees(degrees: number): Angle;
  72053. }
  72054. /**
  72055. * This represents an arc in a 2d space.
  72056. */
  72057. export class Arc2 {
  72058. /** Defines the start point of the arc */
  72059. startPoint: Vector2;
  72060. /** Defines the mid point of the arc */
  72061. midPoint: Vector2;
  72062. /** Defines the end point of the arc */
  72063. endPoint: Vector2;
  72064. /**
  72065. * Defines the center point of the arc.
  72066. */
  72067. centerPoint: Vector2;
  72068. /**
  72069. * Defines the radius of the arc.
  72070. */
  72071. radius: number;
  72072. /**
  72073. * Defines the angle of the arc (from mid point to end point).
  72074. */
  72075. angle: Angle;
  72076. /**
  72077. * Defines the start angle of the arc (from start point to middle point).
  72078. */
  72079. startAngle: Angle;
  72080. /**
  72081. * Defines the orientation of the arc (clock wise/counter clock wise).
  72082. */
  72083. orientation: Orientation;
  72084. /**
  72085. * Creates an Arc object from the three given points : start, middle and end.
  72086. * @param startPoint Defines the start point of the arc
  72087. * @param midPoint Defines the midlle point of the arc
  72088. * @param endPoint Defines the end point of the arc
  72089. */
  72090. constructor(
  72091. /** Defines the start point of the arc */
  72092. startPoint: Vector2,
  72093. /** Defines the mid point of the arc */
  72094. midPoint: Vector2,
  72095. /** Defines the end point of the arc */
  72096. endPoint: Vector2);
  72097. }
  72098. /**
  72099. * Represents a 2D path made up of multiple 2D points
  72100. */
  72101. export class Path2 {
  72102. private _points;
  72103. private _length;
  72104. /**
  72105. * If the path start and end point are the same
  72106. */
  72107. closed: boolean;
  72108. /**
  72109. * Creates a Path2 object from the starting 2D coordinates x and y.
  72110. * @param x the starting points x value
  72111. * @param y the starting points y value
  72112. */
  72113. constructor(x: number, y: number);
  72114. /**
  72115. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72116. * @param x the added points x value
  72117. * @param y the added points y value
  72118. * @returns the updated Path2.
  72119. */
  72120. addLineTo(x: number, y: number): Path2;
  72121. /**
  72122. * 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.
  72123. * @param midX middle point x value
  72124. * @param midY middle point y value
  72125. * @param endX end point x value
  72126. * @param endY end point y value
  72127. * @param numberOfSegments (default: 36)
  72128. * @returns the updated Path2.
  72129. */
  72130. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72131. /**
  72132. * Closes the Path2.
  72133. * @returns the Path2.
  72134. */
  72135. close(): Path2;
  72136. /**
  72137. * Gets the sum of the distance between each sequential point in the path
  72138. * @returns the Path2 total length (float).
  72139. */
  72140. length(): number;
  72141. /**
  72142. * Gets the points which construct the path
  72143. * @returns the Path2 internal array of points.
  72144. */
  72145. getPoints(): Vector2[];
  72146. /**
  72147. * Retreives the point at the distance aways from the starting point
  72148. * @param normalizedLengthPosition the length along the path to retreive the point from
  72149. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72150. */
  72151. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72152. /**
  72153. * Creates a new path starting from an x and y position
  72154. * @param x starting x value
  72155. * @param y starting y value
  72156. * @returns a new Path2 starting at the coordinates (x, y).
  72157. */
  72158. static StartingAt(x: number, y: number): Path2;
  72159. }
  72160. /**
  72161. * Represents a 3D path made up of multiple 3D points
  72162. */
  72163. export class Path3D {
  72164. /**
  72165. * an array of Vector3, the curve axis of the Path3D
  72166. */
  72167. path: Vector3[];
  72168. private _curve;
  72169. private _distances;
  72170. private _tangents;
  72171. private _normals;
  72172. private _binormals;
  72173. private _raw;
  72174. /**
  72175. * new Path3D(path, normal, raw)
  72176. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72177. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72178. * @param path an array of Vector3, the curve axis of the Path3D
  72179. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72180. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72181. */
  72182. constructor(
  72183. /**
  72184. * an array of Vector3, the curve axis of the Path3D
  72185. */
  72186. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72187. /**
  72188. * Returns the Path3D array of successive Vector3 designing its curve.
  72189. * @returns the Path3D array of successive Vector3 designing its curve.
  72190. */
  72191. getCurve(): Vector3[];
  72192. /**
  72193. * Returns an array populated with tangent vectors on each Path3D curve point.
  72194. * @returns an array populated with tangent vectors on each Path3D curve point.
  72195. */
  72196. getTangents(): Vector3[];
  72197. /**
  72198. * Returns an array populated with normal vectors on each Path3D curve point.
  72199. * @returns an array populated with normal vectors on each Path3D curve point.
  72200. */
  72201. getNormals(): Vector3[];
  72202. /**
  72203. * Returns an array populated with binormal vectors on each Path3D curve point.
  72204. * @returns an array populated with binormal vectors on each Path3D curve point.
  72205. */
  72206. getBinormals(): Vector3[];
  72207. /**
  72208. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72209. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72210. */
  72211. getDistances(): number[];
  72212. /**
  72213. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72214. * @param path path which all values are copied into the curves points
  72215. * @param firstNormal which should be projected onto the curve
  72216. * @returns the same object updated.
  72217. */
  72218. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72219. private _compute;
  72220. private _getFirstNonNullVector;
  72221. private _getLastNonNullVector;
  72222. private _normalVector;
  72223. }
  72224. /**
  72225. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72226. * A Curve3 is designed from a series of successive Vector3.
  72227. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72228. */
  72229. export class Curve3 {
  72230. private _points;
  72231. private _length;
  72232. /**
  72233. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72234. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72235. * @param v1 (Vector3) the control point
  72236. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72237. * @param nbPoints (integer) the wanted number of points in the curve
  72238. * @returns the created Curve3
  72239. */
  72240. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72241. /**
  72242. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72243. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72244. * @param v1 (Vector3) the first control point
  72245. * @param v2 (Vector3) the second control point
  72246. * @param v3 (Vector3) the end point of the Cubic Bezier
  72247. * @param nbPoints (integer) the wanted number of points in the curve
  72248. * @returns the created Curve3
  72249. */
  72250. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72251. /**
  72252. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72253. * @param p1 (Vector3) the origin point of the Hermite Spline
  72254. * @param t1 (Vector3) the tangent vector at the origin point
  72255. * @param p2 (Vector3) the end point of the Hermite Spline
  72256. * @param t2 (Vector3) the tangent vector at the end point
  72257. * @param nbPoints (integer) the wanted number of points in the curve
  72258. * @returns the created Curve3
  72259. */
  72260. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72261. /**
  72262. * Returns a Curve3 object along a CatmullRom Spline curve :
  72263. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72264. * @param nbPoints (integer) the wanted number of points between each curve control points
  72265. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72266. * @returns the created Curve3
  72267. */
  72268. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72269. /**
  72270. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72271. * A Curve3 is designed from a series of successive Vector3.
  72272. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72273. * @param points points which make up the curve
  72274. */
  72275. constructor(points: Vector3[]);
  72276. /**
  72277. * @returns the Curve3 stored array of successive Vector3
  72278. */
  72279. getPoints(): Vector3[];
  72280. /**
  72281. * @returns the computed length (float) of the curve.
  72282. */
  72283. length(): number;
  72284. /**
  72285. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72286. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72287. * curveA and curveB keep unchanged.
  72288. * @param curve the curve to continue from this curve
  72289. * @returns the newly constructed curve
  72290. */
  72291. continue(curve: DeepImmutable<Curve3>): Curve3;
  72292. private _computeLength;
  72293. }
  72294. }
  72295. declare module BABYLON {
  72296. /**
  72297. * This represents the main contract an easing function should follow.
  72298. * Easing functions are used throughout the animation system.
  72299. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72300. */
  72301. export interface IEasingFunction {
  72302. /**
  72303. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72304. * of the easing function.
  72305. * The link below provides some of the most common examples of easing functions.
  72306. * @see https://easings.net/
  72307. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72308. * @returns the corresponding value on the curve defined by the easing function
  72309. */
  72310. ease(gradient: number): number;
  72311. }
  72312. /**
  72313. * Base class used for every default easing function.
  72314. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72315. */
  72316. export class EasingFunction implements IEasingFunction {
  72317. /**
  72318. * Interpolation follows the mathematical formula associated with the easing function.
  72319. */
  72320. static readonly EASINGMODE_EASEIN: number;
  72321. /**
  72322. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72323. */
  72324. static readonly EASINGMODE_EASEOUT: number;
  72325. /**
  72326. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72327. */
  72328. static readonly EASINGMODE_EASEINOUT: number;
  72329. private _easingMode;
  72330. /**
  72331. * Sets the easing mode of the current function.
  72332. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72333. */
  72334. setEasingMode(easingMode: number): void;
  72335. /**
  72336. * Gets the current easing mode.
  72337. * @returns the easing mode
  72338. */
  72339. getEasingMode(): number;
  72340. /**
  72341. * @hidden
  72342. */
  72343. easeInCore(gradient: number): number;
  72344. /**
  72345. * Given an input gradient between 0 and 1, this returns the corresponding value
  72346. * of the easing function.
  72347. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72348. * @returns the corresponding value on the curve defined by the easing function
  72349. */
  72350. ease(gradient: number): number;
  72351. }
  72352. /**
  72353. * Easing function with a circle shape (see link below).
  72354. * @see https://easings.net/#easeInCirc
  72355. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72356. */
  72357. export class CircleEase extends EasingFunction implements IEasingFunction {
  72358. /** @hidden */
  72359. easeInCore(gradient: number): number;
  72360. }
  72361. /**
  72362. * Easing function with a ease back shape (see link below).
  72363. * @see https://easings.net/#easeInBack
  72364. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72365. */
  72366. export class BackEase extends EasingFunction implements IEasingFunction {
  72367. /** Defines the amplitude of the function */
  72368. amplitude: number;
  72369. /**
  72370. * Instantiates a back ease easing
  72371. * @see https://easings.net/#easeInBack
  72372. * @param amplitude Defines the amplitude of the function
  72373. */
  72374. constructor(
  72375. /** Defines the amplitude of the function */
  72376. amplitude?: number);
  72377. /** @hidden */
  72378. easeInCore(gradient: number): number;
  72379. }
  72380. /**
  72381. * Easing function with a bouncing shape (see link below).
  72382. * @see https://easings.net/#easeInBounce
  72383. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72384. */
  72385. export class BounceEase extends EasingFunction implements IEasingFunction {
  72386. /** Defines the number of bounces */
  72387. bounces: number;
  72388. /** Defines the amplitude of the bounce */
  72389. bounciness: number;
  72390. /**
  72391. * Instantiates a bounce easing
  72392. * @see https://easings.net/#easeInBounce
  72393. * @param bounces Defines the number of bounces
  72394. * @param bounciness Defines the amplitude of the bounce
  72395. */
  72396. constructor(
  72397. /** Defines the number of bounces */
  72398. bounces?: number,
  72399. /** Defines the amplitude of the bounce */
  72400. bounciness?: number);
  72401. /** @hidden */
  72402. easeInCore(gradient: number): number;
  72403. }
  72404. /**
  72405. * Easing function with a power of 3 shape (see link below).
  72406. * @see https://easings.net/#easeInCubic
  72407. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72408. */
  72409. export class CubicEase extends EasingFunction implements IEasingFunction {
  72410. /** @hidden */
  72411. easeInCore(gradient: number): number;
  72412. }
  72413. /**
  72414. * Easing function with an elastic shape (see link below).
  72415. * @see https://easings.net/#easeInElastic
  72416. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72417. */
  72418. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72419. /** Defines the number of oscillations*/
  72420. oscillations: number;
  72421. /** Defines the amplitude of the oscillations*/
  72422. springiness: number;
  72423. /**
  72424. * Instantiates an elastic easing function
  72425. * @see https://easings.net/#easeInElastic
  72426. * @param oscillations Defines the number of oscillations
  72427. * @param springiness Defines the amplitude of the oscillations
  72428. */
  72429. constructor(
  72430. /** Defines the number of oscillations*/
  72431. oscillations?: number,
  72432. /** Defines the amplitude of the oscillations*/
  72433. springiness?: number);
  72434. /** @hidden */
  72435. easeInCore(gradient: number): number;
  72436. }
  72437. /**
  72438. * Easing function with an exponential shape (see link below).
  72439. * @see https://easings.net/#easeInExpo
  72440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72441. */
  72442. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72443. /** Defines the exponent of the function */
  72444. exponent: number;
  72445. /**
  72446. * Instantiates an exponential easing function
  72447. * @see https://easings.net/#easeInExpo
  72448. * @param exponent Defines the exponent of the function
  72449. */
  72450. constructor(
  72451. /** Defines the exponent of the function */
  72452. exponent?: number);
  72453. /** @hidden */
  72454. easeInCore(gradient: number): number;
  72455. }
  72456. /**
  72457. * Easing function with a power shape (see link below).
  72458. * @see https://easings.net/#easeInQuad
  72459. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72460. */
  72461. export class PowerEase extends EasingFunction implements IEasingFunction {
  72462. /** Defines the power of the function */
  72463. power: number;
  72464. /**
  72465. * Instantiates an power base easing function
  72466. * @see https://easings.net/#easeInQuad
  72467. * @param power Defines the power of the function
  72468. */
  72469. constructor(
  72470. /** Defines the power of the function */
  72471. power?: number);
  72472. /** @hidden */
  72473. easeInCore(gradient: number): number;
  72474. }
  72475. /**
  72476. * Easing function with a power of 2 shape (see link below).
  72477. * @see https://easings.net/#easeInQuad
  72478. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72479. */
  72480. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72481. /** @hidden */
  72482. easeInCore(gradient: number): number;
  72483. }
  72484. /**
  72485. * Easing function with a power of 4 shape (see link below).
  72486. * @see https://easings.net/#easeInQuart
  72487. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72488. */
  72489. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72490. /** @hidden */
  72491. easeInCore(gradient: number): number;
  72492. }
  72493. /**
  72494. * Easing function with a power of 5 shape (see link below).
  72495. * @see https://easings.net/#easeInQuint
  72496. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72497. */
  72498. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72499. /** @hidden */
  72500. easeInCore(gradient: number): number;
  72501. }
  72502. /**
  72503. * Easing function with a sin shape (see link below).
  72504. * @see https://easings.net/#easeInSine
  72505. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72506. */
  72507. export class SineEase extends EasingFunction implements IEasingFunction {
  72508. /** @hidden */
  72509. easeInCore(gradient: number): number;
  72510. }
  72511. /**
  72512. * Easing function with a bezier shape (see link below).
  72513. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72514. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72515. */
  72516. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72517. /** Defines the x component of the start tangent in the bezier curve */
  72518. x1: number;
  72519. /** Defines the y component of the start tangent in the bezier curve */
  72520. y1: number;
  72521. /** Defines the x component of the end tangent in the bezier curve */
  72522. x2: number;
  72523. /** Defines the y component of the end tangent in the bezier curve */
  72524. y2: number;
  72525. /**
  72526. * Instantiates a bezier function
  72527. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72528. * @param x1 Defines the x component of the start tangent in the bezier curve
  72529. * @param y1 Defines the y component of the start tangent in the bezier curve
  72530. * @param x2 Defines the x component of the end tangent in the bezier curve
  72531. * @param y2 Defines the y component of the end tangent in the bezier curve
  72532. */
  72533. constructor(
  72534. /** Defines the x component of the start tangent in the bezier curve */
  72535. x1?: number,
  72536. /** Defines the y component of the start tangent in the bezier curve */
  72537. y1?: number,
  72538. /** Defines the x component of the end tangent in the bezier curve */
  72539. x2?: number,
  72540. /** Defines the y component of the end tangent in the bezier curve */
  72541. y2?: number);
  72542. /** @hidden */
  72543. easeInCore(gradient: number): number;
  72544. }
  72545. }
  72546. declare module BABYLON {
  72547. /**
  72548. * Class used to hold a RBG color
  72549. */
  72550. export class Color3 {
  72551. /**
  72552. * Defines the red component (between 0 and 1, default is 0)
  72553. */
  72554. r: number;
  72555. /**
  72556. * Defines the green component (between 0 and 1, default is 0)
  72557. */
  72558. g: number;
  72559. /**
  72560. * Defines the blue component (between 0 and 1, default is 0)
  72561. */
  72562. b: number;
  72563. /**
  72564. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  72565. * @param r defines the red component (between 0 and 1, default is 0)
  72566. * @param g defines the green component (between 0 and 1, default is 0)
  72567. * @param b defines the blue component (between 0 and 1, default is 0)
  72568. */
  72569. constructor(
  72570. /**
  72571. * Defines the red component (between 0 and 1, default is 0)
  72572. */
  72573. r?: number,
  72574. /**
  72575. * Defines the green component (between 0 and 1, default is 0)
  72576. */
  72577. g?: number,
  72578. /**
  72579. * Defines the blue component (between 0 and 1, default is 0)
  72580. */
  72581. b?: number);
  72582. /**
  72583. * Creates a string with the Color3 current values
  72584. * @returns the string representation of the Color3 object
  72585. */
  72586. toString(): string;
  72587. /**
  72588. * Returns the string "Color3"
  72589. * @returns "Color3"
  72590. */
  72591. getClassName(): string;
  72592. /**
  72593. * Compute the Color3 hash code
  72594. * @returns an unique number that can be used to hash Color3 objects
  72595. */
  72596. getHashCode(): number;
  72597. /**
  72598. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  72599. * @param array defines the array where to store the r,g,b components
  72600. * @param index defines an optional index in the target array to define where to start storing values
  72601. * @returns the current Color3 object
  72602. */
  72603. toArray(array: FloatArray, index?: number): Color3;
  72604. /**
  72605. * Returns a new Color4 object from the current Color3 and the given alpha
  72606. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  72607. * @returns a new Color4 object
  72608. */
  72609. toColor4(alpha?: number): Color4;
  72610. /**
  72611. * Returns a new array populated with 3 numeric elements : red, green and blue values
  72612. * @returns the new array
  72613. */
  72614. asArray(): number[];
  72615. /**
  72616. * Returns the luminance value
  72617. * @returns a float value
  72618. */
  72619. toLuminance(): number;
  72620. /**
  72621. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  72622. * @param otherColor defines the second operand
  72623. * @returns the new Color3 object
  72624. */
  72625. multiply(otherColor: DeepImmutable<Color3>): Color3;
  72626. /**
  72627. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  72628. * @param otherColor defines the second operand
  72629. * @param result defines the Color3 object where to store the result
  72630. * @returns the current Color3
  72631. */
  72632. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72633. /**
  72634. * Determines equality between Color3 objects
  72635. * @param otherColor defines the second operand
  72636. * @returns true if the rgb values are equal to the given ones
  72637. */
  72638. equals(otherColor: DeepImmutable<Color3>): boolean;
  72639. /**
  72640. * Determines equality between the current Color3 object and a set of r,b,g values
  72641. * @param r defines the red component to check
  72642. * @param g defines the green component to check
  72643. * @param b defines the blue component to check
  72644. * @returns true if the rgb values are equal to the given ones
  72645. */
  72646. equalsFloats(r: number, g: number, b: number): boolean;
  72647. /**
  72648. * Multiplies in place each rgb value by scale
  72649. * @param scale defines the scaling factor
  72650. * @returns the updated Color3
  72651. */
  72652. scale(scale: number): Color3;
  72653. /**
  72654. * Multiplies the rgb values by scale and stores the result into "result"
  72655. * @param scale defines the scaling factor
  72656. * @param result defines the Color3 object where to store the result
  72657. * @returns the unmodified current Color3
  72658. */
  72659. scaleToRef(scale: number, result: Color3): Color3;
  72660. /**
  72661. * Scale the current Color3 values by a factor and add the result to a given Color3
  72662. * @param scale defines the scale factor
  72663. * @param result defines color to store the result into
  72664. * @returns the unmodified current Color3
  72665. */
  72666. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72667. /**
  72668. * Clamps the rgb values by the min and max values and stores the result into "result"
  72669. * @param min defines minimum clamping value (default is 0)
  72670. * @param max defines maximum clamping value (default is 1)
  72671. * @param result defines color to store the result into
  72672. * @returns the original Color3
  72673. */
  72674. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72675. /**
  72676. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72677. * @param otherColor defines the second operand
  72678. * @returns the new Color3
  72679. */
  72680. add(otherColor: DeepImmutable<Color3>): Color3;
  72681. /**
  72682. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72683. * @param otherColor defines the second operand
  72684. * @param result defines Color3 object to store the result into
  72685. * @returns the unmodified current Color3
  72686. */
  72687. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72688. /**
  72689. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72690. * @param otherColor defines the second operand
  72691. * @returns the new Color3
  72692. */
  72693. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72694. /**
  72695. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72696. * @param otherColor defines the second operand
  72697. * @param result defines Color3 object to store the result into
  72698. * @returns the unmodified current Color3
  72699. */
  72700. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72701. /**
  72702. * Copy the current object
  72703. * @returns a new Color3 copied the current one
  72704. */
  72705. clone(): Color3;
  72706. /**
  72707. * Copies the rgb values from the source in the current Color3
  72708. * @param source defines the source Color3 object
  72709. * @returns the updated Color3 object
  72710. */
  72711. copyFrom(source: DeepImmutable<Color3>): Color3;
  72712. /**
  72713. * Updates the Color3 rgb values from the given floats
  72714. * @param r defines the red component to read from
  72715. * @param g defines the green component to read from
  72716. * @param b defines the blue component to read from
  72717. * @returns the current Color3 object
  72718. */
  72719. copyFromFloats(r: number, g: number, b: number): Color3;
  72720. /**
  72721. * Updates the Color3 rgb values from the given floats
  72722. * @param r defines the red component to read from
  72723. * @param g defines the green component to read from
  72724. * @param b defines the blue component to read from
  72725. * @returns the current Color3 object
  72726. */
  72727. set(r: number, g: number, b: number): Color3;
  72728. /**
  72729. * Compute the Color3 hexadecimal code as a string
  72730. * @returns a string containing the hexadecimal representation of the Color3 object
  72731. */
  72732. toHexString(): string;
  72733. /**
  72734. * Computes a new Color3 converted from the current one to linear space
  72735. * @returns a new Color3 object
  72736. */
  72737. toLinearSpace(): Color3;
  72738. /**
  72739. * Converts current color in rgb space to HSV values
  72740. * @returns a new color3 representing the HSV values
  72741. */
  72742. toHSV(): Color3;
  72743. /**
  72744. * Converts current color in rgb space to HSV values
  72745. * @param result defines the Color3 where to store the HSV values
  72746. */
  72747. toHSVToRef(result: Color3): void;
  72748. /**
  72749. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72750. * @param convertedColor defines the Color3 object where to store the linear space version
  72751. * @returns the unmodified Color3
  72752. */
  72753. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72754. /**
  72755. * Computes a new Color3 converted from the current one to gamma space
  72756. * @returns a new Color3 object
  72757. */
  72758. toGammaSpace(): Color3;
  72759. /**
  72760. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72761. * @param convertedColor defines the Color3 object where to store the gamma space version
  72762. * @returns the unmodified Color3
  72763. */
  72764. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72765. private static _BlackReadOnly;
  72766. /**
  72767. * Convert Hue, saturation and value to a Color3 (RGB)
  72768. * @param hue defines the hue
  72769. * @param saturation defines the saturation
  72770. * @param value defines the value
  72771. * @param result defines the Color3 where to store the RGB values
  72772. */
  72773. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72774. /**
  72775. * Creates a new Color3 from the string containing valid hexadecimal values
  72776. * @param hex defines a string containing valid hexadecimal values
  72777. * @returns a new Color3 object
  72778. */
  72779. static FromHexString(hex: string): Color3;
  72780. /**
  72781. * Creates a new Color3 from the starting index of the given array
  72782. * @param array defines the source array
  72783. * @param offset defines an offset in the source array
  72784. * @returns a new Color3 object
  72785. */
  72786. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72787. /**
  72788. * Creates a new Color3 from integer values (< 256)
  72789. * @param r defines the red component to read from (value between 0 and 255)
  72790. * @param g defines the green component to read from (value between 0 and 255)
  72791. * @param b defines the blue component to read from (value between 0 and 255)
  72792. * @returns a new Color3 object
  72793. */
  72794. static FromInts(r: number, g: number, b: number): Color3;
  72795. /**
  72796. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72797. * @param start defines the start Color3 value
  72798. * @param end defines the end Color3 value
  72799. * @param amount defines the gradient value between start and end
  72800. * @returns a new Color3 object
  72801. */
  72802. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72803. /**
  72804. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72805. * @param left defines the start value
  72806. * @param right defines the end value
  72807. * @param amount defines the gradient factor
  72808. * @param result defines the Color3 object where to store the result
  72809. */
  72810. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72811. /**
  72812. * Returns a Color3 value containing a red color
  72813. * @returns a new Color3 object
  72814. */
  72815. static Red(): Color3;
  72816. /**
  72817. * Returns a Color3 value containing a green color
  72818. * @returns a new Color3 object
  72819. */
  72820. static Green(): Color3;
  72821. /**
  72822. * Returns a Color3 value containing a blue color
  72823. * @returns a new Color3 object
  72824. */
  72825. static Blue(): Color3;
  72826. /**
  72827. * Returns a Color3 value containing a black color
  72828. * @returns a new Color3 object
  72829. */
  72830. static Black(): Color3;
  72831. /**
  72832. * Gets a Color3 value containing a black color that must not be updated
  72833. */
  72834. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72835. /**
  72836. * Returns a Color3 value containing a white color
  72837. * @returns a new Color3 object
  72838. */
  72839. static White(): Color3;
  72840. /**
  72841. * Returns a Color3 value containing a purple color
  72842. * @returns a new Color3 object
  72843. */
  72844. static Purple(): Color3;
  72845. /**
  72846. * Returns a Color3 value containing a magenta color
  72847. * @returns a new Color3 object
  72848. */
  72849. static Magenta(): Color3;
  72850. /**
  72851. * Returns a Color3 value containing a yellow color
  72852. * @returns a new Color3 object
  72853. */
  72854. static Yellow(): Color3;
  72855. /**
  72856. * Returns a Color3 value containing a gray color
  72857. * @returns a new Color3 object
  72858. */
  72859. static Gray(): Color3;
  72860. /**
  72861. * Returns a Color3 value containing a teal color
  72862. * @returns a new Color3 object
  72863. */
  72864. static Teal(): Color3;
  72865. /**
  72866. * Returns a Color3 value containing a random color
  72867. * @returns a new Color3 object
  72868. */
  72869. static Random(): Color3;
  72870. }
  72871. /**
  72872. * Class used to hold a RBGA color
  72873. */
  72874. export class Color4 {
  72875. /**
  72876. * Defines the red component (between 0 and 1, default is 0)
  72877. */
  72878. r: number;
  72879. /**
  72880. * Defines the green component (between 0 and 1, default is 0)
  72881. */
  72882. g: number;
  72883. /**
  72884. * Defines the blue component (between 0 and 1, default is 0)
  72885. */
  72886. b: number;
  72887. /**
  72888. * Defines the alpha component (between 0 and 1, default is 1)
  72889. */
  72890. a: number;
  72891. /**
  72892. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72893. * @param r defines the red component (between 0 and 1, default is 0)
  72894. * @param g defines the green component (between 0 and 1, default is 0)
  72895. * @param b defines the blue component (between 0 and 1, default is 0)
  72896. * @param a defines the alpha component (between 0 and 1, default is 1)
  72897. */
  72898. constructor(
  72899. /**
  72900. * Defines the red component (between 0 and 1, default is 0)
  72901. */
  72902. r?: number,
  72903. /**
  72904. * Defines the green component (between 0 and 1, default is 0)
  72905. */
  72906. g?: number,
  72907. /**
  72908. * Defines the blue component (between 0 and 1, default is 0)
  72909. */
  72910. b?: number,
  72911. /**
  72912. * Defines the alpha component (between 0 and 1, default is 1)
  72913. */
  72914. a?: number);
  72915. /**
  72916. * Adds in place the given Color4 values to the current Color4 object
  72917. * @param right defines the second operand
  72918. * @returns the current updated Color4 object
  72919. */
  72920. addInPlace(right: DeepImmutable<Color4>): Color4;
  72921. /**
  72922. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72923. * @returns the new array
  72924. */
  72925. asArray(): number[];
  72926. /**
  72927. * Stores from the starting index in the given array the Color4 successive values
  72928. * @param array defines the array where to store the r,g,b components
  72929. * @param index defines an optional index in the target array to define where to start storing values
  72930. * @returns the current Color4 object
  72931. */
  72932. toArray(array: number[], index?: number): Color4;
  72933. /**
  72934. * Determines equality between Color4 objects
  72935. * @param otherColor defines the second operand
  72936. * @returns true if the rgba values are equal to the given ones
  72937. */
  72938. equals(otherColor: DeepImmutable<Color4>): boolean;
  72939. /**
  72940. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72941. * @param right defines the second operand
  72942. * @returns a new Color4 object
  72943. */
  72944. add(right: DeepImmutable<Color4>): Color4;
  72945. /**
  72946. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72947. * @param right defines the second operand
  72948. * @returns a new Color4 object
  72949. */
  72950. subtract(right: DeepImmutable<Color4>): Color4;
  72951. /**
  72952. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72953. * @param right defines the second operand
  72954. * @param result defines the Color4 object where to store the result
  72955. * @returns the current Color4 object
  72956. */
  72957. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72958. /**
  72959. * Creates a new Color4 with the current Color4 values multiplied by scale
  72960. * @param scale defines the scaling factor to apply
  72961. * @returns a new Color4 object
  72962. */
  72963. scale(scale: number): Color4;
  72964. /**
  72965. * Multiplies the current Color4 values by scale and stores the result in "result"
  72966. * @param scale defines the scaling factor to apply
  72967. * @param result defines the Color4 object where to store the result
  72968. * @returns the current unmodified Color4
  72969. */
  72970. scaleToRef(scale: number, result: Color4): Color4;
  72971. /**
  72972. * Scale the current Color4 values by a factor and add the result to a given Color4
  72973. * @param scale defines the scale factor
  72974. * @param result defines the Color4 object where to store the result
  72975. * @returns the unmodified current Color4
  72976. */
  72977. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72978. /**
  72979. * Clamps the rgb values by the min and max values and stores the result into "result"
  72980. * @param min defines minimum clamping value (default is 0)
  72981. * @param max defines maximum clamping value (default is 1)
  72982. * @param result defines color to store the result into.
  72983. * @returns the cuurent Color4
  72984. */
  72985. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  72986. /**
  72987. * Multipy an Color4 value by another and return a new Color4 object
  72988. * @param color defines the Color4 value to multiply by
  72989. * @returns a new Color4 object
  72990. */
  72991. multiply(color: Color4): Color4;
  72992. /**
  72993. * Multipy a Color4 value by another and push the result in a reference value
  72994. * @param color defines the Color4 value to multiply by
  72995. * @param result defines the Color4 to fill the result in
  72996. * @returns the result Color4
  72997. */
  72998. multiplyToRef(color: Color4, result: Color4): Color4;
  72999. /**
  73000. * Creates a string with the Color4 current values
  73001. * @returns the string representation of the Color4 object
  73002. */
  73003. toString(): string;
  73004. /**
  73005. * Returns the string "Color4"
  73006. * @returns "Color4"
  73007. */
  73008. getClassName(): string;
  73009. /**
  73010. * Compute the Color4 hash code
  73011. * @returns an unique number that can be used to hash Color4 objects
  73012. */
  73013. getHashCode(): number;
  73014. /**
  73015. * Creates a new Color4 copied from the current one
  73016. * @returns a new Color4 object
  73017. */
  73018. clone(): Color4;
  73019. /**
  73020. * Copies the given Color4 values into the current one
  73021. * @param source defines the source Color4 object
  73022. * @returns the current updated Color4 object
  73023. */
  73024. copyFrom(source: Color4): Color4;
  73025. /**
  73026. * Copies the given float values into the current one
  73027. * @param r defines the red component to read from
  73028. * @param g defines the green component to read from
  73029. * @param b defines the blue component to read from
  73030. * @param a defines the alpha component to read from
  73031. * @returns the current updated Color4 object
  73032. */
  73033. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73034. /**
  73035. * Copies the given float values into the current one
  73036. * @param r defines the red component to read from
  73037. * @param g defines the green component to read from
  73038. * @param b defines the blue component to read from
  73039. * @param a defines the alpha component to read from
  73040. * @returns the current updated Color4 object
  73041. */
  73042. set(r: number, g: number, b: number, a: number): Color4;
  73043. /**
  73044. * Compute the Color4 hexadecimal code as a string
  73045. * @returns a string containing the hexadecimal representation of the Color4 object
  73046. */
  73047. toHexString(): string;
  73048. /**
  73049. * Computes a new Color4 converted from the current one to linear space
  73050. * @returns a new Color4 object
  73051. */
  73052. toLinearSpace(): Color4;
  73053. /**
  73054. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73055. * @param convertedColor defines the Color4 object where to store the linear space version
  73056. * @returns the unmodified Color4
  73057. */
  73058. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73059. /**
  73060. * Computes a new Color4 converted from the current one to gamma space
  73061. * @returns a new Color4 object
  73062. */
  73063. toGammaSpace(): Color4;
  73064. /**
  73065. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73066. * @param convertedColor defines the Color4 object where to store the gamma space version
  73067. * @returns the unmodified Color4
  73068. */
  73069. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73070. /**
  73071. * Creates a new Color4 from the string containing valid hexadecimal values
  73072. * @param hex defines a string containing valid hexadecimal values
  73073. * @returns a new Color4 object
  73074. */
  73075. static FromHexString(hex: string): Color4;
  73076. /**
  73077. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73078. * @param left defines the start value
  73079. * @param right defines the end value
  73080. * @param amount defines the gradient factor
  73081. * @returns a new Color4 object
  73082. */
  73083. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73084. /**
  73085. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73086. * @param left defines the start value
  73087. * @param right defines the end value
  73088. * @param amount defines the gradient factor
  73089. * @param result defines the Color4 object where to store data
  73090. */
  73091. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73092. /**
  73093. * Creates a new Color4 from a Color3 and an alpha value
  73094. * @param color3 defines the source Color3 to read from
  73095. * @param alpha defines the alpha component (1.0 by default)
  73096. * @returns a new Color4 object
  73097. */
  73098. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73099. /**
  73100. * Creates a new Color4 from the starting index element of the given array
  73101. * @param array defines the source array to read from
  73102. * @param offset defines the offset in the source array
  73103. * @returns a new Color4 object
  73104. */
  73105. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73106. /**
  73107. * Creates a new Color3 from integer values (< 256)
  73108. * @param r defines the red component to read from (value between 0 and 255)
  73109. * @param g defines the green component to read from (value between 0 and 255)
  73110. * @param b defines the blue component to read from (value between 0 and 255)
  73111. * @param a defines the alpha component to read from (value between 0 and 255)
  73112. * @returns a new Color3 object
  73113. */
  73114. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73115. /**
  73116. * Check the content of a given array and convert it to an array containing RGBA data
  73117. * If the original array was already containing count * 4 values then it is returned directly
  73118. * @param colors defines the array to check
  73119. * @param count defines the number of RGBA data to expect
  73120. * @returns an array containing count * 4 values (RGBA)
  73121. */
  73122. static CheckColors4(colors: number[], count: number): number[];
  73123. }
  73124. /**
  73125. * @hidden
  73126. */
  73127. export class TmpColors {
  73128. static Color3: Color3[];
  73129. static Color4: Color4[];
  73130. }
  73131. }
  73132. declare module BABYLON {
  73133. /**
  73134. * Defines an interface which represents an animation key frame
  73135. */
  73136. export interface IAnimationKey {
  73137. /**
  73138. * Frame of the key frame
  73139. */
  73140. frame: number;
  73141. /**
  73142. * Value at the specifies key frame
  73143. */
  73144. value: any;
  73145. /**
  73146. * The input tangent for the cubic hermite spline
  73147. */
  73148. inTangent?: any;
  73149. /**
  73150. * The output tangent for the cubic hermite spline
  73151. */
  73152. outTangent?: any;
  73153. /**
  73154. * The animation interpolation type
  73155. */
  73156. interpolation?: AnimationKeyInterpolation;
  73157. }
  73158. /**
  73159. * Enum for the animation key frame interpolation type
  73160. */
  73161. export enum AnimationKeyInterpolation {
  73162. /**
  73163. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73164. */
  73165. STEP = 1
  73166. }
  73167. }
  73168. declare module BABYLON {
  73169. /**
  73170. * Represents the range of an animation
  73171. */
  73172. export class AnimationRange {
  73173. /**The name of the animation range**/
  73174. name: string;
  73175. /**The starting frame of the animation */
  73176. from: number;
  73177. /**The ending frame of the animation*/
  73178. to: number;
  73179. /**
  73180. * Initializes the range of an animation
  73181. * @param name The name of the animation range
  73182. * @param from The starting frame of the animation
  73183. * @param to The ending frame of the animation
  73184. */
  73185. constructor(
  73186. /**The name of the animation range**/
  73187. name: string,
  73188. /**The starting frame of the animation */
  73189. from: number,
  73190. /**The ending frame of the animation*/
  73191. to: number);
  73192. /**
  73193. * Makes a copy of the animation range
  73194. * @returns A copy of the animation range
  73195. */
  73196. clone(): AnimationRange;
  73197. }
  73198. }
  73199. declare module BABYLON {
  73200. /**
  73201. * Composed of a frame, and an action function
  73202. */
  73203. export class AnimationEvent {
  73204. /** The frame for which the event is triggered **/
  73205. frame: number;
  73206. /** The event to perform when triggered **/
  73207. action: (currentFrame: number) => void;
  73208. /** Specifies if the event should be triggered only once**/
  73209. onlyOnce?: boolean | undefined;
  73210. /**
  73211. * Specifies if the animation event is done
  73212. */
  73213. isDone: boolean;
  73214. /**
  73215. * Initializes the animation event
  73216. * @param frame The frame for which the event is triggered
  73217. * @param action The event to perform when triggered
  73218. * @param onlyOnce Specifies if the event should be triggered only once
  73219. */
  73220. constructor(
  73221. /** The frame for which the event is triggered **/
  73222. frame: number,
  73223. /** The event to perform when triggered **/
  73224. action: (currentFrame: number) => void,
  73225. /** Specifies if the event should be triggered only once**/
  73226. onlyOnce?: boolean | undefined);
  73227. /** @hidden */
  73228. _clone(): AnimationEvent;
  73229. }
  73230. }
  73231. declare module BABYLON {
  73232. /**
  73233. * Interface used to define a behavior
  73234. */
  73235. export interface Behavior<T> {
  73236. /** gets or sets behavior's name */
  73237. name: string;
  73238. /**
  73239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73240. */
  73241. init(): void;
  73242. /**
  73243. * Called when the behavior is attached to a target
  73244. * @param target defines the target where the behavior is attached to
  73245. */
  73246. attach(target: T): void;
  73247. /**
  73248. * Called when the behavior is detached from its target
  73249. */
  73250. detach(): void;
  73251. }
  73252. /**
  73253. * Interface implemented by classes supporting behaviors
  73254. */
  73255. export interface IBehaviorAware<T> {
  73256. /**
  73257. * Attach a behavior
  73258. * @param behavior defines the behavior to attach
  73259. * @returns the current host
  73260. */
  73261. addBehavior(behavior: Behavior<T>): T;
  73262. /**
  73263. * Remove a behavior from the current object
  73264. * @param behavior defines the behavior to detach
  73265. * @returns the current host
  73266. */
  73267. removeBehavior(behavior: Behavior<T>): T;
  73268. /**
  73269. * Gets a behavior using its name to search
  73270. * @param name defines the name to search
  73271. * @returns the behavior or null if not found
  73272. */
  73273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73274. }
  73275. }
  73276. declare module BABYLON {
  73277. /**
  73278. * Defines an array and its length.
  73279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73280. */
  73281. export interface ISmartArrayLike<T> {
  73282. /**
  73283. * The data of the array.
  73284. */
  73285. data: Array<T>;
  73286. /**
  73287. * The active length of the array.
  73288. */
  73289. length: number;
  73290. }
  73291. /**
  73292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73293. */
  73294. export class SmartArray<T> implements ISmartArrayLike<T> {
  73295. /**
  73296. * The full set of data from the array.
  73297. */
  73298. data: Array<T>;
  73299. /**
  73300. * The active length of the array.
  73301. */
  73302. length: number;
  73303. protected _id: number;
  73304. /**
  73305. * Instantiates a Smart Array.
  73306. * @param capacity defines the default capacity of the array.
  73307. */
  73308. constructor(capacity: number);
  73309. /**
  73310. * Pushes a value at the end of the active data.
  73311. * @param value defines the object to push in the array.
  73312. */
  73313. push(value: T): void;
  73314. /**
  73315. * Iterates over the active data and apply the lambda to them.
  73316. * @param func defines the action to apply on each value.
  73317. */
  73318. forEach(func: (content: T) => void): void;
  73319. /**
  73320. * Sorts the full sets of data.
  73321. * @param compareFn defines the comparison function to apply.
  73322. */
  73323. sort(compareFn: (a: T, b: T) => number): void;
  73324. /**
  73325. * Resets the active data to an empty array.
  73326. */
  73327. reset(): void;
  73328. /**
  73329. * Releases all the data from the array as well as the array.
  73330. */
  73331. dispose(): void;
  73332. /**
  73333. * Concats the active data with a given array.
  73334. * @param array defines the data to concatenate with.
  73335. */
  73336. concat(array: any): void;
  73337. /**
  73338. * Returns the position of a value in the active data.
  73339. * @param value defines the value to find the index for
  73340. * @returns the index if found in the active data otherwise -1
  73341. */
  73342. indexOf(value: T): number;
  73343. /**
  73344. * Returns whether an element is part of the active data.
  73345. * @param value defines the value to look for
  73346. * @returns true if found in the active data otherwise false
  73347. */
  73348. contains(value: T): boolean;
  73349. private static _GlobalId;
  73350. }
  73351. /**
  73352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73353. * The data in this array can only be present once
  73354. */
  73355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73356. private _duplicateId;
  73357. /**
  73358. * Pushes a value at the end of the active data.
  73359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73360. * @param value defines the object to push in the array.
  73361. */
  73362. push(value: T): void;
  73363. /**
  73364. * Pushes a value at the end of the active data.
  73365. * If the data is already present, it won t be added again
  73366. * @param value defines the object to push in the array.
  73367. * @returns true if added false if it was already present
  73368. */
  73369. pushNoDuplicate(value: T): boolean;
  73370. /**
  73371. * Resets the active data to an empty array.
  73372. */
  73373. reset(): void;
  73374. /**
  73375. * Concats the active data with a given array.
  73376. * This ensures no dupplicate will be present in the result.
  73377. * @param array defines the data to concatenate with.
  73378. */
  73379. concatWithNoDuplicate(array: any): void;
  73380. }
  73381. }
  73382. declare module BABYLON {
  73383. /**
  73384. * @ignore
  73385. * This is a list of all the different input types that are available in the application.
  73386. * Fo instance: ArcRotateCameraGamepadInput...
  73387. */
  73388. export var CameraInputTypes: {};
  73389. /**
  73390. * This is the contract to implement in order to create a new input class.
  73391. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73392. */
  73393. export interface ICameraInput<TCamera extends Camera> {
  73394. /**
  73395. * Defines the camera the input is attached to.
  73396. */
  73397. camera: Nullable<TCamera>;
  73398. /**
  73399. * Gets the class name of the current intput.
  73400. * @returns the class name
  73401. */
  73402. getClassName(): string;
  73403. /**
  73404. * Get the friendly name associated with the input class.
  73405. * @returns the input friendly name
  73406. */
  73407. getSimpleName(): string;
  73408. /**
  73409. * Attach the input controls to a specific dom element to get the input from.
  73410. * @param element Defines the element the controls should be listened from
  73411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73412. */
  73413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73414. /**
  73415. * Detach the current controls from the specified dom element.
  73416. * @param element Defines the element to stop listening the inputs from
  73417. */
  73418. detachControl(element: Nullable<HTMLElement>): void;
  73419. /**
  73420. * Update the current camera state depending on the inputs that have been used this frame.
  73421. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73422. */
  73423. checkInputs?: () => void;
  73424. }
  73425. /**
  73426. * Represents a map of input types to input instance or input index to input instance.
  73427. */
  73428. export interface CameraInputsMap<TCamera extends Camera> {
  73429. /**
  73430. * Accessor to the input by input type.
  73431. */
  73432. [name: string]: ICameraInput<TCamera>;
  73433. /**
  73434. * Accessor to the input by input index.
  73435. */
  73436. [idx: number]: ICameraInput<TCamera>;
  73437. }
  73438. /**
  73439. * This represents the input manager used within a camera.
  73440. * It helps dealing with all the different kind of input attached to a camera.
  73441. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73442. */
  73443. export class CameraInputsManager<TCamera extends Camera> {
  73444. /**
  73445. * Defines the list of inputs attahed to the camera.
  73446. */
  73447. attached: CameraInputsMap<TCamera>;
  73448. /**
  73449. * Defines the dom element the camera is collecting inputs from.
  73450. * This is null if the controls have not been attached.
  73451. */
  73452. attachedElement: Nullable<HTMLElement>;
  73453. /**
  73454. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73455. */
  73456. noPreventDefault: boolean;
  73457. /**
  73458. * Defined the camera the input manager belongs to.
  73459. */
  73460. camera: TCamera;
  73461. /**
  73462. * Update the current camera state depending on the inputs that have been used this frame.
  73463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73464. */
  73465. checkInputs: () => void;
  73466. /**
  73467. * Instantiate a new Camera Input Manager.
  73468. * @param camera Defines the camera the input manager blongs to
  73469. */
  73470. constructor(camera: TCamera);
  73471. /**
  73472. * Add an input method to a camera
  73473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73474. * @param input camera input method
  73475. */
  73476. add(input: ICameraInput<TCamera>): void;
  73477. /**
  73478. * Remove a specific input method from a camera
  73479. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  73480. * @param inputToRemove camera input method
  73481. */
  73482. remove(inputToRemove: ICameraInput<TCamera>): void;
  73483. /**
  73484. * Remove a specific input type from a camera
  73485. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  73486. * @param inputType the type of the input to remove
  73487. */
  73488. removeByType(inputType: string): void;
  73489. private _addCheckInputs;
  73490. /**
  73491. * Attach the input controls to the currently attached dom element to listen the events from.
  73492. * @param input Defines the input to attach
  73493. */
  73494. attachInput(input: ICameraInput<TCamera>): void;
  73495. /**
  73496. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  73497. * @param element Defines the dom element to collect the events from
  73498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73499. */
  73500. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  73501. /**
  73502. * Detach the current manager inputs controls from a specific dom element.
  73503. * @param element Defines the dom element to collect the events from
  73504. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  73505. */
  73506. detachElement(element: HTMLElement, disconnect?: boolean): void;
  73507. /**
  73508. * Rebuild the dynamic inputCheck function from the current list of
  73509. * defined inputs in the manager.
  73510. */
  73511. rebuildInputCheck(): void;
  73512. /**
  73513. * Remove all attached input methods from a camera
  73514. */
  73515. clear(): void;
  73516. /**
  73517. * Serialize the current input manager attached to a camera.
  73518. * This ensures than once parsed,
  73519. * the input associated to the camera will be identical to the current ones
  73520. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  73521. */
  73522. serialize(serializedCamera: any): void;
  73523. /**
  73524. * Parses an input manager serialized JSON to restore the previous list of inputs
  73525. * and states associated to a camera.
  73526. * @param parsedCamera Defines the JSON to parse
  73527. */
  73528. parse(parsedCamera: any): void;
  73529. }
  73530. }
  73531. declare module BABYLON {
  73532. /**
  73533. * Class used to store data that will be store in GPU memory
  73534. */
  73535. export class Buffer {
  73536. private _engine;
  73537. private _buffer;
  73538. /** @hidden */
  73539. _data: Nullable<DataArray>;
  73540. private _updatable;
  73541. private _instanced;
  73542. private _divisor;
  73543. /**
  73544. * Gets the byte stride.
  73545. */
  73546. readonly byteStride: number;
  73547. /**
  73548. * Constructor
  73549. * @param engine the engine
  73550. * @param data the data to use for this buffer
  73551. * @param updatable whether the data is updatable
  73552. * @param stride the stride (optional)
  73553. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73554. * @param instanced whether the buffer is instanced (optional)
  73555. * @param useBytes set to true if the stride in in bytes (optional)
  73556. * @param divisor sets an optional divisor for instances (1 by default)
  73557. */
  73558. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  73559. /**
  73560. * Create a new VertexBuffer based on the current buffer
  73561. * @param kind defines the vertex buffer kind (position, normal, etc.)
  73562. * @param offset defines offset in the buffer (0 by default)
  73563. * @param size defines the size in floats of attributes (position is 3 for instance)
  73564. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  73565. * @param instanced defines if the vertex buffer contains indexed data
  73566. * @param useBytes defines if the offset and stride are in bytes *
  73567. * @param divisor sets an optional divisor for instances (1 by default)
  73568. * @returns the new vertex buffer
  73569. */
  73570. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  73571. /**
  73572. * Gets a boolean indicating if the Buffer is updatable?
  73573. * @returns true if the buffer is updatable
  73574. */
  73575. isUpdatable(): boolean;
  73576. /**
  73577. * Gets current buffer's data
  73578. * @returns a DataArray or null
  73579. */
  73580. getData(): Nullable<DataArray>;
  73581. /**
  73582. * Gets underlying native buffer
  73583. * @returns underlying native buffer
  73584. */
  73585. getBuffer(): Nullable<DataBuffer>;
  73586. /**
  73587. * Gets the stride in float32 units (i.e. byte stride / 4).
  73588. * May not be an integer if the byte stride is not divisible by 4.
  73589. * DEPRECATED. Use byteStride instead.
  73590. * @returns the stride in float32 units
  73591. */
  73592. getStrideSize(): number;
  73593. /**
  73594. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73595. * @param data defines the data to store
  73596. */
  73597. create(data?: Nullable<DataArray>): void;
  73598. /** @hidden */
  73599. _rebuild(): void;
  73600. /**
  73601. * Update current buffer data
  73602. * @param data defines the data to store
  73603. */
  73604. update(data: DataArray): void;
  73605. /**
  73606. * Updates the data directly.
  73607. * @param data the new data
  73608. * @param offset the new offset
  73609. * @param vertexCount the vertex count (optional)
  73610. * @param useBytes set to true if the offset is in bytes
  73611. */
  73612. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73613. /**
  73614. * Release all resources
  73615. */
  73616. dispose(): void;
  73617. }
  73618. /**
  73619. * Specialized buffer used to store vertex data
  73620. */
  73621. export class VertexBuffer {
  73622. /** @hidden */
  73623. _buffer: Buffer;
  73624. private _kind;
  73625. private _size;
  73626. private _ownsBuffer;
  73627. private _instanced;
  73628. private _instanceDivisor;
  73629. /**
  73630. * The byte type.
  73631. */
  73632. static readonly BYTE: number;
  73633. /**
  73634. * The unsigned byte type.
  73635. */
  73636. static readonly UNSIGNED_BYTE: number;
  73637. /**
  73638. * The short type.
  73639. */
  73640. static readonly SHORT: number;
  73641. /**
  73642. * The unsigned short type.
  73643. */
  73644. static readonly UNSIGNED_SHORT: number;
  73645. /**
  73646. * The integer type.
  73647. */
  73648. static readonly INT: number;
  73649. /**
  73650. * The unsigned integer type.
  73651. */
  73652. static readonly UNSIGNED_INT: number;
  73653. /**
  73654. * The float type.
  73655. */
  73656. static readonly FLOAT: number;
  73657. /**
  73658. * Gets or sets the instance divisor when in instanced mode
  73659. */
  73660. instanceDivisor: number;
  73661. /**
  73662. * Gets the byte stride.
  73663. */
  73664. readonly byteStride: number;
  73665. /**
  73666. * Gets the byte offset.
  73667. */
  73668. readonly byteOffset: number;
  73669. /**
  73670. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73671. */
  73672. readonly normalized: boolean;
  73673. /**
  73674. * Gets the data type of each component in the array.
  73675. */
  73676. readonly type: number;
  73677. /**
  73678. * Constructor
  73679. * @param engine the engine
  73680. * @param data the data to use for this vertex buffer
  73681. * @param kind the vertex buffer kind
  73682. * @param updatable whether the data is updatable
  73683. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73684. * @param stride the stride (optional)
  73685. * @param instanced whether the buffer is instanced (optional)
  73686. * @param offset the offset of the data (optional)
  73687. * @param size the number of components (optional)
  73688. * @param type the type of the component (optional)
  73689. * @param normalized whether the data contains normalized data (optional)
  73690. * @param useBytes set to true if stride and offset are in bytes (optional)
  73691. * @param divisor defines the instance divisor to use (1 by default)
  73692. */
  73693. 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, divisor?: number);
  73694. /** @hidden */
  73695. _rebuild(): void;
  73696. /**
  73697. * Returns the kind of the VertexBuffer (string)
  73698. * @returns a string
  73699. */
  73700. getKind(): string;
  73701. /**
  73702. * Gets a boolean indicating if the VertexBuffer is updatable?
  73703. * @returns true if the buffer is updatable
  73704. */
  73705. isUpdatable(): boolean;
  73706. /**
  73707. * Gets current buffer's data
  73708. * @returns a DataArray or null
  73709. */
  73710. getData(): Nullable<DataArray>;
  73711. /**
  73712. * Gets underlying native buffer
  73713. * @returns underlying native buffer
  73714. */
  73715. getBuffer(): Nullable<DataBuffer>;
  73716. /**
  73717. * Gets the stride in float32 units (i.e. byte stride / 4).
  73718. * May not be an integer if the byte stride is not divisible by 4.
  73719. * DEPRECATED. Use byteStride instead.
  73720. * @returns the stride in float32 units
  73721. */
  73722. getStrideSize(): number;
  73723. /**
  73724. * Returns the offset as a multiple of the type byte length.
  73725. * DEPRECATED. Use byteOffset instead.
  73726. * @returns the offset in bytes
  73727. */
  73728. getOffset(): number;
  73729. /**
  73730. * Returns the number of components per vertex attribute (integer)
  73731. * @returns the size in float
  73732. */
  73733. getSize(): number;
  73734. /**
  73735. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73736. * @returns true if this buffer is instanced
  73737. */
  73738. getIsInstanced(): boolean;
  73739. /**
  73740. * Returns the instancing divisor, zero for non-instanced (integer).
  73741. * @returns a number
  73742. */
  73743. getInstanceDivisor(): number;
  73744. /**
  73745. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73746. * @param data defines the data to store
  73747. */
  73748. create(data?: DataArray): void;
  73749. /**
  73750. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73751. * This function will create a new buffer if the current one is not updatable
  73752. * @param data defines the data to store
  73753. */
  73754. update(data: DataArray): void;
  73755. /**
  73756. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73757. * Returns the directly updated WebGLBuffer.
  73758. * @param data the new data
  73759. * @param offset the new offset
  73760. * @param useBytes set to true if the offset is in bytes
  73761. */
  73762. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73763. /**
  73764. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73765. */
  73766. dispose(): void;
  73767. /**
  73768. * Enumerates each value of this vertex buffer as numbers.
  73769. * @param count the number of values to enumerate
  73770. * @param callback the callback function called for each value
  73771. */
  73772. forEach(count: number, callback: (value: number, index: number) => void): void;
  73773. /**
  73774. * Positions
  73775. */
  73776. static readonly PositionKind: string;
  73777. /**
  73778. * Normals
  73779. */
  73780. static readonly NormalKind: string;
  73781. /**
  73782. * Tangents
  73783. */
  73784. static readonly TangentKind: string;
  73785. /**
  73786. * Texture coordinates
  73787. */
  73788. static readonly UVKind: string;
  73789. /**
  73790. * Texture coordinates 2
  73791. */
  73792. static readonly UV2Kind: string;
  73793. /**
  73794. * Texture coordinates 3
  73795. */
  73796. static readonly UV3Kind: string;
  73797. /**
  73798. * Texture coordinates 4
  73799. */
  73800. static readonly UV4Kind: string;
  73801. /**
  73802. * Texture coordinates 5
  73803. */
  73804. static readonly UV5Kind: string;
  73805. /**
  73806. * Texture coordinates 6
  73807. */
  73808. static readonly UV6Kind: string;
  73809. /**
  73810. * Colors
  73811. */
  73812. static readonly ColorKind: string;
  73813. /**
  73814. * Matrix indices (for bones)
  73815. */
  73816. static readonly MatricesIndicesKind: string;
  73817. /**
  73818. * Matrix weights (for bones)
  73819. */
  73820. static readonly MatricesWeightsKind: string;
  73821. /**
  73822. * Additional matrix indices (for bones)
  73823. */
  73824. static readonly MatricesIndicesExtraKind: string;
  73825. /**
  73826. * Additional matrix weights (for bones)
  73827. */
  73828. static readonly MatricesWeightsExtraKind: string;
  73829. /**
  73830. * Deduces the stride given a kind.
  73831. * @param kind The kind string to deduce
  73832. * @returns The deduced stride
  73833. */
  73834. static DeduceStride(kind: string): number;
  73835. /**
  73836. * Gets the byte length of the given type.
  73837. * @param type the type
  73838. * @returns the number of bytes
  73839. */
  73840. static GetTypeByteLength(type: number): number;
  73841. /**
  73842. * Enumerates each value of the given parameters as numbers.
  73843. * @param data the data to enumerate
  73844. * @param byteOffset the byte offset of the data
  73845. * @param byteStride the byte stride of the data
  73846. * @param componentCount the number of components per element
  73847. * @param componentType the type of the component
  73848. * @param count the number of values to enumerate
  73849. * @param normalized whether the data is normalized
  73850. * @param callback the callback function called for each value
  73851. */
  73852. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73853. private static _GetFloatValue;
  73854. }
  73855. }
  73856. declare module BABYLON {
  73857. /**
  73858. * @hidden
  73859. */
  73860. export class IntersectionInfo {
  73861. bu: Nullable<number>;
  73862. bv: Nullable<number>;
  73863. distance: number;
  73864. faceId: number;
  73865. subMeshId: number;
  73866. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73867. }
  73868. }
  73869. declare module BABYLON {
  73870. /**
  73871. * Represens a plane by the equation ax + by + cz + d = 0
  73872. */
  73873. export class Plane {
  73874. private static _TmpMatrix;
  73875. /**
  73876. * Normal of the plane (a,b,c)
  73877. */
  73878. normal: Vector3;
  73879. /**
  73880. * d component of the plane
  73881. */
  73882. d: number;
  73883. /**
  73884. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73885. * @param a a component of the plane
  73886. * @param b b component of the plane
  73887. * @param c c component of the plane
  73888. * @param d d component of the plane
  73889. */
  73890. constructor(a: number, b: number, c: number, d: number);
  73891. /**
  73892. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73893. */
  73894. asArray(): number[];
  73895. /**
  73896. * @returns a new plane copied from the current Plane.
  73897. */
  73898. clone(): Plane;
  73899. /**
  73900. * @returns the string "Plane".
  73901. */
  73902. getClassName(): string;
  73903. /**
  73904. * @returns the Plane hash code.
  73905. */
  73906. getHashCode(): number;
  73907. /**
  73908. * Normalize the current Plane in place.
  73909. * @returns the updated Plane.
  73910. */
  73911. normalize(): Plane;
  73912. /**
  73913. * Applies a transformation the plane and returns the result
  73914. * @param transformation the transformation matrix to be applied to the plane
  73915. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73916. */
  73917. transform(transformation: DeepImmutable<Matrix>): Plane;
  73918. /**
  73919. * Calcualtte the dot product between the point and the plane normal
  73920. * @param point point to calculate the dot product with
  73921. * @returns the dot product (float) of the point coordinates and the plane normal.
  73922. */
  73923. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73924. /**
  73925. * Updates the current Plane from the plane defined by the three given points.
  73926. * @param point1 one of the points used to contruct the plane
  73927. * @param point2 one of the points used to contruct the plane
  73928. * @param point3 one of the points used to contruct the plane
  73929. * @returns the updated Plane.
  73930. */
  73931. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73932. /**
  73933. * Checks if the plane is facing a given direction
  73934. * @param direction the direction to check if the plane is facing
  73935. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73936. * @returns True is the vector "direction" is the same side than the plane normal.
  73937. */
  73938. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73939. /**
  73940. * Calculates the distance to a point
  73941. * @param point point to calculate distance to
  73942. * @returns the signed distance (float) from the given point to the Plane.
  73943. */
  73944. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73945. /**
  73946. * Creates a plane from an array
  73947. * @param array the array to create a plane from
  73948. * @returns a new Plane from the given array.
  73949. */
  73950. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73951. /**
  73952. * Creates a plane from three points
  73953. * @param point1 point used to create the plane
  73954. * @param point2 point used to create the plane
  73955. * @param point3 point used to create the plane
  73956. * @returns a new Plane defined by the three given points.
  73957. */
  73958. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73959. /**
  73960. * Creates a plane from an origin point and a normal
  73961. * @param origin origin of the plane to be constructed
  73962. * @param normal normal of the plane to be constructed
  73963. * @returns a new Plane the normal vector to this plane at the given origin point.
  73964. * Note : the vector "normal" is updated because normalized.
  73965. */
  73966. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73967. /**
  73968. * Calculates the distance from a plane and a point
  73969. * @param origin origin of the plane to be constructed
  73970. * @param normal normal of the plane to be constructed
  73971. * @param point point to calculate distance to
  73972. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73973. */
  73974. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73975. }
  73976. }
  73977. declare module BABYLON {
  73978. /**
  73979. * Class used to store bounding sphere information
  73980. */
  73981. export class BoundingSphere {
  73982. /**
  73983. * Gets the center of the bounding sphere in local space
  73984. */
  73985. readonly center: Vector3;
  73986. /**
  73987. * Radius of the bounding sphere in local space
  73988. */
  73989. radius: number;
  73990. /**
  73991. * Gets the center of the bounding sphere in world space
  73992. */
  73993. readonly centerWorld: Vector3;
  73994. /**
  73995. * Radius of the bounding sphere in world space
  73996. */
  73997. radiusWorld: number;
  73998. /**
  73999. * Gets the minimum vector in local space
  74000. */
  74001. readonly minimum: Vector3;
  74002. /**
  74003. * Gets the maximum vector in local space
  74004. */
  74005. readonly maximum: Vector3;
  74006. private _worldMatrix;
  74007. private static readonly TmpVector3;
  74008. /**
  74009. * Creates a new bounding sphere
  74010. * @param min defines the minimum vector (in local space)
  74011. * @param max defines the maximum vector (in local space)
  74012. * @param worldMatrix defines the new world matrix
  74013. */
  74014. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74015. /**
  74016. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74017. * @param min defines the new minimum vector (in local space)
  74018. * @param max defines the new maximum vector (in local space)
  74019. * @param worldMatrix defines the new world matrix
  74020. */
  74021. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74022. /**
  74023. * Scale the current bounding sphere by applying a scale factor
  74024. * @param factor defines the scale factor to apply
  74025. * @returns the current bounding box
  74026. */
  74027. scale(factor: number): BoundingSphere;
  74028. /**
  74029. * Gets the world matrix of the bounding box
  74030. * @returns a matrix
  74031. */
  74032. getWorldMatrix(): DeepImmutable<Matrix>;
  74033. /** @hidden */
  74034. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74035. /**
  74036. * Tests if the bounding sphere is intersecting the frustum planes
  74037. * @param frustumPlanes defines the frustum planes to test
  74038. * @returns true if there is an intersection
  74039. */
  74040. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74041. /**
  74042. * Tests if the bounding sphere center is in between the frustum planes.
  74043. * Used for optimistic fast inclusion.
  74044. * @param frustumPlanes defines the frustum planes to test
  74045. * @returns true if the sphere center is in between the frustum planes
  74046. */
  74047. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74048. /**
  74049. * Tests if a point is inside the bounding sphere
  74050. * @param point defines the point to test
  74051. * @returns true if the point is inside the bounding sphere
  74052. */
  74053. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74054. /**
  74055. * Checks if two sphere intersct
  74056. * @param sphere0 sphere 0
  74057. * @param sphere1 sphere 1
  74058. * @returns true if the speres intersect
  74059. */
  74060. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74061. }
  74062. }
  74063. declare module BABYLON {
  74064. /**
  74065. * Class used to store bounding box information
  74066. */
  74067. export class BoundingBox implements ICullable {
  74068. /**
  74069. * Gets the 8 vectors representing the bounding box in local space
  74070. */
  74071. readonly vectors: Vector3[];
  74072. /**
  74073. * Gets the center of the bounding box in local space
  74074. */
  74075. readonly center: Vector3;
  74076. /**
  74077. * Gets the center of the bounding box in world space
  74078. */
  74079. readonly centerWorld: Vector3;
  74080. /**
  74081. * Gets the extend size in local space
  74082. */
  74083. readonly extendSize: Vector3;
  74084. /**
  74085. * Gets the extend size in world space
  74086. */
  74087. readonly extendSizeWorld: Vector3;
  74088. /**
  74089. * Gets the OBB (object bounding box) directions
  74090. */
  74091. readonly directions: Vector3[];
  74092. /**
  74093. * Gets the 8 vectors representing the bounding box in world space
  74094. */
  74095. readonly vectorsWorld: Vector3[];
  74096. /**
  74097. * Gets the minimum vector in world space
  74098. */
  74099. readonly minimumWorld: Vector3;
  74100. /**
  74101. * Gets the maximum vector in world space
  74102. */
  74103. readonly maximumWorld: Vector3;
  74104. /**
  74105. * Gets the minimum vector in local space
  74106. */
  74107. readonly minimum: Vector3;
  74108. /**
  74109. * Gets the maximum vector in local space
  74110. */
  74111. readonly maximum: Vector3;
  74112. private _worldMatrix;
  74113. private static readonly TmpVector3;
  74114. /**
  74115. * @hidden
  74116. */
  74117. _tag: number;
  74118. /**
  74119. * Creates a new bounding box
  74120. * @param min defines the minimum vector (in local space)
  74121. * @param max defines the maximum vector (in local space)
  74122. * @param worldMatrix defines the new world matrix
  74123. */
  74124. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74125. /**
  74126. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74127. * @param min defines the new minimum vector (in local space)
  74128. * @param max defines the new maximum vector (in local space)
  74129. * @param worldMatrix defines the new world matrix
  74130. */
  74131. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74132. /**
  74133. * Scale the current bounding box by applying a scale factor
  74134. * @param factor defines the scale factor to apply
  74135. * @returns the current bounding box
  74136. */
  74137. scale(factor: number): BoundingBox;
  74138. /**
  74139. * Gets the world matrix of the bounding box
  74140. * @returns a matrix
  74141. */
  74142. getWorldMatrix(): DeepImmutable<Matrix>;
  74143. /** @hidden */
  74144. _update(world: DeepImmutable<Matrix>): void;
  74145. /**
  74146. * Tests if the bounding box is intersecting the frustum planes
  74147. * @param frustumPlanes defines the frustum planes to test
  74148. * @returns true if there is an intersection
  74149. */
  74150. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74151. /**
  74152. * Tests if the bounding box is entirely inside the frustum planes
  74153. * @param frustumPlanes defines the frustum planes to test
  74154. * @returns true if there is an inclusion
  74155. */
  74156. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74157. /**
  74158. * Tests if a point is inside the bounding box
  74159. * @param point defines the point to test
  74160. * @returns true if the point is inside the bounding box
  74161. */
  74162. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74163. /**
  74164. * Tests if the bounding box intersects with a bounding sphere
  74165. * @param sphere defines the sphere to test
  74166. * @returns true if there is an intersection
  74167. */
  74168. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74169. /**
  74170. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74171. * @param min defines the min vector to use
  74172. * @param max defines the max vector to use
  74173. * @returns true if there is an intersection
  74174. */
  74175. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74176. /**
  74177. * Tests if two bounding boxes are intersections
  74178. * @param box0 defines the first box to test
  74179. * @param box1 defines the second box to test
  74180. * @returns true if there is an intersection
  74181. */
  74182. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74183. /**
  74184. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74185. * @param minPoint defines the minimum vector of the bounding box
  74186. * @param maxPoint defines the maximum vector of the bounding box
  74187. * @param sphereCenter defines the sphere center
  74188. * @param sphereRadius defines the sphere radius
  74189. * @returns true if there is an intersection
  74190. */
  74191. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74192. /**
  74193. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74194. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74195. * @param frustumPlanes defines the frustum planes to test
  74196. * @return true if there is an inclusion
  74197. */
  74198. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74199. /**
  74200. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74201. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74202. * @param frustumPlanes defines the frustum planes to test
  74203. * @return true if there is an intersection
  74204. */
  74205. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74206. }
  74207. }
  74208. declare module BABYLON {
  74209. /** @hidden */
  74210. export class Collider {
  74211. /** Define if a collision was found */
  74212. collisionFound: boolean;
  74213. /**
  74214. * Define last intersection point in local space
  74215. */
  74216. intersectionPoint: Vector3;
  74217. /**
  74218. * Define last collided mesh
  74219. */
  74220. collidedMesh: Nullable<AbstractMesh>;
  74221. private _collisionPoint;
  74222. private _planeIntersectionPoint;
  74223. private _tempVector;
  74224. private _tempVector2;
  74225. private _tempVector3;
  74226. private _tempVector4;
  74227. private _edge;
  74228. private _baseToVertex;
  74229. private _destinationPoint;
  74230. private _slidePlaneNormal;
  74231. private _displacementVector;
  74232. /** @hidden */
  74233. _radius: Vector3;
  74234. /** @hidden */
  74235. _retry: number;
  74236. private _velocity;
  74237. private _basePoint;
  74238. private _epsilon;
  74239. /** @hidden */
  74240. _velocityWorldLength: number;
  74241. /** @hidden */
  74242. _basePointWorld: Vector3;
  74243. private _velocityWorld;
  74244. private _normalizedVelocity;
  74245. /** @hidden */
  74246. _initialVelocity: Vector3;
  74247. /** @hidden */
  74248. _initialPosition: Vector3;
  74249. private _nearestDistance;
  74250. private _collisionMask;
  74251. collisionMask: number;
  74252. /**
  74253. * Gets the plane normal used to compute the sliding response (in local space)
  74254. */
  74255. readonly slidePlaneNormal: Vector3;
  74256. /** @hidden */
  74257. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74258. /** @hidden */
  74259. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74260. /** @hidden */
  74261. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74262. /** @hidden */
  74263. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74264. /** @hidden */
  74265. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74266. /** @hidden */
  74267. _getResponse(pos: Vector3, vel: Vector3): void;
  74268. }
  74269. }
  74270. declare module BABYLON {
  74271. /**
  74272. * Interface for cullable objects
  74273. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74274. */
  74275. export interface ICullable {
  74276. /**
  74277. * Checks if the object or part of the object is in the frustum
  74278. * @param frustumPlanes Camera near/planes
  74279. * @returns true if the object is in frustum otherwise false
  74280. */
  74281. isInFrustum(frustumPlanes: Plane[]): boolean;
  74282. /**
  74283. * Checks if a cullable object (mesh...) is in the camera frustum
  74284. * Unlike isInFrustum this cheks the full bounding box
  74285. * @param frustumPlanes Camera near/planes
  74286. * @returns true if the object is in frustum otherwise false
  74287. */
  74288. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74289. }
  74290. /**
  74291. * Info for a bounding data of a mesh
  74292. */
  74293. export class BoundingInfo implements ICullable {
  74294. /**
  74295. * Bounding box for the mesh
  74296. */
  74297. readonly boundingBox: BoundingBox;
  74298. /**
  74299. * Bounding sphere for the mesh
  74300. */
  74301. readonly boundingSphere: BoundingSphere;
  74302. private _isLocked;
  74303. private static readonly TmpVector3;
  74304. /**
  74305. * Constructs bounding info
  74306. * @param minimum min vector of the bounding box/sphere
  74307. * @param maximum max vector of the bounding box/sphere
  74308. * @param worldMatrix defines the new world matrix
  74309. */
  74310. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74311. /**
  74312. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74313. * @param min defines the new minimum vector (in local space)
  74314. * @param max defines the new maximum vector (in local space)
  74315. * @param worldMatrix defines the new world matrix
  74316. */
  74317. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74318. /**
  74319. * min vector of the bounding box/sphere
  74320. */
  74321. readonly minimum: Vector3;
  74322. /**
  74323. * max vector of the bounding box/sphere
  74324. */
  74325. readonly maximum: Vector3;
  74326. /**
  74327. * If the info is locked and won't be updated to avoid perf overhead
  74328. */
  74329. isLocked: boolean;
  74330. /**
  74331. * Updates the bounding sphere and box
  74332. * @param world world matrix to be used to update
  74333. */
  74334. update(world: DeepImmutable<Matrix>): void;
  74335. /**
  74336. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74337. * @param center New center of the bounding info
  74338. * @param extend New extend of the bounding info
  74339. * @returns the current bounding info
  74340. */
  74341. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74342. /**
  74343. * Scale the current bounding info by applying a scale factor
  74344. * @param factor defines the scale factor to apply
  74345. * @returns the current bounding info
  74346. */
  74347. scale(factor: number): BoundingInfo;
  74348. /**
  74349. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74350. * @param frustumPlanes defines the frustum to test
  74351. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74352. * @returns true if the bounding info is in the frustum planes
  74353. */
  74354. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74355. /**
  74356. * Gets the world distance between the min and max points of the bounding box
  74357. */
  74358. readonly diagonalLength: number;
  74359. /**
  74360. * Checks if a cullable object (mesh...) is in the camera frustum
  74361. * Unlike isInFrustum this cheks the full bounding box
  74362. * @param frustumPlanes Camera near/planes
  74363. * @returns true if the object is in frustum otherwise false
  74364. */
  74365. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74366. /** @hidden */
  74367. _checkCollision(collider: Collider): boolean;
  74368. /**
  74369. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74370. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74371. * @param point the point to check intersection with
  74372. * @returns if the point intersects
  74373. */
  74374. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74375. /**
  74376. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74377. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74378. * @param boundingInfo the bounding info to check intersection with
  74379. * @param precise if the intersection should be done using OBB
  74380. * @returns if the bounding info intersects
  74381. */
  74382. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74383. }
  74384. }
  74385. declare module BABYLON {
  74386. /**
  74387. * Extracts minimum and maximum values from a list of indexed positions
  74388. * @param positions defines the positions to use
  74389. * @param indices defines the indices to the positions
  74390. * @param indexStart defines the start index
  74391. * @param indexCount defines the end index
  74392. * @param bias defines bias value to add to the result
  74393. * @return minimum and maximum values
  74394. */
  74395. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74396. minimum: Vector3;
  74397. maximum: Vector3;
  74398. };
  74399. /**
  74400. * Extracts minimum and maximum values from a list of positions
  74401. * @param positions defines the positions to use
  74402. * @param start defines the start index in the positions array
  74403. * @param count defines the number of positions to handle
  74404. * @param bias defines bias value to add to the result
  74405. * @param stride defines the stride size to use (distance between two positions in the positions array)
  74406. * @return minimum and maximum values
  74407. */
  74408. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  74409. minimum: Vector3;
  74410. maximum: Vector3;
  74411. };
  74412. }
  74413. declare module BABYLON {
  74414. /** @hidden */
  74415. export class WebGLDataBuffer extends DataBuffer {
  74416. private _buffer;
  74417. constructor(resource: WebGLBuffer);
  74418. readonly underlyingResource: any;
  74419. }
  74420. }
  74421. declare module BABYLON {
  74422. /** @hidden */
  74423. export class WebGLPipelineContext implements IPipelineContext {
  74424. engine: ThinEngine;
  74425. program: Nullable<WebGLProgram>;
  74426. context?: WebGLRenderingContext;
  74427. vertexShader?: WebGLShader;
  74428. fragmentShader?: WebGLShader;
  74429. isParallelCompiled: boolean;
  74430. onCompiled?: () => void;
  74431. transformFeedback?: WebGLTransformFeedback | null;
  74432. readonly isAsync: boolean;
  74433. readonly isReady: boolean;
  74434. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  74435. }
  74436. }
  74437. declare module BABYLON {
  74438. interface ThinEngine {
  74439. /**
  74440. * Create an uniform buffer
  74441. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74442. * @param elements defines the content of the uniform buffer
  74443. * @returns the webGL uniform buffer
  74444. */
  74445. createUniformBuffer(elements: FloatArray): DataBuffer;
  74446. /**
  74447. * Create a dynamic uniform buffer
  74448. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74449. * @param elements defines the content of the uniform buffer
  74450. * @returns the webGL uniform buffer
  74451. */
  74452. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  74453. /**
  74454. * Update an existing uniform buffer
  74455. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74456. * @param uniformBuffer defines the target uniform buffer
  74457. * @param elements defines the content to update
  74458. * @param offset defines the offset in the uniform buffer where update should start
  74459. * @param count defines the size of the data to update
  74460. */
  74461. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  74462. /**
  74463. * Bind an uniform buffer to the current webGL context
  74464. * @param buffer defines the buffer to bind
  74465. */
  74466. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  74467. /**
  74468. * Bind a buffer to the current webGL context at a given location
  74469. * @param buffer defines the buffer to bind
  74470. * @param location defines the index where to bind the buffer
  74471. */
  74472. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  74473. /**
  74474. * Bind a specific block at a given index in a specific shader program
  74475. * @param pipelineContext defines the pipeline context to use
  74476. * @param blockName defines the block name
  74477. * @param index defines the index where to bind the block
  74478. */
  74479. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  74480. }
  74481. }
  74482. declare module BABYLON {
  74483. /**
  74484. * Uniform buffer objects.
  74485. *
  74486. * Handles blocks of uniform on the GPU.
  74487. *
  74488. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74489. *
  74490. * For more information, please refer to :
  74491. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74492. */
  74493. export class UniformBuffer {
  74494. private _engine;
  74495. private _buffer;
  74496. private _data;
  74497. private _bufferData;
  74498. private _dynamic?;
  74499. private _uniformLocations;
  74500. private _uniformSizes;
  74501. private _uniformLocationPointer;
  74502. private _needSync;
  74503. private _noUBO;
  74504. private _currentEffect;
  74505. /** @hidden */
  74506. _alreadyBound: boolean;
  74507. private static _MAX_UNIFORM_SIZE;
  74508. private static _tempBuffer;
  74509. /**
  74510. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  74511. * This is dynamic to allow compat with webgl 1 and 2.
  74512. * You will need to pass the name of the uniform as well as the value.
  74513. */
  74514. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  74515. /**
  74516. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  74517. * This is dynamic to allow compat with webgl 1 and 2.
  74518. * You will need to pass the name of the uniform as well as the value.
  74519. */
  74520. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  74521. /**
  74522. * Lambda to Update a single float in a uniform buffer.
  74523. * This is dynamic to allow compat with webgl 1 and 2.
  74524. * You will need to pass the name of the uniform as well as the value.
  74525. */
  74526. updateFloat: (name: string, x: number) => void;
  74527. /**
  74528. * Lambda to Update a vec2 of float in a uniform buffer.
  74529. * This is dynamic to allow compat with webgl 1 and 2.
  74530. * You will need to pass the name of the uniform as well as the value.
  74531. */
  74532. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  74533. /**
  74534. * Lambda to Update a vec3 of float in a uniform buffer.
  74535. * This is dynamic to allow compat with webgl 1 and 2.
  74536. * You will need to pass the name of the uniform as well as the value.
  74537. */
  74538. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  74539. /**
  74540. * Lambda to Update a vec4 of float in a uniform buffer.
  74541. * This is dynamic to allow compat with webgl 1 and 2.
  74542. * You will need to pass the name of the uniform as well as the value.
  74543. */
  74544. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  74545. /**
  74546. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  74547. * This is dynamic to allow compat with webgl 1 and 2.
  74548. * You will need to pass the name of the uniform as well as the value.
  74549. */
  74550. updateMatrix: (name: string, mat: Matrix) => void;
  74551. /**
  74552. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  74553. * This is dynamic to allow compat with webgl 1 and 2.
  74554. * You will need to pass the name of the uniform as well as the value.
  74555. */
  74556. updateVector3: (name: string, vector: Vector3) => void;
  74557. /**
  74558. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  74559. * This is dynamic to allow compat with webgl 1 and 2.
  74560. * You will need to pass the name of the uniform as well as the value.
  74561. */
  74562. updateVector4: (name: string, vector: Vector4) => void;
  74563. /**
  74564. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  74565. * This is dynamic to allow compat with webgl 1 and 2.
  74566. * You will need to pass the name of the uniform as well as the value.
  74567. */
  74568. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  74569. /**
  74570. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  74571. * This is dynamic to allow compat with webgl 1 and 2.
  74572. * You will need to pass the name of the uniform as well as the value.
  74573. */
  74574. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  74575. /**
  74576. * Instantiates a new Uniform buffer objects.
  74577. *
  74578. * Handles blocks of uniform on the GPU.
  74579. *
  74580. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74581. *
  74582. * For more information, please refer to :
  74583. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74584. * @param engine Define the engine the buffer is associated with
  74585. * @param data Define the data contained in the buffer
  74586. * @param dynamic Define if the buffer is updatable
  74587. */
  74588. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74589. /**
  74590. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74591. * or just falling back on setUniformXXX calls.
  74592. */
  74593. readonly useUbo: boolean;
  74594. /**
  74595. * Indicates if the WebGL underlying uniform buffer is in sync
  74596. * with the javascript cache data.
  74597. */
  74598. readonly isSync: boolean;
  74599. /**
  74600. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74601. * Also, a dynamic UniformBuffer will disable cache verification and always
  74602. * update the underlying WebGL uniform buffer to the GPU.
  74603. * @returns if Dynamic, otherwise false
  74604. */
  74605. isDynamic(): boolean;
  74606. /**
  74607. * The data cache on JS side.
  74608. * @returns the underlying data as a float array
  74609. */
  74610. getData(): Float32Array;
  74611. /**
  74612. * The underlying WebGL Uniform buffer.
  74613. * @returns the webgl buffer
  74614. */
  74615. getBuffer(): Nullable<DataBuffer>;
  74616. /**
  74617. * std140 layout specifies how to align data within an UBO structure.
  74618. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74619. * for specs.
  74620. */
  74621. private _fillAlignment;
  74622. /**
  74623. * Adds an uniform in the buffer.
  74624. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74625. * for the layout to be correct !
  74626. * @param name Name of the uniform, as used in the uniform block in the shader.
  74627. * @param size Data size, or data directly.
  74628. */
  74629. addUniform(name: string, size: number | number[]): void;
  74630. /**
  74631. * Adds a Matrix 4x4 to the uniform buffer.
  74632. * @param name Name of the uniform, as used in the uniform block in the shader.
  74633. * @param mat A 4x4 matrix.
  74634. */
  74635. addMatrix(name: string, mat: Matrix): void;
  74636. /**
  74637. * Adds a vec2 to the uniform buffer.
  74638. * @param name Name of the uniform, as used in the uniform block in the shader.
  74639. * @param x Define the x component value of the vec2
  74640. * @param y Define the y component value of the vec2
  74641. */
  74642. addFloat2(name: string, x: number, y: number): void;
  74643. /**
  74644. * Adds a vec3 to the uniform buffer.
  74645. * @param name Name of the uniform, as used in the uniform block in the shader.
  74646. * @param x Define the x component value of the vec3
  74647. * @param y Define the y component value of the vec3
  74648. * @param z Define the z component value of the vec3
  74649. */
  74650. addFloat3(name: string, x: number, y: number, z: number): void;
  74651. /**
  74652. * Adds a vec3 to the uniform buffer.
  74653. * @param name Name of the uniform, as used in the uniform block in the shader.
  74654. * @param color Define the vec3 from a Color
  74655. */
  74656. addColor3(name: string, color: Color3): void;
  74657. /**
  74658. * Adds a vec4 to the uniform buffer.
  74659. * @param name Name of the uniform, as used in the uniform block in the shader.
  74660. * @param color Define the rgb components from a Color
  74661. * @param alpha Define the a component of the vec4
  74662. */
  74663. addColor4(name: string, color: Color3, alpha: number): void;
  74664. /**
  74665. * Adds a vec3 to the uniform buffer.
  74666. * @param name Name of the uniform, as used in the uniform block in the shader.
  74667. * @param vector Define the vec3 components from a Vector
  74668. */
  74669. addVector3(name: string, vector: Vector3): void;
  74670. /**
  74671. * Adds a Matrix 3x3 to the uniform buffer.
  74672. * @param name Name of the uniform, as used in the uniform block in the shader.
  74673. */
  74674. addMatrix3x3(name: string): void;
  74675. /**
  74676. * Adds a Matrix 2x2 to the uniform buffer.
  74677. * @param name Name of the uniform, as used in the uniform block in the shader.
  74678. */
  74679. addMatrix2x2(name: string): void;
  74680. /**
  74681. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74682. */
  74683. create(): void;
  74684. /** @hidden */
  74685. _rebuild(): void;
  74686. /**
  74687. * Updates the WebGL Uniform Buffer on the GPU.
  74688. * If the `dynamic` flag is set to true, no cache comparison is done.
  74689. * Otherwise, the buffer will be updated only if the cache differs.
  74690. */
  74691. update(): void;
  74692. /**
  74693. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74694. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74695. * @param data Define the flattened data
  74696. * @param size Define the size of the data.
  74697. */
  74698. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74699. private _valueCache;
  74700. private _cacheMatrix;
  74701. private _updateMatrix3x3ForUniform;
  74702. private _updateMatrix3x3ForEffect;
  74703. private _updateMatrix2x2ForEffect;
  74704. private _updateMatrix2x2ForUniform;
  74705. private _updateFloatForEffect;
  74706. private _updateFloatForUniform;
  74707. private _updateFloat2ForEffect;
  74708. private _updateFloat2ForUniform;
  74709. private _updateFloat3ForEffect;
  74710. private _updateFloat3ForUniform;
  74711. private _updateFloat4ForEffect;
  74712. private _updateFloat4ForUniform;
  74713. private _updateMatrixForEffect;
  74714. private _updateMatrixForUniform;
  74715. private _updateVector3ForEffect;
  74716. private _updateVector3ForUniform;
  74717. private _updateVector4ForEffect;
  74718. private _updateVector4ForUniform;
  74719. private _updateColor3ForEffect;
  74720. private _updateColor3ForUniform;
  74721. private _updateColor4ForEffect;
  74722. private _updateColor4ForUniform;
  74723. /**
  74724. * Sets a sampler uniform on the effect.
  74725. * @param name Define the name of the sampler.
  74726. * @param texture Define the texture to set in the sampler
  74727. */
  74728. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74729. /**
  74730. * Directly updates the value of the uniform in the cache AND on the GPU.
  74731. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74732. * @param data Define the flattened data
  74733. */
  74734. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74735. /**
  74736. * Binds this uniform buffer to an effect.
  74737. * @param effect Define the effect to bind the buffer to
  74738. * @param name Name of the uniform block in the shader.
  74739. */
  74740. bindToEffect(effect: Effect, name: string): void;
  74741. /**
  74742. * Disposes the uniform buffer.
  74743. */
  74744. dispose(): void;
  74745. }
  74746. }
  74747. declare module BABYLON {
  74748. /**
  74749. * Enum that determines the text-wrapping mode to use.
  74750. */
  74751. export enum InspectableType {
  74752. /**
  74753. * Checkbox for booleans
  74754. */
  74755. Checkbox = 0,
  74756. /**
  74757. * Sliders for numbers
  74758. */
  74759. Slider = 1,
  74760. /**
  74761. * Vector3
  74762. */
  74763. Vector3 = 2,
  74764. /**
  74765. * Quaternions
  74766. */
  74767. Quaternion = 3,
  74768. /**
  74769. * Color3
  74770. */
  74771. Color3 = 4,
  74772. /**
  74773. * String
  74774. */
  74775. String = 5
  74776. }
  74777. /**
  74778. * Interface used to define custom inspectable properties.
  74779. * This interface is used by the inspector to display custom property grids
  74780. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74781. */
  74782. export interface IInspectable {
  74783. /**
  74784. * Gets the label to display
  74785. */
  74786. label: string;
  74787. /**
  74788. * Gets the name of the property to edit
  74789. */
  74790. propertyName: string;
  74791. /**
  74792. * Gets the type of the editor to use
  74793. */
  74794. type: InspectableType;
  74795. /**
  74796. * Gets the minimum value of the property when using in "slider" mode
  74797. */
  74798. min?: number;
  74799. /**
  74800. * Gets the maximum value of the property when using in "slider" mode
  74801. */
  74802. max?: number;
  74803. /**
  74804. * Gets the setp to use when using in "slider" mode
  74805. */
  74806. step?: number;
  74807. }
  74808. }
  74809. declare module BABYLON {
  74810. /**
  74811. * Class used to provide helper for timing
  74812. */
  74813. export class TimingTools {
  74814. /**
  74815. * Polyfill for setImmediate
  74816. * @param action defines the action to execute after the current execution block
  74817. */
  74818. static SetImmediate(action: () => void): void;
  74819. }
  74820. }
  74821. declare module BABYLON {
  74822. /**
  74823. * Class used to enable instatition of objects by class name
  74824. */
  74825. export class InstantiationTools {
  74826. /**
  74827. * Use this object to register external classes like custom textures or material
  74828. * to allow the laoders to instantiate them
  74829. */
  74830. static RegisteredExternalClasses: {
  74831. [key: string]: Object;
  74832. };
  74833. /**
  74834. * Tries to instantiate a new object from a given class name
  74835. * @param className defines the class name to instantiate
  74836. * @returns the new object or null if the system was not able to do the instantiation
  74837. */
  74838. static Instantiate(className: string): any;
  74839. }
  74840. }
  74841. declare module BABYLON {
  74842. /**
  74843. * Define options used to create a depth texture
  74844. */
  74845. export class DepthTextureCreationOptions {
  74846. /** Specifies whether or not a stencil should be allocated in the texture */
  74847. generateStencil?: boolean;
  74848. /** Specifies whether or not bilinear filtering is enable on the texture */
  74849. bilinearFiltering?: boolean;
  74850. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74851. comparisonFunction?: number;
  74852. /** Specifies if the created texture is a cube texture */
  74853. isCube?: boolean;
  74854. }
  74855. }
  74856. declare module BABYLON {
  74857. interface ThinEngine {
  74858. /**
  74859. * Creates a depth stencil cube texture.
  74860. * This is only available in WebGL 2.
  74861. * @param size The size of face edge in the cube texture.
  74862. * @param options The options defining the cube texture.
  74863. * @returns The cube texture
  74864. */
  74865. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74866. /**
  74867. * Creates a cube texture
  74868. * @param rootUrl defines the url where the files to load is located
  74869. * @param scene defines the current scene
  74870. * @param files defines the list of files to load (1 per face)
  74871. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74872. * @param onLoad defines an optional callback raised when the texture is loaded
  74873. * @param onError defines an optional callback raised if there is an issue to load the texture
  74874. * @param format defines the format of the data
  74875. * @param forcedExtension defines the extension to use to pick the right loader
  74876. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74877. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74878. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74879. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74880. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74881. * @returns the cube texture as an InternalTexture
  74882. */
  74883. 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;
  74884. /**
  74885. * Creates a cube texture
  74886. * @param rootUrl defines the url where the files to load is located
  74887. * @param scene defines the current scene
  74888. * @param files defines the list of files to load (1 per face)
  74889. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74890. * @param onLoad defines an optional callback raised when the texture is loaded
  74891. * @param onError defines an optional callback raised if there is an issue to load the texture
  74892. * @param format defines the format of the data
  74893. * @param forcedExtension defines the extension to use to pick the right loader
  74894. * @returns the cube texture as an InternalTexture
  74895. */
  74896. 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;
  74897. /**
  74898. * Creates a cube texture
  74899. * @param rootUrl defines the url where the files to load is located
  74900. * @param scene defines the current scene
  74901. * @param files defines the list of files to load (1 per face)
  74902. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74903. * @param onLoad defines an optional callback raised when the texture is loaded
  74904. * @param onError defines an optional callback raised if there is an issue to load the texture
  74905. * @param format defines the format of the data
  74906. * @param forcedExtension defines the extension to use to pick the right loader
  74907. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74908. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74909. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74910. * @returns the cube texture as an InternalTexture
  74911. */
  74912. 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;
  74913. /** @hidden */
  74914. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74915. /** @hidden */
  74916. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74917. /** @hidden */
  74918. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74919. /** @hidden */
  74920. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74921. }
  74922. }
  74923. declare module BABYLON {
  74924. /**
  74925. * Class for creating a cube texture
  74926. */
  74927. export class CubeTexture extends BaseTexture {
  74928. private _delayedOnLoad;
  74929. /**
  74930. * The url of the texture
  74931. */
  74932. url: string;
  74933. /**
  74934. * Gets or sets the center of the bounding box associated with the cube texture.
  74935. * It must define where the camera used to render the texture was set
  74936. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74937. */
  74938. boundingBoxPosition: Vector3;
  74939. private _boundingBoxSize;
  74940. /**
  74941. * Gets or sets the size of the bounding box associated with the cube texture
  74942. * When defined, the cubemap will switch to local mode
  74943. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74944. * @example https://www.babylonjs-playground.com/#RNASML
  74945. */
  74946. /**
  74947. * Returns the bounding box size
  74948. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74949. */
  74950. boundingBoxSize: Vector3;
  74951. protected _rotationY: number;
  74952. /**
  74953. * Sets texture matrix rotation angle around Y axis in radians.
  74954. */
  74955. /**
  74956. * Gets texture matrix rotation angle around Y axis radians.
  74957. */
  74958. rotationY: number;
  74959. /**
  74960. * Are mip maps generated for this texture or not.
  74961. */
  74962. readonly noMipmap: boolean;
  74963. private _noMipmap;
  74964. private _files;
  74965. protected _forcedExtension: Nullable<string>;
  74966. private _extensions;
  74967. private _textureMatrix;
  74968. private _format;
  74969. private _createPolynomials;
  74970. /** @hidden */
  74971. _prefiltered: boolean;
  74972. /**
  74973. * Creates a cube texture from an array of image urls
  74974. * @param files defines an array of image urls
  74975. * @param scene defines the hosting scene
  74976. * @param noMipmap specifies if mip maps are not used
  74977. * @returns a cube texture
  74978. */
  74979. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74980. /**
  74981. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74982. * @param url defines the url of the prefiltered texture
  74983. * @param scene defines the scene the texture is attached to
  74984. * @param forcedExtension defines the extension of the file if different from the url
  74985. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74986. * @return the prefiltered texture
  74987. */
  74988. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74989. /**
  74990. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74991. * as prefiltered data.
  74992. * @param rootUrl defines the url of the texture or the root name of the six images
  74993. * @param scene defines the scene the texture is attached to
  74994. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74995. * @param noMipmap defines if mipmaps should be created or not
  74996. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74997. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74998. * @param onError defines a callback triggered in case of error during load
  74999. * @param format defines the internal format to use for the texture once loaded
  75000. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75001. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75002. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75003. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75004. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75005. * @return the cube texture
  75006. */
  75007. 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);
  75008. /**
  75009. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75010. */
  75011. readonly isPrefiltered: boolean;
  75012. /**
  75013. * Get the current class name of the texture useful for serialization or dynamic coding.
  75014. * @returns "CubeTexture"
  75015. */
  75016. getClassName(): string;
  75017. /**
  75018. * Update the url (and optional buffer) of this texture if url was null during construction.
  75019. * @param url the url of the texture
  75020. * @param forcedExtension defines the extension to use
  75021. * @param onLoad callback called when the texture is loaded (defaults to null)
  75022. */
  75023. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75024. /**
  75025. * Delays loading of the cube texture
  75026. * @param forcedExtension defines the extension to use
  75027. */
  75028. delayLoad(forcedExtension?: string): void;
  75029. /**
  75030. * Returns the reflection texture matrix
  75031. * @returns the reflection texture matrix
  75032. */
  75033. getReflectionTextureMatrix(): Matrix;
  75034. /**
  75035. * Sets the reflection texture matrix
  75036. * @param value Reflection texture matrix
  75037. */
  75038. setReflectionTextureMatrix(value: Matrix): void;
  75039. /**
  75040. * Parses text to create a cube texture
  75041. * @param parsedTexture define the serialized text to read from
  75042. * @param scene defines the hosting scene
  75043. * @param rootUrl defines the root url of the cube texture
  75044. * @returns a cube texture
  75045. */
  75046. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75047. /**
  75048. * Makes a clone, or deep copy, of the cube texture
  75049. * @returns a new cube texture
  75050. */
  75051. clone(): CubeTexture;
  75052. }
  75053. }
  75054. declare module BABYLON {
  75055. /**
  75056. * Manages the defines for the Material
  75057. */
  75058. export class MaterialDefines {
  75059. /** @hidden */
  75060. protected _keys: string[];
  75061. private _isDirty;
  75062. /** @hidden */
  75063. _renderId: number;
  75064. /** @hidden */
  75065. _areLightsDirty: boolean;
  75066. /** @hidden */
  75067. _areLightsDisposed: boolean;
  75068. /** @hidden */
  75069. _areAttributesDirty: boolean;
  75070. /** @hidden */
  75071. _areTexturesDirty: boolean;
  75072. /** @hidden */
  75073. _areFresnelDirty: boolean;
  75074. /** @hidden */
  75075. _areMiscDirty: boolean;
  75076. /** @hidden */
  75077. _areImageProcessingDirty: boolean;
  75078. /** @hidden */
  75079. _normals: boolean;
  75080. /** @hidden */
  75081. _uvs: boolean;
  75082. /** @hidden */
  75083. _needNormals: boolean;
  75084. /** @hidden */
  75085. _needUVs: boolean;
  75086. [id: string]: any;
  75087. /**
  75088. * Specifies if the material needs to be re-calculated
  75089. */
  75090. readonly isDirty: boolean;
  75091. /**
  75092. * Marks the material to indicate that it has been re-calculated
  75093. */
  75094. markAsProcessed(): void;
  75095. /**
  75096. * Marks the material to indicate that it needs to be re-calculated
  75097. */
  75098. markAsUnprocessed(): void;
  75099. /**
  75100. * Marks the material to indicate all of its defines need to be re-calculated
  75101. */
  75102. markAllAsDirty(): void;
  75103. /**
  75104. * Marks the material to indicate that image processing needs to be re-calculated
  75105. */
  75106. markAsImageProcessingDirty(): void;
  75107. /**
  75108. * Marks the material to indicate the lights need to be re-calculated
  75109. * @param disposed Defines whether the light is dirty due to dispose or not
  75110. */
  75111. markAsLightDirty(disposed?: boolean): void;
  75112. /**
  75113. * Marks the attribute state as changed
  75114. */
  75115. markAsAttributesDirty(): void;
  75116. /**
  75117. * Marks the texture state as changed
  75118. */
  75119. markAsTexturesDirty(): void;
  75120. /**
  75121. * Marks the fresnel state as changed
  75122. */
  75123. markAsFresnelDirty(): void;
  75124. /**
  75125. * Marks the misc state as changed
  75126. */
  75127. markAsMiscDirty(): void;
  75128. /**
  75129. * Rebuilds the material defines
  75130. */
  75131. rebuild(): void;
  75132. /**
  75133. * Specifies if two material defines are equal
  75134. * @param other - A material define instance to compare to
  75135. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75136. */
  75137. isEqual(other: MaterialDefines): boolean;
  75138. /**
  75139. * Clones this instance's defines to another instance
  75140. * @param other - material defines to clone values to
  75141. */
  75142. cloneTo(other: MaterialDefines): void;
  75143. /**
  75144. * Resets the material define values
  75145. */
  75146. reset(): void;
  75147. /**
  75148. * Converts the material define values to a string
  75149. * @returns - String of material define information
  75150. */
  75151. toString(): string;
  75152. }
  75153. }
  75154. declare module BABYLON {
  75155. /**
  75156. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75157. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75158. * 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;
  75159. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75160. */
  75161. export class ColorCurves {
  75162. private _dirty;
  75163. private _tempColor;
  75164. private _globalCurve;
  75165. private _highlightsCurve;
  75166. private _midtonesCurve;
  75167. private _shadowsCurve;
  75168. private _positiveCurve;
  75169. private _negativeCurve;
  75170. private _globalHue;
  75171. private _globalDensity;
  75172. private _globalSaturation;
  75173. private _globalExposure;
  75174. /**
  75175. * Gets the global Hue value.
  75176. * 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).
  75177. */
  75178. /**
  75179. * Sets the global Hue value.
  75180. * 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).
  75181. */
  75182. globalHue: number;
  75183. /**
  75184. * Gets the global Density value.
  75185. * 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.
  75186. * Values less than zero provide a filter of opposite hue.
  75187. */
  75188. /**
  75189. * Sets the global Density value.
  75190. * 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.
  75191. * Values less than zero provide a filter of opposite hue.
  75192. */
  75193. globalDensity: number;
  75194. /**
  75195. * Gets the global Saturation value.
  75196. * 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.
  75197. */
  75198. /**
  75199. * Sets the global Saturation value.
  75200. * 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.
  75201. */
  75202. globalSaturation: number;
  75203. /**
  75204. * Gets the global Exposure value.
  75205. * 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.
  75206. */
  75207. /**
  75208. * Sets the global Exposure value.
  75209. * 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.
  75210. */
  75211. globalExposure: number;
  75212. private _highlightsHue;
  75213. private _highlightsDensity;
  75214. private _highlightsSaturation;
  75215. private _highlightsExposure;
  75216. /**
  75217. * Gets the highlights Hue value.
  75218. * 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).
  75219. */
  75220. /**
  75221. * Sets the highlights Hue value.
  75222. * 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).
  75223. */
  75224. highlightsHue: number;
  75225. /**
  75226. * Gets the highlights Density value.
  75227. * 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.
  75228. * Values less than zero provide a filter of opposite hue.
  75229. */
  75230. /**
  75231. * Sets the highlights Density value.
  75232. * 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.
  75233. * Values less than zero provide a filter of opposite hue.
  75234. */
  75235. highlightsDensity: number;
  75236. /**
  75237. * Gets the highlights Saturation value.
  75238. * 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.
  75239. */
  75240. /**
  75241. * Sets the highlights Saturation value.
  75242. * 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.
  75243. */
  75244. highlightsSaturation: number;
  75245. /**
  75246. * Gets the highlights Exposure value.
  75247. * 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.
  75248. */
  75249. /**
  75250. * Sets the highlights Exposure value.
  75251. * 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.
  75252. */
  75253. highlightsExposure: number;
  75254. private _midtonesHue;
  75255. private _midtonesDensity;
  75256. private _midtonesSaturation;
  75257. private _midtonesExposure;
  75258. /**
  75259. * Gets the midtones Hue value.
  75260. * 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).
  75261. */
  75262. /**
  75263. * Sets the midtones Hue value.
  75264. * 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).
  75265. */
  75266. midtonesHue: number;
  75267. /**
  75268. * Gets the midtones Density value.
  75269. * 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.
  75270. * Values less than zero provide a filter of opposite hue.
  75271. */
  75272. /**
  75273. * Sets the midtones Density value.
  75274. * 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.
  75275. * Values less than zero provide a filter of opposite hue.
  75276. */
  75277. midtonesDensity: number;
  75278. /**
  75279. * Gets the midtones Saturation value.
  75280. * 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.
  75281. */
  75282. /**
  75283. * Sets the midtones Saturation value.
  75284. * 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.
  75285. */
  75286. midtonesSaturation: number;
  75287. /**
  75288. * Gets the midtones Exposure value.
  75289. * 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.
  75290. */
  75291. /**
  75292. * Sets the midtones Exposure value.
  75293. * 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.
  75294. */
  75295. midtonesExposure: number;
  75296. private _shadowsHue;
  75297. private _shadowsDensity;
  75298. private _shadowsSaturation;
  75299. private _shadowsExposure;
  75300. /**
  75301. * Gets the shadows Hue value.
  75302. * 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).
  75303. */
  75304. /**
  75305. * Sets the shadows Hue value.
  75306. * 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).
  75307. */
  75308. shadowsHue: number;
  75309. /**
  75310. * Gets the shadows Density value.
  75311. * 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.
  75312. * Values less than zero provide a filter of opposite hue.
  75313. */
  75314. /**
  75315. * Sets the shadows Density value.
  75316. * 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.
  75317. * Values less than zero provide a filter of opposite hue.
  75318. */
  75319. shadowsDensity: number;
  75320. /**
  75321. * Gets the shadows Saturation value.
  75322. * 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.
  75323. */
  75324. /**
  75325. * Sets the shadows Saturation value.
  75326. * 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.
  75327. */
  75328. shadowsSaturation: number;
  75329. /**
  75330. * Gets the shadows Exposure value.
  75331. * 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.
  75332. */
  75333. /**
  75334. * Sets the shadows Exposure value.
  75335. * 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.
  75336. */
  75337. shadowsExposure: number;
  75338. /**
  75339. * Returns the class name
  75340. * @returns The class name
  75341. */
  75342. getClassName(): string;
  75343. /**
  75344. * Binds the color curves to the shader.
  75345. * @param colorCurves The color curve to bind
  75346. * @param effect The effect to bind to
  75347. * @param positiveUniform The positive uniform shader parameter
  75348. * @param neutralUniform The neutral uniform shader parameter
  75349. * @param negativeUniform The negative uniform shader parameter
  75350. */
  75351. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75352. /**
  75353. * Prepare the list of uniforms associated with the ColorCurves effects.
  75354. * @param uniformsList The list of uniforms used in the effect
  75355. */
  75356. static PrepareUniforms(uniformsList: string[]): void;
  75357. /**
  75358. * Returns color grading data based on a hue, density, saturation and exposure value.
  75359. * @param filterHue The hue of the color filter.
  75360. * @param filterDensity The density of the color filter.
  75361. * @param saturation The saturation.
  75362. * @param exposure The exposure.
  75363. * @param result The result data container.
  75364. */
  75365. private getColorGradingDataToRef;
  75366. /**
  75367. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75368. * @param value The input slider value in range [-100,100].
  75369. * @returns Adjusted value.
  75370. */
  75371. private static applyColorGradingSliderNonlinear;
  75372. /**
  75373. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75374. * @param hue The hue (H) input.
  75375. * @param saturation The saturation (S) input.
  75376. * @param brightness The brightness (B) input.
  75377. * @result An RGBA color represented as Vector4.
  75378. */
  75379. private static fromHSBToRef;
  75380. /**
  75381. * Returns a value clamped between min and max
  75382. * @param value The value to clamp
  75383. * @param min The minimum of value
  75384. * @param max The maximum of value
  75385. * @returns The clamped value.
  75386. */
  75387. private static clamp;
  75388. /**
  75389. * Clones the current color curve instance.
  75390. * @return The cloned curves
  75391. */
  75392. clone(): ColorCurves;
  75393. /**
  75394. * Serializes the current color curve instance to a json representation.
  75395. * @return a JSON representation
  75396. */
  75397. serialize(): any;
  75398. /**
  75399. * Parses the color curve from a json representation.
  75400. * @param source the JSON source to parse
  75401. * @return The parsed curves
  75402. */
  75403. static Parse(source: any): ColorCurves;
  75404. }
  75405. }
  75406. declare module BABYLON {
  75407. /**
  75408. * Interface to follow in your material defines to integrate easily the
  75409. * Image proccessing functions.
  75410. * @hidden
  75411. */
  75412. export interface IImageProcessingConfigurationDefines {
  75413. IMAGEPROCESSING: boolean;
  75414. VIGNETTE: boolean;
  75415. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75416. VIGNETTEBLENDMODEOPAQUE: boolean;
  75417. TONEMAPPING: boolean;
  75418. TONEMAPPING_ACES: boolean;
  75419. CONTRAST: boolean;
  75420. EXPOSURE: boolean;
  75421. COLORCURVES: boolean;
  75422. COLORGRADING: boolean;
  75423. COLORGRADING3D: boolean;
  75424. SAMPLER3DGREENDEPTH: boolean;
  75425. SAMPLER3DBGRMAP: boolean;
  75426. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75427. }
  75428. /**
  75429. * @hidden
  75430. */
  75431. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  75432. IMAGEPROCESSING: boolean;
  75433. VIGNETTE: boolean;
  75434. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75435. VIGNETTEBLENDMODEOPAQUE: boolean;
  75436. TONEMAPPING: boolean;
  75437. TONEMAPPING_ACES: boolean;
  75438. CONTRAST: boolean;
  75439. COLORCURVES: boolean;
  75440. COLORGRADING: boolean;
  75441. COLORGRADING3D: boolean;
  75442. SAMPLER3DGREENDEPTH: boolean;
  75443. SAMPLER3DBGRMAP: boolean;
  75444. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75445. EXPOSURE: boolean;
  75446. constructor();
  75447. }
  75448. /**
  75449. * This groups together the common properties used for image processing either in direct forward pass
  75450. * or through post processing effect depending on the use of the image processing pipeline in your scene
  75451. * or not.
  75452. */
  75453. export class ImageProcessingConfiguration {
  75454. /**
  75455. * Default tone mapping applied in BabylonJS.
  75456. */
  75457. static readonly TONEMAPPING_STANDARD: number;
  75458. /**
  75459. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  75460. * to other engines rendering to increase portability.
  75461. */
  75462. static readonly TONEMAPPING_ACES: number;
  75463. /**
  75464. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  75465. */
  75466. colorCurves: Nullable<ColorCurves>;
  75467. private _colorCurvesEnabled;
  75468. /**
  75469. * Gets wether the color curves effect is enabled.
  75470. */
  75471. /**
  75472. * Sets wether the color curves effect is enabled.
  75473. */
  75474. colorCurvesEnabled: boolean;
  75475. private _colorGradingTexture;
  75476. /**
  75477. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75478. */
  75479. /**
  75480. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75481. */
  75482. colorGradingTexture: Nullable<BaseTexture>;
  75483. private _colorGradingEnabled;
  75484. /**
  75485. * Gets wether the color grading effect is enabled.
  75486. */
  75487. /**
  75488. * Sets wether the color grading effect is enabled.
  75489. */
  75490. colorGradingEnabled: boolean;
  75491. private _colorGradingWithGreenDepth;
  75492. /**
  75493. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  75494. */
  75495. /**
  75496. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  75497. */
  75498. colorGradingWithGreenDepth: boolean;
  75499. private _colorGradingBGR;
  75500. /**
  75501. * Gets wether the color grading texture contains BGR values.
  75502. */
  75503. /**
  75504. * Sets wether the color grading texture contains BGR values.
  75505. */
  75506. colorGradingBGR: boolean;
  75507. /** @hidden */
  75508. _exposure: number;
  75509. /**
  75510. * Gets the Exposure used in the effect.
  75511. */
  75512. /**
  75513. * Sets the Exposure used in the effect.
  75514. */
  75515. exposure: number;
  75516. private _toneMappingEnabled;
  75517. /**
  75518. * Gets wether the tone mapping effect is enabled.
  75519. */
  75520. /**
  75521. * Sets wether the tone mapping effect is enabled.
  75522. */
  75523. toneMappingEnabled: boolean;
  75524. private _toneMappingType;
  75525. /**
  75526. * Gets the type of tone mapping effect.
  75527. */
  75528. /**
  75529. * Sets the type of tone mapping effect used in BabylonJS.
  75530. */
  75531. toneMappingType: number;
  75532. protected _contrast: number;
  75533. /**
  75534. * Gets the contrast used in the effect.
  75535. */
  75536. /**
  75537. * Sets the contrast used in the effect.
  75538. */
  75539. contrast: number;
  75540. /**
  75541. * Vignette stretch size.
  75542. */
  75543. vignetteStretch: number;
  75544. /**
  75545. * Vignette centre X Offset.
  75546. */
  75547. vignetteCentreX: number;
  75548. /**
  75549. * Vignette centre Y Offset.
  75550. */
  75551. vignetteCentreY: number;
  75552. /**
  75553. * Vignette weight or intensity of the vignette effect.
  75554. */
  75555. vignetteWeight: number;
  75556. /**
  75557. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  75558. * if vignetteEnabled is set to true.
  75559. */
  75560. vignetteColor: Color4;
  75561. /**
  75562. * Camera field of view used by the Vignette effect.
  75563. */
  75564. vignetteCameraFov: number;
  75565. private _vignetteBlendMode;
  75566. /**
  75567. * Gets the vignette blend mode allowing different kind of effect.
  75568. */
  75569. /**
  75570. * Sets the vignette blend mode allowing different kind of effect.
  75571. */
  75572. vignetteBlendMode: number;
  75573. private _vignetteEnabled;
  75574. /**
  75575. * Gets wether the vignette effect is enabled.
  75576. */
  75577. /**
  75578. * Sets wether the vignette effect is enabled.
  75579. */
  75580. vignetteEnabled: boolean;
  75581. private _applyByPostProcess;
  75582. /**
  75583. * Gets wether the image processing is applied through a post process or not.
  75584. */
  75585. /**
  75586. * Sets wether the image processing is applied through a post process or not.
  75587. */
  75588. applyByPostProcess: boolean;
  75589. private _isEnabled;
  75590. /**
  75591. * Gets wether the image processing is enabled or not.
  75592. */
  75593. /**
  75594. * Sets wether the image processing is enabled or not.
  75595. */
  75596. isEnabled: boolean;
  75597. /**
  75598. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75599. */
  75600. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75601. /**
  75602. * Method called each time the image processing information changes requires to recompile the effect.
  75603. */
  75604. protected _updateParameters(): void;
  75605. /**
  75606. * Gets the current class name.
  75607. * @return "ImageProcessingConfiguration"
  75608. */
  75609. getClassName(): string;
  75610. /**
  75611. * Prepare the list of uniforms associated with the Image Processing effects.
  75612. * @param uniforms The list of uniforms used in the effect
  75613. * @param defines the list of defines currently in use
  75614. */
  75615. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75616. /**
  75617. * Prepare the list of samplers associated with the Image Processing effects.
  75618. * @param samplersList The list of uniforms used in the effect
  75619. * @param defines the list of defines currently in use
  75620. */
  75621. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75622. /**
  75623. * Prepare the list of defines associated to the shader.
  75624. * @param defines the list of defines to complete
  75625. * @param forPostProcess Define if we are currently in post process mode or not
  75626. */
  75627. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75628. /**
  75629. * Returns true if all the image processing information are ready.
  75630. * @returns True if ready, otherwise, false
  75631. */
  75632. isReady(): boolean;
  75633. /**
  75634. * Binds the image processing to the shader.
  75635. * @param effect The effect to bind to
  75636. * @param aspectRatio Define the current aspect ratio of the effect
  75637. */
  75638. bind(effect: Effect, aspectRatio?: number): void;
  75639. /**
  75640. * Clones the current image processing instance.
  75641. * @return The cloned image processing
  75642. */
  75643. clone(): ImageProcessingConfiguration;
  75644. /**
  75645. * Serializes the current image processing instance to a json representation.
  75646. * @return a JSON representation
  75647. */
  75648. serialize(): any;
  75649. /**
  75650. * Parses the image processing from a json representation.
  75651. * @param source the JSON source to parse
  75652. * @return The parsed image processing
  75653. */
  75654. static Parse(source: any): ImageProcessingConfiguration;
  75655. private static _VIGNETTEMODE_MULTIPLY;
  75656. private static _VIGNETTEMODE_OPAQUE;
  75657. /**
  75658. * Used to apply the vignette as a mix with the pixel color.
  75659. */
  75660. static readonly VIGNETTEMODE_MULTIPLY: number;
  75661. /**
  75662. * Used to apply the vignette as a replacement of the pixel color.
  75663. */
  75664. static readonly VIGNETTEMODE_OPAQUE: number;
  75665. }
  75666. }
  75667. declare module BABYLON {
  75668. /** @hidden */
  75669. export var postprocessVertexShader: {
  75670. name: string;
  75671. shader: string;
  75672. };
  75673. }
  75674. declare module BABYLON {
  75675. interface ThinEngine {
  75676. /**
  75677. * Creates a new render target texture
  75678. * @param size defines the size of the texture
  75679. * @param options defines the options used to create the texture
  75680. * @returns a new render target texture stored in an InternalTexture
  75681. */
  75682. createRenderTargetTexture(size: number | {
  75683. width: number;
  75684. height: number;
  75685. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75686. }
  75687. }
  75688. declare module BABYLON {
  75689. /** Defines supported spaces */
  75690. export enum Space {
  75691. /** Local (object) space */
  75692. LOCAL = 0,
  75693. /** World space */
  75694. WORLD = 1,
  75695. /** Bone space */
  75696. BONE = 2
  75697. }
  75698. /** Defines the 3 main axes */
  75699. export class Axis {
  75700. /** X axis */
  75701. static X: Vector3;
  75702. /** Y axis */
  75703. static Y: Vector3;
  75704. /** Z axis */
  75705. static Z: Vector3;
  75706. }
  75707. }
  75708. declare module BABYLON {
  75709. /**
  75710. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75711. * This is the base of the follow, arc rotate cameras and Free camera
  75712. * @see http://doc.babylonjs.com/features/cameras
  75713. */
  75714. export class TargetCamera extends Camera {
  75715. private static _RigCamTransformMatrix;
  75716. private static _TargetTransformMatrix;
  75717. private static _TargetFocalPoint;
  75718. /**
  75719. * Define the current direction the camera is moving to
  75720. */
  75721. cameraDirection: Vector3;
  75722. /**
  75723. * Define the current rotation the camera is rotating to
  75724. */
  75725. cameraRotation: Vector2;
  75726. /**
  75727. * When set, the up vector of the camera will be updated by the rotation of the camera
  75728. */
  75729. updateUpVectorFromRotation: boolean;
  75730. private _tmpQuaternion;
  75731. /**
  75732. * Define the current rotation of the camera
  75733. */
  75734. rotation: Vector3;
  75735. /**
  75736. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75737. */
  75738. rotationQuaternion: Quaternion;
  75739. /**
  75740. * Define the current speed of the camera
  75741. */
  75742. speed: number;
  75743. /**
  75744. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75745. * around all axis.
  75746. */
  75747. noRotationConstraint: boolean;
  75748. /**
  75749. * Define the current target of the camera as an object or a position.
  75750. */
  75751. lockedTarget: any;
  75752. /** @hidden */
  75753. _currentTarget: Vector3;
  75754. /** @hidden */
  75755. _initialFocalDistance: number;
  75756. /** @hidden */
  75757. _viewMatrix: Matrix;
  75758. /** @hidden */
  75759. _camMatrix: Matrix;
  75760. /** @hidden */
  75761. _cameraTransformMatrix: Matrix;
  75762. /** @hidden */
  75763. _cameraRotationMatrix: Matrix;
  75764. /** @hidden */
  75765. _referencePoint: Vector3;
  75766. /** @hidden */
  75767. _transformedReferencePoint: Vector3;
  75768. protected _globalCurrentTarget: Vector3;
  75769. protected _globalCurrentUpVector: Vector3;
  75770. /** @hidden */
  75771. _reset: () => void;
  75772. private _defaultUp;
  75773. /**
  75774. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75775. * This is the base of the follow, arc rotate cameras and Free camera
  75776. * @see http://doc.babylonjs.com/features/cameras
  75777. * @param name Defines the name of the camera in the scene
  75778. * @param position Defines the start position of the camera in the scene
  75779. * @param scene Defines the scene the camera belongs to
  75780. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75781. */
  75782. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75783. /**
  75784. * Gets the position in front of the camera at a given distance.
  75785. * @param distance The distance from the camera we want the position to be
  75786. * @returns the position
  75787. */
  75788. getFrontPosition(distance: number): Vector3;
  75789. /** @hidden */
  75790. _getLockedTargetPosition(): Nullable<Vector3>;
  75791. private _storedPosition;
  75792. private _storedRotation;
  75793. private _storedRotationQuaternion;
  75794. /**
  75795. * Store current camera state of the camera (fov, position, rotation, etc..)
  75796. * @returns the camera
  75797. */
  75798. storeState(): Camera;
  75799. /**
  75800. * Restored camera state. You must call storeState() first
  75801. * @returns whether it was successful or not
  75802. * @hidden
  75803. */
  75804. _restoreStateValues(): boolean;
  75805. /** @hidden */
  75806. _initCache(): void;
  75807. /** @hidden */
  75808. _updateCache(ignoreParentClass?: boolean): void;
  75809. /** @hidden */
  75810. _isSynchronizedViewMatrix(): boolean;
  75811. /** @hidden */
  75812. _computeLocalCameraSpeed(): number;
  75813. /**
  75814. * Defines the target the camera should look at.
  75815. * @param target Defines the new target as a Vector or a mesh
  75816. */
  75817. setTarget(target: Vector3): void;
  75818. /**
  75819. * Return the current target position of the camera. This value is expressed in local space.
  75820. * @returns the target position
  75821. */
  75822. getTarget(): Vector3;
  75823. /** @hidden */
  75824. _decideIfNeedsToMove(): boolean;
  75825. /** @hidden */
  75826. _updatePosition(): void;
  75827. /** @hidden */
  75828. _checkInputs(): void;
  75829. protected _updateCameraRotationMatrix(): void;
  75830. /**
  75831. * 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)
  75832. * @returns the current camera
  75833. */
  75834. private _rotateUpVectorWithCameraRotationMatrix;
  75835. private _cachedRotationZ;
  75836. private _cachedQuaternionRotationZ;
  75837. /** @hidden */
  75838. _getViewMatrix(): Matrix;
  75839. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75840. /**
  75841. * @hidden
  75842. */
  75843. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75844. /**
  75845. * @hidden
  75846. */
  75847. _updateRigCameras(): void;
  75848. private _getRigCamPositionAndTarget;
  75849. /**
  75850. * Gets the current object class name.
  75851. * @return the class name
  75852. */
  75853. getClassName(): string;
  75854. }
  75855. }
  75856. declare module BABYLON {
  75857. /**
  75858. * Gather the list of keyboard event types as constants.
  75859. */
  75860. export class KeyboardEventTypes {
  75861. /**
  75862. * The keydown event is fired when a key becomes active (pressed).
  75863. */
  75864. static readonly KEYDOWN: number;
  75865. /**
  75866. * The keyup event is fired when a key has been released.
  75867. */
  75868. static readonly KEYUP: number;
  75869. }
  75870. /**
  75871. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75872. */
  75873. export class KeyboardInfo {
  75874. /**
  75875. * Defines the type of event (KeyboardEventTypes)
  75876. */
  75877. type: number;
  75878. /**
  75879. * Defines the related dom event
  75880. */
  75881. event: KeyboardEvent;
  75882. /**
  75883. * Instantiates a new keyboard info.
  75884. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75885. * @param type Defines the type of event (KeyboardEventTypes)
  75886. * @param event Defines the related dom event
  75887. */
  75888. constructor(
  75889. /**
  75890. * Defines the type of event (KeyboardEventTypes)
  75891. */
  75892. type: number,
  75893. /**
  75894. * Defines the related dom event
  75895. */
  75896. event: KeyboardEvent);
  75897. }
  75898. /**
  75899. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75900. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75901. */
  75902. export class KeyboardInfoPre extends KeyboardInfo {
  75903. /**
  75904. * Defines the type of event (KeyboardEventTypes)
  75905. */
  75906. type: number;
  75907. /**
  75908. * Defines the related dom event
  75909. */
  75910. event: KeyboardEvent;
  75911. /**
  75912. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75913. */
  75914. skipOnPointerObservable: boolean;
  75915. /**
  75916. * Instantiates a new keyboard pre info.
  75917. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75918. * @param type Defines the type of event (KeyboardEventTypes)
  75919. * @param event Defines the related dom event
  75920. */
  75921. constructor(
  75922. /**
  75923. * Defines the type of event (KeyboardEventTypes)
  75924. */
  75925. type: number,
  75926. /**
  75927. * Defines the related dom event
  75928. */
  75929. event: KeyboardEvent);
  75930. }
  75931. }
  75932. declare module BABYLON {
  75933. /**
  75934. * Manage the keyboard inputs to control the movement of a free camera.
  75935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75936. */
  75937. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75938. /**
  75939. * Defines the camera the input is attached to.
  75940. */
  75941. camera: FreeCamera;
  75942. /**
  75943. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75944. */
  75945. keysUp: number[];
  75946. /**
  75947. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75948. */
  75949. keysDown: number[];
  75950. /**
  75951. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75952. */
  75953. keysLeft: number[];
  75954. /**
  75955. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75956. */
  75957. keysRight: number[];
  75958. private _keys;
  75959. private _onCanvasBlurObserver;
  75960. private _onKeyboardObserver;
  75961. private _engine;
  75962. private _scene;
  75963. /**
  75964. * Attach the input controls to a specific dom element to get the input from.
  75965. * @param element Defines the element the controls should be listened from
  75966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75967. */
  75968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75969. /**
  75970. * Detach the current controls from the specified dom element.
  75971. * @param element Defines the element to stop listening the inputs from
  75972. */
  75973. detachControl(element: Nullable<HTMLElement>): void;
  75974. /**
  75975. * Update the current camera state depending on the inputs that have been used this frame.
  75976. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75977. */
  75978. checkInputs(): void;
  75979. /**
  75980. * Gets the class name of the current intput.
  75981. * @returns the class name
  75982. */
  75983. getClassName(): string;
  75984. /** @hidden */
  75985. _onLostFocus(): void;
  75986. /**
  75987. * Get the friendly name associated with the input class.
  75988. * @returns the input friendly name
  75989. */
  75990. getSimpleName(): string;
  75991. }
  75992. }
  75993. declare module BABYLON {
  75994. /**
  75995. * Interface describing all the common properties and methods a shadow light needs to implement.
  75996. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75997. * as well as binding the different shadow properties to the effects.
  75998. */
  75999. export interface IShadowLight extends Light {
  76000. /**
  76001. * The light id in the scene (used in scene.findLighById for instance)
  76002. */
  76003. id: string;
  76004. /**
  76005. * The position the shdow will be casted from.
  76006. */
  76007. position: Vector3;
  76008. /**
  76009. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76010. */
  76011. direction: Vector3;
  76012. /**
  76013. * The transformed position. Position of the light in world space taking parenting in account.
  76014. */
  76015. transformedPosition: Vector3;
  76016. /**
  76017. * The transformed direction. Direction of the light in world space taking parenting in account.
  76018. */
  76019. transformedDirection: Vector3;
  76020. /**
  76021. * The friendly name of the light in the scene.
  76022. */
  76023. name: string;
  76024. /**
  76025. * Defines the shadow projection clipping minimum z value.
  76026. */
  76027. shadowMinZ: number;
  76028. /**
  76029. * Defines the shadow projection clipping maximum z value.
  76030. */
  76031. shadowMaxZ: number;
  76032. /**
  76033. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76034. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76035. */
  76036. computeTransformedInformation(): boolean;
  76037. /**
  76038. * Gets the scene the light belongs to.
  76039. * @returns The scene
  76040. */
  76041. getScene(): Scene;
  76042. /**
  76043. * Callback defining a custom Projection Matrix Builder.
  76044. * This can be used to override the default projection matrix computation.
  76045. */
  76046. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76047. /**
  76048. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76049. * @param matrix The materix to updated with the projection information
  76050. * @param viewMatrix The transform matrix of the light
  76051. * @param renderList The list of mesh to render in the map
  76052. * @returns The current light
  76053. */
  76054. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76055. /**
  76056. * Gets the current depth scale used in ESM.
  76057. * @returns The scale
  76058. */
  76059. getDepthScale(): number;
  76060. /**
  76061. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76062. * @returns true if a cube texture needs to be use
  76063. */
  76064. needCube(): boolean;
  76065. /**
  76066. * Detects if the projection matrix requires to be recomputed this frame.
  76067. * @returns true if it requires to be recomputed otherwise, false.
  76068. */
  76069. needProjectionMatrixCompute(): boolean;
  76070. /**
  76071. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76072. */
  76073. forceProjectionMatrixCompute(): void;
  76074. /**
  76075. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76076. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76077. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76078. */
  76079. getShadowDirection(faceIndex?: number): Vector3;
  76080. /**
  76081. * Gets the minZ used for shadow according to both the scene and the light.
  76082. * @param activeCamera The camera we are returning the min for
  76083. * @returns the depth min z
  76084. */
  76085. getDepthMinZ(activeCamera: Camera): number;
  76086. /**
  76087. * Gets the maxZ used for shadow according to both the scene and the light.
  76088. * @param activeCamera The camera we are returning the max for
  76089. * @returns the depth max z
  76090. */
  76091. getDepthMaxZ(activeCamera: Camera): number;
  76092. }
  76093. /**
  76094. * Base implementation IShadowLight
  76095. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76096. */
  76097. export abstract class ShadowLight extends Light implements IShadowLight {
  76098. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76099. protected _position: Vector3;
  76100. protected _setPosition(value: Vector3): void;
  76101. /**
  76102. * Sets the position the shadow will be casted from. Also use as the light position for both
  76103. * point and spot lights.
  76104. */
  76105. /**
  76106. * Sets the position the shadow will be casted from. Also use as the light position for both
  76107. * point and spot lights.
  76108. */
  76109. position: Vector3;
  76110. protected _direction: Vector3;
  76111. protected _setDirection(value: Vector3): void;
  76112. /**
  76113. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76114. * Also use as the light direction on spot and directional lights.
  76115. */
  76116. /**
  76117. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76118. * Also use as the light direction on spot and directional lights.
  76119. */
  76120. direction: Vector3;
  76121. private _shadowMinZ;
  76122. /**
  76123. * Gets the shadow projection clipping minimum z value.
  76124. */
  76125. /**
  76126. * Sets the shadow projection clipping minimum z value.
  76127. */
  76128. shadowMinZ: number;
  76129. private _shadowMaxZ;
  76130. /**
  76131. * Sets the shadow projection clipping maximum z value.
  76132. */
  76133. /**
  76134. * Gets the shadow projection clipping maximum z value.
  76135. */
  76136. shadowMaxZ: number;
  76137. /**
  76138. * Callback defining a custom Projection Matrix Builder.
  76139. * This can be used to override the default projection matrix computation.
  76140. */
  76141. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76142. /**
  76143. * The transformed position. Position of the light in world space taking parenting in account.
  76144. */
  76145. transformedPosition: Vector3;
  76146. /**
  76147. * The transformed direction. Direction of the light in world space taking parenting in account.
  76148. */
  76149. transformedDirection: Vector3;
  76150. private _needProjectionMatrixCompute;
  76151. /**
  76152. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76153. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76154. */
  76155. computeTransformedInformation(): boolean;
  76156. /**
  76157. * Return the depth scale used for the shadow map.
  76158. * @returns the depth scale.
  76159. */
  76160. getDepthScale(): number;
  76161. /**
  76162. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76163. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76164. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76165. */
  76166. getShadowDirection(faceIndex?: number): Vector3;
  76167. /**
  76168. * Returns the ShadowLight absolute position in the World.
  76169. * @returns the position vector in world space
  76170. */
  76171. getAbsolutePosition(): Vector3;
  76172. /**
  76173. * Sets the ShadowLight direction toward the passed target.
  76174. * @param target The point to target in local space
  76175. * @returns the updated ShadowLight direction
  76176. */
  76177. setDirectionToTarget(target: Vector3): Vector3;
  76178. /**
  76179. * Returns the light rotation in euler definition.
  76180. * @returns the x y z rotation in local space.
  76181. */
  76182. getRotation(): Vector3;
  76183. /**
  76184. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76185. * @returns true if a cube texture needs to be use
  76186. */
  76187. needCube(): boolean;
  76188. /**
  76189. * Detects if the projection matrix requires to be recomputed this frame.
  76190. * @returns true if it requires to be recomputed otherwise, false.
  76191. */
  76192. needProjectionMatrixCompute(): boolean;
  76193. /**
  76194. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76195. */
  76196. forceProjectionMatrixCompute(): void;
  76197. /** @hidden */
  76198. _initCache(): void;
  76199. /** @hidden */
  76200. _isSynchronized(): boolean;
  76201. /**
  76202. * Computes the world matrix of the node
  76203. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76204. * @returns the world matrix
  76205. */
  76206. computeWorldMatrix(force?: boolean): Matrix;
  76207. /**
  76208. * Gets the minZ used for shadow according to both the scene and the light.
  76209. * @param activeCamera The camera we are returning the min for
  76210. * @returns the depth min z
  76211. */
  76212. getDepthMinZ(activeCamera: Camera): number;
  76213. /**
  76214. * Gets the maxZ used for shadow according to both the scene and the light.
  76215. * @param activeCamera The camera we are returning the max for
  76216. * @returns the depth max z
  76217. */
  76218. getDepthMaxZ(activeCamera: Camera): number;
  76219. /**
  76220. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76221. * @param matrix The materix to updated with the projection information
  76222. * @param viewMatrix The transform matrix of the light
  76223. * @param renderList The list of mesh to render in the map
  76224. * @returns The current light
  76225. */
  76226. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76227. }
  76228. }
  76229. declare module BABYLON {
  76230. /**
  76231. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76232. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76233. */
  76234. export class EffectFallbacks implements IEffectFallbacks {
  76235. private _defines;
  76236. private _currentRank;
  76237. private _maxRank;
  76238. private _mesh;
  76239. /**
  76240. * Removes the fallback from the bound mesh.
  76241. */
  76242. unBindMesh(): void;
  76243. /**
  76244. * Adds a fallback on the specified property.
  76245. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76246. * @param define The name of the define in the shader
  76247. */
  76248. addFallback(rank: number, define: string): void;
  76249. /**
  76250. * Sets the mesh to use CPU skinning when needing to fallback.
  76251. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76252. * @param mesh The mesh to use the fallbacks.
  76253. */
  76254. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76255. /**
  76256. * Checks to see if more fallbacks are still availible.
  76257. */
  76258. readonly hasMoreFallbacks: boolean;
  76259. /**
  76260. * Removes the defines that should be removed when falling back.
  76261. * @param currentDefines defines the current define statements for the shader.
  76262. * @param effect defines the current effect we try to compile
  76263. * @returns The resulting defines with defines of the current rank removed.
  76264. */
  76265. reduce(currentDefines: string, effect: Effect): string;
  76266. }
  76267. }
  76268. declare module BABYLON {
  76269. /**
  76270. * "Static Class" containing the most commonly used helper while dealing with material for
  76271. * rendering purpose.
  76272. *
  76273. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76274. *
  76275. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76276. */
  76277. export class MaterialHelper {
  76278. /**
  76279. * Bind the current view position to an effect.
  76280. * @param effect The effect to be bound
  76281. * @param scene The scene the eyes position is used from
  76282. */
  76283. static BindEyePosition(effect: Effect, scene: Scene): void;
  76284. /**
  76285. * Helps preparing the defines values about the UVs in used in the effect.
  76286. * UVs are shared as much as we can accross channels in the shaders.
  76287. * @param texture The texture we are preparing the UVs for
  76288. * @param defines The defines to update
  76289. * @param key The channel key "diffuse", "specular"... used in the shader
  76290. */
  76291. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76292. /**
  76293. * Binds a texture matrix value to its corrsponding uniform
  76294. * @param texture The texture to bind the matrix for
  76295. * @param uniformBuffer The uniform buffer receivin the data
  76296. * @param key The channel key "diffuse", "specular"... used in the shader
  76297. */
  76298. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76299. /**
  76300. * Gets the current status of the fog (should it be enabled?)
  76301. * @param mesh defines the mesh to evaluate for fog support
  76302. * @param scene defines the hosting scene
  76303. * @returns true if fog must be enabled
  76304. */
  76305. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76306. /**
  76307. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76308. * @param mesh defines the current mesh
  76309. * @param scene defines the current scene
  76310. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76311. * @param pointsCloud defines if point cloud rendering has to be turned on
  76312. * @param fogEnabled defines if fog has to be turned on
  76313. * @param alphaTest defines if alpha testing has to be turned on
  76314. * @param defines defines the current list of defines
  76315. */
  76316. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76317. /**
  76318. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76319. * @param scene defines the current scene
  76320. * @param engine defines the current engine
  76321. * @param defines specifies the list of active defines
  76322. * @param useInstances defines if instances have to be turned on
  76323. * @param useClipPlane defines if clip plane have to be turned on
  76324. */
  76325. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76326. /**
  76327. * Prepares the defines for bones
  76328. * @param mesh The mesh containing the geometry data we will draw
  76329. * @param defines The defines to update
  76330. */
  76331. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76332. /**
  76333. * Prepares the defines for morph targets
  76334. * @param mesh The mesh containing the geometry data we will draw
  76335. * @param defines The defines to update
  76336. */
  76337. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76338. /**
  76339. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76340. * @param mesh The mesh containing the geometry data we will draw
  76341. * @param defines The defines to update
  76342. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76343. * @param useBones Precise whether bones should be used or not (override mesh info)
  76344. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76345. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76346. * @returns false if defines are considered not dirty and have not been checked
  76347. */
  76348. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76349. /**
  76350. * Prepares the defines related to multiview
  76351. * @param scene The scene we are intending to draw
  76352. * @param defines The defines to update
  76353. */
  76354. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76355. /**
  76356. * Prepares the defines related to the light information passed in parameter
  76357. * @param scene The scene we are intending to draw
  76358. * @param mesh The mesh the effect is compiling for
  76359. * @param light The light the effect is compiling for
  76360. * @param lightIndex The index of the light
  76361. * @param defines The defines to update
  76362. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76363. * @param state Defines the current state regarding what is needed (normals, etc...)
  76364. */
  76365. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76366. needNormals: boolean;
  76367. needRebuild: boolean;
  76368. shadowEnabled: boolean;
  76369. specularEnabled: boolean;
  76370. lightmapMode: boolean;
  76371. }): void;
  76372. /**
  76373. * Prepares the defines related to the light information passed in parameter
  76374. * @param scene The scene we are intending to draw
  76375. * @param mesh The mesh the effect is compiling for
  76376. * @param defines The defines to update
  76377. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76378. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76379. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76380. * @returns true if normals will be required for the rest of the effect
  76381. */
  76382. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76383. /**
  76384. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76385. * @param lightIndex defines the light index
  76386. * @param uniformsList The uniform list
  76387. * @param samplersList The sampler list
  76388. * @param projectedLightTexture defines if projected texture must be used
  76389. * @param uniformBuffersList defines an optional list of uniform buffers
  76390. */
  76391. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  76392. /**
  76393. * Prepares the uniforms and samplers list to be used in the effect
  76394. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  76395. * @param samplersList The sampler list
  76396. * @param defines The defines helping in the list generation
  76397. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  76398. */
  76399. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  76400. /**
  76401. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  76402. * @param defines The defines to update while falling back
  76403. * @param fallbacks The authorized effect fallbacks
  76404. * @param maxSimultaneousLights The maximum number of lights allowed
  76405. * @param rank the current rank of the Effect
  76406. * @returns The newly affected rank
  76407. */
  76408. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  76409. private static _TmpMorphInfluencers;
  76410. /**
  76411. * Prepares the list of attributes required for morph targets according to the effect defines.
  76412. * @param attribs The current list of supported attribs
  76413. * @param mesh The mesh to prepare the morph targets attributes for
  76414. * @param influencers The number of influencers
  76415. */
  76416. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  76417. /**
  76418. * Prepares the list of attributes required for morph targets according to the effect defines.
  76419. * @param attribs The current list of supported attribs
  76420. * @param mesh The mesh to prepare the morph targets attributes for
  76421. * @param defines The current Defines of the effect
  76422. */
  76423. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  76424. /**
  76425. * Prepares the list of attributes required for bones according to the effect defines.
  76426. * @param attribs The current list of supported attribs
  76427. * @param mesh The mesh to prepare the bones attributes for
  76428. * @param defines The current Defines of the effect
  76429. * @param fallbacks The current efffect fallback strategy
  76430. */
  76431. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  76432. /**
  76433. * Check and prepare the list of attributes required for instances according to the effect defines.
  76434. * @param attribs The current list of supported attribs
  76435. * @param defines The current MaterialDefines of the effect
  76436. */
  76437. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  76438. /**
  76439. * Add the list of attributes required for instances to the attribs array.
  76440. * @param attribs The current list of supported attribs
  76441. */
  76442. static PushAttributesForInstances(attribs: string[]): void;
  76443. /**
  76444. * Binds the light information to the effect.
  76445. * @param light The light containing the generator
  76446. * @param effect The effect we are binding the data to
  76447. * @param lightIndex The light index in the effect used to render
  76448. */
  76449. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  76450. /**
  76451. * Binds the lights information from the scene to the effect for the given mesh.
  76452. * @param light Light to bind
  76453. * @param lightIndex Light index
  76454. * @param scene The scene where the light belongs to
  76455. * @param effect The effect we are binding the data to
  76456. * @param useSpecular Defines if specular is supported
  76457. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76458. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76459. */
  76460. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76461. /**
  76462. * Binds the lights information from the scene to the effect for the given mesh.
  76463. * @param scene The scene the lights belongs to
  76464. * @param mesh The mesh we are binding the information to render
  76465. * @param effect The effect we are binding the data to
  76466. * @param defines The generated defines for the effect
  76467. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  76468. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76469. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76470. */
  76471. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76472. private static _tempFogColor;
  76473. /**
  76474. * Binds the fog information from the scene to the effect for the given mesh.
  76475. * @param scene The scene the lights belongs to
  76476. * @param mesh The mesh we are binding the information to render
  76477. * @param effect The effect we are binding the data to
  76478. * @param linearSpace Defines if the fog effect is applied in linear space
  76479. */
  76480. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  76481. /**
  76482. * Binds the bones information from the mesh to the effect.
  76483. * @param mesh The mesh we are binding the information to render
  76484. * @param effect The effect we are binding the data to
  76485. */
  76486. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  76487. /**
  76488. * Binds the morph targets information from the mesh to the effect.
  76489. * @param abstractMesh The mesh we are binding the information to render
  76490. * @param effect The effect we are binding the data to
  76491. */
  76492. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  76493. /**
  76494. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  76495. * @param defines The generated defines used in the effect
  76496. * @param effect The effect we are binding the data to
  76497. * @param scene The scene we are willing to render with logarithmic scale for
  76498. */
  76499. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  76500. /**
  76501. * Binds the clip plane information from the scene to the effect.
  76502. * @param scene The scene the clip plane information are extracted from
  76503. * @param effect The effect we are binding the data to
  76504. */
  76505. static BindClipPlane(effect: Effect, scene: Scene): void;
  76506. }
  76507. }
  76508. declare module BABYLON {
  76509. /** @hidden */
  76510. export var packingFunctions: {
  76511. name: string;
  76512. shader: string;
  76513. };
  76514. }
  76515. declare module BABYLON {
  76516. /** @hidden */
  76517. export var shadowMapPixelShader: {
  76518. name: string;
  76519. shader: string;
  76520. };
  76521. }
  76522. declare module BABYLON {
  76523. /** @hidden */
  76524. export var bonesDeclaration: {
  76525. name: string;
  76526. shader: string;
  76527. };
  76528. }
  76529. declare module BABYLON {
  76530. /** @hidden */
  76531. export var morphTargetsVertexGlobalDeclaration: {
  76532. name: string;
  76533. shader: string;
  76534. };
  76535. }
  76536. declare module BABYLON {
  76537. /** @hidden */
  76538. export var morphTargetsVertexDeclaration: {
  76539. name: string;
  76540. shader: string;
  76541. };
  76542. }
  76543. declare module BABYLON {
  76544. /** @hidden */
  76545. export var instancesDeclaration: {
  76546. name: string;
  76547. shader: string;
  76548. };
  76549. }
  76550. declare module BABYLON {
  76551. /** @hidden */
  76552. export var helperFunctions: {
  76553. name: string;
  76554. shader: string;
  76555. };
  76556. }
  76557. declare module BABYLON {
  76558. /** @hidden */
  76559. export var morphTargetsVertex: {
  76560. name: string;
  76561. shader: string;
  76562. };
  76563. }
  76564. declare module BABYLON {
  76565. /** @hidden */
  76566. export var instancesVertex: {
  76567. name: string;
  76568. shader: string;
  76569. };
  76570. }
  76571. declare module BABYLON {
  76572. /** @hidden */
  76573. export var bonesVertex: {
  76574. name: string;
  76575. shader: string;
  76576. };
  76577. }
  76578. declare module BABYLON {
  76579. /** @hidden */
  76580. export var shadowMapVertexShader: {
  76581. name: string;
  76582. shader: string;
  76583. };
  76584. }
  76585. declare module BABYLON {
  76586. /** @hidden */
  76587. export var depthBoxBlurPixelShader: {
  76588. name: string;
  76589. shader: string;
  76590. };
  76591. }
  76592. declare module BABYLON {
  76593. /**
  76594. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76595. */
  76596. export interface ICustomShaderOptions {
  76597. /**
  76598. * Gets or sets the custom shader name to use
  76599. */
  76600. shaderName: string;
  76601. /**
  76602. * The list of attribute names used in the shader
  76603. */
  76604. attributes?: string[];
  76605. /**
  76606. * The list of unifrom names used in the shader
  76607. */
  76608. uniforms?: string[];
  76609. /**
  76610. * The list of sampler names used in the shader
  76611. */
  76612. samplers?: string[];
  76613. /**
  76614. * The list of defines used in the shader
  76615. */
  76616. defines?: string[];
  76617. }
  76618. /**
  76619. * Interface to implement to create a shadow generator compatible with BJS.
  76620. */
  76621. export interface IShadowGenerator {
  76622. /**
  76623. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76624. * @returns The render target texture if present otherwise, null
  76625. */
  76626. getShadowMap(): Nullable<RenderTargetTexture>;
  76627. /**
  76628. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76629. * @returns The render target texture if the shadow map is present otherwise, null
  76630. */
  76631. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76632. /**
  76633. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76634. * @param subMesh The submesh we want to render in the shadow map
  76635. * @param useInstances Defines wether will draw in the map using instances
  76636. * @returns true if ready otherwise, false
  76637. */
  76638. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76639. /**
  76640. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76641. * @param defines Defines of the material we want to update
  76642. * @param lightIndex Index of the light in the enabled light list of the material
  76643. */
  76644. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76645. /**
  76646. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76647. * defined in the generator but impacting the effect).
  76648. * It implies the unifroms available on the materials are the standard BJS ones.
  76649. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76650. * @param effect The effect we are binfing the information for
  76651. */
  76652. bindShadowLight(lightIndex: string, effect: Effect): void;
  76653. /**
  76654. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76655. * (eq to shadow prjection matrix * light transform matrix)
  76656. * @returns The transform matrix used to create the shadow map
  76657. */
  76658. getTransformMatrix(): Matrix;
  76659. /**
  76660. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76661. * Cube and 2D textures for instance.
  76662. */
  76663. recreateShadowMap(): void;
  76664. /**
  76665. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76666. * @param onCompiled Callback triggered at the and of the effects compilation
  76667. * @param options Sets of optional options forcing the compilation with different modes
  76668. */
  76669. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76670. useInstances: boolean;
  76671. }>): void;
  76672. /**
  76673. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76674. * @param options Sets of optional options forcing the compilation with different modes
  76675. * @returns A promise that resolves when the compilation completes
  76676. */
  76677. forceCompilationAsync(options?: Partial<{
  76678. useInstances: boolean;
  76679. }>): Promise<void>;
  76680. /**
  76681. * Serializes the shadow generator setup to a json object.
  76682. * @returns The serialized JSON object
  76683. */
  76684. serialize(): any;
  76685. /**
  76686. * Disposes the Shadow map and related Textures and effects.
  76687. */
  76688. dispose(): void;
  76689. }
  76690. /**
  76691. * Default implementation IShadowGenerator.
  76692. * This is the main object responsible of generating shadows in the framework.
  76693. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76694. */
  76695. export class ShadowGenerator implements IShadowGenerator {
  76696. /**
  76697. * Shadow generator mode None: no filtering applied.
  76698. */
  76699. static readonly FILTER_NONE: number;
  76700. /**
  76701. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76702. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76703. */
  76704. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76705. /**
  76706. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76707. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76708. */
  76709. static readonly FILTER_POISSONSAMPLING: number;
  76710. /**
  76711. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76712. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76713. */
  76714. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76715. /**
  76716. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76717. * edge artifacts on steep falloff.
  76718. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76719. */
  76720. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76721. /**
  76722. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76723. * edge artifacts on steep falloff.
  76724. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76725. */
  76726. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76727. /**
  76728. * Shadow generator mode PCF: Percentage Closer Filtering
  76729. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76730. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76731. */
  76732. static readonly FILTER_PCF: number;
  76733. /**
  76734. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76735. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76736. * Contact Hardening
  76737. */
  76738. static readonly FILTER_PCSS: number;
  76739. /**
  76740. * Reserved for PCF and PCSS
  76741. * Highest Quality.
  76742. *
  76743. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76744. *
  76745. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76746. */
  76747. static readonly QUALITY_HIGH: number;
  76748. /**
  76749. * Reserved for PCF and PCSS
  76750. * Good tradeoff for quality/perf cross devices
  76751. *
  76752. * Execute PCF on a 3*3 kernel.
  76753. *
  76754. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76755. */
  76756. static readonly QUALITY_MEDIUM: number;
  76757. /**
  76758. * Reserved for PCF and PCSS
  76759. * The lowest quality but the fastest.
  76760. *
  76761. * Execute PCF on a 1*1 kernel.
  76762. *
  76763. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76764. */
  76765. static readonly QUALITY_LOW: number;
  76766. /** Gets or sets the custom shader name to use */
  76767. customShaderOptions: ICustomShaderOptions;
  76768. /**
  76769. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76770. */
  76771. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76772. /**
  76773. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76774. */
  76775. onAfterShadowMapRenderObservable: Observable<Effect>;
  76776. /**
  76777. * Observable triggered before a mesh is rendered in the shadow map.
  76778. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76779. */
  76780. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76781. /**
  76782. * Observable triggered after a mesh is rendered in the shadow map.
  76783. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76784. */
  76785. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76786. private _bias;
  76787. /**
  76788. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76789. */
  76790. /**
  76791. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76792. */
  76793. bias: number;
  76794. private _normalBias;
  76795. /**
  76796. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76797. */
  76798. /**
  76799. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76800. */
  76801. normalBias: number;
  76802. private _blurBoxOffset;
  76803. /**
  76804. * Gets the blur box offset: offset applied during the blur pass.
  76805. * Only useful if useKernelBlur = false
  76806. */
  76807. /**
  76808. * Sets the blur box offset: offset applied during the blur pass.
  76809. * Only useful if useKernelBlur = false
  76810. */
  76811. blurBoxOffset: number;
  76812. private _blurScale;
  76813. /**
  76814. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76815. * 2 means half of the size.
  76816. */
  76817. /**
  76818. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76819. * 2 means half of the size.
  76820. */
  76821. blurScale: number;
  76822. private _blurKernel;
  76823. /**
  76824. * Gets the blur kernel: kernel size of the blur pass.
  76825. * Only useful if useKernelBlur = true
  76826. */
  76827. /**
  76828. * Sets the blur kernel: kernel size of the blur pass.
  76829. * Only useful if useKernelBlur = true
  76830. */
  76831. blurKernel: number;
  76832. private _useKernelBlur;
  76833. /**
  76834. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76835. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76836. */
  76837. /**
  76838. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76839. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76840. */
  76841. useKernelBlur: boolean;
  76842. private _depthScale;
  76843. /**
  76844. * Gets the depth scale used in ESM mode.
  76845. */
  76846. /**
  76847. * Sets the depth scale used in ESM mode.
  76848. * This can override the scale stored on the light.
  76849. */
  76850. depthScale: number;
  76851. private _filter;
  76852. /**
  76853. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76854. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76855. */
  76856. /**
  76857. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76858. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76859. */
  76860. filter: number;
  76861. /**
  76862. * Gets if the current filter is set to Poisson Sampling.
  76863. */
  76864. /**
  76865. * Sets the current filter to Poisson Sampling.
  76866. */
  76867. usePoissonSampling: boolean;
  76868. /**
  76869. * Gets if the current filter is set to ESM.
  76870. */
  76871. /**
  76872. * Sets the current filter is to ESM.
  76873. */
  76874. useExponentialShadowMap: boolean;
  76875. /**
  76876. * Gets if the current filter is set to filtered ESM.
  76877. */
  76878. /**
  76879. * Gets if the current filter is set to filtered ESM.
  76880. */
  76881. useBlurExponentialShadowMap: boolean;
  76882. /**
  76883. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76884. * exponential to prevent steep falloff artifacts).
  76885. */
  76886. /**
  76887. * Sets the current filter to "close ESM" (using the inverse of the
  76888. * exponential to prevent steep falloff artifacts).
  76889. */
  76890. useCloseExponentialShadowMap: boolean;
  76891. /**
  76892. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76893. * exponential to prevent steep falloff artifacts).
  76894. */
  76895. /**
  76896. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76897. * exponential to prevent steep falloff artifacts).
  76898. */
  76899. useBlurCloseExponentialShadowMap: boolean;
  76900. /**
  76901. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76902. */
  76903. /**
  76904. * Sets the current filter to "PCF" (percentage closer filtering).
  76905. */
  76906. usePercentageCloserFiltering: boolean;
  76907. private _filteringQuality;
  76908. /**
  76909. * Gets the PCF or PCSS Quality.
  76910. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76911. */
  76912. /**
  76913. * Sets the PCF or PCSS Quality.
  76914. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76915. */
  76916. filteringQuality: number;
  76917. /**
  76918. * Gets if the current filter is set to "PCSS" (contact hardening).
  76919. */
  76920. /**
  76921. * Sets the current filter to "PCSS" (contact hardening).
  76922. */
  76923. useContactHardeningShadow: boolean;
  76924. private _contactHardeningLightSizeUVRatio;
  76925. /**
  76926. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76927. * Using a ratio helps keeping shape stability independently of the map size.
  76928. *
  76929. * It does not account for the light projection as it was having too much
  76930. * instability during the light setup or during light position changes.
  76931. *
  76932. * Only valid if useContactHardeningShadow is true.
  76933. */
  76934. /**
  76935. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76936. * Using a ratio helps keeping shape stability independently of the map size.
  76937. *
  76938. * It does not account for the light projection as it was having too much
  76939. * instability during the light setup or during light position changes.
  76940. *
  76941. * Only valid if useContactHardeningShadow is true.
  76942. */
  76943. contactHardeningLightSizeUVRatio: number;
  76944. private _darkness;
  76945. /** Gets or sets the actual darkness of a shadow */
  76946. darkness: number;
  76947. /**
  76948. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76949. * 0 means strongest and 1 would means no shadow.
  76950. * @returns the darkness.
  76951. */
  76952. getDarkness(): number;
  76953. /**
  76954. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76955. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76956. * @returns the shadow generator allowing fluent coding.
  76957. */
  76958. setDarkness(darkness: number): ShadowGenerator;
  76959. private _transparencyShadow;
  76960. /** Gets or sets the ability to have transparent shadow */
  76961. transparencyShadow: boolean;
  76962. /**
  76963. * Sets the ability to have transparent shadow (boolean).
  76964. * @param transparent True if transparent else False
  76965. * @returns the shadow generator allowing fluent coding
  76966. */
  76967. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76968. private _shadowMap;
  76969. private _shadowMap2;
  76970. /**
  76971. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76972. * @returns The render target texture if present otherwise, null
  76973. */
  76974. getShadowMap(): Nullable<RenderTargetTexture>;
  76975. /**
  76976. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76977. * @returns The render target texture if the shadow map is present otherwise, null
  76978. */
  76979. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76980. /**
  76981. * Gets the class name of that object
  76982. * @returns "ShadowGenerator"
  76983. */
  76984. getClassName(): string;
  76985. /**
  76986. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76987. * @param mesh Mesh to add
  76988. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76989. * @returns the Shadow Generator itself
  76990. */
  76991. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76992. /**
  76993. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76994. * @param mesh Mesh to remove
  76995. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76996. * @returns the Shadow Generator itself
  76997. */
  76998. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76999. /**
  77000. * Controls the extent to which the shadows fade out at the edge of the frustum
  77001. * Used only by directionals and spots
  77002. */
  77003. frustumEdgeFalloff: number;
  77004. private _light;
  77005. /**
  77006. * Returns the associated light object.
  77007. * @returns the light generating the shadow
  77008. */
  77009. getLight(): IShadowLight;
  77010. /**
  77011. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77012. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77013. * It might on the other hand introduce peter panning.
  77014. */
  77015. forceBackFacesOnly: boolean;
  77016. private _scene;
  77017. private _lightDirection;
  77018. private _effect;
  77019. private _viewMatrix;
  77020. private _projectionMatrix;
  77021. private _transformMatrix;
  77022. private _cachedPosition;
  77023. private _cachedDirection;
  77024. private _cachedDefines;
  77025. private _currentRenderID;
  77026. private _boxBlurPostprocess;
  77027. private _kernelBlurXPostprocess;
  77028. private _kernelBlurYPostprocess;
  77029. private _blurPostProcesses;
  77030. private _mapSize;
  77031. private _currentFaceIndex;
  77032. private _currentFaceIndexCache;
  77033. private _textureType;
  77034. private _defaultTextureMatrix;
  77035. private _storedUniqueId;
  77036. /** @hidden */
  77037. static _SceneComponentInitialization: (scene: Scene) => void;
  77038. /**
  77039. * Creates a ShadowGenerator object.
  77040. * A ShadowGenerator is the required tool to use the shadows.
  77041. * Each light casting shadows needs to use its own ShadowGenerator.
  77042. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77043. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77044. * @param light The light object generating the shadows.
  77045. * @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.
  77046. */
  77047. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77048. private _initializeGenerator;
  77049. private _initializeShadowMap;
  77050. private _initializeBlurRTTAndPostProcesses;
  77051. private _renderForShadowMap;
  77052. private _renderSubMeshForShadowMap;
  77053. private _applyFilterValues;
  77054. /**
  77055. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77056. * @param onCompiled Callback triggered at the and of the effects compilation
  77057. * @param options Sets of optional options forcing the compilation with different modes
  77058. */
  77059. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77060. useInstances: boolean;
  77061. }>): void;
  77062. /**
  77063. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77064. * @param options Sets of optional options forcing the compilation with different modes
  77065. * @returns A promise that resolves when the compilation completes
  77066. */
  77067. forceCompilationAsync(options?: Partial<{
  77068. useInstances: boolean;
  77069. }>): Promise<void>;
  77070. /**
  77071. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77072. * @param subMesh The submesh we want to render in the shadow map
  77073. * @param useInstances Defines wether will draw in the map using instances
  77074. * @returns true if ready otherwise, false
  77075. */
  77076. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77077. /**
  77078. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77079. * @param defines Defines of the material we want to update
  77080. * @param lightIndex Index of the light in the enabled light list of the material
  77081. */
  77082. prepareDefines(defines: any, lightIndex: number): void;
  77083. /**
  77084. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77085. * defined in the generator but impacting the effect).
  77086. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77087. * @param effect The effect we are binfing the information for
  77088. */
  77089. bindShadowLight(lightIndex: string, effect: Effect): void;
  77090. /**
  77091. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77092. * (eq to shadow prjection matrix * light transform matrix)
  77093. * @returns The transform matrix used to create the shadow map
  77094. */
  77095. getTransformMatrix(): Matrix;
  77096. /**
  77097. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77098. * Cube and 2D textures for instance.
  77099. */
  77100. recreateShadowMap(): void;
  77101. private _disposeBlurPostProcesses;
  77102. private _disposeRTTandPostProcesses;
  77103. /**
  77104. * Disposes the ShadowGenerator.
  77105. * Returns nothing.
  77106. */
  77107. dispose(): void;
  77108. /**
  77109. * Serializes the shadow generator setup to a json object.
  77110. * @returns The serialized JSON object
  77111. */
  77112. serialize(): any;
  77113. /**
  77114. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77115. * @param parsedShadowGenerator The JSON object to parse
  77116. * @param scene The scene to create the shadow map for
  77117. * @returns The parsed shadow generator
  77118. */
  77119. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77120. }
  77121. }
  77122. declare module BABYLON {
  77123. /**
  77124. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77125. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77126. * 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.
  77127. */
  77128. export abstract class Light extends Node {
  77129. /**
  77130. * Falloff Default: light is falling off following the material specification:
  77131. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77132. */
  77133. static readonly FALLOFF_DEFAULT: number;
  77134. /**
  77135. * Falloff Physical: light is falling off following the inverse squared distance law.
  77136. */
  77137. static readonly FALLOFF_PHYSICAL: number;
  77138. /**
  77139. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77140. * to enhance interoperability with other engines.
  77141. */
  77142. static readonly FALLOFF_GLTF: number;
  77143. /**
  77144. * Falloff Standard: light is falling off like in the standard material
  77145. * to enhance interoperability with other materials.
  77146. */
  77147. static readonly FALLOFF_STANDARD: number;
  77148. /**
  77149. * If every light affecting the material is in this lightmapMode,
  77150. * material.lightmapTexture adds or multiplies
  77151. * (depends on material.useLightmapAsShadowmap)
  77152. * after every other light calculations.
  77153. */
  77154. static readonly LIGHTMAP_DEFAULT: number;
  77155. /**
  77156. * material.lightmapTexture as only diffuse lighting from this light
  77157. * adds only specular lighting from this light
  77158. * adds dynamic shadows
  77159. */
  77160. static readonly LIGHTMAP_SPECULAR: number;
  77161. /**
  77162. * material.lightmapTexture as only lighting
  77163. * no light calculation from this light
  77164. * only adds dynamic shadows from this light
  77165. */
  77166. static readonly LIGHTMAP_SHADOWSONLY: number;
  77167. /**
  77168. * Each light type uses the default quantity according to its type:
  77169. * point/spot lights use luminous intensity
  77170. * directional lights use illuminance
  77171. */
  77172. static readonly INTENSITYMODE_AUTOMATIC: number;
  77173. /**
  77174. * lumen (lm)
  77175. */
  77176. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77177. /**
  77178. * candela (lm/sr)
  77179. */
  77180. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77181. /**
  77182. * lux (lm/m^2)
  77183. */
  77184. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77185. /**
  77186. * nit (cd/m^2)
  77187. */
  77188. static readonly INTENSITYMODE_LUMINANCE: number;
  77189. /**
  77190. * Light type const id of the point light.
  77191. */
  77192. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77193. /**
  77194. * Light type const id of the directional light.
  77195. */
  77196. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77197. /**
  77198. * Light type const id of the spot light.
  77199. */
  77200. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77201. /**
  77202. * Light type const id of the hemispheric light.
  77203. */
  77204. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77205. /**
  77206. * Diffuse gives the basic color to an object.
  77207. */
  77208. diffuse: Color3;
  77209. /**
  77210. * Specular produces a highlight color on an object.
  77211. * Note: This is note affecting PBR materials.
  77212. */
  77213. specular: Color3;
  77214. /**
  77215. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77216. * falling off base on range or angle.
  77217. * This can be set to any values in Light.FALLOFF_x.
  77218. *
  77219. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77220. * other types of materials.
  77221. */
  77222. falloffType: number;
  77223. /**
  77224. * Strength of the light.
  77225. * Note: By default it is define in the framework own unit.
  77226. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77227. */
  77228. intensity: number;
  77229. private _range;
  77230. protected _inverseSquaredRange: number;
  77231. /**
  77232. * Defines how far from the source the light is impacting in scene units.
  77233. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77234. */
  77235. /**
  77236. * Defines how far from the source the light is impacting in scene units.
  77237. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77238. */
  77239. range: number;
  77240. /**
  77241. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77242. * of light.
  77243. */
  77244. private _photometricScale;
  77245. private _intensityMode;
  77246. /**
  77247. * Gets the photometric scale used to interpret the intensity.
  77248. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77249. */
  77250. /**
  77251. * Sets the photometric scale used to interpret the intensity.
  77252. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77253. */
  77254. intensityMode: number;
  77255. private _radius;
  77256. /**
  77257. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77258. */
  77259. /**
  77260. * sets the light radius used by PBR Materials to simulate soft area lights.
  77261. */
  77262. radius: number;
  77263. private _renderPriority;
  77264. /**
  77265. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77266. * exceeding the number allowed of the materials.
  77267. */
  77268. renderPriority: number;
  77269. private _shadowEnabled;
  77270. /**
  77271. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77272. * the current shadow generator.
  77273. */
  77274. /**
  77275. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77276. * the current shadow generator.
  77277. */
  77278. shadowEnabled: boolean;
  77279. private _includedOnlyMeshes;
  77280. /**
  77281. * Gets the only meshes impacted by this light.
  77282. */
  77283. /**
  77284. * Sets the only meshes impacted by this light.
  77285. */
  77286. includedOnlyMeshes: AbstractMesh[];
  77287. private _excludedMeshes;
  77288. /**
  77289. * Gets the meshes not impacted by this light.
  77290. */
  77291. /**
  77292. * Sets the meshes not impacted by this light.
  77293. */
  77294. excludedMeshes: AbstractMesh[];
  77295. private _excludeWithLayerMask;
  77296. /**
  77297. * Gets the layer id use to find what meshes are not impacted by the light.
  77298. * Inactive if 0
  77299. */
  77300. /**
  77301. * Sets the layer id use to find what meshes are not impacted by the light.
  77302. * Inactive if 0
  77303. */
  77304. excludeWithLayerMask: number;
  77305. private _includeOnlyWithLayerMask;
  77306. /**
  77307. * Gets the layer id use to find what meshes are impacted by the light.
  77308. * Inactive if 0
  77309. */
  77310. /**
  77311. * Sets the layer id use to find what meshes are impacted by the light.
  77312. * Inactive if 0
  77313. */
  77314. includeOnlyWithLayerMask: number;
  77315. private _lightmapMode;
  77316. /**
  77317. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77318. */
  77319. /**
  77320. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77321. */
  77322. lightmapMode: number;
  77323. /**
  77324. * Shadow generator associted to the light.
  77325. * @hidden Internal use only.
  77326. */
  77327. _shadowGenerator: Nullable<IShadowGenerator>;
  77328. /**
  77329. * @hidden Internal use only.
  77330. */
  77331. _excludedMeshesIds: string[];
  77332. /**
  77333. * @hidden Internal use only.
  77334. */
  77335. _includedOnlyMeshesIds: string[];
  77336. /**
  77337. * The current light unifom buffer.
  77338. * @hidden Internal use only.
  77339. */
  77340. _uniformBuffer: UniformBuffer;
  77341. /** @hidden */
  77342. _renderId: number;
  77343. /**
  77344. * Creates a Light object in the scene.
  77345. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77346. * @param name The firendly name of the light
  77347. * @param scene The scene the light belongs too
  77348. */
  77349. constructor(name: string, scene: Scene);
  77350. protected abstract _buildUniformLayout(): void;
  77351. /**
  77352. * Sets the passed Effect "effect" with the Light information.
  77353. * @param effect The effect to update
  77354. * @param lightIndex The index of the light in the effect to update
  77355. * @returns The light
  77356. */
  77357. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77358. /**
  77359. * Sets the passed Effect "effect" with the Light information.
  77360. * @param effect The effect to update
  77361. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77362. * @returns The light
  77363. */
  77364. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77365. /**
  77366. * Returns the string "Light".
  77367. * @returns the class name
  77368. */
  77369. getClassName(): string;
  77370. /** @hidden */
  77371. readonly _isLight: boolean;
  77372. /**
  77373. * Converts the light information to a readable string for debug purpose.
  77374. * @param fullDetails Supports for multiple levels of logging within scene loading
  77375. * @returns the human readable light info
  77376. */
  77377. toString(fullDetails?: boolean): string;
  77378. /** @hidden */
  77379. protected _syncParentEnabledState(): void;
  77380. /**
  77381. * Set the enabled state of this node.
  77382. * @param value - the new enabled state
  77383. */
  77384. setEnabled(value: boolean): void;
  77385. /**
  77386. * Returns the Light associated shadow generator if any.
  77387. * @return the associated shadow generator.
  77388. */
  77389. getShadowGenerator(): Nullable<IShadowGenerator>;
  77390. /**
  77391. * Returns a Vector3, the absolute light position in the World.
  77392. * @returns the world space position of the light
  77393. */
  77394. getAbsolutePosition(): Vector3;
  77395. /**
  77396. * Specifies if the light will affect the passed mesh.
  77397. * @param mesh The mesh to test against the light
  77398. * @return true the mesh is affected otherwise, false.
  77399. */
  77400. canAffectMesh(mesh: AbstractMesh): boolean;
  77401. /**
  77402. * Sort function to order lights for rendering.
  77403. * @param a First Light object to compare to second.
  77404. * @param b Second Light object to compare first.
  77405. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  77406. */
  77407. static CompareLightsPriority(a: Light, b: Light): number;
  77408. /**
  77409. * Releases resources associated with this node.
  77410. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77411. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77412. */
  77413. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77414. /**
  77415. * Returns the light type ID (integer).
  77416. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  77417. */
  77418. getTypeID(): number;
  77419. /**
  77420. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  77421. * @returns the scaled intensity in intensity mode unit
  77422. */
  77423. getScaledIntensity(): number;
  77424. /**
  77425. * Returns a new Light object, named "name", from the current one.
  77426. * @param name The name of the cloned light
  77427. * @returns the new created light
  77428. */
  77429. clone(name: string): Nullable<Light>;
  77430. /**
  77431. * Serializes the current light into a Serialization object.
  77432. * @returns the serialized object.
  77433. */
  77434. serialize(): any;
  77435. /**
  77436. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  77437. * This new light is named "name" and added to the passed scene.
  77438. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  77439. * @param name The friendly name of the light
  77440. * @param scene The scene the new light will belong to
  77441. * @returns the constructor function
  77442. */
  77443. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  77444. /**
  77445. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  77446. * @param parsedLight The JSON representation of the light
  77447. * @param scene The scene to create the parsed light in
  77448. * @returns the created light after parsing
  77449. */
  77450. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  77451. private _hookArrayForExcluded;
  77452. private _hookArrayForIncludedOnly;
  77453. private _resyncMeshes;
  77454. /**
  77455. * Forces the meshes to update their light related information in their rendering used effects
  77456. * @hidden Internal Use Only
  77457. */
  77458. _markMeshesAsLightDirty(): void;
  77459. /**
  77460. * Recomputes the cached photometric scale if needed.
  77461. */
  77462. private _computePhotometricScale;
  77463. /**
  77464. * Returns the Photometric Scale according to the light type and intensity mode.
  77465. */
  77466. private _getPhotometricScale;
  77467. /**
  77468. * Reorder the light in the scene according to their defined priority.
  77469. * @hidden Internal Use Only
  77470. */
  77471. _reorderLightsInScene(): void;
  77472. /**
  77473. * Prepares the list of defines specific to the light type.
  77474. * @param defines the list of defines
  77475. * @param lightIndex defines the index of the light for the effect
  77476. */
  77477. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  77478. }
  77479. }
  77480. declare module BABYLON {
  77481. /**
  77482. * Interface used to define Action
  77483. */
  77484. export interface IAction {
  77485. /**
  77486. * Trigger for the action
  77487. */
  77488. trigger: number;
  77489. /** Options of the trigger */
  77490. triggerOptions: any;
  77491. /**
  77492. * Gets the trigger parameters
  77493. * @returns the trigger parameters
  77494. */
  77495. getTriggerParameter(): any;
  77496. /**
  77497. * Internal only - executes current action event
  77498. * @hidden
  77499. */
  77500. _executeCurrent(evt?: ActionEvent): void;
  77501. /**
  77502. * Serialize placeholder for child classes
  77503. * @param parent of child
  77504. * @returns the serialized object
  77505. */
  77506. serialize(parent: any): any;
  77507. /**
  77508. * Internal only
  77509. * @hidden
  77510. */
  77511. _prepare(): void;
  77512. /**
  77513. * Internal only - manager for action
  77514. * @hidden
  77515. */
  77516. _actionManager: AbstractActionManager;
  77517. /**
  77518. * Adds action to chain of actions, may be a DoNothingAction
  77519. * @param action defines the next action to execute
  77520. * @returns The action passed in
  77521. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77522. */
  77523. then(action: IAction): IAction;
  77524. }
  77525. /**
  77526. * The action to be carried out following a trigger
  77527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77528. */
  77529. export class Action implements IAction {
  77530. /** the trigger, with or without parameters, for the action */
  77531. triggerOptions: any;
  77532. /**
  77533. * Trigger for the action
  77534. */
  77535. trigger: number;
  77536. /**
  77537. * Internal only - manager for action
  77538. * @hidden
  77539. */
  77540. _actionManager: ActionManager;
  77541. private _nextActiveAction;
  77542. private _child;
  77543. private _condition?;
  77544. private _triggerParameter;
  77545. /**
  77546. * An event triggered prior to action being executed.
  77547. */
  77548. onBeforeExecuteObservable: Observable<Action>;
  77549. /**
  77550. * Creates a new Action
  77551. * @param triggerOptions the trigger, with or without parameters, for the action
  77552. * @param condition an optional determinant of action
  77553. */
  77554. constructor(
  77555. /** the trigger, with or without parameters, for the action */
  77556. triggerOptions: any, condition?: Condition);
  77557. /**
  77558. * Internal only
  77559. * @hidden
  77560. */
  77561. _prepare(): void;
  77562. /**
  77563. * Gets the trigger parameters
  77564. * @returns the trigger parameters
  77565. */
  77566. getTriggerParameter(): any;
  77567. /**
  77568. * Internal only - executes current action event
  77569. * @hidden
  77570. */
  77571. _executeCurrent(evt?: ActionEvent): void;
  77572. /**
  77573. * Execute placeholder for child classes
  77574. * @param evt optional action event
  77575. */
  77576. execute(evt?: ActionEvent): void;
  77577. /**
  77578. * Skips to next active action
  77579. */
  77580. skipToNextActiveAction(): void;
  77581. /**
  77582. * Adds action to chain of actions, may be a DoNothingAction
  77583. * @param action defines the next action to execute
  77584. * @returns The action passed in
  77585. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77586. */
  77587. then(action: Action): Action;
  77588. /**
  77589. * Internal only
  77590. * @hidden
  77591. */
  77592. _getProperty(propertyPath: string): string;
  77593. /**
  77594. * Internal only
  77595. * @hidden
  77596. */
  77597. _getEffectiveTarget(target: any, propertyPath: string): any;
  77598. /**
  77599. * Serialize placeholder for child classes
  77600. * @param parent of child
  77601. * @returns the serialized object
  77602. */
  77603. serialize(parent: any): any;
  77604. /**
  77605. * Internal only called by serialize
  77606. * @hidden
  77607. */
  77608. protected _serialize(serializedAction: any, parent?: any): any;
  77609. /**
  77610. * Internal only
  77611. * @hidden
  77612. */
  77613. static _SerializeValueAsString: (value: any) => string;
  77614. /**
  77615. * Internal only
  77616. * @hidden
  77617. */
  77618. static _GetTargetProperty: (target: Node | Scene) => {
  77619. name: string;
  77620. targetType: string;
  77621. value: string;
  77622. };
  77623. }
  77624. }
  77625. declare module BABYLON {
  77626. /**
  77627. * A Condition applied to an Action
  77628. */
  77629. export class Condition {
  77630. /**
  77631. * Internal only - manager for action
  77632. * @hidden
  77633. */
  77634. _actionManager: ActionManager;
  77635. /**
  77636. * Internal only
  77637. * @hidden
  77638. */
  77639. _evaluationId: number;
  77640. /**
  77641. * Internal only
  77642. * @hidden
  77643. */
  77644. _currentResult: boolean;
  77645. /**
  77646. * Creates a new Condition
  77647. * @param actionManager the manager of the action the condition is applied to
  77648. */
  77649. constructor(actionManager: ActionManager);
  77650. /**
  77651. * Check if the current condition is valid
  77652. * @returns a boolean
  77653. */
  77654. isValid(): boolean;
  77655. /**
  77656. * Internal only
  77657. * @hidden
  77658. */
  77659. _getProperty(propertyPath: string): string;
  77660. /**
  77661. * Internal only
  77662. * @hidden
  77663. */
  77664. _getEffectiveTarget(target: any, propertyPath: string): any;
  77665. /**
  77666. * Serialize placeholder for child classes
  77667. * @returns the serialized object
  77668. */
  77669. serialize(): any;
  77670. /**
  77671. * Internal only
  77672. * @hidden
  77673. */
  77674. protected _serialize(serializedCondition: any): any;
  77675. }
  77676. /**
  77677. * Defines specific conditional operators as extensions of Condition
  77678. */
  77679. export class ValueCondition extends Condition {
  77680. /** path to specify the property of the target the conditional operator uses */
  77681. propertyPath: string;
  77682. /** the value compared by the conditional operator against the current value of the property */
  77683. value: any;
  77684. /** the conditional operator, default ValueCondition.IsEqual */
  77685. operator: number;
  77686. /**
  77687. * Internal only
  77688. * @hidden
  77689. */
  77690. private static _IsEqual;
  77691. /**
  77692. * Internal only
  77693. * @hidden
  77694. */
  77695. private static _IsDifferent;
  77696. /**
  77697. * Internal only
  77698. * @hidden
  77699. */
  77700. private static _IsGreater;
  77701. /**
  77702. * Internal only
  77703. * @hidden
  77704. */
  77705. private static _IsLesser;
  77706. /**
  77707. * returns the number for IsEqual
  77708. */
  77709. static readonly IsEqual: number;
  77710. /**
  77711. * Returns the number for IsDifferent
  77712. */
  77713. static readonly IsDifferent: number;
  77714. /**
  77715. * Returns the number for IsGreater
  77716. */
  77717. static readonly IsGreater: number;
  77718. /**
  77719. * Returns the number for IsLesser
  77720. */
  77721. static readonly IsLesser: number;
  77722. /**
  77723. * Internal only The action manager for the condition
  77724. * @hidden
  77725. */
  77726. _actionManager: ActionManager;
  77727. /**
  77728. * Internal only
  77729. * @hidden
  77730. */
  77731. private _target;
  77732. /**
  77733. * Internal only
  77734. * @hidden
  77735. */
  77736. private _effectiveTarget;
  77737. /**
  77738. * Internal only
  77739. * @hidden
  77740. */
  77741. private _property;
  77742. /**
  77743. * Creates a new ValueCondition
  77744. * @param actionManager manager for the action the condition applies to
  77745. * @param target for the action
  77746. * @param propertyPath path to specify the property of the target the conditional operator uses
  77747. * @param value the value compared by the conditional operator against the current value of the property
  77748. * @param operator the conditional operator, default ValueCondition.IsEqual
  77749. */
  77750. constructor(actionManager: ActionManager, target: any,
  77751. /** path to specify the property of the target the conditional operator uses */
  77752. propertyPath: string,
  77753. /** the value compared by the conditional operator against the current value of the property */
  77754. value: any,
  77755. /** the conditional operator, default ValueCondition.IsEqual */
  77756. operator?: number);
  77757. /**
  77758. * Compares the given value with the property value for the specified conditional operator
  77759. * @returns the result of the comparison
  77760. */
  77761. isValid(): boolean;
  77762. /**
  77763. * Serialize the ValueCondition into a JSON compatible object
  77764. * @returns serialization object
  77765. */
  77766. serialize(): any;
  77767. /**
  77768. * Gets the name of the conditional operator for the ValueCondition
  77769. * @param operator the conditional operator
  77770. * @returns the name
  77771. */
  77772. static GetOperatorName(operator: number): string;
  77773. }
  77774. /**
  77775. * Defines a predicate condition as an extension of Condition
  77776. */
  77777. export class PredicateCondition extends Condition {
  77778. /** defines the predicate function used to validate the condition */
  77779. predicate: () => boolean;
  77780. /**
  77781. * Internal only - manager for action
  77782. * @hidden
  77783. */
  77784. _actionManager: ActionManager;
  77785. /**
  77786. * Creates a new PredicateCondition
  77787. * @param actionManager manager for the action the condition applies to
  77788. * @param predicate defines the predicate function used to validate the condition
  77789. */
  77790. constructor(actionManager: ActionManager,
  77791. /** defines the predicate function used to validate the condition */
  77792. predicate: () => boolean);
  77793. /**
  77794. * @returns the validity of the predicate condition
  77795. */
  77796. isValid(): boolean;
  77797. }
  77798. /**
  77799. * Defines a state condition as an extension of Condition
  77800. */
  77801. export class StateCondition extends Condition {
  77802. /** Value to compare with target state */
  77803. value: string;
  77804. /**
  77805. * Internal only - manager for action
  77806. * @hidden
  77807. */
  77808. _actionManager: ActionManager;
  77809. /**
  77810. * Internal only
  77811. * @hidden
  77812. */
  77813. private _target;
  77814. /**
  77815. * Creates a new StateCondition
  77816. * @param actionManager manager for the action the condition applies to
  77817. * @param target of the condition
  77818. * @param value to compare with target state
  77819. */
  77820. constructor(actionManager: ActionManager, target: any,
  77821. /** Value to compare with target state */
  77822. value: string);
  77823. /**
  77824. * Gets a boolean indicating if the current condition is met
  77825. * @returns the validity of the state
  77826. */
  77827. isValid(): boolean;
  77828. /**
  77829. * Serialize the StateCondition into a JSON compatible object
  77830. * @returns serialization object
  77831. */
  77832. serialize(): any;
  77833. }
  77834. }
  77835. declare module BABYLON {
  77836. /**
  77837. * This defines an action responsible to toggle a boolean once triggered.
  77838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77839. */
  77840. export class SwitchBooleanAction extends Action {
  77841. /**
  77842. * The path to the boolean property in the target object
  77843. */
  77844. propertyPath: string;
  77845. private _target;
  77846. private _effectiveTarget;
  77847. private _property;
  77848. /**
  77849. * Instantiate the action
  77850. * @param triggerOptions defines the trigger options
  77851. * @param target defines the object containing the boolean
  77852. * @param propertyPath defines the path to the boolean property in the target object
  77853. * @param condition defines the trigger related conditions
  77854. */
  77855. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77856. /** @hidden */
  77857. _prepare(): void;
  77858. /**
  77859. * Execute the action toggle the boolean value.
  77860. */
  77861. execute(): void;
  77862. /**
  77863. * Serializes the actions and its related information.
  77864. * @param parent defines the object to serialize in
  77865. * @returns the serialized object
  77866. */
  77867. serialize(parent: any): any;
  77868. }
  77869. /**
  77870. * This defines an action responsible to set a the state field of the target
  77871. * to a desired value once triggered.
  77872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77873. */
  77874. export class SetStateAction extends Action {
  77875. /**
  77876. * The value to store in the state field.
  77877. */
  77878. value: string;
  77879. private _target;
  77880. /**
  77881. * Instantiate the action
  77882. * @param triggerOptions defines the trigger options
  77883. * @param target defines the object containing the state property
  77884. * @param value defines the value to store in the state field
  77885. * @param condition defines the trigger related conditions
  77886. */
  77887. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77888. /**
  77889. * Execute the action and store the value on the target state property.
  77890. */
  77891. execute(): void;
  77892. /**
  77893. * Serializes the actions and its related information.
  77894. * @param parent defines the object to serialize in
  77895. * @returns the serialized object
  77896. */
  77897. serialize(parent: any): any;
  77898. }
  77899. /**
  77900. * This defines an action responsible to set a property of the target
  77901. * to a desired value once triggered.
  77902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77903. */
  77904. export class SetValueAction extends Action {
  77905. /**
  77906. * The path of the property to set in the target.
  77907. */
  77908. propertyPath: string;
  77909. /**
  77910. * The value to set in the property
  77911. */
  77912. value: any;
  77913. private _target;
  77914. private _effectiveTarget;
  77915. private _property;
  77916. /**
  77917. * Instantiate the action
  77918. * @param triggerOptions defines the trigger options
  77919. * @param target defines the object containing the property
  77920. * @param propertyPath defines the path of the property to set in the target
  77921. * @param value defines the value to set in the property
  77922. * @param condition defines the trigger related conditions
  77923. */
  77924. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77925. /** @hidden */
  77926. _prepare(): void;
  77927. /**
  77928. * Execute the action and set the targetted property to the desired value.
  77929. */
  77930. execute(): void;
  77931. /**
  77932. * Serializes the actions and its related information.
  77933. * @param parent defines the object to serialize in
  77934. * @returns the serialized object
  77935. */
  77936. serialize(parent: any): any;
  77937. }
  77938. /**
  77939. * This defines an action responsible to increment the target value
  77940. * to a desired value once triggered.
  77941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77942. */
  77943. export class IncrementValueAction extends Action {
  77944. /**
  77945. * The path of the property to increment in the target.
  77946. */
  77947. propertyPath: string;
  77948. /**
  77949. * The value we should increment the property by.
  77950. */
  77951. value: any;
  77952. private _target;
  77953. private _effectiveTarget;
  77954. private _property;
  77955. /**
  77956. * Instantiate the action
  77957. * @param triggerOptions defines the trigger options
  77958. * @param target defines the object containing the property
  77959. * @param propertyPath defines the path of the property to increment in the target
  77960. * @param value defines the value value we should increment the property by
  77961. * @param condition defines the trigger related conditions
  77962. */
  77963. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77964. /** @hidden */
  77965. _prepare(): void;
  77966. /**
  77967. * Execute the action and increment the target of the value amount.
  77968. */
  77969. execute(): void;
  77970. /**
  77971. * Serializes the actions and its related information.
  77972. * @param parent defines the object to serialize in
  77973. * @returns the serialized object
  77974. */
  77975. serialize(parent: any): any;
  77976. }
  77977. /**
  77978. * This defines an action responsible to start an animation once triggered.
  77979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77980. */
  77981. export class PlayAnimationAction extends Action {
  77982. /**
  77983. * Where the animation should start (animation frame)
  77984. */
  77985. from: number;
  77986. /**
  77987. * Where the animation should stop (animation frame)
  77988. */
  77989. to: number;
  77990. /**
  77991. * Define if the animation should loop or stop after the first play.
  77992. */
  77993. loop?: boolean;
  77994. private _target;
  77995. /**
  77996. * Instantiate the action
  77997. * @param triggerOptions defines the trigger options
  77998. * @param target defines the target animation or animation name
  77999. * @param from defines from where the animation should start (animation frame)
  78000. * @param end defines where the animation should stop (animation frame)
  78001. * @param loop defines if the animation should loop or stop after the first play
  78002. * @param condition defines the trigger related conditions
  78003. */
  78004. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78005. /** @hidden */
  78006. _prepare(): void;
  78007. /**
  78008. * Execute the action and play the animation.
  78009. */
  78010. execute(): void;
  78011. /**
  78012. * Serializes the actions and its related information.
  78013. * @param parent defines the object to serialize in
  78014. * @returns the serialized object
  78015. */
  78016. serialize(parent: any): any;
  78017. }
  78018. /**
  78019. * This defines an action responsible to stop an animation once triggered.
  78020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78021. */
  78022. export class StopAnimationAction extends Action {
  78023. private _target;
  78024. /**
  78025. * Instantiate the action
  78026. * @param triggerOptions defines the trigger options
  78027. * @param target defines the target animation or animation name
  78028. * @param condition defines the trigger related conditions
  78029. */
  78030. constructor(triggerOptions: any, target: any, condition?: Condition);
  78031. /** @hidden */
  78032. _prepare(): void;
  78033. /**
  78034. * Execute the action and stop the animation.
  78035. */
  78036. execute(): void;
  78037. /**
  78038. * Serializes the actions and its related information.
  78039. * @param parent defines the object to serialize in
  78040. * @returns the serialized object
  78041. */
  78042. serialize(parent: any): any;
  78043. }
  78044. /**
  78045. * This defines an action responsible that does nothing once triggered.
  78046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78047. */
  78048. export class DoNothingAction extends Action {
  78049. /**
  78050. * Instantiate the action
  78051. * @param triggerOptions defines the trigger options
  78052. * @param condition defines the trigger related conditions
  78053. */
  78054. constructor(triggerOptions?: any, condition?: Condition);
  78055. /**
  78056. * Execute the action and do nothing.
  78057. */
  78058. execute(): void;
  78059. /**
  78060. * Serializes the actions and its related information.
  78061. * @param parent defines the object to serialize in
  78062. * @returns the serialized object
  78063. */
  78064. serialize(parent: any): any;
  78065. }
  78066. /**
  78067. * This defines an action responsible to trigger several actions once triggered.
  78068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78069. */
  78070. export class CombineAction extends Action {
  78071. /**
  78072. * The list of aggregated animations to run.
  78073. */
  78074. children: Action[];
  78075. /**
  78076. * Instantiate the action
  78077. * @param triggerOptions defines the trigger options
  78078. * @param children defines the list of aggregated animations to run
  78079. * @param condition defines the trigger related conditions
  78080. */
  78081. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78082. /** @hidden */
  78083. _prepare(): void;
  78084. /**
  78085. * Execute the action and executes all the aggregated actions.
  78086. */
  78087. execute(evt: ActionEvent): void;
  78088. /**
  78089. * Serializes the actions and its related information.
  78090. * @param parent defines the object to serialize in
  78091. * @returns the serialized object
  78092. */
  78093. serialize(parent: any): any;
  78094. }
  78095. /**
  78096. * This defines an action responsible to run code (external event) once triggered.
  78097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78098. */
  78099. export class ExecuteCodeAction extends Action {
  78100. /**
  78101. * The callback function to run.
  78102. */
  78103. func: (evt: ActionEvent) => void;
  78104. /**
  78105. * Instantiate the action
  78106. * @param triggerOptions defines the trigger options
  78107. * @param func defines the callback function to run
  78108. * @param condition defines the trigger related conditions
  78109. */
  78110. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78111. /**
  78112. * Execute the action and run the attached code.
  78113. */
  78114. execute(evt: ActionEvent): void;
  78115. }
  78116. /**
  78117. * This defines an action responsible to set the parent property of the target once triggered.
  78118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78119. */
  78120. export class SetParentAction extends Action {
  78121. private _parent;
  78122. private _target;
  78123. /**
  78124. * Instantiate the action
  78125. * @param triggerOptions defines the trigger options
  78126. * @param target defines the target containing the parent property
  78127. * @param parent defines from where the animation should start (animation frame)
  78128. * @param condition defines the trigger related conditions
  78129. */
  78130. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78131. /** @hidden */
  78132. _prepare(): void;
  78133. /**
  78134. * Execute the action and set the parent property.
  78135. */
  78136. execute(): void;
  78137. /**
  78138. * Serializes the actions and its related information.
  78139. * @param parent defines the object to serialize in
  78140. * @returns the serialized object
  78141. */
  78142. serialize(parent: any): any;
  78143. }
  78144. }
  78145. declare module BABYLON {
  78146. /**
  78147. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78148. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78150. */
  78151. export class ActionManager extends AbstractActionManager {
  78152. /**
  78153. * Nothing
  78154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78155. */
  78156. static readonly NothingTrigger: number;
  78157. /**
  78158. * On pick
  78159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78160. */
  78161. static readonly OnPickTrigger: number;
  78162. /**
  78163. * On left pick
  78164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78165. */
  78166. static readonly OnLeftPickTrigger: number;
  78167. /**
  78168. * On right pick
  78169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78170. */
  78171. static readonly OnRightPickTrigger: number;
  78172. /**
  78173. * On center pick
  78174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78175. */
  78176. static readonly OnCenterPickTrigger: number;
  78177. /**
  78178. * On pick down
  78179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78180. */
  78181. static readonly OnPickDownTrigger: number;
  78182. /**
  78183. * On double pick
  78184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78185. */
  78186. static readonly OnDoublePickTrigger: number;
  78187. /**
  78188. * On pick up
  78189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78190. */
  78191. static readonly OnPickUpTrigger: number;
  78192. /**
  78193. * On pick out.
  78194. * This trigger will only be raised if you also declared a OnPickDown
  78195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78196. */
  78197. static readonly OnPickOutTrigger: number;
  78198. /**
  78199. * On long press
  78200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78201. */
  78202. static readonly OnLongPressTrigger: number;
  78203. /**
  78204. * On pointer over
  78205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78206. */
  78207. static readonly OnPointerOverTrigger: number;
  78208. /**
  78209. * On pointer out
  78210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78211. */
  78212. static readonly OnPointerOutTrigger: number;
  78213. /**
  78214. * On every frame
  78215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78216. */
  78217. static readonly OnEveryFrameTrigger: number;
  78218. /**
  78219. * On intersection enter
  78220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78221. */
  78222. static readonly OnIntersectionEnterTrigger: number;
  78223. /**
  78224. * On intersection exit
  78225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78226. */
  78227. static readonly OnIntersectionExitTrigger: number;
  78228. /**
  78229. * On key down
  78230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78231. */
  78232. static readonly OnKeyDownTrigger: number;
  78233. /**
  78234. * On key up
  78235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78236. */
  78237. static readonly OnKeyUpTrigger: number;
  78238. private _scene;
  78239. /**
  78240. * Creates a new action manager
  78241. * @param scene defines the hosting scene
  78242. */
  78243. constructor(scene: Scene);
  78244. /**
  78245. * Releases all associated resources
  78246. */
  78247. dispose(): void;
  78248. /**
  78249. * Gets hosting scene
  78250. * @returns the hosting scene
  78251. */
  78252. getScene(): Scene;
  78253. /**
  78254. * Does this action manager handles actions of any of the given triggers
  78255. * @param triggers defines the triggers to be tested
  78256. * @return a boolean indicating whether one (or more) of the triggers is handled
  78257. */
  78258. hasSpecificTriggers(triggers: number[]): boolean;
  78259. /**
  78260. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78261. * speed.
  78262. * @param triggerA defines the trigger to be tested
  78263. * @param triggerB defines the trigger to be tested
  78264. * @return a boolean indicating whether one (or more) of the triggers is handled
  78265. */
  78266. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78267. /**
  78268. * Does this action manager handles actions of a given trigger
  78269. * @param trigger defines the trigger to be tested
  78270. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78271. * @return whether the trigger is handled
  78272. */
  78273. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78274. /**
  78275. * Does this action manager has pointer triggers
  78276. */
  78277. readonly hasPointerTriggers: boolean;
  78278. /**
  78279. * Does this action manager has pick triggers
  78280. */
  78281. readonly hasPickTriggers: boolean;
  78282. /**
  78283. * Registers an action to this action manager
  78284. * @param action defines the action to be registered
  78285. * @return the action amended (prepared) after registration
  78286. */
  78287. registerAction(action: IAction): Nullable<IAction>;
  78288. /**
  78289. * Unregisters an action to this action manager
  78290. * @param action defines the action to be unregistered
  78291. * @return a boolean indicating whether the action has been unregistered
  78292. */
  78293. unregisterAction(action: IAction): Boolean;
  78294. /**
  78295. * Process a specific trigger
  78296. * @param trigger defines the trigger to process
  78297. * @param evt defines the event details to be processed
  78298. */
  78299. processTrigger(trigger: number, evt?: IActionEvent): void;
  78300. /** @hidden */
  78301. _getEffectiveTarget(target: any, propertyPath: string): any;
  78302. /** @hidden */
  78303. _getProperty(propertyPath: string): string;
  78304. /**
  78305. * Serialize this manager to a JSON object
  78306. * @param name defines the property name to store this manager
  78307. * @returns a JSON representation of this manager
  78308. */
  78309. serialize(name: string): any;
  78310. /**
  78311. * Creates a new ActionManager from a JSON data
  78312. * @param parsedActions defines the JSON data to read from
  78313. * @param object defines the hosting mesh
  78314. * @param scene defines the hosting scene
  78315. */
  78316. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78317. /**
  78318. * Get a trigger name by index
  78319. * @param trigger defines the trigger index
  78320. * @returns a trigger name
  78321. */
  78322. static GetTriggerName(trigger: number): string;
  78323. }
  78324. }
  78325. declare module BABYLON {
  78326. /**
  78327. * Class representing a ray with position and direction
  78328. */
  78329. export class Ray {
  78330. /** origin point */
  78331. origin: Vector3;
  78332. /** direction */
  78333. direction: Vector3;
  78334. /** length of the ray */
  78335. length: number;
  78336. private static readonly TmpVector3;
  78337. private _tmpRay;
  78338. /**
  78339. * Creates a new ray
  78340. * @param origin origin point
  78341. * @param direction direction
  78342. * @param length length of the ray
  78343. */
  78344. constructor(
  78345. /** origin point */
  78346. origin: Vector3,
  78347. /** direction */
  78348. direction: Vector3,
  78349. /** length of the ray */
  78350. length?: number);
  78351. /**
  78352. * Checks if the ray intersects a box
  78353. * @param minimum bound of the box
  78354. * @param maximum bound of the box
  78355. * @param intersectionTreshold extra extend to be added to the box in all direction
  78356. * @returns if the box was hit
  78357. */
  78358. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78359. /**
  78360. * Checks if the ray intersects a box
  78361. * @param box the bounding box to check
  78362. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78363. * @returns if the box was hit
  78364. */
  78365. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78366. /**
  78367. * If the ray hits a sphere
  78368. * @param sphere the bounding sphere to check
  78369. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78370. * @returns true if it hits the sphere
  78371. */
  78372. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78373. /**
  78374. * If the ray hits a triange
  78375. * @param vertex0 triangle vertex
  78376. * @param vertex1 triangle vertex
  78377. * @param vertex2 triangle vertex
  78378. * @returns intersection information if hit
  78379. */
  78380. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78381. /**
  78382. * Checks if ray intersects a plane
  78383. * @param plane the plane to check
  78384. * @returns the distance away it was hit
  78385. */
  78386. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78387. /**
  78388. * Calculate the intercept of a ray on a given axis
  78389. * @param axis to check 'x' | 'y' | 'z'
  78390. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78391. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78392. */
  78393. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78394. /**
  78395. * Checks if ray intersects a mesh
  78396. * @param mesh the mesh to check
  78397. * @param fastCheck if only the bounding box should checked
  78398. * @returns picking info of the intersecton
  78399. */
  78400. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78401. /**
  78402. * Checks if ray intersects a mesh
  78403. * @param meshes the meshes to check
  78404. * @param fastCheck if only the bounding box should checked
  78405. * @param results array to store result in
  78406. * @returns Array of picking infos
  78407. */
  78408. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78409. private _comparePickingInfo;
  78410. private static smallnum;
  78411. private static rayl;
  78412. /**
  78413. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78414. * @param sega the first point of the segment to test the intersection against
  78415. * @param segb the second point of the segment to test the intersection against
  78416. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78417. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78418. */
  78419. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78420. /**
  78421. * Update the ray from viewport position
  78422. * @param x position
  78423. * @param y y position
  78424. * @param viewportWidth viewport width
  78425. * @param viewportHeight viewport height
  78426. * @param world world matrix
  78427. * @param view view matrix
  78428. * @param projection projection matrix
  78429. * @returns this ray updated
  78430. */
  78431. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78432. /**
  78433. * Creates a ray with origin and direction of 0,0,0
  78434. * @returns the new ray
  78435. */
  78436. static Zero(): Ray;
  78437. /**
  78438. * Creates a new ray from screen space and viewport
  78439. * @param x position
  78440. * @param y y position
  78441. * @param viewportWidth viewport width
  78442. * @param viewportHeight viewport height
  78443. * @param world world matrix
  78444. * @param view view matrix
  78445. * @param projection projection matrix
  78446. * @returns new ray
  78447. */
  78448. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78449. /**
  78450. * 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
  78451. * transformed to the given world matrix.
  78452. * @param origin The origin point
  78453. * @param end The end point
  78454. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78455. * @returns the new ray
  78456. */
  78457. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78458. /**
  78459. * Transforms a ray by a matrix
  78460. * @param ray ray to transform
  78461. * @param matrix matrix to apply
  78462. * @returns the resulting new ray
  78463. */
  78464. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78465. /**
  78466. * Transforms a ray by a matrix
  78467. * @param ray ray to transform
  78468. * @param matrix matrix to apply
  78469. * @param result ray to store result in
  78470. */
  78471. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78472. /**
  78473. * Unproject a ray from screen space to object space
  78474. * @param sourceX defines the screen space x coordinate to use
  78475. * @param sourceY defines the screen space y coordinate to use
  78476. * @param viewportWidth defines the current width of the viewport
  78477. * @param viewportHeight defines the current height of the viewport
  78478. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78479. * @param view defines the view matrix to use
  78480. * @param projection defines the projection matrix to use
  78481. */
  78482. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78483. }
  78484. /**
  78485. * Type used to define predicate used to select faces when a mesh intersection is detected
  78486. */
  78487. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78488. interface Scene {
  78489. /** @hidden */
  78490. _tempPickingRay: Nullable<Ray>;
  78491. /** @hidden */
  78492. _cachedRayForTransform: Ray;
  78493. /** @hidden */
  78494. _pickWithRayInverseMatrix: Matrix;
  78495. /** @hidden */
  78496. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78497. /** @hidden */
  78498. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78499. }
  78500. }
  78501. declare module BABYLON {
  78502. /**
  78503. * Groups all the scene component constants in one place to ease maintenance.
  78504. * @hidden
  78505. */
  78506. export class SceneComponentConstants {
  78507. static readonly NAME_EFFECTLAYER: string;
  78508. static readonly NAME_LAYER: string;
  78509. static readonly NAME_LENSFLARESYSTEM: string;
  78510. static readonly NAME_BOUNDINGBOXRENDERER: string;
  78511. static readonly NAME_PARTICLESYSTEM: string;
  78512. static readonly NAME_GAMEPAD: string;
  78513. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  78514. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  78515. static readonly NAME_DEPTHRENDERER: string;
  78516. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  78517. static readonly NAME_SPRITE: string;
  78518. static readonly NAME_OUTLINERENDERER: string;
  78519. static readonly NAME_PROCEDURALTEXTURE: string;
  78520. static readonly NAME_SHADOWGENERATOR: string;
  78521. static readonly NAME_OCTREE: string;
  78522. static readonly NAME_PHYSICSENGINE: string;
  78523. static readonly NAME_AUDIO: string;
  78524. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  78525. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78526. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  78527. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78528. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  78529. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  78530. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  78531. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  78532. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  78533. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  78534. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  78535. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  78536. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  78537. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  78538. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  78539. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  78540. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  78541. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  78542. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  78543. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  78544. static readonly STEP_AFTERRENDER_AUDIO: number;
  78545. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  78546. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  78547. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  78548. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  78549. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  78550. static readonly STEP_POINTERMOVE_SPRITE: number;
  78551. static readonly STEP_POINTERDOWN_SPRITE: number;
  78552. static readonly STEP_POINTERUP_SPRITE: number;
  78553. }
  78554. /**
  78555. * This represents a scene component.
  78556. *
  78557. * This is used to decouple the dependency the scene is having on the different workloads like
  78558. * layers, post processes...
  78559. */
  78560. export interface ISceneComponent {
  78561. /**
  78562. * The name of the component. Each component must have a unique name.
  78563. */
  78564. name: string;
  78565. /**
  78566. * The scene the component belongs to.
  78567. */
  78568. scene: Scene;
  78569. /**
  78570. * Register the component to one instance of a scene.
  78571. */
  78572. register(): void;
  78573. /**
  78574. * Rebuilds the elements related to this component in case of
  78575. * context lost for instance.
  78576. */
  78577. rebuild(): void;
  78578. /**
  78579. * Disposes the component and the associated ressources.
  78580. */
  78581. dispose(): void;
  78582. }
  78583. /**
  78584. * This represents a SERIALIZABLE scene component.
  78585. *
  78586. * This extends Scene Component to add Serialization methods on top.
  78587. */
  78588. export interface ISceneSerializableComponent extends ISceneComponent {
  78589. /**
  78590. * Adds all the elements from the container to the scene
  78591. * @param container the container holding the elements
  78592. */
  78593. addFromContainer(container: AbstractScene): void;
  78594. /**
  78595. * Removes all the elements in the container from the scene
  78596. * @param container contains the elements to remove
  78597. * @param dispose if the removed element should be disposed (default: false)
  78598. */
  78599. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78600. /**
  78601. * Serializes the component data to the specified json object
  78602. * @param serializationObject The object to serialize to
  78603. */
  78604. serialize(serializationObject: any): void;
  78605. }
  78606. /**
  78607. * Strong typing of a Mesh related stage step action
  78608. */
  78609. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  78610. /**
  78611. * Strong typing of a Evaluate Sub Mesh related stage step action
  78612. */
  78613. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  78614. /**
  78615. * Strong typing of a Active Mesh related stage step action
  78616. */
  78617. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  78618. /**
  78619. * Strong typing of a Camera related stage step action
  78620. */
  78621. export type CameraStageAction = (camera: Camera) => void;
  78622. /**
  78623. * Strong typing of a Camera Frame buffer related stage step action
  78624. */
  78625. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  78626. /**
  78627. * Strong typing of a Render Target related stage step action
  78628. */
  78629. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  78630. /**
  78631. * Strong typing of a RenderingGroup related stage step action
  78632. */
  78633. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78634. /**
  78635. * Strong typing of a Mesh Render related stage step action
  78636. */
  78637. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78638. /**
  78639. * Strong typing of a simple stage step action
  78640. */
  78641. export type SimpleStageAction = () => void;
  78642. /**
  78643. * Strong typing of a render target action.
  78644. */
  78645. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78646. /**
  78647. * Strong typing of a pointer move action.
  78648. */
  78649. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78650. /**
  78651. * Strong typing of a pointer up/down action.
  78652. */
  78653. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78654. /**
  78655. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78656. * @hidden
  78657. */
  78658. export class Stage<T extends Function> extends Array<{
  78659. index: number;
  78660. component: ISceneComponent;
  78661. action: T;
  78662. }> {
  78663. /**
  78664. * Hide ctor from the rest of the world.
  78665. * @param items The items to add.
  78666. */
  78667. private constructor();
  78668. /**
  78669. * Creates a new Stage.
  78670. * @returns A new instance of a Stage
  78671. */
  78672. static Create<T extends Function>(): Stage<T>;
  78673. /**
  78674. * Registers a step in an ordered way in the targeted stage.
  78675. * @param index Defines the position to register the step in
  78676. * @param component Defines the component attached to the step
  78677. * @param action Defines the action to launch during the step
  78678. */
  78679. registerStep(index: number, component: ISceneComponent, action: T): void;
  78680. /**
  78681. * Clears all the steps from the stage.
  78682. */
  78683. clear(): void;
  78684. }
  78685. }
  78686. declare module BABYLON {
  78687. interface Scene {
  78688. /** @hidden */
  78689. _pointerOverSprite: Nullable<Sprite>;
  78690. /** @hidden */
  78691. _pickedDownSprite: Nullable<Sprite>;
  78692. /** @hidden */
  78693. _tempSpritePickingRay: Nullable<Ray>;
  78694. /**
  78695. * All of the sprite managers added to this scene
  78696. * @see http://doc.babylonjs.com/babylon101/sprites
  78697. */
  78698. spriteManagers: Array<ISpriteManager>;
  78699. /**
  78700. * An event triggered when sprites rendering is about to start
  78701. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78702. */
  78703. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78704. /**
  78705. * An event triggered when sprites rendering is done
  78706. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78707. */
  78708. onAfterSpritesRenderingObservable: Observable<Scene>;
  78709. /** @hidden */
  78710. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78711. /** Launch a ray to try to pick a sprite in the scene
  78712. * @param x position on screen
  78713. * @param y position on screen
  78714. * @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
  78715. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78716. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78717. * @returns a PickingInfo
  78718. */
  78719. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78720. /** Use the given ray to pick a sprite in the scene
  78721. * @param ray The ray (in world space) to use to pick meshes
  78722. * @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
  78723. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78724. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78725. * @returns a PickingInfo
  78726. */
  78727. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78728. /** @hidden */
  78729. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78730. /** Launch a ray to try to pick sprites in the scene
  78731. * @param x position on screen
  78732. * @param y position on screen
  78733. * @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
  78734. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78735. * @returns a PickingInfo array
  78736. */
  78737. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78738. /** Use the given ray to pick sprites in the scene
  78739. * @param ray The ray (in world space) to use to pick meshes
  78740. * @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
  78741. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78742. * @returns a PickingInfo array
  78743. */
  78744. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78745. /**
  78746. * Force the sprite under the pointer
  78747. * @param sprite defines the sprite to use
  78748. */
  78749. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78750. /**
  78751. * Gets the sprite under the pointer
  78752. * @returns a Sprite or null if no sprite is under the pointer
  78753. */
  78754. getPointerOverSprite(): Nullable<Sprite>;
  78755. }
  78756. /**
  78757. * Defines the sprite scene component responsible to manage sprites
  78758. * in a given scene.
  78759. */
  78760. export class SpriteSceneComponent implements ISceneComponent {
  78761. /**
  78762. * The component name helpfull to identify the component in the list of scene components.
  78763. */
  78764. readonly name: string;
  78765. /**
  78766. * The scene the component belongs to.
  78767. */
  78768. scene: Scene;
  78769. /** @hidden */
  78770. private _spritePredicate;
  78771. /**
  78772. * Creates a new instance of the component for the given scene
  78773. * @param scene Defines the scene to register the component in
  78774. */
  78775. constructor(scene: Scene);
  78776. /**
  78777. * Registers the component in a given scene
  78778. */
  78779. register(): void;
  78780. /**
  78781. * Rebuilds the elements related to this component in case of
  78782. * context lost for instance.
  78783. */
  78784. rebuild(): void;
  78785. /**
  78786. * Disposes the component and the associated ressources.
  78787. */
  78788. dispose(): void;
  78789. private _pickSpriteButKeepRay;
  78790. private _pointerMove;
  78791. private _pointerDown;
  78792. private _pointerUp;
  78793. }
  78794. }
  78795. declare module BABYLON {
  78796. /** @hidden */
  78797. export var fogFragmentDeclaration: {
  78798. name: string;
  78799. shader: string;
  78800. };
  78801. }
  78802. declare module BABYLON {
  78803. /** @hidden */
  78804. export var fogFragment: {
  78805. name: string;
  78806. shader: string;
  78807. };
  78808. }
  78809. declare module BABYLON {
  78810. /** @hidden */
  78811. export var spritesPixelShader: {
  78812. name: string;
  78813. shader: string;
  78814. };
  78815. }
  78816. declare module BABYLON {
  78817. /** @hidden */
  78818. export var fogVertexDeclaration: {
  78819. name: string;
  78820. shader: string;
  78821. };
  78822. }
  78823. declare module BABYLON {
  78824. /** @hidden */
  78825. export var spritesVertexShader: {
  78826. name: string;
  78827. shader: string;
  78828. };
  78829. }
  78830. declare module BABYLON {
  78831. /**
  78832. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78833. */
  78834. export interface ISpriteManager extends IDisposable {
  78835. /**
  78836. * Restricts the camera to viewing objects with the same layerMask.
  78837. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78838. */
  78839. layerMask: number;
  78840. /**
  78841. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78842. */
  78843. isPickable: boolean;
  78844. /**
  78845. * Specifies the rendering group id for this mesh (0 by default)
  78846. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78847. */
  78848. renderingGroupId: number;
  78849. /**
  78850. * Defines the list of sprites managed by the manager.
  78851. */
  78852. sprites: Array<Sprite>;
  78853. /**
  78854. * Tests the intersection of a sprite with a specific ray.
  78855. * @param ray The ray we are sending to test the collision
  78856. * @param camera The camera space we are sending rays in
  78857. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78858. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78859. * @returns picking info or null.
  78860. */
  78861. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78862. /**
  78863. * Intersects the sprites with a ray
  78864. * @param ray defines the ray to intersect with
  78865. * @param camera defines the current active camera
  78866. * @param predicate defines a predicate used to select candidate sprites
  78867. * @returns null if no hit or a PickingInfo array
  78868. */
  78869. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78870. /**
  78871. * Renders the list of sprites on screen.
  78872. */
  78873. render(): void;
  78874. }
  78875. /**
  78876. * Class used to manage multiple sprites on the same spritesheet
  78877. * @see http://doc.babylonjs.com/babylon101/sprites
  78878. */
  78879. export class SpriteManager implements ISpriteManager {
  78880. /** defines the manager's name */
  78881. name: string;
  78882. /** Gets the list of sprites */
  78883. sprites: Sprite[];
  78884. /** Gets or sets the rendering group id (0 by default) */
  78885. renderingGroupId: number;
  78886. /** Gets or sets camera layer mask */
  78887. layerMask: number;
  78888. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78889. fogEnabled: boolean;
  78890. /** Gets or sets a boolean indicating if the sprites are pickable */
  78891. isPickable: boolean;
  78892. /** Defines the default width of a cell in the spritesheet */
  78893. cellWidth: number;
  78894. /** Defines the default height of a cell in the spritesheet */
  78895. cellHeight: number;
  78896. /** Associative array from JSON sprite data file */
  78897. private _cellData;
  78898. /** Array of sprite names from JSON sprite data file */
  78899. private _spriteMap;
  78900. /** True when packed cell data from JSON file is ready*/
  78901. private _packedAndReady;
  78902. /**
  78903. * An event triggered when the manager is disposed.
  78904. */
  78905. onDisposeObservable: Observable<SpriteManager>;
  78906. private _onDisposeObserver;
  78907. /**
  78908. * Callback called when the manager is disposed
  78909. */
  78910. onDispose: () => void;
  78911. private _capacity;
  78912. private _fromPacked;
  78913. private _spriteTexture;
  78914. private _epsilon;
  78915. private _scene;
  78916. private _vertexData;
  78917. private _buffer;
  78918. private _vertexBuffers;
  78919. private _indexBuffer;
  78920. private _effectBase;
  78921. private _effectFog;
  78922. /**
  78923. * Gets or sets the spritesheet texture
  78924. */
  78925. texture: Texture;
  78926. /**
  78927. * Creates a new sprite manager
  78928. * @param name defines the manager's name
  78929. * @param imgUrl defines the sprite sheet url
  78930. * @param capacity defines the maximum allowed number of sprites
  78931. * @param cellSize defines the size of a sprite cell
  78932. * @param scene defines the hosting scene
  78933. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78934. * @param samplingMode defines the smapling mode to use with spritesheet
  78935. * @param fromPacked set to false; do not alter
  78936. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78937. */
  78938. constructor(
  78939. /** defines the manager's name */
  78940. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78941. private _makePacked;
  78942. private _appendSpriteVertex;
  78943. /**
  78944. * Intersects the sprites with a ray
  78945. * @param ray defines the ray to intersect with
  78946. * @param camera defines the current active camera
  78947. * @param predicate defines a predicate used to select candidate sprites
  78948. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78949. * @returns null if no hit or a PickingInfo
  78950. */
  78951. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78952. /**
  78953. * Intersects the sprites with a ray
  78954. * @param ray defines the ray to intersect with
  78955. * @param camera defines the current active camera
  78956. * @param predicate defines a predicate used to select candidate sprites
  78957. * @returns null if no hit or a PickingInfo array
  78958. */
  78959. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78960. /**
  78961. * Render all child sprites
  78962. */
  78963. render(): void;
  78964. /**
  78965. * Release associated resources
  78966. */
  78967. dispose(): void;
  78968. }
  78969. }
  78970. declare module BABYLON {
  78971. /**
  78972. * Class used to represent a sprite
  78973. * @see http://doc.babylonjs.com/babylon101/sprites
  78974. */
  78975. export class Sprite {
  78976. /** defines the name */
  78977. name: string;
  78978. /** Gets or sets the current world position */
  78979. position: Vector3;
  78980. /** Gets or sets the main color */
  78981. color: Color4;
  78982. /** Gets or sets the width */
  78983. width: number;
  78984. /** Gets or sets the height */
  78985. height: number;
  78986. /** Gets or sets rotation angle */
  78987. angle: number;
  78988. /** Gets or sets the cell index in the sprite sheet */
  78989. cellIndex: number;
  78990. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78991. cellRef: string;
  78992. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78993. invertU: number;
  78994. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78995. invertV: number;
  78996. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78997. disposeWhenFinishedAnimating: boolean;
  78998. /** Gets the list of attached animations */
  78999. animations: Animation[];
  79000. /** Gets or sets a boolean indicating if the sprite can be picked */
  79001. isPickable: boolean;
  79002. /**
  79003. * Gets or sets the associated action manager
  79004. */
  79005. actionManager: Nullable<ActionManager>;
  79006. private _animationStarted;
  79007. private _loopAnimation;
  79008. private _fromIndex;
  79009. private _toIndex;
  79010. private _delay;
  79011. private _direction;
  79012. private _manager;
  79013. private _time;
  79014. private _onAnimationEnd;
  79015. /**
  79016. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79017. */
  79018. isVisible: boolean;
  79019. /**
  79020. * Gets or sets the sprite size
  79021. */
  79022. size: number;
  79023. /**
  79024. * Creates a new Sprite
  79025. * @param name defines the name
  79026. * @param manager defines the manager
  79027. */
  79028. constructor(
  79029. /** defines the name */
  79030. name: string, manager: ISpriteManager);
  79031. /**
  79032. * Starts an animation
  79033. * @param from defines the initial key
  79034. * @param to defines the end key
  79035. * @param loop defines if the animation must loop
  79036. * @param delay defines the start delay (in ms)
  79037. * @param onAnimationEnd defines a callback to call when animation ends
  79038. */
  79039. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79040. /** Stops current animation (if any) */
  79041. stopAnimation(): void;
  79042. /** @hidden */
  79043. _animate(deltaTime: number): void;
  79044. /** Release associated resources */
  79045. dispose(): void;
  79046. }
  79047. }
  79048. declare module BABYLON {
  79049. /**
  79050. * Information about the result of picking within a scene
  79051. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79052. */
  79053. export class PickingInfo {
  79054. /** @hidden */
  79055. _pickingUnavailable: boolean;
  79056. /**
  79057. * If the pick collided with an object
  79058. */
  79059. hit: boolean;
  79060. /**
  79061. * Distance away where the pick collided
  79062. */
  79063. distance: number;
  79064. /**
  79065. * The location of pick collision
  79066. */
  79067. pickedPoint: Nullable<Vector3>;
  79068. /**
  79069. * The mesh corresponding the the pick collision
  79070. */
  79071. pickedMesh: Nullable<AbstractMesh>;
  79072. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79073. bu: number;
  79074. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79075. bv: number;
  79076. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79077. faceId: number;
  79078. /** Id of the the submesh that was picked */
  79079. subMeshId: number;
  79080. /** If a sprite was picked, this will be the sprite the pick collided with */
  79081. pickedSprite: Nullable<Sprite>;
  79082. /**
  79083. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79084. */
  79085. originMesh: Nullable<AbstractMesh>;
  79086. /**
  79087. * The ray that was used to perform the picking.
  79088. */
  79089. ray: Nullable<Ray>;
  79090. /**
  79091. * Gets the normal correspodning to the face the pick collided with
  79092. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79093. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79094. * @returns The normal correspodning to the face the pick collided with
  79095. */
  79096. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79097. /**
  79098. * Gets the texture coordinates of where the pick occured
  79099. * @returns the vector containing the coordnates of the texture
  79100. */
  79101. getTextureCoordinates(): Nullable<Vector2>;
  79102. }
  79103. }
  79104. declare module BABYLON {
  79105. /**
  79106. * Gather the list of pointer event types as constants.
  79107. */
  79108. export class PointerEventTypes {
  79109. /**
  79110. * 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.
  79111. */
  79112. static readonly POINTERDOWN: number;
  79113. /**
  79114. * The pointerup event is fired when a pointer is no longer active.
  79115. */
  79116. static readonly POINTERUP: number;
  79117. /**
  79118. * The pointermove event is fired when a pointer changes coordinates.
  79119. */
  79120. static readonly POINTERMOVE: number;
  79121. /**
  79122. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79123. */
  79124. static readonly POINTERWHEEL: number;
  79125. /**
  79126. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79127. */
  79128. static readonly POINTERPICK: number;
  79129. /**
  79130. * The pointertap event is fired when a the object has been touched and released without drag.
  79131. */
  79132. static readonly POINTERTAP: number;
  79133. /**
  79134. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79135. */
  79136. static readonly POINTERDOUBLETAP: number;
  79137. }
  79138. /**
  79139. * Base class of pointer info types.
  79140. */
  79141. export class PointerInfoBase {
  79142. /**
  79143. * Defines the type of event (PointerEventTypes)
  79144. */
  79145. type: number;
  79146. /**
  79147. * Defines the related dom event
  79148. */
  79149. event: PointerEvent | MouseWheelEvent;
  79150. /**
  79151. * Instantiates the base class of pointers info.
  79152. * @param type Defines the type of event (PointerEventTypes)
  79153. * @param event Defines the related dom event
  79154. */
  79155. constructor(
  79156. /**
  79157. * Defines the type of event (PointerEventTypes)
  79158. */
  79159. type: number,
  79160. /**
  79161. * Defines the related dom event
  79162. */
  79163. event: PointerEvent | MouseWheelEvent);
  79164. }
  79165. /**
  79166. * This class is used to store pointer related info for the onPrePointerObservable event.
  79167. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79168. */
  79169. export class PointerInfoPre extends PointerInfoBase {
  79170. /**
  79171. * Ray from a pointer if availible (eg. 6dof controller)
  79172. */
  79173. ray: Nullable<Ray>;
  79174. /**
  79175. * Defines the local position of the pointer on the canvas.
  79176. */
  79177. localPosition: Vector2;
  79178. /**
  79179. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79180. */
  79181. skipOnPointerObservable: boolean;
  79182. /**
  79183. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79184. * @param type Defines the type of event (PointerEventTypes)
  79185. * @param event Defines the related dom event
  79186. * @param localX Defines the local x coordinates of the pointer when the event occured
  79187. * @param localY Defines the local y coordinates of the pointer when the event occured
  79188. */
  79189. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79190. }
  79191. /**
  79192. * This type contains all the data related to a pointer event in Babylon.js.
  79193. * 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.
  79194. */
  79195. export class PointerInfo extends PointerInfoBase {
  79196. /**
  79197. * Defines the picking info associated to the info (if any)\
  79198. */
  79199. pickInfo: Nullable<PickingInfo>;
  79200. /**
  79201. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79202. * @param type Defines the type of event (PointerEventTypes)
  79203. * @param event Defines the related dom event
  79204. * @param pickInfo Defines the picking info associated to the info (if any)\
  79205. */
  79206. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79207. /**
  79208. * Defines the picking info associated to the info (if any)\
  79209. */
  79210. pickInfo: Nullable<PickingInfo>);
  79211. }
  79212. /**
  79213. * Data relating to a touch event on the screen.
  79214. */
  79215. export interface PointerTouch {
  79216. /**
  79217. * X coordinate of touch.
  79218. */
  79219. x: number;
  79220. /**
  79221. * Y coordinate of touch.
  79222. */
  79223. y: number;
  79224. /**
  79225. * Id of touch. Unique for each finger.
  79226. */
  79227. pointerId: number;
  79228. /**
  79229. * Event type passed from DOM.
  79230. */
  79231. type: any;
  79232. }
  79233. }
  79234. declare module BABYLON {
  79235. /**
  79236. * Manage the mouse inputs to control the movement of a free camera.
  79237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79238. */
  79239. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79240. /**
  79241. * Define if touch is enabled in the mouse input
  79242. */
  79243. touchEnabled: boolean;
  79244. /**
  79245. * Defines the camera the input is attached to.
  79246. */
  79247. camera: FreeCamera;
  79248. /**
  79249. * Defines the buttons associated with the input to handle camera move.
  79250. */
  79251. buttons: number[];
  79252. /**
  79253. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79254. */
  79255. angularSensibility: number;
  79256. private _pointerInput;
  79257. private _onMouseMove;
  79258. private _observer;
  79259. private previousPosition;
  79260. /**
  79261. * Observable for when a pointer move event occurs containing the move offset
  79262. */
  79263. onPointerMovedObservable: Observable<{
  79264. offsetX: number;
  79265. offsetY: number;
  79266. }>;
  79267. /**
  79268. * @hidden
  79269. * If the camera should be rotated automatically based on pointer movement
  79270. */
  79271. _allowCameraRotation: boolean;
  79272. /**
  79273. * Manage the mouse inputs to control the movement of a free camera.
  79274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79275. * @param touchEnabled Defines if touch is enabled or not
  79276. */
  79277. constructor(
  79278. /**
  79279. * Define if touch is enabled in the mouse input
  79280. */
  79281. touchEnabled?: boolean);
  79282. /**
  79283. * Attach the input controls to a specific dom element to get the input from.
  79284. * @param element Defines the element the controls should be listened from
  79285. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79286. */
  79287. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79288. /**
  79289. * Called on JS contextmenu event.
  79290. * Override this method to provide functionality.
  79291. */
  79292. protected onContextMenu(evt: PointerEvent): void;
  79293. /**
  79294. * Detach the current controls from the specified dom element.
  79295. * @param element Defines the element to stop listening the inputs from
  79296. */
  79297. detachControl(element: Nullable<HTMLElement>): void;
  79298. /**
  79299. * Gets the class name of the current intput.
  79300. * @returns the class name
  79301. */
  79302. getClassName(): string;
  79303. /**
  79304. * Get the friendly name associated with the input class.
  79305. * @returns the input friendly name
  79306. */
  79307. getSimpleName(): string;
  79308. }
  79309. }
  79310. declare module BABYLON {
  79311. /**
  79312. * Manage the touch inputs to control the movement of a free camera.
  79313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79314. */
  79315. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79316. /**
  79317. * Defines the camera the input is attached to.
  79318. */
  79319. camera: FreeCamera;
  79320. /**
  79321. * Defines the touch sensibility for rotation.
  79322. * The higher the faster.
  79323. */
  79324. touchAngularSensibility: number;
  79325. /**
  79326. * Defines the touch sensibility for move.
  79327. * The higher the faster.
  79328. */
  79329. touchMoveSensibility: number;
  79330. private _offsetX;
  79331. private _offsetY;
  79332. private _pointerPressed;
  79333. private _pointerInput;
  79334. private _observer;
  79335. private _onLostFocus;
  79336. /**
  79337. * Attach the input controls to a specific dom element to get the input from.
  79338. * @param element Defines the element the controls should be listened from
  79339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79340. */
  79341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79342. /**
  79343. * Detach the current controls from the specified dom element.
  79344. * @param element Defines the element to stop listening the inputs from
  79345. */
  79346. detachControl(element: Nullable<HTMLElement>): void;
  79347. /**
  79348. * Update the current camera state depending on the inputs that have been used this frame.
  79349. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79350. */
  79351. checkInputs(): void;
  79352. /**
  79353. * Gets the class name of the current intput.
  79354. * @returns the class name
  79355. */
  79356. getClassName(): string;
  79357. /**
  79358. * Get the friendly name associated with the input class.
  79359. * @returns the input friendly name
  79360. */
  79361. getSimpleName(): string;
  79362. }
  79363. }
  79364. declare module BABYLON {
  79365. /**
  79366. * Default Inputs manager for the FreeCamera.
  79367. * It groups all the default supported inputs for ease of use.
  79368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79369. */
  79370. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79371. /**
  79372. * @hidden
  79373. */
  79374. _mouseInput: Nullable<FreeCameraMouseInput>;
  79375. /**
  79376. * Instantiates a new FreeCameraInputsManager.
  79377. * @param camera Defines the camera the inputs belong to
  79378. */
  79379. constructor(camera: FreeCamera);
  79380. /**
  79381. * Add keyboard input support to the input manager.
  79382. * @returns the current input manager
  79383. */
  79384. addKeyboard(): FreeCameraInputsManager;
  79385. /**
  79386. * Add mouse input support to the input manager.
  79387. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79388. * @returns the current input manager
  79389. */
  79390. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79391. /**
  79392. * Removes the mouse input support from the manager
  79393. * @returns the current input manager
  79394. */
  79395. removeMouse(): FreeCameraInputsManager;
  79396. /**
  79397. * Add touch input support to the input manager.
  79398. * @returns the current input manager
  79399. */
  79400. addTouch(): FreeCameraInputsManager;
  79401. /**
  79402. * Remove all attached input methods from a camera
  79403. */
  79404. clear(): void;
  79405. }
  79406. }
  79407. declare module BABYLON {
  79408. /**
  79409. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79410. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79411. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79412. */
  79413. export class FreeCamera extends TargetCamera {
  79414. /**
  79415. * Define the collision ellipsoid of the camera.
  79416. * This is helpful to simulate a camera body like the player body around the camera
  79417. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79418. */
  79419. ellipsoid: Vector3;
  79420. /**
  79421. * Define an offset for the position of the ellipsoid around the camera.
  79422. * This can be helpful to determine the center of the body near the gravity center of the body
  79423. * instead of its head.
  79424. */
  79425. ellipsoidOffset: Vector3;
  79426. /**
  79427. * Enable or disable collisions of the camera with the rest of the scene objects.
  79428. */
  79429. checkCollisions: boolean;
  79430. /**
  79431. * Enable or disable gravity on the camera.
  79432. */
  79433. applyGravity: boolean;
  79434. /**
  79435. * Define the input manager associated to the camera.
  79436. */
  79437. inputs: FreeCameraInputsManager;
  79438. /**
  79439. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79440. * Higher values reduce sensitivity.
  79441. */
  79442. /**
  79443. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79444. * Higher values reduce sensitivity.
  79445. */
  79446. angularSensibility: number;
  79447. /**
  79448. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79449. */
  79450. keysUp: number[];
  79451. /**
  79452. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79453. */
  79454. keysDown: number[];
  79455. /**
  79456. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79457. */
  79458. keysLeft: number[];
  79459. /**
  79460. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79461. */
  79462. keysRight: number[];
  79463. /**
  79464. * Event raised when the camera collide with a mesh in the scene.
  79465. */
  79466. onCollide: (collidedMesh: AbstractMesh) => void;
  79467. private _collider;
  79468. private _needMoveForGravity;
  79469. private _oldPosition;
  79470. private _diffPosition;
  79471. private _newPosition;
  79472. /** @hidden */
  79473. _localDirection: Vector3;
  79474. /** @hidden */
  79475. _transformedDirection: Vector3;
  79476. /**
  79477. * Instantiates a Free Camera.
  79478. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79479. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79480. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79481. * @param name Define the name of the camera in the scene
  79482. * @param position Define the start position of the camera in the scene
  79483. * @param scene Define the scene the camera belongs to
  79484. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79485. */
  79486. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79487. /**
  79488. * Attached controls to the current camera.
  79489. * @param element Defines the element the controls should be listened from
  79490. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79491. */
  79492. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79493. /**
  79494. * Detach the current controls from the camera.
  79495. * The camera will stop reacting to inputs.
  79496. * @param element Defines the element to stop listening the inputs from
  79497. */
  79498. detachControl(element: HTMLElement): void;
  79499. private _collisionMask;
  79500. /**
  79501. * Define a collision mask to limit the list of object the camera can collide with
  79502. */
  79503. collisionMask: number;
  79504. /** @hidden */
  79505. _collideWithWorld(displacement: Vector3): void;
  79506. private _onCollisionPositionChange;
  79507. /** @hidden */
  79508. _checkInputs(): void;
  79509. /** @hidden */
  79510. _decideIfNeedsToMove(): boolean;
  79511. /** @hidden */
  79512. _updatePosition(): void;
  79513. /**
  79514. * Destroy the camera and release the current resources hold by it.
  79515. */
  79516. dispose(): void;
  79517. /**
  79518. * Gets the current object class name.
  79519. * @return the class name
  79520. */
  79521. getClassName(): string;
  79522. }
  79523. }
  79524. declare module BABYLON {
  79525. /**
  79526. * Represents a gamepad control stick position
  79527. */
  79528. export class StickValues {
  79529. /**
  79530. * The x component of the control stick
  79531. */
  79532. x: number;
  79533. /**
  79534. * The y component of the control stick
  79535. */
  79536. y: number;
  79537. /**
  79538. * Initializes the gamepad x and y control stick values
  79539. * @param x The x component of the gamepad control stick value
  79540. * @param y The y component of the gamepad control stick value
  79541. */
  79542. constructor(
  79543. /**
  79544. * The x component of the control stick
  79545. */
  79546. x: number,
  79547. /**
  79548. * The y component of the control stick
  79549. */
  79550. y: number);
  79551. }
  79552. /**
  79553. * An interface which manages callbacks for gamepad button changes
  79554. */
  79555. export interface GamepadButtonChanges {
  79556. /**
  79557. * Called when a gamepad has been changed
  79558. */
  79559. changed: boolean;
  79560. /**
  79561. * Called when a gamepad press event has been triggered
  79562. */
  79563. pressChanged: boolean;
  79564. /**
  79565. * Called when a touch event has been triggered
  79566. */
  79567. touchChanged: boolean;
  79568. /**
  79569. * Called when a value has changed
  79570. */
  79571. valueChanged: boolean;
  79572. }
  79573. /**
  79574. * Represents a gamepad
  79575. */
  79576. export class Gamepad {
  79577. /**
  79578. * The id of the gamepad
  79579. */
  79580. id: string;
  79581. /**
  79582. * The index of the gamepad
  79583. */
  79584. index: number;
  79585. /**
  79586. * The browser gamepad
  79587. */
  79588. browserGamepad: any;
  79589. /**
  79590. * Specifies what type of gamepad this represents
  79591. */
  79592. type: number;
  79593. private _leftStick;
  79594. private _rightStick;
  79595. /** @hidden */
  79596. _isConnected: boolean;
  79597. private _leftStickAxisX;
  79598. private _leftStickAxisY;
  79599. private _rightStickAxisX;
  79600. private _rightStickAxisY;
  79601. /**
  79602. * Triggered when the left control stick has been changed
  79603. */
  79604. private _onleftstickchanged;
  79605. /**
  79606. * Triggered when the right control stick has been changed
  79607. */
  79608. private _onrightstickchanged;
  79609. /**
  79610. * Represents a gamepad controller
  79611. */
  79612. static GAMEPAD: number;
  79613. /**
  79614. * Represents a generic controller
  79615. */
  79616. static GENERIC: number;
  79617. /**
  79618. * Represents an XBox controller
  79619. */
  79620. static XBOX: number;
  79621. /**
  79622. * Represents a pose-enabled controller
  79623. */
  79624. static POSE_ENABLED: number;
  79625. /**
  79626. * Represents an Dual Shock controller
  79627. */
  79628. static DUALSHOCK: number;
  79629. /**
  79630. * Specifies whether the left control stick should be Y-inverted
  79631. */
  79632. protected _invertLeftStickY: boolean;
  79633. /**
  79634. * Specifies if the gamepad has been connected
  79635. */
  79636. readonly isConnected: boolean;
  79637. /**
  79638. * Initializes the gamepad
  79639. * @param id The id of the gamepad
  79640. * @param index The index of the gamepad
  79641. * @param browserGamepad The browser gamepad
  79642. * @param leftStickX The x component of the left joystick
  79643. * @param leftStickY The y component of the left joystick
  79644. * @param rightStickX The x component of the right joystick
  79645. * @param rightStickY The y component of the right joystick
  79646. */
  79647. constructor(
  79648. /**
  79649. * The id of the gamepad
  79650. */
  79651. id: string,
  79652. /**
  79653. * The index of the gamepad
  79654. */
  79655. index: number,
  79656. /**
  79657. * The browser gamepad
  79658. */
  79659. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79660. /**
  79661. * Callback triggered when the left joystick has changed
  79662. * @param callback
  79663. */
  79664. onleftstickchanged(callback: (values: StickValues) => void): void;
  79665. /**
  79666. * Callback triggered when the right joystick has changed
  79667. * @param callback
  79668. */
  79669. onrightstickchanged(callback: (values: StickValues) => void): void;
  79670. /**
  79671. * Gets the left joystick
  79672. */
  79673. /**
  79674. * Sets the left joystick values
  79675. */
  79676. leftStick: StickValues;
  79677. /**
  79678. * Gets the right joystick
  79679. */
  79680. /**
  79681. * Sets the right joystick value
  79682. */
  79683. rightStick: StickValues;
  79684. /**
  79685. * Updates the gamepad joystick positions
  79686. */
  79687. update(): void;
  79688. /**
  79689. * Disposes the gamepad
  79690. */
  79691. dispose(): void;
  79692. }
  79693. /**
  79694. * Represents a generic gamepad
  79695. */
  79696. export class GenericPad extends Gamepad {
  79697. private _buttons;
  79698. private _onbuttondown;
  79699. private _onbuttonup;
  79700. /**
  79701. * Observable triggered when a button has been pressed
  79702. */
  79703. onButtonDownObservable: Observable<number>;
  79704. /**
  79705. * Observable triggered when a button has been released
  79706. */
  79707. onButtonUpObservable: Observable<number>;
  79708. /**
  79709. * Callback triggered when a button has been pressed
  79710. * @param callback Called when a button has been pressed
  79711. */
  79712. onbuttondown(callback: (buttonPressed: number) => void): void;
  79713. /**
  79714. * Callback triggered when a button has been released
  79715. * @param callback Called when a button has been released
  79716. */
  79717. onbuttonup(callback: (buttonReleased: number) => void): void;
  79718. /**
  79719. * Initializes the generic gamepad
  79720. * @param id The id of the generic gamepad
  79721. * @param index The index of the generic gamepad
  79722. * @param browserGamepad The browser gamepad
  79723. */
  79724. constructor(id: string, index: number, browserGamepad: any);
  79725. private _setButtonValue;
  79726. /**
  79727. * Updates the generic gamepad
  79728. */
  79729. update(): void;
  79730. /**
  79731. * Disposes the generic gamepad
  79732. */
  79733. dispose(): void;
  79734. }
  79735. }
  79736. declare module BABYLON {
  79737. interface Engine {
  79738. /**
  79739. * Creates a raw texture
  79740. * @param data defines the data to store in the texture
  79741. * @param width defines the width of the texture
  79742. * @param height defines the height of the texture
  79743. * @param format defines the format of the data
  79744. * @param generateMipMaps defines if the engine should generate the mip levels
  79745. * @param invertY defines if data must be stored with Y axis inverted
  79746. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79747. * @param compression defines the compression used (null by default)
  79748. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79749. * @returns the raw texture inside an InternalTexture
  79750. */
  79751. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79752. /**
  79753. * Update a raw texture
  79754. * @param texture defines the texture to update
  79755. * @param data defines the data to store in the texture
  79756. * @param format defines the format of the data
  79757. * @param invertY defines if data must be stored with Y axis inverted
  79758. */
  79759. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79760. /**
  79761. * Update a raw texture
  79762. * @param texture defines the texture to update
  79763. * @param data defines the data to store in the texture
  79764. * @param format defines the format of the data
  79765. * @param invertY defines if data must be stored with Y axis inverted
  79766. * @param compression defines the compression used (null by default)
  79767. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79768. */
  79769. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79770. /**
  79771. * Creates a new raw cube texture
  79772. * @param data defines the array of data to use to create each face
  79773. * @param size defines the size of the textures
  79774. * @param format defines the format of the data
  79775. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79776. * @param generateMipMaps defines if the engine should generate the mip levels
  79777. * @param invertY defines if data must be stored with Y axis inverted
  79778. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79779. * @param compression defines the compression used (null by default)
  79780. * @returns the cube texture as an InternalTexture
  79781. */
  79782. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79783. /**
  79784. * Update a raw cube texture
  79785. * @param texture defines the texture to udpdate
  79786. * @param data defines the data to store
  79787. * @param format defines the data format
  79788. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79789. * @param invertY defines if data must be stored with Y axis inverted
  79790. */
  79791. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79792. /**
  79793. * Update a raw cube texture
  79794. * @param texture defines the texture to udpdate
  79795. * @param data defines the data to store
  79796. * @param format defines the data format
  79797. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79798. * @param invertY defines if data must be stored with Y axis inverted
  79799. * @param compression defines the compression used (null by default)
  79800. */
  79801. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79802. /**
  79803. * Update a raw cube texture
  79804. * @param texture defines the texture to udpdate
  79805. * @param data defines the data to store
  79806. * @param format defines the data format
  79807. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79808. * @param invertY defines if data must be stored with Y axis inverted
  79809. * @param compression defines the compression used (null by default)
  79810. * @param level defines which level of the texture to update
  79811. */
  79812. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79813. /**
  79814. * Creates a new raw cube texture from a specified url
  79815. * @param url defines the url where the data is located
  79816. * @param scene defines the current scene
  79817. * @param size defines the size of the textures
  79818. * @param format defines the format of the data
  79819. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79820. * @param noMipmap defines if the engine should avoid generating the mip levels
  79821. * @param callback defines a callback used to extract texture data from loaded data
  79822. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79823. * @param onLoad defines a callback called when texture is loaded
  79824. * @param onError defines a callback called if there is an error
  79825. * @returns the cube texture as an InternalTexture
  79826. */
  79827. 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;
  79828. /**
  79829. * Creates a new raw cube texture from a specified url
  79830. * @param url defines the url where the data is located
  79831. * @param scene defines the current scene
  79832. * @param size defines the size of the textures
  79833. * @param format defines the format of the data
  79834. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79835. * @param noMipmap defines if the engine should avoid generating the mip levels
  79836. * @param callback defines a callback used to extract texture data from loaded data
  79837. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79838. * @param onLoad defines a callback called when texture is loaded
  79839. * @param onError defines a callback called if there is an error
  79840. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79841. * @param invertY defines if data must be stored with Y axis inverted
  79842. * @returns the cube texture as an InternalTexture
  79843. */
  79844. 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;
  79845. /**
  79846. * Creates a new raw 3D texture
  79847. * @param data defines the data used to create the texture
  79848. * @param width defines the width of the texture
  79849. * @param height defines the height of the texture
  79850. * @param depth defines the depth of the texture
  79851. * @param format defines the format of the texture
  79852. * @param generateMipMaps defines if the engine must generate mip levels
  79853. * @param invertY defines if data must be stored with Y axis inverted
  79854. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79855. * @param compression defines the compressed used (can be null)
  79856. * @param textureType defines the compressed used (can be null)
  79857. * @returns a new raw 3D texture (stored in an InternalTexture)
  79858. */
  79859. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79860. /**
  79861. * Update a raw 3D texture
  79862. * @param texture defines the texture to update
  79863. * @param data defines the data to store
  79864. * @param format defines the data format
  79865. * @param invertY defines if data must be stored with Y axis inverted
  79866. */
  79867. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79868. /**
  79869. * Update a raw 3D texture
  79870. * @param texture defines the texture to update
  79871. * @param data defines the data to store
  79872. * @param format defines the data format
  79873. * @param invertY defines if data must be stored with Y axis inverted
  79874. * @param compression defines the used compression (can be null)
  79875. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79876. */
  79877. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79878. }
  79879. }
  79880. declare module BABYLON {
  79881. /**
  79882. * Raw texture can help creating a texture directly from an array of data.
  79883. * This can be super useful if you either get the data from an uncompressed source or
  79884. * if you wish to create your texture pixel by pixel.
  79885. */
  79886. export class RawTexture extends Texture {
  79887. /**
  79888. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79889. */
  79890. format: number;
  79891. private _engine;
  79892. /**
  79893. * Instantiates a new RawTexture.
  79894. * Raw texture can help creating a texture directly from an array of data.
  79895. * This can be super useful if you either get the data from an uncompressed source or
  79896. * if you wish to create your texture pixel by pixel.
  79897. * @param data define the array of data to use to create the texture
  79898. * @param width define the width of the texture
  79899. * @param height define the height of the texture
  79900. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79901. * @param scene define the scene the texture belongs to
  79902. * @param generateMipMaps define whether mip maps should be generated or not
  79903. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79904. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79905. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79906. */
  79907. constructor(data: ArrayBufferView, width: number, height: number,
  79908. /**
  79909. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79910. */
  79911. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79912. /**
  79913. * Updates the texture underlying data.
  79914. * @param data Define the new data of the texture
  79915. */
  79916. update(data: ArrayBufferView): void;
  79917. /**
  79918. * Creates a luminance texture from some data.
  79919. * @param data Define the texture data
  79920. * @param width Define the width of the texture
  79921. * @param height Define the height of the texture
  79922. * @param scene Define the scene the texture belongs to
  79923. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79924. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79925. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79926. * @returns the luminance texture
  79927. */
  79928. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79929. /**
  79930. * Creates a luminance alpha texture from some data.
  79931. * @param data Define the texture data
  79932. * @param width Define the width of the texture
  79933. * @param height Define the height of the texture
  79934. * @param scene Define the scene the texture belongs to
  79935. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79936. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79937. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79938. * @returns the luminance alpha texture
  79939. */
  79940. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79941. /**
  79942. * Creates an alpha texture from some data.
  79943. * @param data Define the texture data
  79944. * @param width Define the width of the texture
  79945. * @param height Define the height of the texture
  79946. * @param scene Define the scene the texture belongs to
  79947. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79948. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79949. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79950. * @returns the alpha texture
  79951. */
  79952. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79953. /**
  79954. * Creates a RGB texture from some data.
  79955. * @param data Define the texture data
  79956. * @param width Define the width of the texture
  79957. * @param height Define the height of the texture
  79958. * @param scene Define the scene the texture belongs to
  79959. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79960. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79961. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79962. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79963. * @returns the RGB alpha texture
  79964. */
  79965. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79966. /**
  79967. * Creates a RGBA texture from some data.
  79968. * @param data Define the texture data
  79969. * @param width Define the width of the texture
  79970. * @param height Define the height of the texture
  79971. * @param scene Define the scene the texture belongs to
  79972. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79973. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79974. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79975. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79976. * @returns the RGBA texture
  79977. */
  79978. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79979. /**
  79980. * Creates a R texture from some data.
  79981. * @param data Define the texture data
  79982. * @param width Define the width of the texture
  79983. * @param height Define the height of the texture
  79984. * @param scene Define the scene the texture belongs to
  79985. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79986. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79987. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79988. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79989. * @returns the R texture
  79990. */
  79991. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79992. }
  79993. }
  79994. declare module BABYLON {
  79995. /**
  79996. * Interface for the size containing width and height
  79997. */
  79998. export interface ISize {
  79999. /**
  80000. * Width
  80001. */
  80002. width: number;
  80003. /**
  80004. * Heighht
  80005. */
  80006. height: number;
  80007. }
  80008. /**
  80009. * Size containing widht and height
  80010. */
  80011. export class Size implements ISize {
  80012. /**
  80013. * Width
  80014. */
  80015. width: number;
  80016. /**
  80017. * Height
  80018. */
  80019. height: number;
  80020. /**
  80021. * Creates a Size object from the given width and height (floats).
  80022. * @param width width of the new size
  80023. * @param height height of the new size
  80024. */
  80025. constructor(width: number, height: number);
  80026. /**
  80027. * Returns a string with the Size width and height
  80028. * @returns a string with the Size width and height
  80029. */
  80030. toString(): string;
  80031. /**
  80032. * "Size"
  80033. * @returns the string "Size"
  80034. */
  80035. getClassName(): string;
  80036. /**
  80037. * Returns the Size hash code.
  80038. * @returns a hash code for a unique width and height
  80039. */
  80040. getHashCode(): number;
  80041. /**
  80042. * Updates the current size from the given one.
  80043. * @param src the given size
  80044. */
  80045. copyFrom(src: Size): void;
  80046. /**
  80047. * Updates in place the current Size from the given floats.
  80048. * @param width width of the new size
  80049. * @param height height of the new size
  80050. * @returns the updated Size.
  80051. */
  80052. copyFromFloats(width: number, height: number): Size;
  80053. /**
  80054. * Updates in place the current Size from the given floats.
  80055. * @param width width to set
  80056. * @param height height to set
  80057. * @returns the updated Size.
  80058. */
  80059. set(width: number, height: number): Size;
  80060. /**
  80061. * Multiplies the width and height by numbers
  80062. * @param w factor to multiple the width by
  80063. * @param h factor to multiple the height by
  80064. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80065. */
  80066. multiplyByFloats(w: number, h: number): Size;
  80067. /**
  80068. * Clones the size
  80069. * @returns a new Size copied from the given one.
  80070. */
  80071. clone(): Size;
  80072. /**
  80073. * True if the current Size and the given one width and height are strictly equal.
  80074. * @param other the other size to compare against
  80075. * @returns True if the current Size and the given one width and height are strictly equal.
  80076. */
  80077. equals(other: Size): boolean;
  80078. /**
  80079. * The surface of the Size : width * height (float).
  80080. */
  80081. readonly surface: number;
  80082. /**
  80083. * Create a new size of zero
  80084. * @returns a new Size set to (0.0, 0.0)
  80085. */
  80086. static Zero(): Size;
  80087. /**
  80088. * Sums the width and height of two sizes
  80089. * @param otherSize size to add to this size
  80090. * @returns a new Size set as the addition result of the current Size and the given one.
  80091. */
  80092. add(otherSize: Size): Size;
  80093. /**
  80094. * Subtracts the width and height of two
  80095. * @param otherSize size to subtract to this size
  80096. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80097. */
  80098. subtract(otherSize: Size): Size;
  80099. /**
  80100. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80101. * @param start starting size to lerp between
  80102. * @param end end size to lerp between
  80103. * @param amount amount to lerp between the start and end values
  80104. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80105. */
  80106. static Lerp(start: Size, end: Size, amount: number): Size;
  80107. }
  80108. }
  80109. declare module BABYLON {
  80110. /**
  80111. * Defines a runtime animation
  80112. */
  80113. export class RuntimeAnimation {
  80114. private _events;
  80115. /**
  80116. * The current frame of the runtime animation
  80117. */
  80118. private _currentFrame;
  80119. /**
  80120. * The animation used by the runtime animation
  80121. */
  80122. private _animation;
  80123. /**
  80124. * The target of the runtime animation
  80125. */
  80126. private _target;
  80127. /**
  80128. * The initiating animatable
  80129. */
  80130. private _host;
  80131. /**
  80132. * The original value of the runtime animation
  80133. */
  80134. private _originalValue;
  80135. /**
  80136. * The original blend value of the runtime animation
  80137. */
  80138. private _originalBlendValue;
  80139. /**
  80140. * The offsets cache of the runtime animation
  80141. */
  80142. private _offsetsCache;
  80143. /**
  80144. * The high limits cache of the runtime animation
  80145. */
  80146. private _highLimitsCache;
  80147. /**
  80148. * Specifies if the runtime animation has been stopped
  80149. */
  80150. private _stopped;
  80151. /**
  80152. * The blending factor of the runtime animation
  80153. */
  80154. private _blendingFactor;
  80155. /**
  80156. * The BabylonJS scene
  80157. */
  80158. private _scene;
  80159. /**
  80160. * The current value of the runtime animation
  80161. */
  80162. private _currentValue;
  80163. /** @hidden */
  80164. _animationState: _IAnimationState;
  80165. /**
  80166. * The active target of the runtime animation
  80167. */
  80168. private _activeTargets;
  80169. private _currentActiveTarget;
  80170. private _directTarget;
  80171. /**
  80172. * The target path of the runtime animation
  80173. */
  80174. private _targetPath;
  80175. /**
  80176. * The weight of the runtime animation
  80177. */
  80178. private _weight;
  80179. /**
  80180. * The ratio offset of the runtime animation
  80181. */
  80182. private _ratioOffset;
  80183. /**
  80184. * The previous delay of the runtime animation
  80185. */
  80186. private _previousDelay;
  80187. /**
  80188. * The previous ratio of the runtime animation
  80189. */
  80190. private _previousRatio;
  80191. private _enableBlending;
  80192. private _keys;
  80193. private _minFrame;
  80194. private _maxFrame;
  80195. private _minValue;
  80196. private _maxValue;
  80197. private _targetIsArray;
  80198. /**
  80199. * Gets the current frame of the runtime animation
  80200. */
  80201. readonly currentFrame: number;
  80202. /**
  80203. * Gets the weight of the runtime animation
  80204. */
  80205. readonly weight: number;
  80206. /**
  80207. * Gets the current value of the runtime animation
  80208. */
  80209. readonly currentValue: any;
  80210. /**
  80211. * Gets the target path of the runtime animation
  80212. */
  80213. readonly targetPath: string;
  80214. /**
  80215. * Gets the actual target of the runtime animation
  80216. */
  80217. readonly target: any;
  80218. /** @hidden */
  80219. _onLoop: () => void;
  80220. /**
  80221. * Create a new RuntimeAnimation object
  80222. * @param target defines the target of the animation
  80223. * @param animation defines the source animation object
  80224. * @param scene defines the hosting scene
  80225. * @param host defines the initiating Animatable
  80226. */
  80227. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80228. private _preparePath;
  80229. /**
  80230. * Gets the animation from the runtime animation
  80231. */
  80232. readonly animation: Animation;
  80233. /**
  80234. * Resets the runtime animation to the beginning
  80235. * @param restoreOriginal defines whether to restore the target property to the original value
  80236. */
  80237. reset(restoreOriginal?: boolean): void;
  80238. /**
  80239. * Specifies if the runtime animation is stopped
  80240. * @returns Boolean specifying if the runtime animation is stopped
  80241. */
  80242. isStopped(): boolean;
  80243. /**
  80244. * Disposes of the runtime animation
  80245. */
  80246. dispose(): void;
  80247. /**
  80248. * Apply the interpolated value to the target
  80249. * @param currentValue defines the value computed by the animation
  80250. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80251. */
  80252. setValue(currentValue: any, weight: number): void;
  80253. private _getOriginalValues;
  80254. private _setValue;
  80255. /**
  80256. * Gets the loop pmode of the runtime animation
  80257. * @returns Loop Mode
  80258. */
  80259. private _getCorrectLoopMode;
  80260. /**
  80261. * Move the current animation to a given frame
  80262. * @param frame defines the frame to move to
  80263. */
  80264. goToFrame(frame: number): void;
  80265. /**
  80266. * @hidden Internal use only
  80267. */
  80268. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80269. /**
  80270. * Execute the current animation
  80271. * @param delay defines the delay to add to the current frame
  80272. * @param from defines the lower bound of the animation range
  80273. * @param to defines the upper bound of the animation range
  80274. * @param loop defines if the current animation must loop
  80275. * @param speedRatio defines the current speed ratio
  80276. * @param weight defines the weight of the animation (default is -1 so no weight)
  80277. * @param onLoop optional callback called when animation loops
  80278. * @returns a boolean indicating if the animation is running
  80279. */
  80280. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80281. }
  80282. }
  80283. declare module BABYLON {
  80284. /**
  80285. * Class used to store an actual running animation
  80286. */
  80287. export class Animatable {
  80288. /** defines the target object */
  80289. target: any;
  80290. /** defines the starting frame number (default is 0) */
  80291. fromFrame: number;
  80292. /** defines the ending frame number (default is 100) */
  80293. toFrame: number;
  80294. /** defines if the animation must loop (default is false) */
  80295. loopAnimation: boolean;
  80296. /** defines a callback to call when animation ends if it is not looping */
  80297. onAnimationEnd?: (() => void) | null | undefined;
  80298. /** defines a callback to call when animation loops */
  80299. onAnimationLoop?: (() => void) | null | undefined;
  80300. private _localDelayOffset;
  80301. private _pausedDelay;
  80302. private _runtimeAnimations;
  80303. private _paused;
  80304. private _scene;
  80305. private _speedRatio;
  80306. private _weight;
  80307. private _syncRoot;
  80308. /**
  80309. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80310. * This will only apply for non looping animation (default is true)
  80311. */
  80312. disposeOnEnd: boolean;
  80313. /**
  80314. * Gets a boolean indicating if the animation has started
  80315. */
  80316. animationStarted: boolean;
  80317. /**
  80318. * Observer raised when the animation ends
  80319. */
  80320. onAnimationEndObservable: Observable<Animatable>;
  80321. /**
  80322. * Observer raised when the animation loops
  80323. */
  80324. onAnimationLoopObservable: Observable<Animatable>;
  80325. /**
  80326. * Gets the root Animatable used to synchronize and normalize animations
  80327. */
  80328. readonly syncRoot: Nullable<Animatable>;
  80329. /**
  80330. * Gets the current frame of the first RuntimeAnimation
  80331. * Used to synchronize Animatables
  80332. */
  80333. readonly masterFrame: number;
  80334. /**
  80335. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80336. */
  80337. weight: number;
  80338. /**
  80339. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80340. */
  80341. speedRatio: number;
  80342. /**
  80343. * Creates a new Animatable
  80344. * @param scene defines the hosting scene
  80345. * @param target defines the target object
  80346. * @param fromFrame defines the starting frame number (default is 0)
  80347. * @param toFrame defines the ending frame number (default is 100)
  80348. * @param loopAnimation defines if the animation must loop (default is false)
  80349. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80350. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80351. * @param animations defines a group of animation to add to the new Animatable
  80352. * @param onAnimationLoop defines a callback to call when animation loops
  80353. */
  80354. constructor(scene: Scene,
  80355. /** defines the target object */
  80356. target: any,
  80357. /** defines the starting frame number (default is 0) */
  80358. fromFrame?: number,
  80359. /** defines the ending frame number (default is 100) */
  80360. toFrame?: number,
  80361. /** defines if the animation must loop (default is false) */
  80362. loopAnimation?: boolean, speedRatio?: number,
  80363. /** defines a callback to call when animation ends if it is not looping */
  80364. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80365. /** defines a callback to call when animation loops */
  80366. onAnimationLoop?: (() => void) | null | undefined);
  80367. /**
  80368. * Synchronize and normalize current Animatable with a source Animatable
  80369. * This is useful when using animation weights and when animations are not of the same length
  80370. * @param root defines the root Animatable to synchronize with
  80371. * @returns the current Animatable
  80372. */
  80373. syncWith(root: Animatable): Animatable;
  80374. /**
  80375. * Gets the list of runtime animations
  80376. * @returns an array of RuntimeAnimation
  80377. */
  80378. getAnimations(): RuntimeAnimation[];
  80379. /**
  80380. * Adds more animations to the current animatable
  80381. * @param target defines the target of the animations
  80382. * @param animations defines the new animations to add
  80383. */
  80384. appendAnimations(target: any, animations: Animation[]): void;
  80385. /**
  80386. * Gets the source animation for a specific property
  80387. * @param property defines the propertyu to look for
  80388. * @returns null or the source animation for the given property
  80389. */
  80390. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80391. /**
  80392. * Gets the runtime animation for a specific property
  80393. * @param property defines the propertyu to look for
  80394. * @returns null or the runtime animation for the given property
  80395. */
  80396. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80397. /**
  80398. * Resets the animatable to its original state
  80399. */
  80400. reset(): void;
  80401. /**
  80402. * Allows the animatable to blend with current running animations
  80403. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80404. * @param blendingSpeed defines the blending speed to use
  80405. */
  80406. enableBlending(blendingSpeed: number): void;
  80407. /**
  80408. * Disable animation blending
  80409. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80410. */
  80411. disableBlending(): void;
  80412. /**
  80413. * Jump directly to a given frame
  80414. * @param frame defines the frame to jump to
  80415. */
  80416. goToFrame(frame: number): void;
  80417. /**
  80418. * Pause the animation
  80419. */
  80420. pause(): void;
  80421. /**
  80422. * Restart the animation
  80423. */
  80424. restart(): void;
  80425. private _raiseOnAnimationEnd;
  80426. /**
  80427. * Stop and delete the current animation
  80428. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80429. * @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)
  80430. */
  80431. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80432. /**
  80433. * Wait asynchronously for the animation to end
  80434. * @returns a promise which will be fullfilled when the animation ends
  80435. */
  80436. waitAsync(): Promise<Animatable>;
  80437. /** @hidden */
  80438. _animate(delay: number): boolean;
  80439. }
  80440. interface Scene {
  80441. /** @hidden */
  80442. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80443. /** @hidden */
  80444. _processLateAnimationBindingsForMatrices(holder: {
  80445. totalWeight: number;
  80446. animations: RuntimeAnimation[];
  80447. originalValue: Matrix;
  80448. }): any;
  80449. /** @hidden */
  80450. _processLateAnimationBindingsForQuaternions(holder: {
  80451. totalWeight: number;
  80452. animations: RuntimeAnimation[];
  80453. originalValue: Quaternion;
  80454. }, refQuaternion: Quaternion): Quaternion;
  80455. /** @hidden */
  80456. _processLateAnimationBindings(): void;
  80457. /**
  80458. * Will start the animation sequence of a given target
  80459. * @param target defines the target
  80460. * @param from defines from which frame should animation start
  80461. * @param to defines until which frame should animation run.
  80462. * @param weight defines the weight to apply to the animation (1.0 by default)
  80463. * @param loop defines if the animation loops
  80464. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80465. * @param onAnimationEnd defines the function to be executed when the animation ends
  80466. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80467. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80468. * @param onAnimationLoop defines the callback to call when an animation loops
  80469. * @returns the animatable object created for this animation
  80470. */
  80471. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80472. /**
  80473. * Will start the animation sequence of a given target
  80474. * @param target defines the target
  80475. * @param from defines from which frame should animation start
  80476. * @param to defines until which frame should animation run.
  80477. * @param loop defines if the animation loops
  80478. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80479. * @param onAnimationEnd defines the function to be executed when the animation ends
  80480. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80481. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80482. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80483. * @param onAnimationLoop defines the callback to call when an animation loops
  80484. * @returns the animatable object created for this animation
  80485. */
  80486. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80487. /**
  80488. * Will start the animation sequence of a given target and its hierarchy
  80489. * @param target defines the target
  80490. * @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.
  80491. * @param from defines from which frame should animation start
  80492. * @param to defines until which frame should animation run.
  80493. * @param loop defines if the animation loops
  80494. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80495. * @param onAnimationEnd defines the function to be executed when the animation ends
  80496. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80497. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80498. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80499. * @param onAnimationLoop defines the callback to call when an animation loops
  80500. * @returns the list of created animatables
  80501. */
  80502. 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[];
  80503. /**
  80504. * Begin a new animation on a given node
  80505. * @param target defines the target where the animation will take place
  80506. * @param animations defines the list of animations to start
  80507. * @param from defines the initial value
  80508. * @param to defines the final value
  80509. * @param loop defines if you want animation to loop (off by default)
  80510. * @param speedRatio defines the speed ratio to apply to all animations
  80511. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80512. * @param onAnimationLoop defines the callback to call when an animation loops
  80513. * @returns the list of created animatables
  80514. */
  80515. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80516. /**
  80517. * Begin a new animation on a given node and its hierarchy
  80518. * @param target defines the root node where the animation will take place
  80519. * @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.
  80520. * @param animations defines the list of animations to start
  80521. * @param from defines the initial value
  80522. * @param to defines the final value
  80523. * @param loop defines if you want animation to loop (off by default)
  80524. * @param speedRatio defines the speed ratio to apply to all animations
  80525. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80526. * @param onAnimationLoop defines the callback to call when an animation loops
  80527. * @returns the list of animatables created for all nodes
  80528. */
  80529. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80530. /**
  80531. * Gets the animatable associated with a specific target
  80532. * @param target defines the target of the animatable
  80533. * @returns the required animatable if found
  80534. */
  80535. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80536. /**
  80537. * Gets all animatables associated with a given target
  80538. * @param target defines the target to look animatables for
  80539. * @returns an array of Animatables
  80540. */
  80541. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80542. /**
  80543. * Stops and removes all animations that have been applied to the scene
  80544. */
  80545. stopAllAnimations(): void;
  80546. /**
  80547. * Gets the current delta time used by animation engine
  80548. */
  80549. deltaTime: number;
  80550. }
  80551. interface Bone {
  80552. /**
  80553. * Copy an animation range from another bone
  80554. * @param source defines the source bone
  80555. * @param rangeName defines the range name to copy
  80556. * @param frameOffset defines the frame offset
  80557. * @param rescaleAsRequired defines if rescaling must be applied if required
  80558. * @param skelDimensionsRatio defines the scaling ratio
  80559. * @returns true if operation was successful
  80560. */
  80561. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80562. }
  80563. }
  80564. declare module BABYLON {
  80565. /**
  80566. * Class used to override all child animations of a given target
  80567. */
  80568. export class AnimationPropertiesOverride {
  80569. /**
  80570. * Gets or sets a value indicating if animation blending must be used
  80571. */
  80572. enableBlending: boolean;
  80573. /**
  80574. * Gets or sets the blending speed to use when enableBlending is true
  80575. */
  80576. blendingSpeed: number;
  80577. /**
  80578. * Gets or sets the default loop mode to use
  80579. */
  80580. loopMode: number;
  80581. }
  80582. }
  80583. declare module BABYLON {
  80584. /**
  80585. * Class used to handle skinning animations
  80586. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80587. */
  80588. export class Skeleton implements IAnimatable {
  80589. /** defines the skeleton name */
  80590. name: string;
  80591. /** defines the skeleton Id */
  80592. id: string;
  80593. /**
  80594. * Defines the list of child bones
  80595. */
  80596. bones: Bone[];
  80597. /**
  80598. * Defines an estimate of the dimension of the skeleton at rest
  80599. */
  80600. dimensionsAtRest: Vector3;
  80601. /**
  80602. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80603. */
  80604. needInitialSkinMatrix: boolean;
  80605. /**
  80606. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80607. */
  80608. overrideMesh: Nullable<AbstractMesh>;
  80609. /**
  80610. * Gets the list of animations attached to this skeleton
  80611. */
  80612. animations: Array<Animation>;
  80613. private _scene;
  80614. private _isDirty;
  80615. private _transformMatrices;
  80616. private _transformMatrixTexture;
  80617. private _meshesWithPoseMatrix;
  80618. private _animatables;
  80619. private _identity;
  80620. private _synchronizedWithMesh;
  80621. private _ranges;
  80622. private _lastAbsoluteTransformsUpdateId;
  80623. private _canUseTextureForBones;
  80624. private _uniqueId;
  80625. /** @hidden */
  80626. _numBonesWithLinkedTransformNode: number;
  80627. /** @hidden */
  80628. _hasWaitingData: Nullable<boolean>;
  80629. /**
  80630. * Specifies if the skeleton should be serialized
  80631. */
  80632. doNotSerialize: boolean;
  80633. private _useTextureToStoreBoneMatrices;
  80634. /**
  80635. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80636. * Please note that this option is not available if the hardware does not support it
  80637. */
  80638. useTextureToStoreBoneMatrices: boolean;
  80639. private _animationPropertiesOverride;
  80640. /**
  80641. * Gets or sets the animation properties override
  80642. */
  80643. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80644. /**
  80645. * List of inspectable custom properties (used by the Inspector)
  80646. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80647. */
  80648. inspectableCustomProperties: IInspectable[];
  80649. /**
  80650. * An observable triggered before computing the skeleton's matrices
  80651. */
  80652. onBeforeComputeObservable: Observable<Skeleton>;
  80653. /**
  80654. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80655. */
  80656. readonly isUsingTextureForMatrices: boolean;
  80657. /**
  80658. * Gets the unique ID of this skeleton
  80659. */
  80660. readonly uniqueId: number;
  80661. /**
  80662. * Creates a new skeleton
  80663. * @param name defines the skeleton name
  80664. * @param id defines the skeleton Id
  80665. * @param scene defines the hosting scene
  80666. */
  80667. constructor(
  80668. /** defines the skeleton name */
  80669. name: string,
  80670. /** defines the skeleton Id */
  80671. id: string, scene: Scene);
  80672. /**
  80673. * Gets the current object class name.
  80674. * @return the class name
  80675. */
  80676. getClassName(): string;
  80677. /**
  80678. * Returns an array containing the root bones
  80679. * @returns an array containing the root bones
  80680. */
  80681. getChildren(): Array<Bone>;
  80682. /**
  80683. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80684. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80685. * @returns a Float32Array containing matrices data
  80686. */
  80687. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80688. /**
  80689. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80690. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80691. * @returns a raw texture containing the data
  80692. */
  80693. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80694. /**
  80695. * Gets the current hosting scene
  80696. * @returns a scene object
  80697. */
  80698. getScene(): Scene;
  80699. /**
  80700. * Gets a string representing the current skeleton data
  80701. * @param fullDetails defines a boolean indicating if we want a verbose version
  80702. * @returns a string representing the current skeleton data
  80703. */
  80704. toString(fullDetails?: boolean): string;
  80705. /**
  80706. * Get bone's index searching by name
  80707. * @param name defines bone's name to search for
  80708. * @return the indice of the bone. Returns -1 if not found
  80709. */
  80710. getBoneIndexByName(name: string): number;
  80711. /**
  80712. * Creater a new animation range
  80713. * @param name defines the name of the range
  80714. * @param from defines the start key
  80715. * @param to defines the end key
  80716. */
  80717. createAnimationRange(name: string, from: number, to: number): void;
  80718. /**
  80719. * Delete a specific animation range
  80720. * @param name defines the name of the range
  80721. * @param deleteFrames defines if frames must be removed as well
  80722. */
  80723. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80724. /**
  80725. * Gets a specific animation range
  80726. * @param name defines the name of the range to look for
  80727. * @returns the requested animation range or null if not found
  80728. */
  80729. getAnimationRange(name: string): Nullable<AnimationRange>;
  80730. /**
  80731. * Gets the list of all animation ranges defined on this skeleton
  80732. * @returns an array
  80733. */
  80734. getAnimationRanges(): Nullable<AnimationRange>[];
  80735. /**
  80736. * Copy animation range from a source skeleton.
  80737. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80738. * @param source defines the source skeleton
  80739. * @param name defines the name of the range to copy
  80740. * @param rescaleAsRequired defines if rescaling must be applied if required
  80741. * @returns true if operation was successful
  80742. */
  80743. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80744. /**
  80745. * Forces the skeleton to go to rest pose
  80746. */
  80747. returnToRest(): void;
  80748. private _getHighestAnimationFrame;
  80749. /**
  80750. * Begin a specific animation range
  80751. * @param name defines the name of the range to start
  80752. * @param loop defines if looping must be turned on (false by default)
  80753. * @param speedRatio defines the speed ratio to apply (1 by default)
  80754. * @param onAnimationEnd defines a callback which will be called when animation will end
  80755. * @returns a new animatable
  80756. */
  80757. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80758. /** @hidden */
  80759. _markAsDirty(): void;
  80760. /** @hidden */
  80761. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80762. /** @hidden */
  80763. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80764. private _computeTransformMatrices;
  80765. /**
  80766. * Build all resources required to render a skeleton
  80767. */
  80768. prepare(): void;
  80769. /**
  80770. * Gets the list of animatables currently running for this skeleton
  80771. * @returns an array of animatables
  80772. */
  80773. getAnimatables(): IAnimatable[];
  80774. /**
  80775. * Clone the current skeleton
  80776. * @param name defines the name of the new skeleton
  80777. * @param id defines the id of the new skeleton
  80778. * @returns the new skeleton
  80779. */
  80780. clone(name: string, id: string): Skeleton;
  80781. /**
  80782. * Enable animation blending for this skeleton
  80783. * @param blendingSpeed defines the blending speed to apply
  80784. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80785. */
  80786. enableBlending(blendingSpeed?: number): void;
  80787. /**
  80788. * Releases all resources associated with the current skeleton
  80789. */
  80790. dispose(): void;
  80791. /**
  80792. * Serialize the skeleton in a JSON object
  80793. * @returns a JSON object
  80794. */
  80795. serialize(): any;
  80796. /**
  80797. * Creates a new skeleton from serialized data
  80798. * @param parsedSkeleton defines the serialized data
  80799. * @param scene defines the hosting scene
  80800. * @returns a new skeleton
  80801. */
  80802. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80803. /**
  80804. * Compute all node absolute transforms
  80805. * @param forceUpdate defines if computation must be done even if cache is up to date
  80806. */
  80807. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80808. /**
  80809. * Gets the root pose matrix
  80810. * @returns a matrix
  80811. */
  80812. getPoseMatrix(): Nullable<Matrix>;
  80813. /**
  80814. * Sorts bones per internal index
  80815. */
  80816. sortBones(): void;
  80817. private _sortBones;
  80818. }
  80819. }
  80820. declare module BABYLON {
  80821. /**
  80822. * Class used to store bone information
  80823. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80824. */
  80825. export class Bone extends Node {
  80826. /**
  80827. * defines the bone name
  80828. */
  80829. name: string;
  80830. private static _tmpVecs;
  80831. private static _tmpQuat;
  80832. private static _tmpMats;
  80833. /**
  80834. * Gets the list of child bones
  80835. */
  80836. children: Bone[];
  80837. /** Gets the animations associated with this bone */
  80838. animations: Animation[];
  80839. /**
  80840. * Gets or sets bone length
  80841. */
  80842. length: number;
  80843. /**
  80844. * @hidden Internal only
  80845. * Set this value to map this bone to a different index in the transform matrices
  80846. * Set this value to -1 to exclude the bone from the transform matrices
  80847. */
  80848. _index: Nullable<number>;
  80849. private _skeleton;
  80850. private _localMatrix;
  80851. private _restPose;
  80852. private _baseMatrix;
  80853. private _absoluteTransform;
  80854. private _invertedAbsoluteTransform;
  80855. private _parent;
  80856. private _scalingDeterminant;
  80857. private _worldTransform;
  80858. private _localScaling;
  80859. private _localRotation;
  80860. private _localPosition;
  80861. private _needToDecompose;
  80862. private _needToCompose;
  80863. /** @hidden */
  80864. _linkedTransformNode: Nullable<TransformNode>;
  80865. /** @hidden */
  80866. _waitingTransformNodeId: Nullable<string>;
  80867. /** @hidden */
  80868. /** @hidden */
  80869. _matrix: Matrix;
  80870. /**
  80871. * Create a new bone
  80872. * @param name defines the bone name
  80873. * @param skeleton defines the parent skeleton
  80874. * @param parentBone defines the parent (can be null if the bone is the root)
  80875. * @param localMatrix defines the local matrix
  80876. * @param restPose defines the rest pose matrix
  80877. * @param baseMatrix defines the base matrix
  80878. * @param index defines index of the bone in the hiearchy
  80879. */
  80880. constructor(
  80881. /**
  80882. * defines the bone name
  80883. */
  80884. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80885. /**
  80886. * Gets the current object class name.
  80887. * @return the class name
  80888. */
  80889. getClassName(): string;
  80890. /**
  80891. * Gets the parent skeleton
  80892. * @returns a skeleton
  80893. */
  80894. getSkeleton(): Skeleton;
  80895. /**
  80896. * Gets parent bone
  80897. * @returns a bone or null if the bone is the root of the bone hierarchy
  80898. */
  80899. getParent(): Nullable<Bone>;
  80900. /**
  80901. * Returns an array containing the root bones
  80902. * @returns an array containing the root bones
  80903. */
  80904. getChildren(): Array<Bone>;
  80905. /**
  80906. * Sets the parent bone
  80907. * @param parent defines the parent (can be null if the bone is the root)
  80908. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80909. */
  80910. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80911. /**
  80912. * Gets the local matrix
  80913. * @returns a matrix
  80914. */
  80915. getLocalMatrix(): Matrix;
  80916. /**
  80917. * Gets the base matrix (initial matrix which remains unchanged)
  80918. * @returns a matrix
  80919. */
  80920. getBaseMatrix(): Matrix;
  80921. /**
  80922. * Gets the rest pose matrix
  80923. * @returns a matrix
  80924. */
  80925. getRestPose(): Matrix;
  80926. /**
  80927. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80928. */
  80929. getWorldMatrix(): Matrix;
  80930. /**
  80931. * Sets the local matrix to rest pose matrix
  80932. */
  80933. returnToRest(): void;
  80934. /**
  80935. * Gets the inverse of the absolute transform matrix.
  80936. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80937. * @returns a matrix
  80938. */
  80939. getInvertedAbsoluteTransform(): Matrix;
  80940. /**
  80941. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80942. * @returns a matrix
  80943. */
  80944. getAbsoluteTransform(): Matrix;
  80945. /**
  80946. * Links with the given transform node.
  80947. * The local matrix of this bone is copied from the transform node every frame.
  80948. * @param transformNode defines the transform node to link to
  80949. */
  80950. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80951. /**
  80952. * Gets the node used to drive the bone's transformation
  80953. * @returns a transform node or null
  80954. */
  80955. getTransformNode(): Nullable<TransformNode>;
  80956. /** Gets or sets current position (in local space) */
  80957. position: Vector3;
  80958. /** Gets or sets current rotation (in local space) */
  80959. rotation: Vector3;
  80960. /** Gets or sets current rotation quaternion (in local space) */
  80961. rotationQuaternion: Quaternion;
  80962. /** Gets or sets current scaling (in local space) */
  80963. scaling: Vector3;
  80964. /**
  80965. * Gets the animation properties override
  80966. */
  80967. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80968. private _decompose;
  80969. private _compose;
  80970. /**
  80971. * Update the base and local matrices
  80972. * @param matrix defines the new base or local matrix
  80973. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80974. * @param updateLocalMatrix defines if the local matrix should be updated
  80975. */
  80976. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80977. /** @hidden */
  80978. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80979. /**
  80980. * Flag the bone as dirty (Forcing it to update everything)
  80981. */
  80982. markAsDirty(): void;
  80983. /** @hidden */
  80984. _markAsDirtyAndCompose(): void;
  80985. private _markAsDirtyAndDecompose;
  80986. /**
  80987. * Translate the bone in local or world space
  80988. * @param vec The amount to translate the bone
  80989. * @param space The space that the translation is in
  80990. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80991. */
  80992. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80993. /**
  80994. * Set the postion of the bone in local or world space
  80995. * @param position The position to set the bone
  80996. * @param space The space that the position is in
  80997. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80998. */
  80999. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81000. /**
  81001. * Set the absolute position of the bone (world space)
  81002. * @param position The position to set the bone
  81003. * @param mesh The mesh that this bone is attached to
  81004. */
  81005. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81006. /**
  81007. * Scale the bone on the x, y and z axes (in local space)
  81008. * @param x The amount to scale the bone on the x axis
  81009. * @param y The amount to scale the bone on the y axis
  81010. * @param z The amount to scale the bone on the z axis
  81011. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81012. */
  81013. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81014. /**
  81015. * Set the bone scaling in local space
  81016. * @param scale defines the scaling vector
  81017. */
  81018. setScale(scale: Vector3): void;
  81019. /**
  81020. * Gets the current scaling in local space
  81021. * @returns the current scaling vector
  81022. */
  81023. getScale(): Vector3;
  81024. /**
  81025. * Gets the current scaling in local space and stores it in a target vector
  81026. * @param result defines the target vector
  81027. */
  81028. getScaleToRef(result: Vector3): void;
  81029. /**
  81030. * Set the yaw, pitch, and roll of the bone in local or world space
  81031. * @param yaw The rotation of the bone on the y axis
  81032. * @param pitch The rotation of the bone on the x axis
  81033. * @param roll The rotation of the bone on the z axis
  81034. * @param space The space that the axes of rotation are in
  81035. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81036. */
  81037. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81038. /**
  81039. * Add a rotation to the bone on an axis in local or world space
  81040. * @param axis The axis to rotate the bone on
  81041. * @param amount The amount to rotate the bone
  81042. * @param space The space that the axis is in
  81043. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81044. */
  81045. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81046. /**
  81047. * Set the rotation of the bone to a particular axis angle in local or world space
  81048. * @param axis The axis to rotate the bone on
  81049. * @param angle The angle that the bone should be rotated to
  81050. * @param space The space that the axis is in
  81051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81052. */
  81053. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81054. /**
  81055. * Set the euler rotation of the bone in local of world space
  81056. * @param rotation The euler rotation that the bone should be set to
  81057. * @param space The space that the rotation is in
  81058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81059. */
  81060. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81061. /**
  81062. * Set the quaternion rotation of the bone in local of world space
  81063. * @param quat The quaternion rotation that the bone should be set to
  81064. * @param space The space that the rotation is in
  81065. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81066. */
  81067. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81068. /**
  81069. * Set the rotation matrix of the bone in local of world space
  81070. * @param rotMat The rotation matrix that the bone should be set to
  81071. * @param space The space that the rotation is in
  81072. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81073. */
  81074. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81075. private _rotateWithMatrix;
  81076. private _getNegativeRotationToRef;
  81077. /**
  81078. * Get the position of the bone in local or world space
  81079. * @param space The space that the returned position is in
  81080. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81081. * @returns The position of the bone
  81082. */
  81083. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81084. /**
  81085. * Copy the position of the bone to a vector3 in local or world space
  81086. * @param space The space that the returned position is in
  81087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81088. * @param result The vector3 to copy the position to
  81089. */
  81090. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81091. /**
  81092. * Get the absolute position of the bone (world space)
  81093. * @param mesh The mesh that this bone is attached to
  81094. * @returns The absolute position of the bone
  81095. */
  81096. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81097. /**
  81098. * Copy the absolute position of the bone (world space) to the result param
  81099. * @param mesh The mesh that this bone is attached to
  81100. * @param result The vector3 to copy the absolute position to
  81101. */
  81102. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81103. /**
  81104. * Compute the absolute transforms of this bone and its children
  81105. */
  81106. computeAbsoluteTransforms(): void;
  81107. /**
  81108. * Get the world direction from an axis that is in the local space of the bone
  81109. * @param localAxis The local direction that is used to compute the world direction
  81110. * @param mesh The mesh that this bone is attached to
  81111. * @returns The world direction
  81112. */
  81113. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81114. /**
  81115. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81116. * @param localAxis The local direction that is used to compute the world direction
  81117. * @param mesh The mesh that this bone is attached to
  81118. * @param result The vector3 that the world direction will be copied to
  81119. */
  81120. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81121. /**
  81122. * Get the euler rotation of the bone in local or world space
  81123. * @param space The space that the rotation should be in
  81124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81125. * @returns The euler rotation
  81126. */
  81127. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81128. /**
  81129. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81130. * @param space The space that the rotation should be in
  81131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81132. * @param result The vector3 that the rotation should be copied to
  81133. */
  81134. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81135. /**
  81136. * Get the quaternion rotation of the bone in either local or world space
  81137. * @param space The space that the rotation should be in
  81138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81139. * @returns The quaternion rotation
  81140. */
  81141. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81142. /**
  81143. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81144. * @param space The space that the rotation should be in
  81145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81146. * @param result The quaternion that the rotation should be copied to
  81147. */
  81148. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81149. /**
  81150. * Get the rotation matrix of the bone in local or world space
  81151. * @param space The space that the rotation should be in
  81152. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81153. * @returns The rotation matrix
  81154. */
  81155. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81156. /**
  81157. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  81158. * @param space The space that the rotation should be in
  81159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81160. * @param result The quaternion that the rotation should be copied to
  81161. */
  81162. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81163. /**
  81164. * Get the world position of a point that is in the local space of the bone
  81165. * @param position The local position
  81166. * @param mesh The mesh that this bone is attached to
  81167. * @returns The world position
  81168. */
  81169. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81170. /**
  81171. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81172. * @param position The local position
  81173. * @param mesh The mesh that this bone is attached to
  81174. * @param result The vector3 that the world position should be copied to
  81175. */
  81176. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81177. /**
  81178. * Get the local position of a point that is in world space
  81179. * @param position The world position
  81180. * @param mesh The mesh that this bone is attached to
  81181. * @returns The local position
  81182. */
  81183. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81184. /**
  81185. * Get the local position of a point that is in world space and copy it to the result param
  81186. * @param position The world position
  81187. * @param mesh The mesh that this bone is attached to
  81188. * @param result The vector3 that the local position should be copied to
  81189. */
  81190. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81191. }
  81192. }
  81193. declare module BABYLON {
  81194. /**
  81195. * 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.
  81196. * @see https://doc.babylonjs.com/how_to/transformnode
  81197. */
  81198. export class TransformNode extends Node {
  81199. /**
  81200. * Object will not rotate to face the camera
  81201. */
  81202. static BILLBOARDMODE_NONE: number;
  81203. /**
  81204. * Object will rotate to face the camera but only on the x axis
  81205. */
  81206. static BILLBOARDMODE_X: number;
  81207. /**
  81208. * Object will rotate to face the camera but only on the y axis
  81209. */
  81210. static BILLBOARDMODE_Y: number;
  81211. /**
  81212. * Object will rotate to face the camera but only on the z axis
  81213. */
  81214. static BILLBOARDMODE_Z: number;
  81215. /**
  81216. * Object will rotate to face the camera
  81217. */
  81218. static BILLBOARDMODE_ALL: number;
  81219. /**
  81220. * Object will rotate to face the camera's position instead of orientation
  81221. */
  81222. static BILLBOARDMODE_USE_POSITION: number;
  81223. private _forward;
  81224. private _forwardInverted;
  81225. private _up;
  81226. private _right;
  81227. private _rightInverted;
  81228. private _position;
  81229. private _rotation;
  81230. private _rotationQuaternion;
  81231. protected _scaling: Vector3;
  81232. protected _isDirty: boolean;
  81233. private _transformToBoneReferal;
  81234. private _isAbsoluteSynced;
  81235. private _billboardMode;
  81236. /**
  81237. * Gets or sets the billboard mode. Default is 0.
  81238. *
  81239. * | Value | Type | Description |
  81240. * | --- | --- | --- |
  81241. * | 0 | BILLBOARDMODE_NONE | |
  81242. * | 1 | BILLBOARDMODE_X | |
  81243. * | 2 | BILLBOARDMODE_Y | |
  81244. * | 4 | BILLBOARDMODE_Z | |
  81245. * | 7 | BILLBOARDMODE_ALL | |
  81246. *
  81247. */
  81248. billboardMode: number;
  81249. private _preserveParentRotationForBillboard;
  81250. /**
  81251. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81252. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81253. */
  81254. preserveParentRotationForBillboard: boolean;
  81255. /**
  81256. * 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
  81257. */
  81258. scalingDeterminant: number;
  81259. private _infiniteDistance;
  81260. /**
  81261. * Gets or sets the distance of the object to max, often used by skybox
  81262. */
  81263. infiniteDistance: boolean;
  81264. /**
  81265. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81266. * By default the system will update normals to compensate
  81267. */
  81268. ignoreNonUniformScaling: boolean;
  81269. /**
  81270. * 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
  81271. */
  81272. reIntegrateRotationIntoRotationQuaternion: boolean;
  81273. /** @hidden */
  81274. _poseMatrix: Nullable<Matrix>;
  81275. /** @hidden */
  81276. _localMatrix: Matrix;
  81277. private _usePivotMatrix;
  81278. private _absolutePosition;
  81279. private _absoluteScaling;
  81280. private _absoluteRotationQuaternion;
  81281. private _pivotMatrix;
  81282. private _pivotMatrixInverse;
  81283. protected _postMultiplyPivotMatrix: boolean;
  81284. protected _isWorldMatrixFrozen: boolean;
  81285. /** @hidden */
  81286. _indexInSceneTransformNodesArray: number;
  81287. /**
  81288. * An event triggered after the world matrix is updated
  81289. */
  81290. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81291. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81292. /**
  81293. * Gets a string identifying the name of the class
  81294. * @returns "TransformNode" string
  81295. */
  81296. getClassName(): string;
  81297. /**
  81298. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81299. */
  81300. position: Vector3;
  81301. /**
  81302. * 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)).
  81303. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81304. */
  81305. rotation: Vector3;
  81306. /**
  81307. * 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)).
  81308. */
  81309. scaling: Vector3;
  81310. /**
  81311. * 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).
  81312. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81313. */
  81314. rotationQuaternion: Nullable<Quaternion>;
  81315. /**
  81316. * The forward direction of that transform in world space.
  81317. */
  81318. readonly forward: Vector3;
  81319. /**
  81320. * The up direction of that transform in world space.
  81321. */
  81322. readonly up: Vector3;
  81323. /**
  81324. * The right direction of that transform in world space.
  81325. */
  81326. readonly right: Vector3;
  81327. /**
  81328. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81329. * @param matrix the matrix to copy the pose from
  81330. * @returns this TransformNode.
  81331. */
  81332. updatePoseMatrix(matrix: Matrix): TransformNode;
  81333. /**
  81334. * Returns the mesh Pose matrix.
  81335. * @returns the pose matrix
  81336. */
  81337. getPoseMatrix(): Matrix;
  81338. /** @hidden */
  81339. _isSynchronized(): boolean;
  81340. /** @hidden */
  81341. _initCache(): void;
  81342. /**
  81343. * Flag the transform node as dirty (Forcing it to update everything)
  81344. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81345. * @returns this transform node
  81346. */
  81347. markAsDirty(property: string): TransformNode;
  81348. /**
  81349. * Returns the current mesh absolute position.
  81350. * Returns a Vector3.
  81351. */
  81352. readonly absolutePosition: Vector3;
  81353. /**
  81354. * Returns the current mesh absolute scaling.
  81355. * Returns a Vector3.
  81356. */
  81357. readonly absoluteScaling: Vector3;
  81358. /**
  81359. * Returns the current mesh absolute rotation.
  81360. * Returns a Quaternion.
  81361. */
  81362. readonly absoluteRotationQuaternion: Quaternion;
  81363. /**
  81364. * Sets a new matrix to apply before all other transformation
  81365. * @param matrix defines the transform matrix
  81366. * @returns the current TransformNode
  81367. */
  81368. setPreTransformMatrix(matrix: Matrix): TransformNode;
  81369. /**
  81370. * Sets a new pivot matrix to the current node
  81371. * @param matrix defines the new pivot matrix to use
  81372. * @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
  81373. * @returns the current TransformNode
  81374. */
  81375. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  81376. /**
  81377. * Returns the mesh pivot matrix.
  81378. * Default : Identity.
  81379. * @returns the matrix
  81380. */
  81381. getPivotMatrix(): Matrix;
  81382. /**
  81383. * Instantiate (when possible) or clone that node with its hierarchy
  81384. * @param newParent defines the new parent to use for the instance (or clone)
  81385. * @returns an instance (or a clone) of the current node with its hiearchy
  81386. */
  81387. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  81388. /**
  81389. * Prevents the World matrix to be computed any longer
  81390. * @param newWorldMatrix defines an optional matrix to use as world matrix
  81391. * @returns the TransformNode.
  81392. */
  81393. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  81394. /**
  81395. * Allows back the World matrix computation.
  81396. * @returns the TransformNode.
  81397. */
  81398. unfreezeWorldMatrix(): this;
  81399. /**
  81400. * True if the World matrix has been frozen.
  81401. */
  81402. readonly isWorldMatrixFrozen: boolean;
  81403. /**
  81404. * Retuns the mesh absolute position in the World.
  81405. * @returns a Vector3.
  81406. */
  81407. getAbsolutePosition(): Vector3;
  81408. /**
  81409. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  81410. * @param absolutePosition the absolute position to set
  81411. * @returns the TransformNode.
  81412. */
  81413. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  81414. /**
  81415. * Sets the mesh position in its local space.
  81416. * @param vector3 the position to set in localspace
  81417. * @returns the TransformNode.
  81418. */
  81419. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  81420. /**
  81421. * Returns the mesh position in the local space from the current World matrix values.
  81422. * @returns a new Vector3.
  81423. */
  81424. getPositionExpressedInLocalSpace(): Vector3;
  81425. /**
  81426. * Translates the mesh along the passed Vector3 in its local space.
  81427. * @param vector3 the distance to translate in localspace
  81428. * @returns the TransformNode.
  81429. */
  81430. locallyTranslate(vector3: Vector3): TransformNode;
  81431. private static _lookAtVectorCache;
  81432. /**
  81433. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  81434. * @param targetPoint the position (must be in same space as current mesh) to look at
  81435. * @param yawCor optional yaw (y-axis) correction in radians
  81436. * @param pitchCor optional pitch (x-axis) correction in radians
  81437. * @param rollCor optional roll (z-axis) correction in radians
  81438. * @param space the choosen space of the target
  81439. * @returns the TransformNode.
  81440. */
  81441. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  81442. /**
  81443. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81444. * This Vector3 is expressed in the World space.
  81445. * @param localAxis axis to rotate
  81446. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81447. */
  81448. getDirection(localAxis: Vector3): Vector3;
  81449. /**
  81450. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  81451. * localAxis is expressed in the mesh local space.
  81452. * result is computed in the Wordl space from the mesh World matrix.
  81453. * @param localAxis axis to rotate
  81454. * @param result the resulting transformnode
  81455. * @returns this TransformNode.
  81456. */
  81457. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  81458. /**
  81459. * Sets this transform node rotation to the given local axis.
  81460. * @param localAxis the axis in local space
  81461. * @param yawCor optional yaw (y-axis) correction in radians
  81462. * @param pitchCor optional pitch (x-axis) correction in radians
  81463. * @param rollCor optional roll (z-axis) correction in radians
  81464. * @returns this TransformNode
  81465. */
  81466. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  81467. /**
  81468. * Sets a new pivot point to the current node
  81469. * @param point defines the new pivot point to use
  81470. * @param space defines if the point is in world or local space (local by default)
  81471. * @returns the current TransformNode
  81472. */
  81473. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  81474. /**
  81475. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  81476. * @returns the pivot point
  81477. */
  81478. getPivotPoint(): Vector3;
  81479. /**
  81480. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  81481. * @param result the vector3 to store the result
  81482. * @returns this TransformNode.
  81483. */
  81484. getPivotPointToRef(result: Vector3): TransformNode;
  81485. /**
  81486. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  81487. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  81488. */
  81489. getAbsolutePivotPoint(): Vector3;
  81490. /**
  81491. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  81492. * @param result vector3 to store the result
  81493. * @returns this TransformNode.
  81494. */
  81495. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  81496. /**
  81497. * Defines the passed node as the parent of the current node.
  81498. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  81499. * @see https://doc.babylonjs.com/how_to/parenting
  81500. * @param node the node ot set as the parent
  81501. * @returns this TransformNode.
  81502. */
  81503. setParent(node: Nullable<Node>): TransformNode;
  81504. private _nonUniformScaling;
  81505. /**
  81506. * True if the scaling property of this object is non uniform eg. (1,2,1)
  81507. */
  81508. readonly nonUniformScaling: boolean;
  81509. /** @hidden */
  81510. _updateNonUniformScalingState(value: boolean): boolean;
  81511. /**
  81512. * Attach the current TransformNode to another TransformNode associated with a bone
  81513. * @param bone Bone affecting the TransformNode
  81514. * @param affectedTransformNode TransformNode associated with the bone
  81515. * @returns this object
  81516. */
  81517. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  81518. /**
  81519. * Detach the transform node if its associated with a bone
  81520. * @returns this object
  81521. */
  81522. detachFromBone(): TransformNode;
  81523. private static _rotationAxisCache;
  81524. /**
  81525. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  81526. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81527. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81528. * The passed axis is also normalized.
  81529. * @param axis the axis to rotate around
  81530. * @param amount the amount to rotate in radians
  81531. * @param space Space to rotate in (Default: local)
  81532. * @returns the TransformNode.
  81533. */
  81534. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  81535. /**
  81536. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  81537. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81538. * The passed axis is also normalized. .
  81539. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  81540. * @param point the point to rotate around
  81541. * @param axis the axis to rotate around
  81542. * @param amount the amount to rotate in radians
  81543. * @returns the TransformNode
  81544. */
  81545. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  81546. /**
  81547. * Translates the mesh along the axis vector for the passed distance in the given space.
  81548. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81549. * @param axis the axis to translate in
  81550. * @param distance the distance to translate
  81551. * @param space Space to rotate in (Default: local)
  81552. * @returns the TransformNode.
  81553. */
  81554. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  81555. /**
  81556. * Adds a rotation step to the mesh current rotation.
  81557. * x, y, z are Euler angles expressed in radians.
  81558. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  81559. * This means this rotation is made in the mesh local space only.
  81560. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  81561. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  81562. * ```javascript
  81563. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  81564. * ```
  81565. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  81566. * 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.
  81567. * @param x Rotation to add
  81568. * @param y Rotation to add
  81569. * @param z Rotation to add
  81570. * @returns the TransformNode.
  81571. */
  81572. addRotation(x: number, y: number, z: number): TransformNode;
  81573. /**
  81574. * @hidden
  81575. */
  81576. protected _getEffectiveParent(): Nullable<Node>;
  81577. /**
  81578. * Computes the world matrix of the node
  81579. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81580. * @returns the world matrix
  81581. */
  81582. computeWorldMatrix(force?: boolean): Matrix;
  81583. protected _afterComputeWorldMatrix(): void;
  81584. /**
  81585. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  81586. * @param func callback function to add
  81587. *
  81588. * @returns the TransformNode.
  81589. */
  81590. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81591. /**
  81592. * Removes a registered callback function.
  81593. * @param func callback function to remove
  81594. * @returns the TransformNode.
  81595. */
  81596. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81597. /**
  81598. * Gets the position of the current mesh in camera space
  81599. * @param camera defines the camera to use
  81600. * @returns a position
  81601. */
  81602. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  81603. /**
  81604. * Returns the distance from the mesh to the active camera
  81605. * @param camera defines the camera to use
  81606. * @returns the distance
  81607. */
  81608. getDistanceToCamera(camera?: Nullable<Camera>): number;
  81609. /**
  81610. * Clone the current transform node
  81611. * @param name Name of the new clone
  81612. * @param newParent New parent for the clone
  81613. * @param doNotCloneChildren Do not clone children hierarchy
  81614. * @returns the new transform node
  81615. */
  81616. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  81617. /**
  81618. * Serializes the objects information.
  81619. * @param currentSerializationObject defines the object to serialize in
  81620. * @returns the serialized object
  81621. */
  81622. serialize(currentSerializationObject?: any): any;
  81623. /**
  81624. * Returns a new TransformNode object parsed from the source provided.
  81625. * @param parsedTransformNode is the source.
  81626. * @param scene the scne the object belongs to
  81627. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  81628. * @returns a new TransformNode object parsed from the source provided.
  81629. */
  81630. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  81631. /**
  81632. * Get all child-transformNodes of this node
  81633. * @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
  81634. * @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
  81635. * @returns an array of TransformNode
  81636. */
  81637. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81638. /**
  81639. * Releases resources associated with this transform node.
  81640. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81641. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81642. */
  81643. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81644. /**
  81645. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81646. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81647. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81648. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81649. * @returns the current mesh
  81650. */
  81651. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81652. private _syncAbsoluteScalingAndRotation;
  81653. }
  81654. }
  81655. declare module BABYLON {
  81656. /**
  81657. * Defines the types of pose enabled controllers that are supported
  81658. */
  81659. export enum PoseEnabledControllerType {
  81660. /**
  81661. * HTC Vive
  81662. */
  81663. VIVE = 0,
  81664. /**
  81665. * Oculus Rift
  81666. */
  81667. OCULUS = 1,
  81668. /**
  81669. * Windows mixed reality
  81670. */
  81671. WINDOWS = 2,
  81672. /**
  81673. * Samsung gear VR
  81674. */
  81675. GEAR_VR = 3,
  81676. /**
  81677. * Google Daydream
  81678. */
  81679. DAYDREAM = 4,
  81680. /**
  81681. * Generic
  81682. */
  81683. GENERIC = 5
  81684. }
  81685. /**
  81686. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81687. */
  81688. export interface MutableGamepadButton {
  81689. /**
  81690. * Value of the button/trigger
  81691. */
  81692. value: number;
  81693. /**
  81694. * If the button/trigger is currently touched
  81695. */
  81696. touched: boolean;
  81697. /**
  81698. * If the button/trigger is currently pressed
  81699. */
  81700. pressed: boolean;
  81701. }
  81702. /**
  81703. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81704. * @hidden
  81705. */
  81706. export interface ExtendedGamepadButton extends GamepadButton {
  81707. /**
  81708. * If the button/trigger is currently pressed
  81709. */
  81710. readonly pressed: boolean;
  81711. /**
  81712. * If the button/trigger is currently touched
  81713. */
  81714. readonly touched: boolean;
  81715. /**
  81716. * Value of the button/trigger
  81717. */
  81718. readonly value: number;
  81719. }
  81720. /** @hidden */
  81721. export interface _GamePadFactory {
  81722. /**
  81723. * Returns wether or not the current gamepad can be created for this type of controller.
  81724. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81725. * @returns true if it can be created, otherwise false
  81726. */
  81727. canCreate(gamepadInfo: any): boolean;
  81728. /**
  81729. * Creates a new instance of the Gamepad.
  81730. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81731. * @returns the new gamepad instance
  81732. */
  81733. create(gamepadInfo: any): Gamepad;
  81734. }
  81735. /**
  81736. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81737. */
  81738. export class PoseEnabledControllerHelper {
  81739. /** @hidden */
  81740. static _ControllerFactories: _GamePadFactory[];
  81741. /** @hidden */
  81742. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81743. /**
  81744. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81745. * @param vrGamepad the gamepad to initialized
  81746. * @returns a vr controller of the type the gamepad identified as
  81747. */
  81748. static InitiateController(vrGamepad: any): Gamepad;
  81749. }
  81750. /**
  81751. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81752. */
  81753. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81754. /**
  81755. * If the controller is used in a webXR session
  81756. */
  81757. isXR: boolean;
  81758. private _deviceRoomPosition;
  81759. private _deviceRoomRotationQuaternion;
  81760. /**
  81761. * The device position in babylon space
  81762. */
  81763. devicePosition: Vector3;
  81764. /**
  81765. * The device rotation in babylon space
  81766. */
  81767. deviceRotationQuaternion: Quaternion;
  81768. /**
  81769. * The scale factor of the device in babylon space
  81770. */
  81771. deviceScaleFactor: number;
  81772. /**
  81773. * (Likely devicePosition should be used instead) The device position in its room space
  81774. */
  81775. position: Vector3;
  81776. /**
  81777. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81778. */
  81779. rotationQuaternion: Quaternion;
  81780. /**
  81781. * The type of controller (Eg. Windows mixed reality)
  81782. */
  81783. controllerType: PoseEnabledControllerType;
  81784. protected _calculatedPosition: Vector3;
  81785. private _calculatedRotation;
  81786. /**
  81787. * The raw pose from the device
  81788. */
  81789. rawPose: DevicePose;
  81790. private _trackPosition;
  81791. private _maxRotationDistFromHeadset;
  81792. private _draggedRoomRotation;
  81793. /**
  81794. * @hidden
  81795. */
  81796. _disableTrackPosition(fixedPosition: Vector3): void;
  81797. /**
  81798. * Internal, the mesh attached to the controller
  81799. * @hidden
  81800. */
  81801. _mesh: Nullable<AbstractMesh>;
  81802. private _poseControlledCamera;
  81803. private _leftHandSystemQuaternion;
  81804. /**
  81805. * Internal, matrix used to convert room space to babylon space
  81806. * @hidden
  81807. */
  81808. _deviceToWorld: Matrix;
  81809. /**
  81810. * Node to be used when casting a ray from the controller
  81811. * @hidden
  81812. */
  81813. _pointingPoseNode: Nullable<TransformNode>;
  81814. /**
  81815. * Name of the child mesh that can be used to cast a ray from the controller
  81816. */
  81817. static readonly POINTING_POSE: string;
  81818. /**
  81819. * Creates a new PoseEnabledController from a gamepad
  81820. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81821. */
  81822. constructor(browserGamepad: any);
  81823. private _workingMatrix;
  81824. /**
  81825. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81826. */
  81827. update(): void;
  81828. /**
  81829. * Updates only the pose device and mesh without doing any button event checking
  81830. */
  81831. protected _updatePoseAndMesh(): void;
  81832. /**
  81833. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81834. * @param poseData raw pose fromthe device
  81835. */
  81836. updateFromDevice(poseData: DevicePose): void;
  81837. /**
  81838. * @hidden
  81839. */
  81840. _meshAttachedObservable: Observable<AbstractMesh>;
  81841. /**
  81842. * Attaches a mesh to the controller
  81843. * @param mesh the mesh to be attached
  81844. */
  81845. attachToMesh(mesh: AbstractMesh): void;
  81846. /**
  81847. * Attaches the controllers mesh to a camera
  81848. * @param camera the camera the mesh should be attached to
  81849. */
  81850. attachToPoseControlledCamera(camera: TargetCamera): void;
  81851. /**
  81852. * Disposes of the controller
  81853. */
  81854. dispose(): void;
  81855. /**
  81856. * The mesh that is attached to the controller
  81857. */
  81858. readonly mesh: Nullable<AbstractMesh>;
  81859. /**
  81860. * Gets the ray of the controller in the direction the controller is pointing
  81861. * @param length the length the resulting ray should be
  81862. * @returns a ray in the direction the controller is pointing
  81863. */
  81864. getForwardRay(length?: number): Ray;
  81865. }
  81866. }
  81867. declare module BABYLON {
  81868. /**
  81869. * Defines the WebVRController object that represents controllers tracked in 3D space
  81870. */
  81871. export abstract class WebVRController extends PoseEnabledController {
  81872. /**
  81873. * Internal, the default controller model for the controller
  81874. */
  81875. protected _defaultModel: Nullable<AbstractMesh>;
  81876. /**
  81877. * Fired when the trigger state has changed
  81878. */
  81879. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81880. /**
  81881. * Fired when the main button state has changed
  81882. */
  81883. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81884. /**
  81885. * Fired when the secondary button state has changed
  81886. */
  81887. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81888. /**
  81889. * Fired when the pad state has changed
  81890. */
  81891. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81892. /**
  81893. * Fired when controllers stick values have changed
  81894. */
  81895. onPadValuesChangedObservable: Observable<StickValues>;
  81896. /**
  81897. * Array of button availible on the controller
  81898. */
  81899. protected _buttons: Array<MutableGamepadButton>;
  81900. private _onButtonStateChange;
  81901. /**
  81902. * Fired when a controller button's state has changed
  81903. * @param callback the callback containing the button that was modified
  81904. */
  81905. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81906. /**
  81907. * X and Y axis corresponding to the controllers joystick
  81908. */
  81909. pad: StickValues;
  81910. /**
  81911. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81912. */
  81913. hand: string;
  81914. /**
  81915. * The default controller model for the controller
  81916. */
  81917. readonly defaultModel: Nullable<AbstractMesh>;
  81918. /**
  81919. * Creates a new WebVRController from a gamepad
  81920. * @param vrGamepad the gamepad that the WebVRController should be created from
  81921. */
  81922. constructor(vrGamepad: any);
  81923. /**
  81924. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81925. */
  81926. update(): void;
  81927. /**
  81928. * Function to be called when a button is modified
  81929. */
  81930. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81931. /**
  81932. * Loads a mesh and attaches it to the controller
  81933. * @param scene the scene the mesh should be added to
  81934. * @param meshLoaded callback for when the mesh has been loaded
  81935. */
  81936. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81937. private _setButtonValue;
  81938. private _changes;
  81939. private _checkChanges;
  81940. /**
  81941. * Disposes of th webVRCOntroller
  81942. */
  81943. dispose(): void;
  81944. }
  81945. }
  81946. declare module BABYLON {
  81947. /**
  81948. * The HemisphericLight simulates the ambient environment light,
  81949. * so the passed direction is the light reflection direction, not the incoming direction.
  81950. */
  81951. export class HemisphericLight extends Light {
  81952. /**
  81953. * The groundColor is the light in the opposite direction to the one specified during creation.
  81954. * 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.
  81955. */
  81956. groundColor: Color3;
  81957. /**
  81958. * The light reflection direction, not the incoming direction.
  81959. */
  81960. direction: Vector3;
  81961. /**
  81962. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81963. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81964. * The HemisphericLight can't cast shadows.
  81965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81966. * @param name The friendly name of the light
  81967. * @param direction The direction of the light reflection
  81968. * @param scene The scene the light belongs to
  81969. */
  81970. constructor(name: string, direction: Vector3, scene: Scene);
  81971. protected _buildUniformLayout(): void;
  81972. /**
  81973. * Returns the string "HemisphericLight".
  81974. * @return The class name
  81975. */
  81976. getClassName(): string;
  81977. /**
  81978. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81979. * Returns the updated direction.
  81980. * @param target The target the direction should point to
  81981. * @return The computed direction
  81982. */
  81983. setDirectionToTarget(target: Vector3): Vector3;
  81984. /**
  81985. * Returns the shadow generator associated to the light.
  81986. * @returns Always null for hemispheric lights because it does not support shadows.
  81987. */
  81988. getShadowGenerator(): Nullable<IShadowGenerator>;
  81989. /**
  81990. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81991. * @param effect The effect to update
  81992. * @param lightIndex The index of the light in the effect to update
  81993. * @returns The hemispheric light
  81994. */
  81995. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81996. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81997. /**
  81998. * Computes the world matrix of the node
  81999. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82000. * @param useWasUpdatedFlag defines a reserved property
  82001. * @returns the world matrix
  82002. */
  82003. computeWorldMatrix(): Matrix;
  82004. /**
  82005. * Returns the integer 3.
  82006. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82007. */
  82008. getTypeID(): number;
  82009. /**
  82010. * Prepares the list of defines specific to the light type.
  82011. * @param defines the list of defines
  82012. * @param lightIndex defines the index of the light for the effect
  82013. */
  82014. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82015. }
  82016. }
  82017. declare module BABYLON {
  82018. /** @hidden */
  82019. export var vrMultiviewToSingleviewPixelShader: {
  82020. name: string;
  82021. shader: string;
  82022. };
  82023. }
  82024. declare module BABYLON {
  82025. /**
  82026. * Renders to multiple views with a single draw call
  82027. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82028. */
  82029. export class MultiviewRenderTarget extends RenderTargetTexture {
  82030. /**
  82031. * Creates a multiview render target
  82032. * @param scene scene used with the render target
  82033. * @param size the size of the render target (used for each view)
  82034. */
  82035. constructor(scene: Scene, size?: number | {
  82036. width: number;
  82037. height: number;
  82038. } | {
  82039. ratio: number;
  82040. });
  82041. /**
  82042. * @hidden
  82043. * @param faceIndex the face index, if its a cube texture
  82044. */
  82045. _bindFrameBuffer(faceIndex?: number): void;
  82046. /**
  82047. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82048. * @returns the view count
  82049. */
  82050. getViewCount(): number;
  82051. }
  82052. }
  82053. declare module BABYLON {
  82054. /**
  82055. * Represents a camera frustum
  82056. */
  82057. export class Frustum {
  82058. /**
  82059. * Gets the planes representing the frustum
  82060. * @param transform matrix to be applied to the returned planes
  82061. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82062. */
  82063. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82064. /**
  82065. * Gets the near frustum plane transformed by the transform matrix
  82066. * @param transform transformation matrix to be applied to the resulting frustum plane
  82067. * @param frustumPlane the resuling frustum plane
  82068. */
  82069. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82070. /**
  82071. * Gets the far frustum plane transformed by the transform matrix
  82072. * @param transform transformation matrix to be applied to the resulting frustum plane
  82073. * @param frustumPlane the resuling frustum plane
  82074. */
  82075. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82076. /**
  82077. * Gets the left frustum plane transformed by the transform matrix
  82078. * @param transform transformation matrix to be applied to the resulting frustum plane
  82079. * @param frustumPlane the resuling frustum plane
  82080. */
  82081. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82082. /**
  82083. * Gets the right frustum plane transformed by the transform matrix
  82084. * @param transform transformation matrix to be applied to the resulting frustum plane
  82085. * @param frustumPlane the resuling frustum plane
  82086. */
  82087. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82088. /**
  82089. * Gets the top frustum plane transformed by the transform matrix
  82090. * @param transform transformation matrix to be applied to the resulting frustum plane
  82091. * @param frustumPlane the resuling frustum plane
  82092. */
  82093. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82094. /**
  82095. * Gets the bottom frustum plane transformed by the transform matrix
  82096. * @param transform transformation matrix to be applied to the resulting frustum plane
  82097. * @param frustumPlane the resuling frustum plane
  82098. */
  82099. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82100. /**
  82101. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82102. * @param transform transformation matrix to be applied to the resulting frustum planes
  82103. * @param frustumPlanes the resuling frustum planes
  82104. */
  82105. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82106. }
  82107. }
  82108. declare module BABYLON {
  82109. interface Engine {
  82110. /**
  82111. * Creates a new multiview render target
  82112. * @param width defines the width of the texture
  82113. * @param height defines the height of the texture
  82114. * @returns the created multiview texture
  82115. */
  82116. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82117. /**
  82118. * Binds a multiview framebuffer to be drawn to
  82119. * @param multiviewTexture texture to bind
  82120. */
  82121. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82122. }
  82123. interface Camera {
  82124. /**
  82125. * @hidden
  82126. * 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)
  82127. */
  82128. _useMultiviewToSingleView: boolean;
  82129. /**
  82130. * @hidden
  82131. * 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)
  82132. */
  82133. _multiviewTexture: Nullable<RenderTargetTexture>;
  82134. /**
  82135. * @hidden
  82136. * ensures the multiview texture of the camera exists and has the specified width/height
  82137. * @param width height to set on the multiview texture
  82138. * @param height width to set on the multiview texture
  82139. */
  82140. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82141. }
  82142. interface Scene {
  82143. /** @hidden */
  82144. _transformMatrixR: Matrix;
  82145. /** @hidden */
  82146. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82147. /** @hidden */
  82148. _createMultiviewUbo(): void;
  82149. /** @hidden */
  82150. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82151. /** @hidden */
  82152. _renderMultiviewToSingleView(camera: Camera): void;
  82153. }
  82154. }
  82155. declare module BABYLON {
  82156. /**
  82157. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82158. * This will not be used for webXR as it supports displaying texture arrays directly
  82159. */
  82160. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82161. /**
  82162. * Initializes a VRMultiviewToSingleview
  82163. * @param name name of the post process
  82164. * @param camera camera to be applied to
  82165. * @param scaleFactor scaling factor to the size of the output texture
  82166. */
  82167. constructor(name: string, camera: Camera, scaleFactor: number);
  82168. }
  82169. }
  82170. declare module BABYLON {
  82171. interface Engine {
  82172. /** @hidden */
  82173. _vrDisplay: any;
  82174. /** @hidden */
  82175. _vrSupported: boolean;
  82176. /** @hidden */
  82177. _oldSize: Size;
  82178. /** @hidden */
  82179. _oldHardwareScaleFactor: number;
  82180. /** @hidden */
  82181. _vrExclusivePointerMode: boolean;
  82182. /** @hidden */
  82183. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82184. /** @hidden */
  82185. _onVRDisplayPointerRestricted: () => void;
  82186. /** @hidden */
  82187. _onVRDisplayPointerUnrestricted: () => void;
  82188. /** @hidden */
  82189. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82190. /** @hidden */
  82191. _onVrDisplayDisconnect: Nullable<() => void>;
  82192. /** @hidden */
  82193. _onVrDisplayPresentChange: Nullable<() => void>;
  82194. /**
  82195. * Observable signaled when VR display mode changes
  82196. */
  82197. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82198. /**
  82199. * Observable signaled when VR request present is complete
  82200. */
  82201. onVRRequestPresentComplete: Observable<boolean>;
  82202. /**
  82203. * Observable signaled when VR request present starts
  82204. */
  82205. onVRRequestPresentStart: Observable<Engine>;
  82206. /**
  82207. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82208. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82209. */
  82210. isInVRExclusivePointerMode: boolean;
  82211. /**
  82212. * Gets a boolean indicating if a webVR device was detected
  82213. * @returns true if a webVR device was detected
  82214. */
  82215. isVRDevicePresent(): boolean;
  82216. /**
  82217. * Gets the current webVR device
  82218. * @returns the current webVR device (or null)
  82219. */
  82220. getVRDevice(): any;
  82221. /**
  82222. * Initializes a webVR display and starts listening to display change events
  82223. * The onVRDisplayChangedObservable will be notified upon these changes
  82224. * @returns A promise containing a VRDisplay and if vr is supported
  82225. */
  82226. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82227. /** @hidden */
  82228. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82229. /**
  82230. * Call this function to switch to webVR mode
  82231. * Will do nothing if webVR is not supported or if there is no webVR device
  82232. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82233. */
  82234. enableVR(): void;
  82235. /** @hidden */
  82236. _onVRFullScreenTriggered(): void;
  82237. }
  82238. }
  82239. declare module BABYLON {
  82240. /**
  82241. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82242. * IMPORTANT!! The data is right-hand data.
  82243. * @export
  82244. * @interface DevicePose
  82245. */
  82246. export interface DevicePose {
  82247. /**
  82248. * The position of the device, values in array are [x,y,z].
  82249. */
  82250. readonly position: Nullable<Float32Array>;
  82251. /**
  82252. * The linearVelocity of the device, values in array are [x,y,z].
  82253. */
  82254. readonly linearVelocity: Nullable<Float32Array>;
  82255. /**
  82256. * The linearAcceleration of the device, values in array are [x,y,z].
  82257. */
  82258. readonly linearAcceleration: Nullable<Float32Array>;
  82259. /**
  82260. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82261. */
  82262. readonly orientation: Nullable<Float32Array>;
  82263. /**
  82264. * The angularVelocity of the device, values in array are [x,y,z].
  82265. */
  82266. readonly angularVelocity: Nullable<Float32Array>;
  82267. /**
  82268. * The angularAcceleration of the device, values in array are [x,y,z].
  82269. */
  82270. readonly angularAcceleration: Nullable<Float32Array>;
  82271. }
  82272. /**
  82273. * Interface representing a pose controlled object in Babylon.
  82274. * A pose controlled object has both regular pose values as well as pose values
  82275. * from an external device such as a VR head mounted display
  82276. */
  82277. export interface PoseControlled {
  82278. /**
  82279. * The position of the object in babylon space.
  82280. */
  82281. position: Vector3;
  82282. /**
  82283. * The rotation quaternion of the object in babylon space.
  82284. */
  82285. rotationQuaternion: Quaternion;
  82286. /**
  82287. * The position of the device in babylon space.
  82288. */
  82289. devicePosition?: Vector3;
  82290. /**
  82291. * The rotation quaternion of the device in babylon space.
  82292. */
  82293. deviceRotationQuaternion: Quaternion;
  82294. /**
  82295. * The raw pose coming from the device.
  82296. */
  82297. rawPose: Nullable<DevicePose>;
  82298. /**
  82299. * The scale of the device to be used when translating from device space to babylon space.
  82300. */
  82301. deviceScaleFactor: number;
  82302. /**
  82303. * Updates the poseControlled values based on the input device pose.
  82304. * @param poseData the pose data to update the object with
  82305. */
  82306. updateFromDevice(poseData: DevicePose): void;
  82307. }
  82308. /**
  82309. * Set of options to customize the webVRCamera
  82310. */
  82311. export interface WebVROptions {
  82312. /**
  82313. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82314. */
  82315. trackPosition?: boolean;
  82316. /**
  82317. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82318. */
  82319. positionScale?: number;
  82320. /**
  82321. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82322. */
  82323. displayName?: string;
  82324. /**
  82325. * Should the native controller meshes be initialized. (default: true)
  82326. */
  82327. controllerMeshes?: boolean;
  82328. /**
  82329. * Creating a default HemiLight only on controllers. (default: true)
  82330. */
  82331. defaultLightingOnControllers?: boolean;
  82332. /**
  82333. * If you don't want to use the default VR button of the helper. (default: false)
  82334. */
  82335. useCustomVRButton?: boolean;
  82336. /**
  82337. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  82338. */
  82339. customVRButton?: HTMLButtonElement;
  82340. /**
  82341. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  82342. */
  82343. rayLength?: number;
  82344. /**
  82345. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  82346. */
  82347. defaultHeight?: number;
  82348. /**
  82349. * If multiview should be used if availible (default: false)
  82350. */
  82351. useMultiview?: boolean;
  82352. }
  82353. /**
  82354. * This represents a WebVR camera.
  82355. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  82356. * @example http://doc.babylonjs.com/how_to/webvr_camera
  82357. */
  82358. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  82359. private webVROptions;
  82360. /**
  82361. * @hidden
  82362. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  82363. */
  82364. _vrDevice: any;
  82365. /**
  82366. * The rawPose of the vrDevice.
  82367. */
  82368. rawPose: Nullable<DevicePose>;
  82369. private _onVREnabled;
  82370. private _specsVersion;
  82371. private _attached;
  82372. private _frameData;
  82373. protected _descendants: Array<Node>;
  82374. private _deviceRoomPosition;
  82375. /** @hidden */
  82376. _deviceRoomRotationQuaternion: Quaternion;
  82377. private _standingMatrix;
  82378. /**
  82379. * Represents device position in babylon space.
  82380. */
  82381. devicePosition: Vector3;
  82382. /**
  82383. * Represents device rotation in babylon space.
  82384. */
  82385. deviceRotationQuaternion: Quaternion;
  82386. /**
  82387. * The scale of the device to be used when translating from device space to babylon space.
  82388. */
  82389. deviceScaleFactor: number;
  82390. private _deviceToWorld;
  82391. private _worldToDevice;
  82392. /**
  82393. * References to the webVR controllers for the vrDevice.
  82394. */
  82395. controllers: Array<WebVRController>;
  82396. /**
  82397. * Emits an event when a controller is attached.
  82398. */
  82399. onControllersAttachedObservable: Observable<WebVRController[]>;
  82400. /**
  82401. * Emits an event when a controller's mesh has been loaded;
  82402. */
  82403. onControllerMeshLoadedObservable: Observable<WebVRController>;
  82404. /**
  82405. * Emits an event when the HMD's pose has been updated.
  82406. */
  82407. onPoseUpdatedFromDeviceObservable: Observable<any>;
  82408. private _poseSet;
  82409. /**
  82410. * If the rig cameras be used as parent instead of this camera.
  82411. */
  82412. rigParenting: boolean;
  82413. private _lightOnControllers;
  82414. private _defaultHeight?;
  82415. /**
  82416. * Instantiates a WebVRFreeCamera.
  82417. * @param name The name of the WebVRFreeCamera
  82418. * @param position The starting anchor position for the camera
  82419. * @param scene The scene the camera belongs to
  82420. * @param webVROptions a set of customizable options for the webVRCamera
  82421. */
  82422. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  82423. /**
  82424. * Gets the device distance from the ground in meters.
  82425. * @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.
  82426. */
  82427. deviceDistanceToRoomGround(): number;
  82428. /**
  82429. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82430. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  82431. */
  82432. useStandingMatrix(callback?: (bool: boolean) => void): void;
  82433. /**
  82434. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82435. * @returns A promise with a boolean set to if the standing matrix is supported.
  82436. */
  82437. useStandingMatrixAsync(): Promise<boolean>;
  82438. /**
  82439. * Disposes the camera
  82440. */
  82441. dispose(): void;
  82442. /**
  82443. * Gets a vrController by name.
  82444. * @param name The name of the controller to retreive
  82445. * @returns the controller matching the name specified or null if not found
  82446. */
  82447. getControllerByName(name: string): Nullable<WebVRController>;
  82448. private _leftController;
  82449. /**
  82450. * The controller corresponding to the users left hand.
  82451. */
  82452. readonly leftController: Nullable<WebVRController>;
  82453. private _rightController;
  82454. /**
  82455. * The controller corresponding to the users right hand.
  82456. */
  82457. readonly rightController: Nullable<WebVRController>;
  82458. /**
  82459. * Casts a ray forward from the vrCamera's gaze.
  82460. * @param length Length of the ray (default: 100)
  82461. * @returns the ray corresponding to the gaze
  82462. */
  82463. getForwardRay(length?: number): Ray;
  82464. /**
  82465. * @hidden
  82466. * Updates the camera based on device's frame data
  82467. */
  82468. _checkInputs(): void;
  82469. /**
  82470. * Updates the poseControlled values based on the input device pose.
  82471. * @param poseData Pose coming from the device
  82472. */
  82473. updateFromDevice(poseData: DevicePose): void;
  82474. private _htmlElementAttached;
  82475. private _detachIfAttached;
  82476. /**
  82477. * WebVR's attach control will start broadcasting frames to the device.
  82478. * Note that in certain browsers (chrome for example) this function must be called
  82479. * within a user-interaction callback. Example:
  82480. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  82481. *
  82482. * @param element html element to attach the vrDevice to
  82483. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  82484. */
  82485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82486. /**
  82487. * Detaches the camera from the html element and disables VR
  82488. *
  82489. * @param element html element to detach from
  82490. */
  82491. detachControl(element: HTMLElement): void;
  82492. /**
  82493. * @returns the name of this class
  82494. */
  82495. getClassName(): string;
  82496. /**
  82497. * Calls resetPose on the vrDisplay
  82498. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  82499. */
  82500. resetToCurrentRotation(): void;
  82501. /**
  82502. * @hidden
  82503. * Updates the rig cameras (left and right eye)
  82504. */
  82505. _updateRigCameras(): void;
  82506. private _workingVector;
  82507. private _oneVector;
  82508. private _workingMatrix;
  82509. private updateCacheCalled;
  82510. private _correctPositionIfNotTrackPosition;
  82511. /**
  82512. * @hidden
  82513. * Updates the cached values of the camera
  82514. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  82515. */
  82516. _updateCache(ignoreParentClass?: boolean): void;
  82517. /**
  82518. * @hidden
  82519. * Get current device position in babylon world
  82520. */
  82521. _computeDevicePosition(): void;
  82522. /**
  82523. * Updates the current device position and rotation in the babylon world
  82524. */
  82525. update(): void;
  82526. /**
  82527. * @hidden
  82528. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  82529. * @returns an identity matrix
  82530. */
  82531. _getViewMatrix(): Matrix;
  82532. private _tmpMatrix;
  82533. /**
  82534. * This function is called by the two RIG cameras.
  82535. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  82536. * @hidden
  82537. */
  82538. _getWebVRViewMatrix(): Matrix;
  82539. /** @hidden */
  82540. _getWebVRProjectionMatrix(): Matrix;
  82541. private _onGamepadConnectedObserver;
  82542. private _onGamepadDisconnectedObserver;
  82543. private _updateCacheWhenTrackingDisabledObserver;
  82544. /**
  82545. * Initializes the controllers and their meshes
  82546. */
  82547. initControllers(): void;
  82548. }
  82549. }
  82550. declare module BABYLON {
  82551. /**
  82552. * Size options for a post process
  82553. */
  82554. export type PostProcessOptions = {
  82555. width: number;
  82556. height: number;
  82557. };
  82558. /**
  82559. * PostProcess can be used to apply a shader to a texture after it has been rendered
  82560. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82561. */
  82562. export class PostProcess {
  82563. /** Name of the PostProcess. */
  82564. name: string;
  82565. /**
  82566. * Gets or sets the unique id of the post process
  82567. */
  82568. uniqueId: number;
  82569. /**
  82570. * Width of the texture to apply the post process on
  82571. */
  82572. width: number;
  82573. /**
  82574. * Height of the texture to apply the post process on
  82575. */
  82576. height: number;
  82577. /**
  82578. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  82579. * @hidden
  82580. */
  82581. _outputTexture: Nullable<InternalTexture>;
  82582. /**
  82583. * Sampling mode used by the shader
  82584. * See https://doc.babylonjs.com/classes/3.1/texture
  82585. */
  82586. renderTargetSamplingMode: number;
  82587. /**
  82588. * Clear color to use when screen clearing
  82589. */
  82590. clearColor: Color4;
  82591. /**
  82592. * If the buffer needs to be cleared before applying the post process. (default: true)
  82593. * Should be set to false if shader will overwrite all previous pixels.
  82594. */
  82595. autoClear: boolean;
  82596. /**
  82597. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  82598. */
  82599. alphaMode: number;
  82600. /**
  82601. * Sets the setAlphaBlendConstants of the babylon engine
  82602. */
  82603. alphaConstants: Color4;
  82604. /**
  82605. * Animations to be used for the post processing
  82606. */
  82607. animations: Animation[];
  82608. /**
  82609. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  82610. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  82611. */
  82612. enablePixelPerfectMode: boolean;
  82613. /**
  82614. * Force the postprocess to be applied without taking in account viewport
  82615. */
  82616. forceFullscreenViewport: boolean;
  82617. /**
  82618. * List of inspectable custom properties (used by the Inspector)
  82619. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82620. */
  82621. inspectableCustomProperties: IInspectable[];
  82622. /**
  82623. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  82624. *
  82625. * | Value | Type | Description |
  82626. * | ----- | ----------------------------------- | ----------- |
  82627. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  82628. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  82629. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  82630. *
  82631. */
  82632. scaleMode: number;
  82633. /**
  82634. * Force textures to be a power of two (default: false)
  82635. */
  82636. alwaysForcePOT: boolean;
  82637. private _samples;
  82638. /**
  82639. * Number of sample textures (default: 1)
  82640. */
  82641. samples: number;
  82642. /**
  82643. * Modify the scale of the post process to be the same as the viewport (default: false)
  82644. */
  82645. adaptScaleToCurrentViewport: boolean;
  82646. private _camera;
  82647. private _scene;
  82648. private _engine;
  82649. private _options;
  82650. private _reusable;
  82651. private _textureType;
  82652. /**
  82653. * Smart array of input and output textures for the post process.
  82654. * @hidden
  82655. */
  82656. _textures: SmartArray<InternalTexture>;
  82657. /**
  82658. * The index in _textures that corresponds to the output texture.
  82659. * @hidden
  82660. */
  82661. _currentRenderTextureInd: number;
  82662. private _effect;
  82663. private _samplers;
  82664. private _fragmentUrl;
  82665. private _vertexUrl;
  82666. private _parameters;
  82667. private _scaleRatio;
  82668. protected _indexParameters: any;
  82669. private _shareOutputWithPostProcess;
  82670. private _texelSize;
  82671. private _forcedOutputTexture;
  82672. /**
  82673. * Returns the fragment url or shader name used in the post process.
  82674. * @returns the fragment url or name in the shader store.
  82675. */
  82676. getEffectName(): string;
  82677. /**
  82678. * An event triggered when the postprocess is activated.
  82679. */
  82680. onActivateObservable: Observable<Camera>;
  82681. private _onActivateObserver;
  82682. /**
  82683. * A function that is added to the onActivateObservable
  82684. */
  82685. onActivate: Nullable<(camera: Camera) => void>;
  82686. /**
  82687. * An event triggered when the postprocess changes its size.
  82688. */
  82689. onSizeChangedObservable: Observable<PostProcess>;
  82690. private _onSizeChangedObserver;
  82691. /**
  82692. * A function that is added to the onSizeChangedObservable
  82693. */
  82694. onSizeChanged: (postProcess: PostProcess) => void;
  82695. /**
  82696. * An event triggered when the postprocess applies its effect.
  82697. */
  82698. onApplyObservable: Observable<Effect>;
  82699. private _onApplyObserver;
  82700. /**
  82701. * A function that is added to the onApplyObservable
  82702. */
  82703. onApply: (effect: Effect) => void;
  82704. /**
  82705. * An event triggered before rendering the postprocess
  82706. */
  82707. onBeforeRenderObservable: Observable<Effect>;
  82708. private _onBeforeRenderObserver;
  82709. /**
  82710. * A function that is added to the onBeforeRenderObservable
  82711. */
  82712. onBeforeRender: (effect: Effect) => void;
  82713. /**
  82714. * An event triggered after rendering the postprocess
  82715. */
  82716. onAfterRenderObservable: Observable<Effect>;
  82717. private _onAfterRenderObserver;
  82718. /**
  82719. * A function that is added to the onAfterRenderObservable
  82720. */
  82721. onAfterRender: (efect: Effect) => void;
  82722. /**
  82723. * 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
  82724. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82725. */
  82726. inputTexture: InternalTexture;
  82727. /**
  82728. * Gets the camera which post process is applied to.
  82729. * @returns The camera the post process is applied to.
  82730. */
  82731. getCamera(): Camera;
  82732. /**
  82733. * Gets the texel size of the postprocess.
  82734. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82735. */
  82736. readonly texelSize: Vector2;
  82737. /**
  82738. * Creates a new instance PostProcess
  82739. * @param name The name of the PostProcess.
  82740. * @param fragmentUrl The url of the fragment shader to be used.
  82741. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82742. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82743. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82744. * @param camera The camera to apply the render pass to.
  82745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82746. * @param engine The engine which the post process will be applied. (default: current engine)
  82747. * @param reusable If the post process can be reused on the same frame. (default: false)
  82748. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82749. * @param textureType Type of textures used when performing the post process. (default: 0)
  82750. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82751. * @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
  82752. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82753. */
  82754. constructor(
  82755. /** Name of the PostProcess. */
  82756. 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);
  82757. /**
  82758. * Gets a string idenfifying the name of the class
  82759. * @returns "PostProcess" string
  82760. */
  82761. getClassName(): string;
  82762. /**
  82763. * Gets the engine which this post process belongs to.
  82764. * @returns The engine the post process was enabled with.
  82765. */
  82766. getEngine(): Engine;
  82767. /**
  82768. * The effect that is created when initializing the post process.
  82769. * @returns The created effect corresponding the the postprocess.
  82770. */
  82771. getEffect(): Effect;
  82772. /**
  82773. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82774. * @param postProcess The post process to share the output with.
  82775. * @returns This post process.
  82776. */
  82777. shareOutputWith(postProcess: PostProcess): PostProcess;
  82778. /**
  82779. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82780. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82781. */
  82782. useOwnOutput(): void;
  82783. /**
  82784. * Updates the effect with the current post process compile time values and recompiles the shader.
  82785. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82786. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82787. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82788. * @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
  82789. * @param onCompiled Called when the shader has been compiled.
  82790. * @param onError Called if there is an error when compiling a shader.
  82791. */
  82792. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82793. /**
  82794. * The post process is reusable if it can be used multiple times within one frame.
  82795. * @returns If the post process is reusable
  82796. */
  82797. isReusable(): boolean;
  82798. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82799. markTextureDirty(): void;
  82800. /**
  82801. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82802. * 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.
  82803. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82804. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82805. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82806. * @returns The target texture that was bound to be written to.
  82807. */
  82808. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82809. /**
  82810. * If the post process is supported.
  82811. */
  82812. readonly isSupported: boolean;
  82813. /**
  82814. * The aspect ratio of the output texture.
  82815. */
  82816. readonly aspectRatio: number;
  82817. /**
  82818. * Get a value indicating if the post-process is ready to be used
  82819. * @returns true if the post-process is ready (shader is compiled)
  82820. */
  82821. isReady(): boolean;
  82822. /**
  82823. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82824. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82825. */
  82826. apply(): Nullable<Effect>;
  82827. private _disposeTextures;
  82828. /**
  82829. * Disposes the post process.
  82830. * @param camera The camera to dispose the post process on.
  82831. */
  82832. dispose(camera?: Camera): void;
  82833. }
  82834. }
  82835. declare module BABYLON {
  82836. /** @hidden */
  82837. export var kernelBlurVaryingDeclaration: {
  82838. name: string;
  82839. shader: string;
  82840. };
  82841. }
  82842. declare module BABYLON {
  82843. /** @hidden */
  82844. export var kernelBlurFragment: {
  82845. name: string;
  82846. shader: string;
  82847. };
  82848. }
  82849. declare module BABYLON {
  82850. /** @hidden */
  82851. export var kernelBlurFragment2: {
  82852. name: string;
  82853. shader: string;
  82854. };
  82855. }
  82856. declare module BABYLON {
  82857. /** @hidden */
  82858. export var kernelBlurPixelShader: {
  82859. name: string;
  82860. shader: string;
  82861. };
  82862. }
  82863. declare module BABYLON {
  82864. /** @hidden */
  82865. export var kernelBlurVertex: {
  82866. name: string;
  82867. shader: string;
  82868. };
  82869. }
  82870. declare module BABYLON {
  82871. /** @hidden */
  82872. export var kernelBlurVertexShader: {
  82873. name: string;
  82874. shader: string;
  82875. };
  82876. }
  82877. declare module BABYLON {
  82878. /**
  82879. * The Blur Post Process which blurs an image based on a kernel and direction.
  82880. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82881. */
  82882. export class BlurPostProcess extends PostProcess {
  82883. /** The direction in which to blur the image. */
  82884. direction: Vector2;
  82885. private blockCompilation;
  82886. protected _kernel: number;
  82887. protected _idealKernel: number;
  82888. protected _packedFloat: boolean;
  82889. private _staticDefines;
  82890. /**
  82891. * Sets the length in pixels of the blur sample region
  82892. */
  82893. /**
  82894. * Gets the length in pixels of the blur sample region
  82895. */
  82896. kernel: number;
  82897. /**
  82898. * Sets wether or not the blur needs to unpack/repack floats
  82899. */
  82900. /**
  82901. * Gets wether or not the blur is unpacking/repacking floats
  82902. */
  82903. packedFloat: boolean;
  82904. /**
  82905. * Creates a new instance BlurPostProcess
  82906. * @param name The name of the effect.
  82907. * @param direction The direction in which to blur the image.
  82908. * @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.
  82909. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82910. * @param camera The camera to apply the render pass to.
  82911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82912. * @param engine The engine which the post process will be applied. (default: current engine)
  82913. * @param reusable If the post process can be reused on the same frame. (default: false)
  82914. * @param textureType Type of textures used when performing the post process. (default: 0)
  82915. * @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)
  82916. */
  82917. constructor(name: string,
  82918. /** The direction in which to blur the image. */
  82919. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82920. /**
  82921. * Updates the effect with the current post process compile time values and recompiles the shader.
  82922. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82923. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82924. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82925. * @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
  82926. * @param onCompiled Called when the shader has been compiled.
  82927. * @param onError Called if there is an error when compiling a shader.
  82928. */
  82929. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82930. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82931. /**
  82932. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82933. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82934. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82935. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82936. * The gaps between physical kernels are compensated for in the weighting of the samples
  82937. * @param idealKernel Ideal blur kernel.
  82938. * @return Nearest best kernel.
  82939. */
  82940. protected _nearestBestKernel(idealKernel: number): number;
  82941. /**
  82942. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82943. * @param x The point on the Gaussian distribution to sample.
  82944. * @return the value of the Gaussian function at x.
  82945. */
  82946. protected _gaussianWeight(x: number): number;
  82947. /**
  82948. * Generates a string that can be used as a floating point number in GLSL.
  82949. * @param x Value to print.
  82950. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82951. * @return GLSL float string.
  82952. */
  82953. protected _glslFloat(x: number, decimalFigures?: number): string;
  82954. }
  82955. }
  82956. declare module BABYLON {
  82957. /**
  82958. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82959. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82960. * You can then easily use it as a reflectionTexture on a flat surface.
  82961. * In case the surface is not a plane, please consider relying on reflection probes.
  82962. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82963. */
  82964. export class MirrorTexture extends RenderTargetTexture {
  82965. private scene;
  82966. /**
  82967. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82968. * 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.
  82969. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82970. */
  82971. mirrorPlane: Plane;
  82972. /**
  82973. * Define the blur ratio used to blur the reflection if needed.
  82974. */
  82975. blurRatio: number;
  82976. /**
  82977. * Define the adaptive blur kernel used to blur the reflection if needed.
  82978. * This will autocompute the closest best match for the `blurKernel`
  82979. */
  82980. adaptiveBlurKernel: number;
  82981. /**
  82982. * Define the blur kernel used to blur the reflection if needed.
  82983. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82984. */
  82985. blurKernel: number;
  82986. /**
  82987. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82988. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82989. */
  82990. blurKernelX: number;
  82991. /**
  82992. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82993. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82994. */
  82995. blurKernelY: number;
  82996. private _autoComputeBlurKernel;
  82997. protected _onRatioRescale(): void;
  82998. private _updateGammaSpace;
  82999. private _imageProcessingConfigChangeObserver;
  83000. private _transformMatrix;
  83001. private _mirrorMatrix;
  83002. private _savedViewMatrix;
  83003. private _blurX;
  83004. private _blurY;
  83005. private _adaptiveBlurKernel;
  83006. private _blurKernelX;
  83007. private _blurKernelY;
  83008. private _blurRatio;
  83009. /**
  83010. * Instantiates a Mirror Texture.
  83011. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83012. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83013. * You can then easily use it as a reflectionTexture on a flat surface.
  83014. * In case the surface is not a plane, please consider relying on reflection probes.
  83015. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83016. * @param name
  83017. * @param size
  83018. * @param scene
  83019. * @param generateMipMaps
  83020. * @param type
  83021. * @param samplingMode
  83022. * @param generateDepthBuffer
  83023. */
  83024. constructor(name: string, size: number | {
  83025. width: number;
  83026. height: number;
  83027. } | {
  83028. ratio: number;
  83029. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83030. private _preparePostProcesses;
  83031. /**
  83032. * Clone the mirror texture.
  83033. * @returns the cloned texture
  83034. */
  83035. clone(): MirrorTexture;
  83036. /**
  83037. * Serialize the texture to a JSON representation you could use in Parse later on
  83038. * @returns the serialized JSON representation
  83039. */
  83040. serialize(): any;
  83041. /**
  83042. * Dispose the texture and release its associated resources.
  83043. */
  83044. dispose(): void;
  83045. }
  83046. }
  83047. declare module BABYLON {
  83048. /**
  83049. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83050. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83051. */
  83052. export class Texture extends BaseTexture {
  83053. /**
  83054. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83055. */
  83056. static SerializeBuffers: boolean;
  83057. /** @hidden */
  83058. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83059. /** @hidden */
  83060. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83061. /** @hidden */
  83062. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83063. /** nearest is mag = nearest and min = nearest and mip = linear */
  83064. static readonly NEAREST_SAMPLINGMODE: number;
  83065. /** nearest is mag = nearest and min = nearest and mip = linear */
  83066. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83067. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83068. static readonly BILINEAR_SAMPLINGMODE: number;
  83069. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83070. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83071. /** Trilinear is mag = linear and min = linear and mip = linear */
  83072. static readonly TRILINEAR_SAMPLINGMODE: number;
  83073. /** Trilinear is mag = linear and min = linear and mip = linear */
  83074. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83075. /** mag = nearest and min = nearest and mip = nearest */
  83076. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83077. /** mag = nearest and min = linear and mip = nearest */
  83078. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83079. /** mag = nearest and min = linear and mip = linear */
  83080. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83081. /** mag = nearest and min = linear and mip = none */
  83082. static readonly NEAREST_LINEAR: number;
  83083. /** mag = nearest and min = nearest and mip = none */
  83084. static readonly NEAREST_NEAREST: number;
  83085. /** mag = linear and min = nearest and mip = nearest */
  83086. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83087. /** mag = linear and min = nearest and mip = linear */
  83088. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83089. /** mag = linear and min = linear and mip = none */
  83090. static readonly LINEAR_LINEAR: number;
  83091. /** mag = linear and min = nearest and mip = none */
  83092. static readonly LINEAR_NEAREST: number;
  83093. /** Explicit coordinates mode */
  83094. static readonly EXPLICIT_MODE: number;
  83095. /** Spherical coordinates mode */
  83096. static readonly SPHERICAL_MODE: number;
  83097. /** Planar coordinates mode */
  83098. static readonly PLANAR_MODE: number;
  83099. /** Cubic coordinates mode */
  83100. static readonly CUBIC_MODE: number;
  83101. /** Projection coordinates mode */
  83102. static readonly PROJECTION_MODE: number;
  83103. /** Inverse Cubic coordinates mode */
  83104. static readonly SKYBOX_MODE: number;
  83105. /** Inverse Cubic coordinates mode */
  83106. static readonly INVCUBIC_MODE: number;
  83107. /** Equirectangular coordinates mode */
  83108. static readonly EQUIRECTANGULAR_MODE: number;
  83109. /** Equirectangular Fixed coordinates mode */
  83110. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83111. /** Equirectangular Fixed Mirrored coordinates mode */
  83112. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83113. /** Texture is not repeating outside of 0..1 UVs */
  83114. static readonly CLAMP_ADDRESSMODE: number;
  83115. /** Texture is repeating outside of 0..1 UVs */
  83116. static readonly WRAP_ADDRESSMODE: number;
  83117. /** Texture is repeating and mirrored */
  83118. static readonly MIRROR_ADDRESSMODE: number;
  83119. /**
  83120. * 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
  83121. */
  83122. static UseSerializedUrlIfAny: boolean;
  83123. /**
  83124. * Define the url of the texture.
  83125. */
  83126. url: Nullable<string>;
  83127. /**
  83128. * Define an offset on the texture to offset the u coordinates of the UVs
  83129. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83130. */
  83131. uOffset: number;
  83132. /**
  83133. * Define an offset on the texture to offset the v coordinates of the UVs
  83134. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83135. */
  83136. vOffset: number;
  83137. /**
  83138. * Define an offset on the texture to scale the u coordinates of the UVs
  83139. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83140. */
  83141. uScale: number;
  83142. /**
  83143. * Define an offset on the texture to scale the v coordinates of the UVs
  83144. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83145. */
  83146. vScale: number;
  83147. /**
  83148. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83149. * @see http://doc.babylonjs.com/how_to/more_materials
  83150. */
  83151. uAng: number;
  83152. /**
  83153. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83154. * @see http://doc.babylonjs.com/how_to/more_materials
  83155. */
  83156. vAng: number;
  83157. /**
  83158. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83159. * @see http://doc.babylonjs.com/how_to/more_materials
  83160. */
  83161. wAng: number;
  83162. /**
  83163. * Defines the center of rotation (U)
  83164. */
  83165. uRotationCenter: number;
  83166. /**
  83167. * Defines the center of rotation (V)
  83168. */
  83169. vRotationCenter: number;
  83170. /**
  83171. * Defines the center of rotation (W)
  83172. */
  83173. wRotationCenter: number;
  83174. /**
  83175. * Are mip maps generated for this texture or not.
  83176. */
  83177. readonly noMipmap: boolean;
  83178. /**
  83179. * List of inspectable custom properties (used by the Inspector)
  83180. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83181. */
  83182. inspectableCustomProperties: Nullable<IInspectable[]>;
  83183. private _noMipmap;
  83184. /** @hidden */
  83185. _invertY: boolean;
  83186. private _rowGenerationMatrix;
  83187. private _cachedTextureMatrix;
  83188. private _projectionModeMatrix;
  83189. private _t0;
  83190. private _t1;
  83191. private _t2;
  83192. private _cachedUOffset;
  83193. private _cachedVOffset;
  83194. private _cachedUScale;
  83195. private _cachedVScale;
  83196. private _cachedUAng;
  83197. private _cachedVAng;
  83198. private _cachedWAng;
  83199. private _cachedProjectionMatrixId;
  83200. private _cachedCoordinatesMode;
  83201. /** @hidden */
  83202. protected _initialSamplingMode: number;
  83203. /** @hidden */
  83204. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83205. private _deleteBuffer;
  83206. protected _format: Nullable<number>;
  83207. private _delayedOnLoad;
  83208. private _delayedOnError;
  83209. private _mimeType?;
  83210. /**
  83211. * Observable triggered once the texture has been loaded.
  83212. */
  83213. onLoadObservable: Observable<Texture>;
  83214. protected _isBlocking: boolean;
  83215. /**
  83216. * Is the texture preventing material to render while loading.
  83217. * If false, a default texture will be used instead of the loading one during the preparation step.
  83218. */
  83219. isBlocking: boolean;
  83220. /**
  83221. * Get the current sampling mode associated with the texture.
  83222. */
  83223. readonly samplingMode: number;
  83224. /**
  83225. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83226. */
  83227. readonly invertY: boolean;
  83228. /**
  83229. * Instantiates a new texture.
  83230. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83231. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83232. * @param url defines the url of the picture to load as a texture
  83233. * @param scene defines the scene or engine the texture will belong to
  83234. * @param noMipmap defines if the texture will require mip maps or not
  83235. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83236. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83237. * @param onLoad defines a callback triggered when the texture has been loaded
  83238. * @param onError defines a callback triggered when an error occurred during the loading session
  83239. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83240. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83241. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83242. * @param mimeType defines an optional mime type information
  83243. */
  83244. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  83245. /**
  83246. * Update the url (and optional buffer) of this texture if url was null during construction.
  83247. * @param url the url of the texture
  83248. * @param buffer the buffer of the texture (defaults to null)
  83249. * @param onLoad callback called when the texture is loaded (defaults to null)
  83250. */
  83251. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83252. /**
  83253. * Finish the loading sequence of a texture flagged as delayed load.
  83254. * @hidden
  83255. */
  83256. delayLoad(): void;
  83257. private _prepareRowForTextureGeneration;
  83258. /**
  83259. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83260. * @returns the transform matrix of the texture.
  83261. */
  83262. getTextureMatrix(): Matrix;
  83263. /**
  83264. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83265. * @returns The reflection texture transform
  83266. */
  83267. getReflectionTextureMatrix(): Matrix;
  83268. /**
  83269. * Clones the texture.
  83270. * @returns the cloned texture
  83271. */
  83272. clone(): Texture;
  83273. /**
  83274. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83275. * @returns The JSON representation of the texture
  83276. */
  83277. serialize(): any;
  83278. /**
  83279. * Get the current class name of the texture useful for serialization or dynamic coding.
  83280. * @returns "Texture"
  83281. */
  83282. getClassName(): string;
  83283. /**
  83284. * Dispose the texture and release its associated resources.
  83285. */
  83286. dispose(): void;
  83287. /**
  83288. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83289. * @param parsedTexture Define the JSON representation of the texture
  83290. * @param scene Define the scene the parsed texture should be instantiated in
  83291. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83292. * @returns The parsed texture if successful
  83293. */
  83294. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83295. /**
  83296. * Creates a texture from its base 64 representation.
  83297. * @param data Define the base64 payload without the data: prefix
  83298. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83299. * @param scene Define the scene the texture should belong to
  83300. * @param noMipmap Forces the texture to not create mip map information if true
  83301. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83302. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83303. * @param onLoad define a callback triggered when the texture has been loaded
  83304. * @param onError define a callback triggered when an error occurred during the loading session
  83305. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83306. * @returns the created texture
  83307. */
  83308. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83309. /**
  83310. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83311. * @param data Define the base64 payload without the data: prefix
  83312. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83313. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83314. * @param scene Define the scene the texture should belong to
  83315. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83316. * @param noMipmap Forces the texture to not create mip map information if true
  83317. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83318. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83319. * @param onLoad define a callback triggered when the texture has been loaded
  83320. * @param onError define a callback triggered when an error occurred during the loading session
  83321. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83322. * @returns the created texture
  83323. */
  83324. 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;
  83325. }
  83326. }
  83327. declare module BABYLON {
  83328. /**
  83329. * PostProcessManager is used to manage one or more post processes or post process pipelines
  83330. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83331. */
  83332. export class PostProcessManager {
  83333. private _scene;
  83334. private _indexBuffer;
  83335. private _vertexBuffers;
  83336. /**
  83337. * Creates a new instance PostProcess
  83338. * @param scene The scene that the post process is associated with.
  83339. */
  83340. constructor(scene: Scene);
  83341. private _prepareBuffers;
  83342. private _buildIndexBuffer;
  83343. /**
  83344. * Rebuilds the vertex buffers of the manager.
  83345. * @hidden
  83346. */
  83347. _rebuild(): void;
  83348. /**
  83349. * Prepares a frame to be run through a post process.
  83350. * @param sourceTexture The input texture to the post procesess. (default: null)
  83351. * @param postProcesses An array of post processes to be run. (default: null)
  83352. * @returns True if the post processes were able to be run.
  83353. * @hidden
  83354. */
  83355. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  83356. /**
  83357. * Manually render a set of post processes to a texture.
  83358. * @param postProcesses An array of post processes to be run.
  83359. * @param targetTexture The target texture to render to.
  83360. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  83361. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  83362. * @param lodLevel defines which lod of the texture to render to
  83363. */
  83364. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  83365. /**
  83366. * Finalize the result of the output of the postprocesses.
  83367. * @param doNotPresent If true the result will not be displayed to the screen.
  83368. * @param targetTexture The target texture to render to.
  83369. * @param faceIndex The index of the face to bind the target texture to.
  83370. * @param postProcesses The array of post processes to render.
  83371. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  83372. * @hidden
  83373. */
  83374. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  83375. /**
  83376. * Disposes of the post process manager.
  83377. */
  83378. dispose(): void;
  83379. }
  83380. }
  83381. declare module BABYLON {
  83382. /** Interface used by value gradients (color, factor, ...) */
  83383. export interface IValueGradient {
  83384. /**
  83385. * Gets or sets the gradient value (between 0 and 1)
  83386. */
  83387. gradient: number;
  83388. }
  83389. /** Class used to store color4 gradient */
  83390. export class ColorGradient implements IValueGradient {
  83391. /**
  83392. * Gets or sets the gradient value (between 0 and 1)
  83393. */
  83394. gradient: number;
  83395. /**
  83396. * Gets or sets first associated color
  83397. */
  83398. color1: Color4;
  83399. /**
  83400. * Gets or sets second associated color
  83401. */
  83402. color2?: Color4;
  83403. /**
  83404. * Will get a color picked randomly between color1 and color2.
  83405. * If color2 is undefined then color1 will be used
  83406. * @param result defines the target Color4 to store the result in
  83407. */
  83408. getColorToRef(result: Color4): void;
  83409. }
  83410. /** Class used to store color 3 gradient */
  83411. export class Color3Gradient implements IValueGradient {
  83412. /**
  83413. * Gets or sets the gradient value (between 0 and 1)
  83414. */
  83415. gradient: number;
  83416. /**
  83417. * Gets or sets the associated color
  83418. */
  83419. color: Color3;
  83420. }
  83421. /** Class used to store factor gradient */
  83422. export class FactorGradient implements IValueGradient {
  83423. /**
  83424. * Gets or sets the gradient value (between 0 and 1)
  83425. */
  83426. gradient: number;
  83427. /**
  83428. * Gets or sets first associated factor
  83429. */
  83430. factor1: number;
  83431. /**
  83432. * Gets or sets second associated factor
  83433. */
  83434. factor2?: number;
  83435. /**
  83436. * Will get a number picked randomly between factor1 and factor2.
  83437. * If factor2 is undefined then factor1 will be used
  83438. * @returns the picked number
  83439. */
  83440. getFactor(): number;
  83441. }
  83442. /**
  83443. * Helper used to simplify some generic gradient tasks
  83444. */
  83445. export class GradientHelper {
  83446. /**
  83447. * Gets the current gradient from an array of IValueGradient
  83448. * @param ratio defines the current ratio to get
  83449. * @param gradients defines the array of IValueGradient
  83450. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83451. */
  83452. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83453. }
  83454. }
  83455. declare module BABYLON {
  83456. interface ThinEngine {
  83457. /**
  83458. * Creates a dynamic texture
  83459. * @param width defines the width of the texture
  83460. * @param height defines the height of the texture
  83461. * @param generateMipMaps defines if the engine should generate the mip levels
  83462. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83463. * @returns the dynamic texture inside an InternalTexture
  83464. */
  83465. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83466. /**
  83467. * Update the content of a dynamic texture
  83468. * @param texture defines the texture to update
  83469. * @param canvas defines the canvas containing the source
  83470. * @param invertY defines if data must be stored with Y axis inverted
  83471. * @param premulAlpha defines if alpha is stored as premultiplied
  83472. * @param format defines the format of the data
  83473. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83474. */
  83475. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83476. }
  83477. }
  83478. declare module BABYLON {
  83479. /**
  83480. * Helper class used to generate a canvas to manipulate images
  83481. */
  83482. export class CanvasGenerator {
  83483. /**
  83484. * Create a new canvas (or offscreen canvas depending on the context)
  83485. * @param width defines the expected width
  83486. * @param height defines the expected height
  83487. * @return a new canvas or offscreen canvas
  83488. */
  83489. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83490. }
  83491. }
  83492. declare module BABYLON {
  83493. /**
  83494. * A class extending Texture allowing drawing on a texture
  83495. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83496. */
  83497. export class DynamicTexture extends Texture {
  83498. private _generateMipMaps;
  83499. private _canvas;
  83500. private _context;
  83501. private _engine;
  83502. /**
  83503. * Creates a DynamicTexture
  83504. * @param name defines the name of the texture
  83505. * @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
  83506. * @param scene defines the scene where you want the texture
  83507. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83508. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83509. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83510. */
  83511. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83512. /**
  83513. * Get the current class name of the texture useful for serialization or dynamic coding.
  83514. * @returns "DynamicTexture"
  83515. */
  83516. getClassName(): string;
  83517. /**
  83518. * Gets the current state of canRescale
  83519. */
  83520. readonly canRescale: boolean;
  83521. private _recreate;
  83522. /**
  83523. * Scales the texture
  83524. * @param ratio the scale factor to apply to both width and height
  83525. */
  83526. scale(ratio: number): void;
  83527. /**
  83528. * Resizes the texture
  83529. * @param width the new width
  83530. * @param height the new height
  83531. */
  83532. scaleTo(width: number, height: number): void;
  83533. /**
  83534. * Gets the context of the canvas used by the texture
  83535. * @returns the canvas context of the dynamic texture
  83536. */
  83537. getContext(): CanvasRenderingContext2D;
  83538. /**
  83539. * Clears the texture
  83540. */
  83541. clear(): void;
  83542. /**
  83543. * Updates the texture
  83544. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83545. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83546. */
  83547. update(invertY?: boolean, premulAlpha?: boolean): void;
  83548. /**
  83549. * Draws text onto the texture
  83550. * @param text defines the text to be drawn
  83551. * @param x defines the placement of the text from the left
  83552. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83553. * @param font defines the font to be used with font-style, font-size, font-name
  83554. * @param color defines the color used for the text
  83555. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83556. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83557. * @param update defines whether texture is immediately update (default is true)
  83558. */
  83559. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83560. /**
  83561. * Clones the texture
  83562. * @returns the clone of the texture.
  83563. */
  83564. clone(): DynamicTexture;
  83565. /**
  83566. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83567. * @returns a serialized dynamic texture object
  83568. */
  83569. serialize(): any;
  83570. /** @hidden */
  83571. _rebuild(): void;
  83572. }
  83573. }
  83574. declare module BABYLON {
  83575. interface AbstractScene {
  83576. /**
  83577. * The list of procedural textures added to the scene
  83578. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83579. */
  83580. proceduralTextures: Array<ProceduralTexture>;
  83581. }
  83582. /**
  83583. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83584. * in a given scene.
  83585. */
  83586. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83587. /**
  83588. * The component name helpfull to identify the component in the list of scene components.
  83589. */
  83590. readonly name: string;
  83591. /**
  83592. * The scene the component belongs to.
  83593. */
  83594. scene: Scene;
  83595. /**
  83596. * Creates a new instance of the component for the given scene
  83597. * @param scene Defines the scene to register the component in
  83598. */
  83599. constructor(scene: Scene);
  83600. /**
  83601. * Registers the component in a given scene
  83602. */
  83603. register(): void;
  83604. /**
  83605. * Rebuilds the elements related to this component in case of
  83606. * context lost for instance.
  83607. */
  83608. rebuild(): void;
  83609. /**
  83610. * Disposes the component and the associated ressources.
  83611. */
  83612. dispose(): void;
  83613. private _beforeClear;
  83614. }
  83615. }
  83616. declare module BABYLON {
  83617. interface ThinEngine {
  83618. /**
  83619. * Creates a new render target cube texture
  83620. * @param size defines the size of the texture
  83621. * @param options defines the options used to create the texture
  83622. * @returns a new render target cube texture stored in an InternalTexture
  83623. */
  83624. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83625. }
  83626. }
  83627. declare module BABYLON {
  83628. /** @hidden */
  83629. export var proceduralVertexShader: {
  83630. name: string;
  83631. shader: string;
  83632. };
  83633. }
  83634. declare module BABYLON {
  83635. /**
  83636. * 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.
  83637. * This is the base class of any Procedural texture and contains most of the shareable code.
  83638. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83639. */
  83640. export class ProceduralTexture extends Texture {
  83641. isCube: boolean;
  83642. /**
  83643. * Define if the texture is enabled or not (disabled texture will not render)
  83644. */
  83645. isEnabled: boolean;
  83646. /**
  83647. * Define if the texture must be cleared before rendering (default is true)
  83648. */
  83649. autoClear: boolean;
  83650. /**
  83651. * Callback called when the texture is generated
  83652. */
  83653. onGenerated: () => void;
  83654. /**
  83655. * Event raised when the texture is generated
  83656. */
  83657. onGeneratedObservable: Observable<ProceduralTexture>;
  83658. /** @hidden */
  83659. _generateMipMaps: boolean;
  83660. /** @hidden **/
  83661. _effect: Effect;
  83662. /** @hidden */
  83663. _textures: {
  83664. [key: string]: Texture;
  83665. };
  83666. private _size;
  83667. private _currentRefreshId;
  83668. private _refreshRate;
  83669. private _vertexBuffers;
  83670. private _indexBuffer;
  83671. private _uniforms;
  83672. private _samplers;
  83673. private _fragment;
  83674. private _floats;
  83675. private _ints;
  83676. private _floatsArrays;
  83677. private _colors3;
  83678. private _colors4;
  83679. private _vectors2;
  83680. private _vectors3;
  83681. private _matrices;
  83682. private _fallbackTexture;
  83683. private _fallbackTextureUsed;
  83684. private _engine;
  83685. private _cachedDefines;
  83686. private _contentUpdateId;
  83687. private _contentData;
  83688. /**
  83689. * Instantiates a new procedural texture.
  83690. * 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.
  83691. * This is the base class of any Procedural texture and contains most of the shareable code.
  83692. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83693. * @param name Define the name of the texture
  83694. * @param size Define the size of the texture to create
  83695. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83696. * @param scene Define the scene the texture belongs to
  83697. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83698. * @param generateMipMaps Define if the texture should creates mip maps or not
  83699. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83700. */
  83701. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83702. /**
  83703. * The effect that is created when initializing the post process.
  83704. * @returns The created effect corresponding the the postprocess.
  83705. */
  83706. getEffect(): Effect;
  83707. /**
  83708. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83709. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83710. */
  83711. getContent(): Nullable<ArrayBufferView>;
  83712. private _createIndexBuffer;
  83713. /** @hidden */
  83714. _rebuild(): void;
  83715. /**
  83716. * Resets the texture in order to recreate its associated resources.
  83717. * This can be called in case of context loss
  83718. */
  83719. reset(): void;
  83720. protected _getDefines(): string;
  83721. /**
  83722. * Is the texture ready to be used ? (rendered at least once)
  83723. * @returns true if ready, otherwise, false.
  83724. */
  83725. isReady(): boolean;
  83726. /**
  83727. * Resets the refresh counter of the texture and start bak from scratch.
  83728. * Could be useful to regenerate the texture if it is setup to render only once.
  83729. */
  83730. resetRefreshCounter(): void;
  83731. /**
  83732. * Set the fragment shader to use in order to render the texture.
  83733. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83734. */
  83735. setFragment(fragment: any): void;
  83736. /**
  83737. * Define the refresh rate of the texture or the rendering frequency.
  83738. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83739. */
  83740. refreshRate: number;
  83741. /** @hidden */
  83742. _shouldRender(): boolean;
  83743. /**
  83744. * Get the size the texture is rendering at.
  83745. * @returns the size (texture is always squared)
  83746. */
  83747. getRenderSize(): number;
  83748. /**
  83749. * Resize the texture to new value.
  83750. * @param size Define the new size the texture should have
  83751. * @param generateMipMaps Define whether the new texture should create mip maps
  83752. */
  83753. resize(size: number, generateMipMaps: boolean): void;
  83754. private _checkUniform;
  83755. /**
  83756. * Set a texture in the shader program used to render.
  83757. * @param name Define the name of the uniform samplers as defined in the shader
  83758. * @param texture Define the texture to bind to this sampler
  83759. * @return the texture itself allowing "fluent" like uniform updates
  83760. */
  83761. setTexture(name: string, texture: Texture): ProceduralTexture;
  83762. /**
  83763. * Set a float in the shader.
  83764. * @param name Define the name of the uniform as defined in the shader
  83765. * @param value Define the value to give to the uniform
  83766. * @return the texture itself allowing "fluent" like uniform updates
  83767. */
  83768. setFloat(name: string, value: number): ProceduralTexture;
  83769. /**
  83770. * Set a int in the shader.
  83771. * @param name Define the name of the uniform as defined in the shader
  83772. * @param value Define the value to give to the uniform
  83773. * @return the texture itself allowing "fluent" like uniform updates
  83774. */
  83775. setInt(name: string, value: number): ProceduralTexture;
  83776. /**
  83777. * Set an array of floats in the shader.
  83778. * @param name Define the name of the uniform as defined in the shader
  83779. * @param value Define the value to give to the uniform
  83780. * @return the texture itself allowing "fluent" like uniform updates
  83781. */
  83782. setFloats(name: string, value: number[]): ProceduralTexture;
  83783. /**
  83784. * Set a vec3 in the shader from a Color3.
  83785. * @param name Define the name of the uniform as defined in the shader
  83786. * @param value Define the value to give to the uniform
  83787. * @return the texture itself allowing "fluent" like uniform updates
  83788. */
  83789. setColor3(name: string, value: Color3): ProceduralTexture;
  83790. /**
  83791. * Set a vec4 in the shader from a Color4.
  83792. * @param name Define the name of the uniform as defined in the shader
  83793. * @param value Define the value to give to the uniform
  83794. * @return the texture itself allowing "fluent" like uniform updates
  83795. */
  83796. setColor4(name: string, value: Color4): ProceduralTexture;
  83797. /**
  83798. * Set a vec2 in the shader from a Vector2.
  83799. * @param name Define the name of the uniform as defined in the shader
  83800. * @param value Define the value to give to the uniform
  83801. * @return the texture itself allowing "fluent" like uniform updates
  83802. */
  83803. setVector2(name: string, value: Vector2): ProceduralTexture;
  83804. /**
  83805. * Set a vec3 in the shader from a Vector3.
  83806. * @param name Define the name of the uniform as defined in the shader
  83807. * @param value Define the value to give to the uniform
  83808. * @return the texture itself allowing "fluent" like uniform updates
  83809. */
  83810. setVector3(name: string, value: Vector3): ProceduralTexture;
  83811. /**
  83812. * Set a mat4 in the shader from a MAtrix.
  83813. * @param name Define the name of the uniform as defined in the shader
  83814. * @param value Define the value to give to the uniform
  83815. * @return the texture itself allowing "fluent" like uniform updates
  83816. */
  83817. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83818. /**
  83819. * Render the texture to its associated render target.
  83820. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83821. */
  83822. render(useCameraPostProcess?: boolean): void;
  83823. /**
  83824. * Clone the texture.
  83825. * @returns the cloned texture
  83826. */
  83827. clone(): ProceduralTexture;
  83828. /**
  83829. * Dispose the texture and release its asoociated resources.
  83830. */
  83831. dispose(): void;
  83832. }
  83833. }
  83834. declare module BABYLON {
  83835. /**
  83836. * This represents the base class for particle system in Babylon.
  83837. * 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.
  83838. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83839. * @example https://doc.babylonjs.com/babylon101/particles
  83840. */
  83841. export class BaseParticleSystem {
  83842. /**
  83843. * Source color is added to the destination color without alpha affecting the result
  83844. */
  83845. static BLENDMODE_ONEONE: number;
  83846. /**
  83847. * Blend current color and particle color using particle’s alpha
  83848. */
  83849. static BLENDMODE_STANDARD: number;
  83850. /**
  83851. * Add current color and particle color multiplied by particle’s alpha
  83852. */
  83853. static BLENDMODE_ADD: number;
  83854. /**
  83855. * Multiply current color with particle color
  83856. */
  83857. static BLENDMODE_MULTIPLY: number;
  83858. /**
  83859. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83860. */
  83861. static BLENDMODE_MULTIPLYADD: number;
  83862. /**
  83863. * List of animations used by the particle system.
  83864. */
  83865. animations: Animation[];
  83866. /**
  83867. * The id of the Particle system.
  83868. */
  83869. id: string;
  83870. /**
  83871. * The friendly name of the Particle system.
  83872. */
  83873. name: string;
  83874. /**
  83875. * The rendering group used by the Particle system to chose when to render.
  83876. */
  83877. renderingGroupId: number;
  83878. /**
  83879. * The emitter represents the Mesh or position we are attaching the particle system to.
  83880. */
  83881. emitter: Nullable<AbstractMesh | Vector3>;
  83882. /**
  83883. * The maximum number of particles to emit per frame
  83884. */
  83885. emitRate: number;
  83886. /**
  83887. * If you want to launch only a few particles at once, that can be done, as well.
  83888. */
  83889. manualEmitCount: number;
  83890. /**
  83891. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83892. */
  83893. updateSpeed: number;
  83894. /**
  83895. * The amount of time the particle system is running (depends of the overall update speed).
  83896. */
  83897. targetStopDuration: number;
  83898. /**
  83899. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83900. */
  83901. disposeOnStop: boolean;
  83902. /**
  83903. * Minimum power of emitting particles.
  83904. */
  83905. minEmitPower: number;
  83906. /**
  83907. * Maximum power of emitting particles.
  83908. */
  83909. maxEmitPower: number;
  83910. /**
  83911. * Minimum life time of emitting particles.
  83912. */
  83913. minLifeTime: number;
  83914. /**
  83915. * Maximum life time of emitting particles.
  83916. */
  83917. maxLifeTime: number;
  83918. /**
  83919. * Minimum Size of emitting particles.
  83920. */
  83921. minSize: number;
  83922. /**
  83923. * Maximum Size of emitting particles.
  83924. */
  83925. maxSize: number;
  83926. /**
  83927. * Minimum scale of emitting particles on X axis.
  83928. */
  83929. minScaleX: number;
  83930. /**
  83931. * Maximum scale of emitting particles on X axis.
  83932. */
  83933. maxScaleX: number;
  83934. /**
  83935. * Minimum scale of emitting particles on Y axis.
  83936. */
  83937. minScaleY: number;
  83938. /**
  83939. * Maximum scale of emitting particles on Y axis.
  83940. */
  83941. maxScaleY: number;
  83942. /**
  83943. * Gets or sets the minimal initial rotation in radians.
  83944. */
  83945. minInitialRotation: number;
  83946. /**
  83947. * Gets or sets the maximal initial rotation in radians.
  83948. */
  83949. maxInitialRotation: number;
  83950. /**
  83951. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83952. */
  83953. minAngularSpeed: number;
  83954. /**
  83955. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83956. */
  83957. maxAngularSpeed: number;
  83958. /**
  83959. * The texture used to render each particle. (this can be a spritesheet)
  83960. */
  83961. particleTexture: Nullable<Texture>;
  83962. /**
  83963. * The layer mask we are rendering the particles through.
  83964. */
  83965. layerMask: number;
  83966. /**
  83967. * This can help using your own shader to render the particle system.
  83968. * The according effect will be created
  83969. */
  83970. customShader: any;
  83971. /**
  83972. * By default particle system starts as soon as they are created. This prevents the
  83973. * automatic start to happen and let you decide when to start emitting particles.
  83974. */
  83975. preventAutoStart: boolean;
  83976. private _noiseTexture;
  83977. /**
  83978. * Gets or sets a texture used to add random noise to particle positions
  83979. */
  83980. noiseTexture: Nullable<ProceduralTexture>;
  83981. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83982. noiseStrength: Vector3;
  83983. /**
  83984. * Callback triggered when the particle animation is ending.
  83985. */
  83986. onAnimationEnd: Nullable<() => void>;
  83987. /**
  83988. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83989. */
  83990. blendMode: number;
  83991. /**
  83992. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83993. * to override the particles.
  83994. */
  83995. forceDepthWrite: boolean;
  83996. /** 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 */
  83997. preWarmCycles: number;
  83998. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83999. preWarmStepOffset: number;
  84000. /**
  84001. * 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)
  84002. */
  84003. spriteCellChangeSpeed: number;
  84004. /**
  84005. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84006. */
  84007. startSpriteCellID: number;
  84008. /**
  84009. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84010. */
  84011. endSpriteCellID: number;
  84012. /**
  84013. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84014. */
  84015. spriteCellWidth: number;
  84016. /**
  84017. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84018. */
  84019. spriteCellHeight: number;
  84020. /**
  84021. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84022. */
  84023. spriteRandomStartCell: boolean;
  84024. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84025. translationPivot: Vector2;
  84026. /** @hidden */
  84027. protected _isAnimationSheetEnabled: boolean;
  84028. /**
  84029. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84030. */
  84031. beginAnimationOnStart: boolean;
  84032. /**
  84033. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84034. */
  84035. beginAnimationFrom: number;
  84036. /**
  84037. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84038. */
  84039. beginAnimationTo: number;
  84040. /**
  84041. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84042. */
  84043. beginAnimationLoop: boolean;
  84044. /**
  84045. * Gets or sets a world offset applied to all particles
  84046. */
  84047. worldOffset: Vector3;
  84048. /**
  84049. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84050. */
  84051. isAnimationSheetEnabled: boolean;
  84052. /**
  84053. * Get hosting scene
  84054. * @returns the scene
  84055. */
  84056. getScene(): Scene;
  84057. /**
  84058. * You can use gravity if you want to give an orientation to your particles.
  84059. */
  84060. gravity: Vector3;
  84061. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84062. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84063. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84064. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84065. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84066. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84067. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84068. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84069. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84070. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84071. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84072. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84073. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84074. /**
  84075. * Defines the delay in milliseconds before starting the system (0 by default)
  84076. */
  84077. startDelay: number;
  84078. /**
  84079. * Gets the current list of drag gradients.
  84080. * You must use addDragGradient and removeDragGradient to udpate this list
  84081. * @returns the list of drag gradients
  84082. */
  84083. getDragGradients(): Nullable<Array<FactorGradient>>;
  84084. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84085. limitVelocityDamping: number;
  84086. /**
  84087. * Gets the current list of limit velocity gradients.
  84088. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84089. * @returns the list of limit velocity gradients
  84090. */
  84091. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84092. /**
  84093. * Gets the current list of color gradients.
  84094. * You must use addColorGradient and removeColorGradient to udpate this list
  84095. * @returns the list of color gradients
  84096. */
  84097. getColorGradients(): Nullable<Array<ColorGradient>>;
  84098. /**
  84099. * Gets the current list of size gradients.
  84100. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84101. * @returns the list of size gradients
  84102. */
  84103. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84104. /**
  84105. * Gets the current list of color remap gradients.
  84106. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84107. * @returns the list of color remap gradients
  84108. */
  84109. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84110. /**
  84111. * Gets the current list of alpha remap gradients.
  84112. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84113. * @returns the list of alpha remap gradients
  84114. */
  84115. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84116. /**
  84117. * Gets the current list of life time gradients.
  84118. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84119. * @returns the list of life time gradients
  84120. */
  84121. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84122. /**
  84123. * Gets the current list of angular speed gradients.
  84124. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84125. * @returns the list of angular speed gradients
  84126. */
  84127. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84128. /**
  84129. * Gets the current list of velocity gradients.
  84130. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84131. * @returns the list of velocity gradients
  84132. */
  84133. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84134. /**
  84135. * Gets the current list of start size gradients.
  84136. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84137. * @returns the list of start size gradients
  84138. */
  84139. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84140. /**
  84141. * Gets the current list of emit rate gradients.
  84142. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84143. * @returns the list of emit rate gradients
  84144. */
  84145. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84146. /**
  84147. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84148. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84149. */
  84150. direction1: Vector3;
  84151. /**
  84152. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84153. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84154. */
  84155. direction2: Vector3;
  84156. /**
  84157. * 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.
  84158. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84159. */
  84160. minEmitBox: Vector3;
  84161. /**
  84162. * 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.
  84163. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84164. */
  84165. maxEmitBox: Vector3;
  84166. /**
  84167. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84168. */
  84169. color1: Color4;
  84170. /**
  84171. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84172. */
  84173. color2: Color4;
  84174. /**
  84175. * Color the particle will have at the end of its lifetime
  84176. */
  84177. colorDead: Color4;
  84178. /**
  84179. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84180. */
  84181. textureMask: Color4;
  84182. /**
  84183. * The particle emitter type defines the emitter used by the particle system.
  84184. * It can be for example box, sphere, or cone...
  84185. */
  84186. particleEmitterType: IParticleEmitterType;
  84187. /** @hidden */
  84188. _isSubEmitter: boolean;
  84189. /**
  84190. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84191. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84192. */
  84193. billboardMode: number;
  84194. protected _isBillboardBased: boolean;
  84195. /**
  84196. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84197. */
  84198. isBillboardBased: boolean;
  84199. /**
  84200. * The scene the particle system belongs to.
  84201. */
  84202. protected _scene: Scene;
  84203. /**
  84204. * Local cache of defines for image processing.
  84205. */
  84206. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84207. /**
  84208. * Default configuration related to image processing available in the standard Material.
  84209. */
  84210. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84211. /**
  84212. * Gets the image processing configuration used either in this material.
  84213. */
  84214. /**
  84215. * Sets the Default image processing configuration used either in the this material.
  84216. *
  84217. * If sets to null, the scene one is in use.
  84218. */
  84219. imageProcessingConfiguration: ImageProcessingConfiguration;
  84220. /**
  84221. * Attaches a new image processing configuration to the Standard Material.
  84222. * @param configuration
  84223. */
  84224. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84225. /** @hidden */
  84226. protected _reset(): void;
  84227. /** @hidden */
  84228. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84229. /**
  84230. * Instantiates a particle system.
  84231. * 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.
  84232. * @param name The name of the particle system
  84233. */
  84234. constructor(name: string);
  84235. /**
  84236. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84237. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84238. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84239. * @returns the emitter
  84240. */
  84241. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84242. /**
  84243. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84244. * @param radius The radius of the hemisphere to emit from
  84245. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84246. * @returns the emitter
  84247. */
  84248. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84249. /**
  84250. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84251. * @param radius The radius of the sphere to emit from
  84252. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84253. * @returns the emitter
  84254. */
  84255. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84256. /**
  84257. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84258. * @param radius The radius of the sphere to emit from
  84259. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84260. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84261. * @returns the emitter
  84262. */
  84263. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84264. /**
  84265. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84266. * @param radius The radius of the emission cylinder
  84267. * @param height The height of the emission cylinder
  84268. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84269. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84270. * @returns the emitter
  84271. */
  84272. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84273. /**
  84274. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84275. * @param radius The radius of the cylinder to emit from
  84276. * @param height The height of the emission cylinder
  84277. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84278. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84279. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84280. * @returns the emitter
  84281. */
  84282. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84283. /**
  84284. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84285. * @param radius The radius of the cone to emit from
  84286. * @param angle The base angle of the cone
  84287. * @returns the emitter
  84288. */
  84289. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84290. /**
  84291. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84292. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84293. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84294. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84295. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84296. * @returns the emitter
  84297. */
  84298. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84299. }
  84300. }
  84301. declare module BABYLON {
  84302. /**
  84303. * Type of sub emitter
  84304. */
  84305. export enum SubEmitterType {
  84306. /**
  84307. * Attached to the particle over it's lifetime
  84308. */
  84309. ATTACHED = 0,
  84310. /**
  84311. * Created when the particle dies
  84312. */
  84313. END = 1
  84314. }
  84315. /**
  84316. * Sub emitter class used to emit particles from an existing particle
  84317. */
  84318. export class SubEmitter {
  84319. /**
  84320. * the particle system to be used by the sub emitter
  84321. */
  84322. particleSystem: ParticleSystem;
  84323. /**
  84324. * Type of the submitter (Default: END)
  84325. */
  84326. type: SubEmitterType;
  84327. /**
  84328. * 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)
  84329. * Note: This only is supported when using an emitter of type Mesh
  84330. */
  84331. inheritDirection: boolean;
  84332. /**
  84333. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84334. */
  84335. inheritedVelocityAmount: number;
  84336. /**
  84337. * Creates a sub emitter
  84338. * @param particleSystem the particle system to be used by the sub emitter
  84339. */
  84340. constructor(
  84341. /**
  84342. * the particle system to be used by the sub emitter
  84343. */
  84344. particleSystem: ParticleSystem);
  84345. /**
  84346. * Clones the sub emitter
  84347. * @returns the cloned sub emitter
  84348. */
  84349. clone(): SubEmitter;
  84350. /**
  84351. * Serialize current object to a JSON object
  84352. * @returns the serialized object
  84353. */
  84354. serialize(): any;
  84355. /** @hidden */
  84356. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84357. /**
  84358. * Creates a new SubEmitter from a serialized JSON version
  84359. * @param serializationObject defines the JSON object to read from
  84360. * @param scene defines the hosting scene
  84361. * @param rootUrl defines the rootUrl for data loading
  84362. * @returns a new SubEmitter
  84363. */
  84364. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84365. /** Release associated resources */
  84366. dispose(): void;
  84367. }
  84368. }
  84369. declare module BABYLON {
  84370. /** @hidden */
  84371. export var clipPlaneFragmentDeclaration: {
  84372. name: string;
  84373. shader: string;
  84374. };
  84375. }
  84376. declare module BABYLON {
  84377. /** @hidden */
  84378. export var imageProcessingDeclaration: {
  84379. name: string;
  84380. shader: string;
  84381. };
  84382. }
  84383. declare module BABYLON {
  84384. /** @hidden */
  84385. export var imageProcessingFunctions: {
  84386. name: string;
  84387. shader: string;
  84388. };
  84389. }
  84390. declare module BABYLON {
  84391. /** @hidden */
  84392. export var clipPlaneFragment: {
  84393. name: string;
  84394. shader: string;
  84395. };
  84396. }
  84397. declare module BABYLON {
  84398. /** @hidden */
  84399. export var particlesPixelShader: {
  84400. name: string;
  84401. shader: string;
  84402. };
  84403. }
  84404. declare module BABYLON {
  84405. /** @hidden */
  84406. export var clipPlaneVertexDeclaration: {
  84407. name: string;
  84408. shader: string;
  84409. };
  84410. }
  84411. declare module BABYLON {
  84412. /** @hidden */
  84413. export var clipPlaneVertex: {
  84414. name: string;
  84415. shader: string;
  84416. };
  84417. }
  84418. declare module BABYLON {
  84419. /** @hidden */
  84420. export var particlesVertexShader: {
  84421. name: string;
  84422. shader: string;
  84423. };
  84424. }
  84425. declare module BABYLON {
  84426. /**
  84427. * This represents a particle system in Babylon.
  84428. * 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.
  84429. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84430. * @example https://doc.babylonjs.com/babylon101/particles
  84431. */
  84432. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84433. /**
  84434. * Billboard mode will only apply to Y axis
  84435. */
  84436. static readonly BILLBOARDMODE_Y: number;
  84437. /**
  84438. * Billboard mode will apply to all axes
  84439. */
  84440. static readonly BILLBOARDMODE_ALL: number;
  84441. /**
  84442. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84443. */
  84444. static readonly BILLBOARDMODE_STRETCHED: number;
  84445. /**
  84446. * This function can be defined to provide custom update for active particles.
  84447. * This function will be called instead of regular update (age, position, color, etc.).
  84448. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84449. */
  84450. updateFunction: (particles: Particle[]) => void;
  84451. private _emitterWorldMatrix;
  84452. /**
  84453. * This function can be defined to specify initial direction for every new particle.
  84454. * It by default use the emitterType defined function
  84455. */
  84456. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84457. /**
  84458. * This function can be defined to specify initial position for every new particle.
  84459. * It by default use the emitterType defined function
  84460. */
  84461. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84462. /**
  84463. * @hidden
  84464. */
  84465. _inheritedVelocityOffset: Vector3;
  84466. /**
  84467. * An event triggered when the system is disposed
  84468. */
  84469. onDisposeObservable: Observable<ParticleSystem>;
  84470. private _onDisposeObserver;
  84471. /**
  84472. * Sets a callback that will be triggered when the system is disposed
  84473. */
  84474. onDispose: () => void;
  84475. private _particles;
  84476. private _epsilon;
  84477. private _capacity;
  84478. private _stockParticles;
  84479. private _newPartsExcess;
  84480. private _vertexData;
  84481. private _vertexBuffer;
  84482. private _vertexBuffers;
  84483. private _spriteBuffer;
  84484. private _indexBuffer;
  84485. private _effect;
  84486. private _customEffect;
  84487. private _cachedDefines;
  84488. private _scaledColorStep;
  84489. private _colorDiff;
  84490. private _scaledDirection;
  84491. private _scaledGravity;
  84492. private _currentRenderId;
  84493. private _alive;
  84494. private _useInstancing;
  84495. private _started;
  84496. private _stopped;
  84497. private _actualFrame;
  84498. private _scaledUpdateSpeed;
  84499. private _vertexBufferSize;
  84500. /** @hidden */
  84501. _currentEmitRateGradient: Nullable<FactorGradient>;
  84502. /** @hidden */
  84503. _currentEmitRate1: number;
  84504. /** @hidden */
  84505. _currentEmitRate2: number;
  84506. /** @hidden */
  84507. _currentStartSizeGradient: Nullable<FactorGradient>;
  84508. /** @hidden */
  84509. _currentStartSize1: number;
  84510. /** @hidden */
  84511. _currentStartSize2: number;
  84512. private readonly _rawTextureWidth;
  84513. private _rampGradientsTexture;
  84514. private _useRampGradients;
  84515. /** Gets or sets a boolean indicating that ramp gradients must be used
  84516. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84517. */
  84518. useRampGradients: boolean;
  84519. /**
  84520. * 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.
  84521. * 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: [])
  84522. */
  84523. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84524. private _subEmitters;
  84525. /**
  84526. * @hidden
  84527. * If the particle systems emitter should be disposed when the particle system is disposed
  84528. */
  84529. _disposeEmitterOnDispose: boolean;
  84530. /**
  84531. * The current active Sub-systems, this property is used by the root particle system only.
  84532. */
  84533. activeSubSystems: Array<ParticleSystem>;
  84534. private _rootParticleSystem;
  84535. /**
  84536. * Gets the current list of active particles
  84537. */
  84538. readonly particles: Particle[];
  84539. /**
  84540. * Returns the string "ParticleSystem"
  84541. * @returns a string containing the class name
  84542. */
  84543. getClassName(): string;
  84544. /**
  84545. * Instantiates a particle system.
  84546. * 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.
  84547. * @param name The name of the particle system
  84548. * @param capacity The max number of particles alive at the same time
  84549. * @param scene The scene the particle system belongs to
  84550. * @param customEffect a custom effect used to change the way particles are rendered by default
  84551. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84552. * @param epsilon Offset used to render the particles
  84553. */
  84554. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84555. private _addFactorGradient;
  84556. private _removeFactorGradient;
  84557. /**
  84558. * Adds a new life time gradient
  84559. * @param gradient defines the gradient to use (between 0 and 1)
  84560. * @param factor defines the life time factor to affect to the specified gradient
  84561. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84562. * @returns the current particle system
  84563. */
  84564. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84565. /**
  84566. * Remove a specific life time gradient
  84567. * @param gradient defines the gradient to remove
  84568. * @returns the current particle system
  84569. */
  84570. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84571. /**
  84572. * Adds a new size gradient
  84573. * @param gradient defines the gradient to use (between 0 and 1)
  84574. * @param factor defines the size factor to affect to the specified gradient
  84575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84576. * @returns the current particle system
  84577. */
  84578. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84579. /**
  84580. * Remove a specific size gradient
  84581. * @param gradient defines the gradient to remove
  84582. * @returns the current particle system
  84583. */
  84584. removeSizeGradient(gradient: number): IParticleSystem;
  84585. /**
  84586. * Adds a new color remap gradient
  84587. * @param gradient defines the gradient to use (between 0 and 1)
  84588. * @param min defines the color remap minimal range
  84589. * @param max defines the color remap maximal range
  84590. * @returns the current particle system
  84591. */
  84592. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84593. /**
  84594. * Remove a specific color remap gradient
  84595. * @param gradient defines the gradient to remove
  84596. * @returns the current particle system
  84597. */
  84598. removeColorRemapGradient(gradient: number): IParticleSystem;
  84599. /**
  84600. * Adds a new alpha remap gradient
  84601. * @param gradient defines the gradient to use (between 0 and 1)
  84602. * @param min defines the alpha remap minimal range
  84603. * @param max defines the alpha remap maximal range
  84604. * @returns the current particle system
  84605. */
  84606. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84607. /**
  84608. * Remove a specific alpha remap gradient
  84609. * @param gradient defines the gradient to remove
  84610. * @returns the current particle system
  84611. */
  84612. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84613. /**
  84614. * Adds a new angular speed gradient
  84615. * @param gradient defines the gradient to use (between 0 and 1)
  84616. * @param factor defines the angular speed to affect to the specified gradient
  84617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84618. * @returns the current particle system
  84619. */
  84620. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84621. /**
  84622. * Remove a specific angular speed gradient
  84623. * @param gradient defines the gradient to remove
  84624. * @returns the current particle system
  84625. */
  84626. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84627. /**
  84628. * Adds a new velocity gradient
  84629. * @param gradient defines the gradient to use (between 0 and 1)
  84630. * @param factor defines the velocity to affect to the specified gradient
  84631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84632. * @returns the current particle system
  84633. */
  84634. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84635. /**
  84636. * Remove a specific velocity gradient
  84637. * @param gradient defines the gradient to remove
  84638. * @returns the current particle system
  84639. */
  84640. removeVelocityGradient(gradient: number): IParticleSystem;
  84641. /**
  84642. * Adds a new limit velocity gradient
  84643. * @param gradient defines the gradient to use (between 0 and 1)
  84644. * @param factor defines the limit velocity value to affect to the specified gradient
  84645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84646. * @returns the current particle system
  84647. */
  84648. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84649. /**
  84650. * Remove a specific limit velocity gradient
  84651. * @param gradient defines the gradient to remove
  84652. * @returns the current particle system
  84653. */
  84654. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84655. /**
  84656. * Adds a new drag gradient
  84657. * @param gradient defines the gradient to use (between 0 and 1)
  84658. * @param factor defines the drag value to affect to the specified gradient
  84659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84660. * @returns the current particle system
  84661. */
  84662. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84663. /**
  84664. * Remove a specific drag gradient
  84665. * @param gradient defines the gradient to remove
  84666. * @returns the current particle system
  84667. */
  84668. removeDragGradient(gradient: number): IParticleSystem;
  84669. /**
  84670. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84671. * @param gradient defines the gradient to use (between 0 and 1)
  84672. * @param factor defines the emit rate value to affect to the specified gradient
  84673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84674. * @returns the current particle system
  84675. */
  84676. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84677. /**
  84678. * Remove a specific emit rate gradient
  84679. * @param gradient defines the gradient to remove
  84680. * @returns the current particle system
  84681. */
  84682. removeEmitRateGradient(gradient: number): IParticleSystem;
  84683. /**
  84684. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84685. * @param gradient defines the gradient to use (between 0 and 1)
  84686. * @param factor defines the start size value to affect to the specified gradient
  84687. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84688. * @returns the current particle system
  84689. */
  84690. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84691. /**
  84692. * Remove a specific start size gradient
  84693. * @param gradient defines the gradient to remove
  84694. * @returns the current particle system
  84695. */
  84696. removeStartSizeGradient(gradient: number): IParticleSystem;
  84697. private _createRampGradientTexture;
  84698. /**
  84699. * Gets the current list of ramp gradients.
  84700. * You must use addRampGradient and removeRampGradient to udpate this list
  84701. * @returns the list of ramp gradients
  84702. */
  84703. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84704. /**
  84705. * Adds a new ramp gradient used to remap particle colors
  84706. * @param gradient defines the gradient to use (between 0 and 1)
  84707. * @param color defines the color to affect to the specified gradient
  84708. * @returns the current particle system
  84709. */
  84710. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84711. /**
  84712. * Remove a specific ramp gradient
  84713. * @param gradient defines the gradient to remove
  84714. * @returns the current particle system
  84715. */
  84716. removeRampGradient(gradient: number): ParticleSystem;
  84717. /**
  84718. * Adds a new color gradient
  84719. * @param gradient defines the gradient to use (between 0 and 1)
  84720. * @param color1 defines the color to affect to the specified gradient
  84721. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84722. * @returns this particle system
  84723. */
  84724. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84725. /**
  84726. * Remove a specific color gradient
  84727. * @param gradient defines the gradient to remove
  84728. * @returns this particle system
  84729. */
  84730. removeColorGradient(gradient: number): IParticleSystem;
  84731. private _fetchR;
  84732. protected _reset(): void;
  84733. private _resetEffect;
  84734. private _createVertexBuffers;
  84735. private _createIndexBuffer;
  84736. /**
  84737. * Gets the maximum number of particles active at the same time.
  84738. * @returns The max number of active particles.
  84739. */
  84740. getCapacity(): number;
  84741. /**
  84742. * Gets whether there are still active particles in the system.
  84743. * @returns True if it is alive, otherwise false.
  84744. */
  84745. isAlive(): boolean;
  84746. /**
  84747. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84748. * @returns True if it has been started, otherwise false.
  84749. */
  84750. isStarted(): boolean;
  84751. private _prepareSubEmitterInternalArray;
  84752. /**
  84753. * Starts the particle system and begins to emit
  84754. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84755. */
  84756. start(delay?: number): void;
  84757. /**
  84758. * Stops the particle system.
  84759. * @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.
  84760. */
  84761. stop(stopSubEmitters?: boolean): void;
  84762. /**
  84763. * Remove all active particles
  84764. */
  84765. reset(): void;
  84766. /**
  84767. * @hidden (for internal use only)
  84768. */
  84769. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84770. /**
  84771. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84772. * Its lifetime will start back at 0.
  84773. */
  84774. recycleParticle: (particle: Particle) => void;
  84775. private _stopSubEmitters;
  84776. private _createParticle;
  84777. private _removeFromRoot;
  84778. private _emitFromParticle;
  84779. private _update;
  84780. /** @hidden */
  84781. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84782. /** @hidden */
  84783. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84784. /** @hidden */
  84785. private _getEffect;
  84786. /**
  84787. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84788. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84789. */
  84790. animate(preWarmOnly?: boolean): void;
  84791. private _appendParticleVertices;
  84792. /**
  84793. * Rebuilds the particle system.
  84794. */
  84795. rebuild(): void;
  84796. /**
  84797. * Is this system ready to be used/rendered
  84798. * @return true if the system is ready
  84799. */
  84800. isReady(): boolean;
  84801. private _render;
  84802. /**
  84803. * Renders the particle system in its current state.
  84804. * @returns the current number of particles
  84805. */
  84806. render(): number;
  84807. /**
  84808. * Disposes the particle system and free the associated resources
  84809. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84810. */
  84811. dispose(disposeTexture?: boolean): void;
  84812. /**
  84813. * Clones the particle system.
  84814. * @param name The name of the cloned object
  84815. * @param newEmitter The new emitter to use
  84816. * @returns the cloned particle system
  84817. */
  84818. clone(name: string, newEmitter: any): ParticleSystem;
  84819. /**
  84820. * Serializes the particle system to a JSON object.
  84821. * @returns the JSON object
  84822. */
  84823. serialize(): any;
  84824. /** @hidden */
  84825. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84826. /** @hidden */
  84827. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84828. /**
  84829. * Parses a JSON object to create a particle system.
  84830. * @param parsedParticleSystem The JSON object to parse
  84831. * @param scene The scene to create the particle system in
  84832. * @param rootUrl The root url to use to load external dependencies like texture
  84833. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84834. * @returns the Parsed particle system
  84835. */
  84836. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84837. }
  84838. }
  84839. declare module BABYLON {
  84840. /**
  84841. * A particle represents one of the element emitted by a particle system.
  84842. * This is mainly define by its coordinates, direction, velocity and age.
  84843. */
  84844. export class Particle {
  84845. /**
  84846. * The particle system the particle belongs to.
  84847. */
  84848. particleSystem: ParticleSystem;
  84849. private static _Count;
  84850. /**
  84851. * Unique ID of the particle
  84852. */
  84853. id: number;
  84854. /**
  84855. * The world position of the particle in the scene.
  84856. */
  84857. position: Vector3;
  84858. /**
  84859. * The world direction of the particle in the scene.
  84860. */
  84861. direction: Vector3;
  84862. /**
  84863. * The color of the particle.
  84864. */
  84865. color: Color4;
  84866. /**
  84867. * The color change of the particle per step.
  84868. */
  84869. colorStep: Color4;
  84870. /**
  84871. * Defines how long will the life of the particle be.
  84872. */
  84873. lifeTime: number;
  84874. /**
  84875. * The current age of the particle.
  84876. */
  84877. age: number;
  84878. /**
  84879. * The current size of the particle.
  84880. */
  84881. size: number;
  84882. /**
  84883. * The current scale of the particle.
  84884. */
  84885. scale: Vector2;
  84886. /**
  84887. * The current angle of the particle.
  84888. */
  84889. angle: number;
  84890. /**
  84891. * Defines how fast is the angle changing.
  84892. */
  84893. angularSpeed: number;
  84894. /**
  84895. * Defines the cell index used by the particle to be rendered from a sprite.
  84896. */
  84897. cellIndex: number;
  84898. /**
  84899. * The information required to support color remapping
  84900. */
  84901. remapData: Vector4;
  84902. /** @hidden */
  84903. _randomCellOffset?: number;
  84904. /** @hidden */
  84905. _initialDirection: Nullable<Vector3>;
  84906. /** @hidden */
  84907. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84908. /** @hidden */
  84909. _initialStartSpriteCellID: number;
  84910. /** @hidden */
  84911. _initialEndSpriteCellID: number;
  84912. /** @hidden */
  84913. _currentColorGradient: Nullable<ColorGradient>;
  84914. /** @hidden */
  84915. _currentColor1: Color4;
  84916. /** @hidden */
  84917. _currentColor2: Color4;
  84918. /** @hidden */
  84919. _currentSizeGradient: Nullable<FactorGradient>;
  84920. /** @hidden */
  84921. _currentSize1: number;
  84922. /** @hidden */
  84923. _currentSize2: number;
  84924. /** @hidden */
  84925. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84926. /** @hidden */
  84927. _currentAngularSpeed1: number;
  84928. /** @hidden */
  84929. _currentAngularSpeed2: number;
  84930. /** @hidden */
  84931. _currentVelocityGradient: Nullable<FactorGradient>;
  84932. /** @hidden */
  84933. _currentVelocity1: number;
  84934. /** @hidden */
  84935. _currentVelocity2: number;
  84936. /** @hidden */
  84937. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84938. /** @hidden */
  84939. _currentLimitVelocity1: number;
  84940. /** @hidden */
  84941. _currentLimitVelocity2: number;
  84942. /** @hidden */
  84943. _currentDragGradient: Nullable<FactorGradient>;
  84944. /** @hidden */
  84945. _currentDrag1: number;
  84946. /** @hidden */
  84947. _currentDrag2: number;
  84948. /** @hidden */
  84949. _randomNoiseCoordinates1: Vector3;
  84950. /** @hidden */
  84951. _randomNoiseCoordinates2: Vector3;
  84952. /**
  84953. * Creates a new instance Particle
  84954. * @param particleSystem the particle system the particle belongs to
  84955. */
  84956. constructor(
  84957. /**
  84958. * The particle system the particle belongs to.
  84959. */
  84960. particleSystem: ParticleSystem);
  84961. private updateCellInfoFromSystem;
  84962. /**
  84963. * Defines how the sprite cell index is updated for the particle
  84964. */
  84965. updateCellIndex(): void;
  84966. /** @hidden */
  84967. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84968. /** @hidden */
  84969. _inheritParticleInfoToSubEmitters(): void;
  84970. /** @hidden */
  84971. _reset(): void;
  84972. /**
  84973. * Copy the properties of particle to another one.
  84974. * @param other the particle to copy the information to.
  84975. */
  84976. copyTo(other: Particle): void;
  84977. }
  84978. }
  84979. declare module BABYLON {
  84980. /**
  84981. * Particle emitter represents a volume emitting particles.
  84982. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84983. */
  84984. export interface IParticleEmitterType {
  84985. /**
  84986. * Called by the particle System when the direction is computed for the created particle.
  84987. * @param worldMatrix is the world matrix of the particle system
  84988. * @param directionToUpdate is the direction vector to update with the result
  84989. * @param particle is the particle we are computed the direction for
  84990. */
  84991. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84992. /**
  84993. * Called by the particle System when the position is computed for the created particle.
  84994. * @param worldMatrix is the world matrix of the particle system
  84995. * @param positionToUpdate is the position vector to update with the result
  84996. * @param particle is the particle we are computed the position for
  84997. */
  84998. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84999. /**
  85000. * Clones the current emitter and returns a copy of it
  85001. * @returns the new emitter
  85002. */
  85003. clone(): IParticleEmitterType;
  85004. /**
  85005. * Called by the GPUParticleSystem to setup the update shader
  85006. * @param effect defines the update shader
  85007. */
  85008. applyToShader(effect: Effect): void;
  85009. /**
  85010. * Returns a string to use to update the GPU particles update shader
  85011. * @returns the effect defines string
  85012. */
  85013. getEffectDefines(): string;
  85014. /**
  85015. * Returns a string representing the class name
  85016. * @returns a string containing the class name
  85017. */
  85018. getClassName(): string;
  85019. /**
  85020. * Serializes the particle system to a JSON object.
  85021. * @returns the JSON object
  85022. */
  85023. serialize(): any;
  85024. /**
  85025. * Parse properties from a JSON object
  85026. * @param serializationObject defines the JSON object
  85027. */
  85028. parse(serializationObject: any): void;
  85029. }
  85030. }
  85031. declare module BABYLON {
  85032. /**
  85033. * Particle emitter emitting particles from the inside of a box.
  85034. * It emits the particles randomly between 2 given directions.
  85035. */
  85036. export class BoxParticleEmitter implements IParticleEmitterType {
  85037. /**
  85038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85039. */
  85040. direction1: Vector3;
  85041. /**
  85042. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85043. */
  85044. direction2: Vector3;
  85045. /**
  85046. * 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.
  85047. */
  85048. minEmitBox: Vector3;
  85049. /**
  85050. * 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.
  85051. */
  85052. maxEmitBox: Vector3;
  85053. /**
  85054. * Creates a new instance BoxParticleEmitter
  85055. */
  85056. constructor();
  85057. /**
  85058. * Called by the particle System when the direction is computed for the created particle.
  85059. * @param worldMatrix is the world matrix of the particle system
  85060. * @param directionToUpdate is the direction vector to update with the result
  85061. * @param particle is the particle we are computed the direction for
  85062. */
  85063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85064. /**
  85065. * Called by the particle System when the position is computed for the created particle.
  85066. * @param worldMatrix is the world matrix of the particle system
  85067. * @param positionToUpdate is the position vector to update with the result
  85068. * @param particle is the particle we are computed the position for
  85069. */
  85070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85071. /**
  85072. * Clones the current emitter and returns a copy of it
  85073. * @returns the new emitter
  85074. */
  85075. clone(): BoxParticleEmitter;
  85076. /**
  85077. * Called by the GPUParticleSystem to setup the update shader
  85078. * @param effect defines the update shader
  85079. */
  85080. applyToShader(effect: Effect): void;
  85081. /**
  85082. * Returns a string to use to update the GPU particles update shader
  85083. * @returns a string containng the defines string
  85084. */
  85085. getEffectDefines(): string;
  85086. /**
  85087. * Returns the string "BoxParticleEmitter"
  85088. * @returns a string containing the class name
  85089. */
  85090. getClassName(): string;
  85091. /**
  85092. * Serializes the particle system to a JSON object.
  85093. * @returns the JSON object
  85094. */
  85095. serialize(): any;
  85096. /**
  85097. * Parse properties from a JSON object
  85098. * @param serializationObject defines the JSON object
  85099. */
  85100. parse(serializationObject: any): void;
  85101. }
  85102. }
  85103. declare module BABYLON {
  85104. /**
  85105. * Particle emitter emitting particles from the inside of a cone.
  85106. * It emits the particles alongside the cone volume from the base to the particle.
  85107. * The emission direction might be randomized.
  85108. */
  85109. export class ConeParticleEmitter implements IParticleEmitterType {
  85110. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85111. directionRandomizer: number;
  85112. private _radius;
  85113. private _angle;
  85114. private _height;
  85115. /**
  85116. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85117. */
  85118. radiusRange: number;
  85119. /**
  85120. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85121. */
  85122. heightRange: number;
  85123. /**
  85124. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85125. */
  85126. emitFromSpawnPointOnly: boolean;
  85127. /**
  85128. * Gets or sets the radius of the emission cone
  85129. */
  85130. radius: number;
  85131. /**
  85132. * Gets or sets the angle of the emission cone
  85133. */
  85134. angle: number;
  85135. private _buildHeight;
  85136. /**
  85137. * Creates a new instance ConeParticleEmitter
  85138. * @param radius the radius of the emission cone (1 by default)
  85139. * @param angle the cone base angle (PI by default)
  85140. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85141. */
  85142. constructor(radius?: number, angle?: number,
  85143. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85144. directionRandomizer?: number);
  85145. /**
  85146. * Called by the particle System when the direction is computed for the created particle.
  85147. * @param worldMatrix is the world matrix of the particle system
  85148. * @param directionToUpdate is the direction vector to update with the result
  85149. * @param particle is the particle we are computed the direction for
  85150. */
  85151. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85152. /**
  85153. * Called by the particle System when the position is computed for the created particle.
  85154. * @param worldMatrix is the world matrix of the particle system
  85155. * @param positionToUpdate is the position vector to update with the result
  85156. * @param particle is the particle we are computed the position for
  85157. */
  85158. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85159. /**
  85160. * Clones the current emitter and returns a copy of it
  85161. * @returns the new emitter
  85162. */
  85163. clone(): ConeParticleEmitter;
  85164. /**
  85165. * Called by the GPUParticleSystem to setup the update shader
  85166. * @param effect defines the update shader
  85167. */
  85168. applyToShader(effect: Effect): void;
  85169. /**
  85170. * Returns a string to use to update the GPU particles update shader
  85171. * @returns a string containng the defines string
  85172. */
  85173. getEffectDefines(): string;
  85174. /**
  85175. * Returns the string "ConeParticleEmitter"
  85176. * @returns a string containing the class name
  85177. */
  85178. getClassName(): string;
  85179. /**
  85180. * Serializes the particle system to a JSON object.
  85181. * @returns the JSON object
  85182. */
  85183. serialize(): any;
  85184. /**
  85185. * Parse properties from a JSON object
  85186. * @param serializationObject defines the JSON object
  85187. */
  85188. parse(serializationObject: any): void;
  85189. }
  85190. }
  85191. declare module BABYLON {
  85192. /**
  85193. * Particle emitter emitting particles from the inside of a cylinder.
  85194. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85195. */
  85196. export class CylinderParticleEmitter implements IParticleEmitterType {
  85197. /**
  85198. * The radius of the emission cylinder.
  85199. */
  85200. radius: number;
  85201. /**
  85202. * The height of the emission cylinder.
  85203. */
  85204. height: number;
  85205. /**
  85206. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85207. */
  85208. radiusRange: number;
  85209. /**
  85210. * How much to randomize the particle direction [0-1].
  85211. */
  85212. directionRandomizer: number;
  85213. /**
  85214. * Creates a new instance CylinderParticleEmitter
  85215. * @param radius the radius of the emission cylinder (1 by default)
  85216. * @param height the height of the emission cylinder (1 by default)
  85217. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85218. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85219. */
  85220. constructor(
  85221. /**
  85222. * The radius of the emission cylinder.
  85223. */
  85224. radius?: number,
  85225. /**
  85226. * The height of the emission cylinder.
  85227. */
  85228. height?: number,
  85229. /**
  85230. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85231. */
  85232. radiusRange?: number,
  85233. /**
  85234. * How much to randomize the particle direction [0-1].
  85235. */
  85236. directionRandomizer?: number);
  85237. /**
  85238. * Called by the particle System when the direction is computed for the created particle.
  85239. * @param worldMatrix is the world matrix of the particle system
  85240. * @param directionToUpdate is the direction vector to update with the result
  85241. * @param particle is the particle we are computed the direction for
  85242. */
  85243. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85244. /**
  85245. * Called by the particle System when the position is computed for the created particle.
  85246. * @param worldMatrix is the world matrix of the particle system
  85247. * @param positionToUpdate is the position vector to update with the result
  85248. * @param particle is the particle we are computed the position for
  85249. */
  85250. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85251. /**
  85252. * Clones the current emitter and returns a copy of it
  85253. * @returns the new emitter
  85254. */
  85255. clone(): CylinderParticleEmitter;
  85256. /**
  85257. * Called by the GPUParticleSystem to setup the update shader
  85258. * @param effect defines the update shader
  85259. */
  85260. applyToShader(effect: Effect): void;
  85261. /**
  85262. * Returns a string to use to update the GPU particles update shader
  85263. * @returns a string containng the defines string
  85264. */
  85265. getEffectDefines(): string;
  85266. /**
  85267. * Returns the string "CylinderParticleEmitter"
  85268. * @returns a string containing the class name
  85269. */
  85270. getClassName(): string;
  85271. /**
  85272. * Serializes the particle system to a JSON object.
  85273. * @returns the JSON object
  85274. */
  85275. serialize(): any;
  85276. /**
  85277. * Parse properties from a JSON object
  85278. * @param serializationObject defines the JSON object
  85279. */
  85280. parse(serializationObject: any): void;
  85281. }
  85282. /**
  85283. * Particle emitter emitting particles from the inside of a cylinder.
  85284. * It emits the particles randomly between two vectors.
  85285. */
  85286. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85287. /**
  85288. * The min limit of the emission direction.
  85289. */
  85290. direction1: Vector3;
  85291. /**
  85292. * The max limit of the emission direction.
  85293. */
  85294. direction2: Vector3;
  85295. /**
  85296. * Creates a new instance CylinderDirectedParticleEmitter
  85297. * @param radius the radius of the emission cylinder (1 by default)
  85298. * @param height the height of the emission cylinder (1 by default)
  85299. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85300. * @param direction1 the min limit of the emission direction (up vector by default)
  85301. * @param direction2 the max limit of the emission direction (up vector by default)
  85302. */
  85303. constructor(radius?: number, height?: number, radiusRange?: number,
  85304. /**
  85305. * The min limit of the emission direction.
  85306. */
  85307. direction1?: Vector3,
  85308. /**
  85309. * The max limit of the emission direction.
  85310. */
  85311. direction2?: Vector3);
  85312. /**
  85313. * Called by the particle System when the direction is computed for the created particle.
  85314. * @param worldMatrix is the world matrix of the particle system
  85315. * @param directionToUpdate is the direction vector to update with the result
  85316. * @param particle is the particle we are computed the direction for
  85317. */
  85318. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85319. /**
  85320. * Clones the current emitter and returns a copy of it
  85321. * @returns the new emitter
  85322. */
  85323. clone(): CylinderDirectedParticleEmitter;
  85324. /**
  85325. * Called by the GPUParticleSystem to setup the update shader
  85326. * @param effect defines the update shader
  85327. */
  85328. applyToShader(effect: Effect): void;
  85329. /**
  85330. * Returns a string to use to update the GPU particles update shader
  85331. * @returns a string containng the defines string
  85332. */
  85333. getEffectDefines(): string;
  85334. /**
  85335. * Returns the string "CylinderDirectedParticleEmitter"
  85336. * @returns a string containing the class name
  85337. */
  85338. getClassName(): string;
  85339. /**
  85340. * Serializes the particle system to a JSON object.
  85341. * @returns the JSON object
  85342. */
  85343. serialize(): any;
  85344. /**
  85345. * Parse properties from a JSON object
  85346. * @param serializationObject defines the JSON object
  85347. */
  85348. parse(serializationObject: any): void;
  85349. }
  85350. }
  85351. declare module BABYLON {
  85352. /**
  85353. * Particle emitter emitting particles from the inside of a hemisphere.
  85354. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85355. */
  85356. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85357. /**
  85358. * The radius of the emission hemisphere.
  85359. */
  85360. radius: number;
  85361. /**
  85362. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85363. */
  85364. radiusRange: number;
  85365. /**
  85366. * How much to randomize the particle direction [0-1].
  85367. */
  85368. directionRandomizer: number;
  85369. /**
  85370. * Creates a new instance HemisphericParticleEmitter
  85371. * @param radius the radius of the emission hemisphere (1 by default)
  85372. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85373. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85374. */
  85375. constructor(
  85376. /**
  85377. * The radius of the emission hemisphere.
  85378. */
  85379. radius?: number,
  85380. /**
  85381. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85382. */
  85383. radiusRange?: number,
  85384. /**
  85385. * How much to randomize the particle direction [0-1].
  85386. */
  85387. directionRandomizer?: number);
  85388. /**
  85389. * Called by the particle System when the direction is computed for the created particle.
  85390. * @param worldMatrix is the world matrix of the particle system
  85391. * @param directionToUpdate is the direction vector to update with the result
  85392. * @param particle is the particle we are computed the direction for
  85393. */
  85394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85395. /**
  85396. * Called by the particle System when the position is computed for the created particle.
  85397. * @param worldMatrix is the world matrix of the particle system
  85398. * @param positionToUpdate is the position vector to update with the result
  85399. * @param particle is the particle we are computed the position for
  85400. */
  85401. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85402. /**
  85403. * Clones the current emitter and returns a copy of it
  85404. * @returns the new emitter
  85405. */
  85406. clone(): HemisphericParticleEmitter;
  85407. /**
  85408. * Called by the GPUParticleSystem to setup the update shader
  85409. * @param effect defines the update shader
  85410. */
  85411. applyToShader(effect: Effect): void;
  85412. /**
  85413. * Returns a string to use to update the GPU particles update shader
  85414. * @returns a string containng the defines string
  85415. */
  85416. getEffectDefines(): string;
  85417. /**
  85418. * Returns the string "HemisphericParticleEmitter"
  85419. * @returns a string containing the class name
  85420. */
  85421. getClassName(): string;
  85422. /**
  85423. * Serializes the particle system to a JSON object.
  85424. * @returns the JSON object
  85425. */
  85426. serialize(): any;
  85427. /**
  85428. * Parse properties from a JSON object
  85429. * @param serializationObject defines the JSON object
  85430. */
  85431. parse(serializationObject: any): void;
  85432. }
  85433. }
  85434. declare module BABYLON {
  85435. /**
  85436. * Particle emitter emitting particles from a point.
  85437. * It emits the particles randomly between 2 given directions.
  85438. */
  85439. export class PointParticleEmitter implements IParticleEmitterType {
  85440. /**
  85441. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85442. */
  85443. direction1: Vector3;
  85444. /**
  85445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85446. */
  85447. direction2: Vector3;
  85448. /**
  85449. * Creates a new instance PointParticleEmitter
  85450. */
  85451. constructor();
  85452. /**
  85453. * Called by the particle System when the direction is computed for the created particle.
  85454. * @param worldMatrix is the world matrix of the particle system
  85455. * @param directionToUpdate is the direction vector to update with the result
  85456. * @param particle is the particle we are computed the direction for
  85457. */
  85458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85459. /**
  85460. * Called by the particle System when the position is computed for the created particle.
  85461. * @param worldMatrix is the world matrix of the particle system
  85462. * @param positionToUpdate is the position vector to update with the result
  85463. * @param particle is the particle we are computed the position for
  85464. */
  85465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85466. /**
  85467. * Clones the current emitter and returns a copy of it
  85468. * @returns the new emitter
  85469. */
  85470. clone(): PointParticleEmitter;
  85471. /**
  85472. * Called by the GPUParticleSystem to setup the update shader
  85473. * @param effect defines the update shader
  85474. */
  85475. applyToShader(effect: Effect): void;
  85476. /**
  85477. * Returns a string to use to update the GPU particles update shader
  85478. * @returns a string containng the defines string
  85479. */
  85480. getEffectDefines(): string;
  85481. /**
  85482. * Returns the string "PointParticleEmitter"
  85483. * @returns a string containing the class name
  85484. */
  85485. getClassName(): string;
  85486. /**
  85487. * Serializes the particle system to a JSON object.
  85488. * @returns the JSON object
  85489. */
  85490. serialize(): any;
  85491. /**
  85492. * Parse properties from a JSON object
  85493. * @param serializationObject defines the JSON object
  85494. */
  85495. parse(serializationObject: any): void;
  85496. }
  85497. }
  85498. declare module BABYLON {
  85499. /**
  85500. * Particle emitter emitting particles from the inside of a sphere.
  85501. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85502. */
  85503. export class SphereParticleEmitter implements IParticleEmitterType {
  85504. /**
  85505. * The radius of the emission sphere.
  85506. */
  85507. radius: number;
  85508. /**
  85509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85510. */
  85511. radiusRange: number;
  85512. /**
  85513. * How much to randomize the particle direction [0-1].
  85514. */
  85515. directionRandomizer: number;
  85516. /**
  85517. * Creates a new instance SphereParticleEmitter
  85518. * @param radius the radius of the emission sphere (1 by default)
  85519. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85521. */
  85522. constructor(
  85523. /**
  85524. * The radius of the emission sphere.
  85525. */
  85526. radius?: number,
  85527. /**
  85528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85529. */
  85530. radiusRange?: number,
  85531. /**
  85532. * How much to randomize the particle direction [0-1].
  85533. */
  85534. directionRandomizer?: number);
  85535. /**
  85536. * Called by the particle System when the direction is computed for the created particle.
  85537. * @param worldMatrix is the world matrix of the particle system
  85538. * @param directionToUpdate is the direction vector to update with the result
  85539. * @param particle is the particle we are computed the direction for
  85540. */
  85541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85542. /**
  85543. * Called by the particle System when the position is computed for the created particle.
  85544. * @param worldMatrix is the world matrix of the particle system
  85545. * @param positionToUpdate is the position vector to update with the result
  85546. * @param particle is the particle we are computed the position for
  85547. */
  85548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85549. /**
  85550. * Clones the current emitter and returns a copy of it
  85551. * @returns the new emitter
  85552. */
  85553. clone(): SphereParticleEmitter;
  85554. /**
  85555. * Called by the GPUParticleSystem to setup the update shader
  85556. * @param effect defines the update shader
  85557. */
  85558. applyToShader(effect: Effect): void;
  85559. /**
  85560. * Returns a string to use to update the GPU particles update shader
  85561. * @returns a string containng the defines string
  85562. */
  85563. getEffectDefines(): string;
  85564. /**
  85565. * Returns the string "SphereParticleEmitter"
  85566. * @returns a string containing the class name
  85567. */
  85568. getClassName(): string;
  85569. /**
  85570. * Serializes the particle system to a JSON object.
  85571. * @returns the JSON object
  85572. */
  85573. serialize(): any;
  85574. /**
  85575. * Parse properties from a JSON object
  85576. * @param serializationObject defines the JSON object
  85577. */
  85578. parse(serializationObject: any): void;
  85579. }
  85580. /**
  85581. * Particle emitter emitting particles from the inside of a sphere.
  85582. * It emits the particles randomly between two vectors.
  85583. */
  85584. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85585. /**
  85586. * The min limit of the emission direction.
  85587. */
  85588. direction1: Vector3;
  85589. /**
  85590. * The max limit of the emission direction.
  85591. */
  85592. direction2: Vector3;
  85593. /**
  85594. * Creates a new instance SphereDirectedParticleEmitter
  85595. * @param radius the radius of the emission sphere (1 by default)
  85596. * @param direction1 the min limit of the emission direction (up vector by default)
  85597. * @param direction2 the max limit of the emission direction (up vector by default)
  85598. */
  85599. constructor(radius?: number,
  85600. /**
  85601. * The min limit of the emission direction.
  85602. */
  85603. direction1?: Vector3,
  85604. /**
  85605. * The max limit of the emission direction.
  85606. */
  85607. direction2?: Vector3);
  85608. /**
  85609. * Called by the particle System when the direction is computed for the created particle.
  85610. * @param worldMatrix is the world matrix of the particle system
  85611. * @param directionToUpdate is the direction vector to update with the result
  85612. * @param particle is the particle we are computed the direction for
  85613. */
  85614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85615. /**
  85616. * Clones the current emitter and returns a copy of it
  85617. * @returns the new emitter
  85618. */
  85619. clone(): SphereDirectedParticleEmitter;
  85620. /**
  85621. * Called by the GPUParticleSystem to setup the update shader
  85622. * @param effect defines the update shader
  85623. */
  85624. applyToShader(effect: Effect): void;
  85625. /**
  85626. * Returns a string to use to update the GPU particles update shader
  85627. * @returns a string containng the defines string
  85628. */
  85629. getEffectDefines(): string;
  85630. /**
  85631. * Returns the string "SphereDirectedParticleEmitter"
  85632. * @returns a string containing the class name
  85633. */
  85634. getClassName(): string;
  85635. /**
  85636. * Serializes the particle system to a JSON object.
  85637. * @returns the JSON object
  85638. */
  85639. serialize(): any;
  85640. /**
  85641. * Parse properties from a JSON object
  85642. * @param serializationObject defines the JSON object
  85643. */
  85644. parse(serializationObject: any): void;
  85645. }
  85646. }
  85647. declare module BABYLON {
  85648. /**
  85649. * Interface representing a particle system in Babylon.js.
  85650. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85651. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85652. */
  85653. export interface IParticleSystem {
  85654. /**
  85655. * List of animations used by the particle system.
  85656. */
  85657. animations: Animation[];
  85658. /**
  85659. * The id of the Particle system.
  85660. */
  85661. id: string;
  85662. /**
  85663. * The name of the Particle system.
  85664. */
  85665. name: string;
  85666. /**
  85667. * The emitter represents the Mesh or position we are attaching the particle system to.
  85668. */
  85669. emitter: Nullable<AbstractMesh | Vector3>;
  85670. /**
  85671. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85672. */
  85673. isBillboardBased: boolean;
  85674. /**
  85675. * The rendering group used by the Particle system to chose when to render.
  85676. */
  85677. renderingGroupId: number;
  85678. /**
  85679. * The layer mask we are rendering the particles through.
  85680. */
  85681. layerMask: number;
  85682. /**
  85683. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85684. */
  85685. updateSpeed: number;
  85686. /**
  85687. * The amount of time the particle system is running (depends of the overall update speed).
  85688. */
  85689. targetStopDuration: number;
  85690. /**
  85691. * The texture used to render each particle. (this can be a spritesheet)
  85692. */
  85693. particleTexture: Nullable<Texture>;
  85694. /**
  85695. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85696. */
  85697. blendMode: number;
  85698. /**
  85699. * Minimum life time of emitting particles.
  85700. */
  85701. minLifeTime: number;
  85702. /**
  85703. * Maximum life time of emitting particles.
  85704. */
  85705. maxLifeTime: number;
  85706. /**
  85707. * Minimum Size of emitting particles.
  85708. */
  85709. minSize: number;
  85710. /**
  85711. * Maximum Size of emitting particles.
  85712. */
  85713. maxSize: number;
  85714. /**
  85715. * Minimum scale of emitting particles on X axis.
  85716. */
  85717. minScaleX: number;
  85718. /**
  85719. * Maximum scale of emitting particles on X axis.
  85720. */
  85721. maxScaleX: number;
  85722. /**
  85723. * Minimum scale of emitting particles on Y axis.
  85724. */
  85725. minScaleY: number;
  85726. /**
  85727. * Maximum scale of emitting particles on Y axis.
  85728. */
  85729. maxScaleY: number;
  85730. /**
  85731. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85732. */
  85733. color1: Color4;
  85734. /**
  85735. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85736. */
  85737. color2: Color4;
  85738. /**
  85739. * Color the particle will have at the end of its lifetime.
  85740. */
  85741. colorDead: Color4;
  85742. /**
  85743. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85744. */
  85745. emitRate: number;
  85746. /**
  85747. * You can use gravity if you want to give an orientation to your particles.
  85748. */
  85749. gravity: Vector3;
  85750. /**
  85751. * Minimum power of emitting particles.
  85752. */
  85753. minEmitPower: number;
  85754. /**
  85755. * Maximum power of emitting particles.
  85756. */
  85757. maxEmitPower: number;
  85758. /**
  85759. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85760. */
  85761. minAngularSpeed: number;
  85762. /**
  85763. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85764. */
  85765. maxAngularSpeed: number;
  85766. /**
  85767. * Gets or sets the minimal initial rotation in radians.
  85768. */
  85769. minInitialRotation: number;
  85770. /**
  85771. * Gets or sets the maximal initial rotation in radians.
  85772. */
  85773. maxInitialRotation: number;
  85774. /**
  85775. * The particle emitter type defines the emitter used by the particle system.
  85776. * It can be for example box, sphere, or cone...
  85777. */
  85778. particleEmitterType: Nullable<IParticleEmitterType>;
  85779. /**
  85780. * Defines the delay in milliseconds before starting the system (0 by default)
  85781. */
  85782. startDelay: number;
  85783. /**
  85784. * 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
  85785. */
  85786. preWarmCycles: number;
  85787. /**
  85788. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85789. */
  85790. preWarmStepOffset: number;
  85791. /**
  85792. * 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)
  85793. */
  85794. spriteCellChangeSpeed: number;
  85795. /**
  85796. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85797. */
  85798. startSpriteCellID: number;
  85799. /**
  85800. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85801. */
  85802. endSpriteCellID: number;
  85803. /**
  85804. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85805. */
  85806. spriteCellWidth: number;
  85807. /**
  85808. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85809. */
  85810. spriteCellHeight: number;
  85811. /**
  85812. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85813. */
  85814. spriteRandomStartCell: boolean;
  85815. /**
  85816. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85817. */
  85818. isAnimationSheetEnabled: boolean;
  85819. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85820. translationPivot: Vector2;
  85821. /**
  85822. * Gets or sets a texture used to add random noise to particle positions
  85823. */
  85824. noiseTexture: Nullable<BaseTexture>;
  85825. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85826. noiseStrength: Vector3;
  85827. /**
  85828. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85829. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85830. */
  85831. billboardMode: number;
  85832. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85833. limitVelocityDamping: number;
  85834. /**
  85835. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85836. */
  85837. beginAnimationOnStart: boolean;
  85838. /**
  85839. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85840. */
  85841. beginAnimationFrom: number;
  85842. /**
  85843. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85844. */
  85845. beginAnimationTo: number;
  85846. /**
  85847. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85848. */
  85849. beginAnimationLoop: boolean;
  85850. /**
  85851. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85852. */
  85853. disposeOnStop: boolean;
  85854. /**
  85855. * Gets the maximum number of particles active at the same time.
  85856. * @returns The max number of active particles.
  85857. */
  85858. getCapacity(): number;
  85859. /**
  85860. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85861. * @returns True if it has been started, otherwise false.
  85862. */
  85863. isStarted(): boolean;
  85864. /**
  85865. * Animates the particle system for this frame.
  85866. */
  85867. animate(): void;
  85868. /**
  85869. * Renders the particle system in its current state.
  85870. * @returns the current number of particles
  85871. */
  85872. render(): number;
  85873. /**
  85874. * Dispose the particle system and frees its associated resources.
  85875. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85876. */
  85877. dispose(disposeTexture?: boolean): void;
  85878. /**
  85879. * Clones the particle system.
  85880. * @param name The name of the cloned object
  85881. * @param newEmitter The new emitter to use
  85882. * @returns the cloned particle system
  85883. */
  85884. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85885. /**
  85886. * Serializes the particle system to a JSON object.
  85887. * @returns the JSON object
  85888. */
  85889. serialize(): any;
  85890. /**
  85891. * Rebuild the particle system
  85892. */
  85893. rebuild(): void;
  85894. /**
  85895. * Starts the particle system and begins to emit
  85896. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85897. */
  85898. start(delay?: number): void;
  85899. /**
  85900. * Stops the particle system.
  85901. */
  85902. stop(): void;
  85903. /**
  85904. * Remove all active particles
  85905. */
  85906. reset(): void;
  85907. /**
  85908. * Is this system ready to be used/rendered
  85909. * @return true if the system is ready
  85910. */
  85911. isReady(): boolean;
  85912. /**
  85913. * Adds a new color gradient
  85914. * @param gradient defines the gradient to use (between 0 and 1)
  85915. * @param color1 defines the color to affect to the specified gradient
  85916. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85917. * @returns the current particle system
  85918. */
  85919. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85920. /**
  85921. * Remove a specific color gradient
  85922. * @param gradient defines the gradient to remove
  85923. * @returns the current particle system
  85924. */
  85925. removeColorGradient(gradient: number): IParticleSystem;
  85926. /**
  85927. * Adds a new size gradient
  85928. * @param gradient defines the gradient to use (between 0 and 1)
  85929. * @param factor defines the size factor to affect to the specified gradient
  85930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85931. * @returns the current particle system
  85932. */
  85933. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85934. /**
  85935. * Remove a specific size gradient
  85936. * @param gradient defines the gradient to remove
  85937. * @returns the current particle system
  85938. */
  85939. removeSizeGradient(gradient: number): IParticleSystem;
  85940. /**
  85941. * Gets the current list of color gradients.
  85942. * You must use addColorGradient and removeColorGradient to udpate this list
  85943. * @returns the list of color gradients
  85944. */
  85945. getColorGradients(): Nullable<Array<ColorGradient>>;
  85946. /**
  85947. * Gets the current list of size gradients.
  85948. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85949. * @returns the list of size gradients
  85950. */
  85951. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85952. /**
  85953. * Gets the current list of angular speed gradients.
  85954. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85955. * @returns the list of angular speed gradients
  85956. */
  85957. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85958. /**
  85959. * Adds a new angular speed gradient
  85960. * @param gradient defines the gradient to use (between 0 and 1)
  85961. * @param factor defines the angular speed to affect to the specified gradient
  85962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85963. * @returns the current particle system
  85964. */
  85965. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85966. /**
  85967. * Remove a specific angular speed gradient
  85968. * @param gradient defines the gradient to remove
  85969. * @returns the current particle system
  85970. */
  85971. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85972. /**
  85973. * Gets the current list of velocity gradients.
  85974. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85975. * @returns the list of velocity gradients
  85976. */
  85977. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85978. /**
  85979. * Adds a new velocity gradient
  85980. * @param gradient defines the gradient to use (between 0 and 1)
  85981. * @param factor defines the velocity to affect to the specified gradient
  85982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85983. * @returns the current particle system
  85984. */
  85985. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85986. /**
  85987. * Remove a specific velocity gradient
  85988. * @param gradient defines the gradient to remove
  85989. * @returns the current particle system
  85990. */
  85991. removeVelocityGradient(gradient: number): IParticleSystem;
  85992. /**
  85993. * Gets the current list of limit velocity gradients.
  85994. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85995. * @returns the list of limit velocity gradients
  85996. */
  85997. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85998. /**
  85999. * Adds a new limit velocity gradient
  86000. * @param gradient defines the gradient to use (between 0 and 1)
  86001. * @param factor defines the limit velocity to affect to the specified gradient
  86002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86003. * @returns the current particle system
  86004. */
  86005. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86006. /**
  86007. * Remove a specific limit velocity gradient
  86008. * @param gradient defines the gradient to remove
  86009. * @returns the current particle system
  86010. */
  86011. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86012. /**
  86013. * Adds a new drag gradient
  86014. * @param gradient defines the gradient to use (between 0 and 1)
  86015. * @param factor defines the drag to affect to the specified gradient
  86016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86017. * @returns the current particle system
  86018. */
  86019. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86020. /**
  86021. * Remove a specific drag gradient
  86022. * @param gradient defines the gradient to remove
  86023. * @returns the current particle system
  86024. */
  86025. removeDragGradient(gradient: number): IParticleSystem;
  86026. /**
  86027. * Gets the current list of drag gradients.
  86028. * You must use addDragGradient and removeDragGradient to udpate this list
  86029. * @returns the list of drag gradients
  86030. */
  86031. getDragGradients(): Nullable<Array<FactorGradient>>;
  86032. /**
  86033. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86034. * @param gradient defines the gradient to use (between 0 and 1)
  86035. * @param factor defines the emit rate to affect to the specified gradient
  86036. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86037. * @returns the current particle system
  86038. */
  86039. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86040. /**
  86041. * Remove a specific emit rate gradient
  86042. * @param gradient defines the gradient to remove
  86043. * @returns the current particle system
  86044. */
  86045. removeEmitRateGradient(gradient: number): IParticleSystem;
  86046. /**
  86047. * Gets the current list of emit rate gradients.
  86048. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86049. * @returns the list of emit rate gradients
  86050. */
  86051. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86052. /**
  86053. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86054. * @param gradient defines the gradient to use (between 0 and 1)
  86055. * @param factor defines the start size to affect to the specified gradient
  86056. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86057. * @returns the current particle system
  86058. */
  86059. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86060. /**
  86061. * Remove a specific start size gradient
  86062. * @param gradient defines the gradient to remove
  86063. * @returns the current particle system
  86064. */
  86065. removeStartSizeGradient(gradient: number): IParticleSystem;
  86066. /**
  86067. * Gets the current list of start size gradients.
  86068. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86069. * @returns the list of start size gradients
  86070. */
  86071. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86072. /**
  86073. * Adds a new life time gradient
  86074. * @param gradient defines the gradient to use (between 0 and 1)
  86075. * @param factor defines the life time factor to affect to the specified gradient
  86076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86077. * @returns the current particle system
  86078. */
  86079. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86080. /**
  86081. * Remove a specific life time gradient
  86082. * @param gradient defines the gradient to remove
  86083. * @returns the current particle system
  86084. */
  86085. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86086. /**
  86087. * Gets the current list of life time gradients.
  86088. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86089. * @returns the list of life time gradients
  86090. */
  86091. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86092. /**
  86093. * Gets the current list of color gradients.
  86094. * You must use addColorGradient and removeColorGradient to udpate this list
  86095. * @returns the list of color gradients
  86096. */
  86097. getColorGradients(): Nullable<Array<ColorGradient>>;
  86098. /**
  86099. * Adds a new ramp gradient used to remap particle colors
  86100. * @param gradient defines the gradient to use (between 0 and 1)
  86101. * @param color defines the color to affect to the specified gradient
  86102. * @returns the current particle system
  86103. */
  86104. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86105. /**
  86106. * Gets the current list of ramp gradients.
  86107. * You must use addRampGradient and removeRampGradient to udpate this list
  86108. * @returns the list of ramp gradients
  86109. */
  86110. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86111. /** Gets or sets a boolean indicating that ramp gradients must be used
  86112. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86113. */
  86114. useRampGradients: boolean;
  86115. /**
  86116. * Adds a new color remap gradient
  86117. * @param gradient defines the gradient to use (between 0 and 1)
  86118. * @param min defines the color remap minimal range
  86119. * @param max defines the color remap maximal range
  86120. * @returns the current particle system
  86121. */
  86122. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86123. /**
  86124. * Gets the current list of color remap gradients.
  86125. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86126. * @returns the list of color remap gradients
  86127. */
  86128. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86129. /**
  86130. * Adds a new alpha remap gradient
  86131. * @param gradient defines the gradient to use (between 0 and 1)
  86132. * @param min defines the alpha remap minimal range
  86133. * @param max defines the alpha remap maximal range
  86134. * @returns the current particle system
  86135. */
  86136. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86137. /**
  86138. * Gets the current list of alpha remap gradients.
  86139. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86140. * @returns the list of alpha remap gradients
  86141. */
  86142. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86143. /**
  86144. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86145. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86146. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86147. * @returns the emitter
  86148. */
  86149. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86150. /**
  86151. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86152. * @param radius The radius of the hemisphere to emit from
  86153. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86154. * @returns the emitter
  86155. */
  86156. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86157. /**
  86158. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86159. * @param radius The radius of the sphere to emit from
  86160. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86161. * @returns the emitter
  86162. */
  86163. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86164. /**
  86165. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86166. * @param radius The radius of the sphere to emit from
  86167. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86168. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86169. * @returns the emitter
  86170. */
  86171. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86172. /**
  86173. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86174. * @param radius The radius of the emission cylinder
  86175. * @param height The height of the emission cylinder
  86176. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86177. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86178. * @returns the emitter
  86179. */
  86180. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86181. /**
  86182. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86183. * @param radius The radius of the cylinder to emit from
  86184. * @param height The height of the emission cylinder
  86185. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86186. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86187. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86188. * @returns the emitter
  86189. */
  86190. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86191. /**
  86192. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86193. * @param radius The radius of the cone to emit from
  86194. * @param angle The base angle of the cone
  86195. * @returns the emitter
  86196. */
  86197. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86198. /**
  86199. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86200. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86201. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86202. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86203. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86204. * @returns the emitter
  86205. */
  86206. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86207. /**
  86208. * Get hosting scene
  86209. * @returns the scene
  86210. */
  86211. getScene(): Scene;
  86212. }
  86213. }
  86214. declare module BABYLON {
  86215. /**
  86216. * Creates an instance based on a source mesh.
  86217. */
  86218. export class InstancedMesh extends AbstractMesh {
  86219. private _sourceMesh;
  86220. private _currentLOD;
  86221. /** @hidden */
  86222. _indexInSourceMeshInstanceArray: number;
  86223. constructor(name: string, source: Mesh);
  86224. /**
  86225. * Returns the string "InstancedMesh".
  86226. */
  86227. getClassName(): string;
  86228. /** Gets the list of lights affecting that mesh */
  86229. readonly lightSources: Light[];
  86230. _resyncLightSources(): void;
  86231. _resyncLighSource(light: Light): void;
  86232. _removeLightSource(light: Light, dispose: boolean): void;
  86233. /**
  86234. * If the source mesh receives shadows
  86235. */
  86236. readonly receiveShadows: boolean;
  86237. /**
  86238. * The material of the source mesh
  86239. */
  86240. readonly material: Nullable<Material>;
  86241. /**
  86242. * Visibility of the source mesh
  86243. */
  86244. readonly visibility: number;
  86245. /**
  86246. * Skeleton of the source mesh
  86247. */
  86248. readonly skeleton: Nullable<Skeleton>;
  86249. /**
  86250. * Rendering ground id of the source mesh
  86251. */
  86252. renderingGroupId: number;
  86253. /**
  86254. * Returns the total number of vertices (integer).
  86255. */
  86256. getTotalVertices(): number;
  86257. /**
  86258. * Returns a positive integer : the total number of indices in this mesh geometry.
  86259. * @returns the numner of indices or zero if the mesh has no geometry.
  86260. */
  86261. getTotalIndices(): number;
  86262. /**
  86263. * The source mesh of the instance
  86264. */
  86265. readonly sourceMesh: Mesh;
  86266. /**
  86267. * Is this node ready to be used/rendered
  86268. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86269. * @return {boolean} is it ready
  86270. */
  86271. isReady(completeCheck?: boolean): boolean;
  86272. /**
  86273. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86274. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86275. * @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.
  86276. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86277. */
  86278. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86279. /**
  86280. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86281. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86282. * The `data` are either a numeric array either a Float32Array.
  86283. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86284. * 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).
  86285. * Note that a new underlying VertexBuffer object is created each call.
  86286. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86287. *
  86288. * Possible `kind` values :
  86289. * - VertexBuffer.PositionKind
  86290. * - VertexBuffer.UVKind
  86291. * - VertexBuffer.UV2Kind
  86292. * - VertexBuffer.UV3Kind
  86293. * - VertexBuffer.UV4Kind
  86294. * - VertexBuffer.UV5Kind
  86295. * - VertexBuffer.UV6Kind
  86296. * - VertexBuffer.ColorKind
  86297. * - VertexBuffer.MatricesIndicesKind
  86298. * - VertexBuffer.MatricesIndicesExtraKind
  86299. * - VertexBuffer.MatricesWeightsKind
  86300. * - VertexBuffer.MatricesWeightsExtraKind
  86301. *
  86302. * Returns the Mesh.
  86303. */
  86304. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86305. /**
  86306. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86307. * If the mesh has no geometry, it is simply returned as it is.
  86308. * The `data` are either a numeric array either a Float32Array.
  86309. * No new underlying VertexBuffer object is created.
  86310. * 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.
  86311. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86312. *
  86313. * Possible `kind` values :
  86314. * - VertexBuffer.PositionKind
  86315. * - VertexBuffer.UVKind
  86316. * - VertexBuffer.UV2Kind
  86317. * - VertexBuffer.UV3Kind
  86318. * - VertexBuffer.UV4Kind
  86319. * - VertexBuffer.UV5Kind
  86320. * - VertexBuffer.UV6Kind
  86321. * - VertexBuffer.ColorKind
  86322. * - VertexBuffer.MatricesIndicesKind
  86323. * - VertexBuffer.MatricesIndicesExtraKind
  86324. * - VertexBuffer.MatricesWeightsKind
  86325. * - VertexBuffer.MatricesWeightsExtraKind
  86326. *
  86327. * Returns the Mesh.
  86328. */
  86329. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  86330. /**
  86331. * Sets the mesh indices.
  86332. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86333. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86334. * This method creates a new index buffer each call.
  86335. * Returns the Mesh.
  86336. */
  86337. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  86338. /**
  86339. * Boolean : True if the mesh owns the requested kind of data.
  86340. */
  86341. isVerticesDataPresent(kind: string): boolean;
  86342. /**
  86343. * Returns an array of indices (IndicesArray).
  86344. */
  86345. getIndices(): Nullable<IndicesArray>;
  86346. readonly _positions: Nullable<Vector3[]>;
  86347. /**
  86348. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86349. * This means the mesh underlying bounding box and sphere are recomputed.
  86350. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86351. * @returns the current mesh
  86352. */
  86353. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  86354. /** @hidden */
  86355. _preActivate(): InstancedMesh;
  86356. /** @hidden */
  86357. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86358. /** @hidden */
  86359. _postActivate(): void;
  86360. getWorldMatrix(): Matrix;
  86361. readonly isAnInstance: boolean;
  86362. /**
  86363. * Returns the current associated LOD AbstractMesh.
  86364. */
  86365. getLOD(camera: Camera): AbstractMesh;
  86366. /** @hidden */
  86367. _syncSubMeshes(): InstancedMesh;
  86368. /** @hidden */
  86369. _generatePointsArray(): boolean;
  86370. /**
  86371. * Creates a new InstancedMesh from the current mesh.
  86372. * - name (string) : the cloned mesh name
  86373. * - newParent (optional Node) : the optional Node to parent the clone to.
  86374. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86375. *
  86376. * Returns the clone.
  86377. */
  86378. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86379. /**
  86380. * Disposes the InstancedMesh.
  86381. * Returns nothing.
  86382. */
  86383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86384. }
  86385. interface Mesh {
  86386. /**
  86387. * Register a custom buffer that will be instanced
  86388. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86389. * @param kind defines the buffer kind
  86390. * @param stride defines the stride in floats
  86391. */
  86392. registerInstancedBuffer(kind: string, stride: number): void;
  86393. /** @hidden */
  86394. _userInstancedBuffersStorage: {
  86395. data: {
  86396. [key: string]: Float32Array;
  86397. };
  86398. sizes: {
  86399. [key: string]: number;
  86400. };
  86401. vertexBuffers: {
  86402. [key: string]: Nullable<VertexBuffer>;
  86403. };
  86404. strides: {
  86405. [key: string]: number;
  86406. };
  86407. };
  86408. }
  86409. interface AbstractMesh {
  86410. /**
  86411. * Object used to store instanced buffers defined by user
  86412. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86413. */
  86414. instancedBuffers: {
  86415. [key: string]: any;
  86416. };
  86417. }
  86418. }
  86419. declare module BABYLON {
  86420. /**
  86421. * Defines the options associated with the creation of a shader material.
  86422. */
  86423. export interface IShaderMaterialOptions {
  86424. /**
  86425. * Does the material work in alpha blend mode
  86426. */
  86427. needAlphaBlending: boolean;
  86428. /**
  86429. * Does the material work in alpha test mode
  86430. */
  86431. needAlphaTesting: boolean;
  86432. /**
  86433. * The list of attribute names used in the shader
  86434. */
  86435. attributes: string[];
  86436. /**
  86437. * The list of unifrom names used in the shader
  86438. */
  86439. uniforms: string[];
  86440. /**
  86441. * The list of UBO names used in the shader
  86442. */
  86443. uniformBuffers: string[];
  86444. /**
  86445. * The list of sampler names used in the shader
  86446. */
  86447. samplers: string[];
  86448. /**
  86449. * The list of defines used in the shader
  86450. */
  86451. defines: string[];
  86452. }
  86453. /**
  86454. * 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.
  86455. *
  86456. * This returned material effects how the mesh will look based on the code in the shaders.
  86457. *
  86458. * @see http://doc.babylonjs.com/how_to/shader_material
  86459. */
  86460. export class ShaderMaterial extends Material {
  86461. private _shaderPath;
  86462. private _options;
  86463. private _textures;
  86464. private _textureArrays;
  86465. private _floats;
  86466. private _ints;
  86467. private _floatsArrays;
  86468. private _colors3;
  86469. private _colors3Arrays;
  86470. private _colors4;
  86471. private _colors4Arrays;
  86472. private _vectors2;
  86473. private _vectors3;
  86474. private _vectors4;
  86475. private _matrices;
  86476. private _matrices3x3;
  86477. private _matrices2x2;
  86478. private _vectors2Arrays;
  86479. private _vectors3Arrays;
  86480. private _vectors4Arrays;
  86481. private _cachedWorldViewMatrix;
  86482. private _cachedWorldViewProjectionMatrix;
  86483. private _renderId;
  86484. /**
  86485. * Instantiate a new shader material.
  86486. * 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.
  86487. * This returned material effects how the mesh will look based on the code in the shaders.
  86488. * @see http://doc.babylonjs.com/how_to/shader_material
  86489. * @param name Define the name of the material in the scene
  86490. * @param scene Define the scene the material belongs to
  86491. * @param shaderPath Defines the route to the shader code in one of three ways:
  86492. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  86493. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  86494. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  86495. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  86496. * @param options Define the options used to create the shader
  86497. */
  86498. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  86499. /**
  86500. * Gets the options used to compile the shader.
  86501. * They can be modified to trigger a new compilation
  86502. */
  86503. readonly options: IShaderMaterialOptions;
  86504. /**
  86505. * Gets the current class name of the material e.g. "ShaderMaterial"
  86506. * Mainly use in serialization.
  86507. * @returns the class name
  86508. */
  86509. getClassName(): string;
  86510. /**
  86511. * Specifies if the material will require alpha blending
  86512. * @returns a boolean specifying if alpha blending is needed
  86513. */
  86514. needAlphaBlending(): boolean;
  86515. /**
  86516. * Specifies if this material should be rendered in alpha test mode
  86517. * @returns a boolean specifying if an alpha test is needed.
  86518. */
  86519. needAlphaTesting(): boolean;
  86520. private _checkUniform;
  86521. /**
  86522. * Set a texture in the shader.
  86523. * @param name Define the name of the uniform samplers as defined in the shader
  86524. * @param texture Define the texture to bind to this sampler
  86525. * @return the material itself allowing "fluent" like uniform updates
  86526. */
  86527. setTexture(name: string, texture: Texture): ShaderMaterial;
  86528. /**
  86529. * Set a texture array in the shader.
  86530. * @param name Define the name of the uniform sampler array as defined in the shader
  86531. * @param textures Define the list of textures to bind to this sampler
  86532. * @return the material itself allowing "fluent" like uniform updates
  86533. */
  86534. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  86535. /**
  86536. * Set a float in the shader.
  86537. * @param name Define the name of the uniform as defined in the shader
  86538. * @param value Define the value to give to the uniform
  86539. * @return the material itself allowing "fluent" like uniform updates
  86540. */
  86541. setFloat(name: string, value: number): ShaderMaterial;
  86542. /**
  86543. * Set a int in the shader.
  86544. * @param name Define the name of the uniform as defined in the shader
  86545. * @param value Define the value to give to the uniform
  86546. * @return the material itself allowing "fluent" like uniform updates
  86547. */
  86548. setInt(name: string, value: number): ShaderMaterial;
  86549. /**
  86550. * Set an array of floats in the shader.
  86551. * @param name Define the name of the uniform as defined in the shader
  86552. * @param value Define the value to give to the uniform
  86553. * @return the material itself allowing "fluent" like uniform updates
  86554. */
  86555. setFloats(name: string, value: number[]): ShaderMaterial;
  86556. /**
  86557. * Set a vec3 in the shader from a Color3.
  86558. * @param name Define the name of the uniform as defined in the shader
  86559. * @param value Define the value to give to the uniform
  86560. * @return the material itself allowing "fluent" like uniform updates
  86561. */
  86562. setColor3(name: string, value: Color3): ShaderMaterial;
  86563. /**
  86564. * Set a vec3 array in the shader from a Color3 array.
  86565. * @param name Define the name of the uniform as defined in the shader
  86566. * @param value Define the value to give to the uniform
  86567. * @return the material itself allowing "fluent" like uniform updates
  86568. */
  86569. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  86570. /**
  86571. * Set a vec4 in the shader from a Color4.
  86572. * @param name Define the name of the uniform as defined in the shader
  86573. * @param value Define the value to give to the uniform
  86574. * @return the material itself allowing "fluent" like uniform updates
  86575. */
  86576. setColor4(name: string, value: Color4): ShaderMaterial;
  86577. /**
  86578. * Set a vec4 array in the shader from a Color4 array.
  86579. * @param name Define the name of the uniform as defined in the shader
  86580. * @param value Define the value to give to the uniform
  86581. * @return the material itself allowing "fluent" like uniform updates
  86582. */
  86583. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  86584. /**
  86585. * Set a vec2 in the shader from a Vector2.
  86586. * @param name Define the name of the uniform as defined in the shader
  86587. * @param value Define the value to give to the uniform
  86588. * @return the material itself allowing "fluent" like uniform updates
  86589. */
  86590. setVector2(name: string, value: Vector2): ShaderMaterial;
  86591. /**
  86592. * Set a vec3 in the shader from a Vector3.
  86593. * @param name Define the name of the uniform as defined in the shader
  86594. * @param value Define the value to give to the uniform
  86595. * @return the material itself allowing "fluent" like uniform updates
  86596. */
  86597. setVector3(name: string, value: Vector3): ShaderMaterial;
  86598. /**
  86599. * Set a vec4 in the shader from a Vector4.
  86600. * @param name Define the name of the uniform as defined in the shader
  86601. * @param value Define the value to give to the uniform
  86602. * @return the material itself allowing "fluent" like uniform updates
  86603. */
  86604. setVector4(name: string, value: Vector4): ShaderMaterial;
  86605. /**
  86606. * Set a mat4 in the shader from a Matrix.
  86607. * @param name Define the name of the uniform as defined in the shader
  86608. * @param value Define the value to give to the uniform
  86609. * @return the material itself allowing "fluent" like uniform updates
  86610. */
  86611. setMatrix(name: string, value: Matrix): ShaderMaterial;
  86612. /**
  86613. * Set a mat3 in the shader from a Float32Array.
  86614. * @param name Define the name of the uniform as defined in the shader
  86615. * @param value Define the value to give to the uniform
  86616. * @return the material itself allowing "fluent" like uniform updates
  86617. */
  86618. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  86619. /**
  86620. * Set a mat2 in the shader from a Float32Array.
  86621. * @param name Define the name of the uniform as defined in the shader
  86622. * @param value Define the value to give to the uniform
  86623. * @return the material itself allowing "fluent" like uniform updates
  86624. */
  86625. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  86626. /**
  86627. * Set a vec2 array in the shader from a number array.
  86628. * @param name Define the name of the uniform as defined in the shader
  86629. * @param value Define the value to give to the uniform
  86630. * @return the material itself allowing "fluent" like uniform updates
  86631. */
  86632. setArray2(name: string, value: number[]): ShaderMaterial;
  86633. /**
  86634. * Set a vec3 array in the shader from a number array.
  86635. * @param name Define the name of the uniform as defined in the shader
  86636. * @param value Define the value to give to the uniform
  86637. * @return the material itself allowing "fluent" like uniform updates
  86638. */
  86639. setArray3(name: string, value: number[]): ShaderMaterial;
  86640. /**
  86641. * Set a vec4 array in the shader from a number array.
  86642. * @param name Define the name of the uniform as defined in the shader
  86643. * @param value Define the value to give to the uniform
  86644. * @return the material itself allowing "fluent" like uniform updates
  86645. */
  86646. setArray4(name: string, value: number[]): ShaderMaterial;
  86647. private _checkCache;
  86648. /**
  86649. * Specifies that the submesh is ready to be used
  86650. * @param mesh defines the mesh to check
  86651. * @param subMesh defines which submesh to check
  86652. * @param useInstances specifies that instances should be used
  86653. * @returns a boolean indicating that the submesh is ready or not
  86654. */
  86655. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86656. /**
  86657. * Checks if the material is ready to render the requested mesh
  86658. * @param mesh Define the mesh to render
  86659. * @param useInstances Define whether or not the material is used with instances
  86660. * @returns true if ready, otherwise false
  86661. */
  86662. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86663. /**
  86664. * Binds the world matrix to the material
  86665. * @param world defines the world transformation matrix
  86666. */
  86667. bindOnlyWorldMatrix(world: Matrix): void;
  86668. /**
  86669. * Binds the material to the mesh
  86670. * @param world defines the world transformation matrix
  86671. * @param mesh defines the mesh to bind the material to
  86672. */
  86673. bind(world: Matrix, mesh?: Mesh): void;
  86674. /**
  86675. * Gets the active textures from the material
  86676. * @returns an array of textures
  86677. */
  86678. getActiveTextures(): BaseTexture[];
  86679. /**
  86680. * Specifies if the material uses a texture
  86681. * @param texture defines the texture to check against the material
  86682. * @returns a boolean specifying if the material uses the texture
  86683. */
  86684. hasTexture(texture: BaseTexture): boolean;
  86685. /**
  86686. * Makes a duplicate of the material, and gives it a new name
  86687. * @param name defines the new name for the duplicated material
  86688. * @returns the cloned material
  86689. */
  86690. clone(name: string): ShaderMaterial;
  86691. /**
  86692. * Disposes the material
  86693. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86694. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86695. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86696. */
  86697. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86698. /**
  86699. * Serializes this material in a JSON representation
  86700. * @returns the serialized material object
  86701. */
  86702. serialize(): any;
  86703. /**
  86704. * Creates a shader material from parsed shader material data
  86705. * @param source defines the JSON represnetation of the material
  86706. * @param scene defines the hosting scene
  86707. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86708. * @returns a new material
  86709. */
  86710. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86711. }
  86712. }
  86713. declare module BABYLON {
  86714. /** @hidden */
  86715. export var colorPixelShader: {
  86716. name: string;
  86717. shader: string;
  86718. };
  86719. }
  86720. declare module BABYLON {
  86721. /** @hidden */
  86722. export var colorVertexShader: {
  86723. name: string;
  86724. shader: string;
  86725. };
  86726. }
  86727. declare module BABYLON {
  86728. /**
  86729. * Line mesh
  86730. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86731. */
  86732. export class LinesMesh extends Mesh {
  86733. /**
  86734. * If vertex color should be applied to the mesh
  86735. */
  86736. readonly useVertexColor?: boolean | undefined;
  86737. /**
  86738. * If vertex alpha should be applied to the mesh
  86739. */
  86740. readonly useVertexAlpha?: boolean | undefined;
  86741. /**
  86742. * Color of the line (Default: White)
  86743. */
  86744. color: Color3;
  86745. /**
  86746. * Alpha of the line (Default: 1)
  86747. */
  86748. alpha: number;
  86749. /**
  86750. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86751. * This margin is expressed in world space coordinates, so its value may vary.
  86752. * Default value is 0.1
  86753. */
  86754. intersectionThreshold: number;
  86755. private _colorShader;
  86756. private color4;
  86757. /**
  86758. * Creates a new LinesMesh
  86759. * @param name defines the name
  86760. * @param scene defines the hosting scene
  86761. * @param parent defines the parent mesh if any
  86762. * @param source defines the optional source LinesMesh used to clone data from
  86763. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86764. * When false, achieved by calling a clone(), also passing False.
  86765. * This will make creation of children, recursive.
  86766. * @param useVertexColor defines if this LinesMesh supports vertex color
  86767. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86768. */
  86769. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86770. /**
  86771. * If vertex color should be applied to the mesh
  86772. */
  86773. useVertexColor?: boolean | undefined,
  86774. /**
  86775. * If vertex alpha should be applied to the mesh
  86776. */
  86777. useVertexAlpha?: boolean | undefined);
  86778. private _addClipPlaneDefine;
  86779. private _removeClipPlaneDefine;
  86780. isReady(): boolean;
  86781. /**
  86782. * Returns the string "LineMesh"
  86783. */
  86784. getClassName(): string;
  86785. /**
  86786. * @hidden
  86787. */
  86788. /**
  86789. * @hidden
  86790. */
  86791. material: Material;
  86792. /**
  86793. * @hidden
  86794. */
  86795. readonly checkCollisions: boolean;
  86796. /** @hidden */
  86797. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86798. /** @hidden */
  86799. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86800. /**
  86801. * Disposes of the line mesh
  86802. * @param doNotRecurse If children should be disposed
  86803. */
  86804. dispose(doNotRecurse?: boolean): void;
  86805. /**
  86806. * Returns a new LineMesh object cloned from the current one.
  86807. */
  86808. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86809. /**
  86810. * Creates a new InstancedLinesMesh object from the mesh model.
  86811. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86812. * @param name defines the name of the new instance
  86813. * @returns a new InstancedLinesMesh
  86814. */
  86815. createInstance(name: string): InstancedLinesMesh;
  86816. }
  86817. /**
  86818. * Creates an instance based on a source LinesMesh
  86819. */
  86820. export class InstancedLinesMesh extends InstancedMesh {
  86821. /**
  86822. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86823. * This margin is expressed in world space coordinates, so its value may vary.
  86824. * Initilized with the intersectionThreshold value of the source LinesMesh
  86825. */
  86826. intersectionThreshold: number;
  86827. constructor(name: string, source: LinesMesh);
  86828. /**
  86829. * Returns the string "InstancedLinesMesh".
  86830. */
  86831. getClassName(): string;
  86832. }
  86833. }
  86834. declare module BABYLON {
  86835. /** @hidden */
  86836. export var linePixelShader: {
  86837. name: string;
  86838. shader: string;
  86839. };
  86840. }
  86841. declare module BABYLON {
  86842. /** @hidden */
  86843. export var lineVertexShader: {
  86844. name: string;
  86845. shader: string;
  86846. };
  86847. }
  86848. declare module BABYLON {
  86849. interface AbstractMesh {
  86850. /**
  86851. * Gets the edgesRenderer associated with the mesh
  86852. */
  86853. edgesRenderer: Nullable<EdgesRenderer>;
  86854. }
  86855. interface LinesMesh {
  86856. /**
  86857. * Enables the edge rendering mode on the mesh.
  86858. * This mode makes the mesh edges visible
  86859. * @param epsilon defines the maximal distance between two angles to detect a face
  86860. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86861. * @returns the currentAbstractMesh
  86862. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86863. */
  86864. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86865. }
  86866. interface InstancedLinesMesh {
  86867. /**
  86868. * Enables the edge rendering mode on the mesh.
  86869. * This mode makes the mesh edges visible
  86870. * @param epsilon defines the maximal distance between two angles to detect a face
  86871. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86872. * @returns the current InstancedLinesMesh
  86873. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86874. */
  86875. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86876. }
  86877. /**
  86878. * Defines the minimum contract an Edges renderer should follow.
  86879. */
  86880. export interface IEdgesRenderer extends IDisposable {
  86881. /**
  86882. * Gets or sets a boolean indicating if the edgesRenderer is active
  86883. */
  86884. isEnabled: boolean;
  86885. /**
  86886. * Renders the edges of the attached mesh,
  86887. */
  86888. render(): void;
  86889. /**
  86890. * Checks wether or not the edges renderer is ready to render.
  86891. * @return true if ready, otherwise false.
  86892. */
  86893. isReady(): boolean;
  86894. }
  86895. /**
  86896. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86897. */
  86898. export class EdgesRenderer implements IEdgesRenderer {
  86899. /**
  86900. * Define the size of the edges with an orthographic camera
  86901. */
  86902. edgesWidthScalerForOrthographic: number;
  86903. /**
  86904. * Define the size of the edges with a perspective camera
  86905. */
  86906. edgesWidthScalerForPerspective: number;
  86907. protected _source: AbstractMesh;
  86908. protected _linesPositions: number[];
  86909. protected _linesNormals: number[];
  86910. protected _linesIndices: number[];
  86911. protected _epsilon: number;
  86912. protected _indicesCount: number;
  86913. protected _lineShader: ShaderMaterial;
  86914. protected _ib: DataBuffer;
  86915. protected _buffers: {
  86916. [key: string]: Nullable<VertexBuffer>;
  86917. };
  86918. protected _checkVerticesInsteadOfIndices: boolean;
  86919. private _meshRebuildObserver;
  86920. private _meshDisposeObserver;
  86921. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86922. isEnabled: boolean;
  86923. /**
  86924. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86925. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86926. * @param source Mesh used to create edges
  86927. * @param epsilon sum of angles in adjacency to check for edge
  86928. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86929. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86930. */
  86931. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86932. protected _prepareRessources(): void;
  86933. /** @hidden */
  86934. _rebuild(): void;
  86935. /**
  86936. * Releases the required resources for the edges renderer
  86937. */
  86938. dispose(): void;
  86939. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86940. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86941. /**
  86942. * Checks if the pair of p0 and p1 is en edge
  86943. * @param faceIndex
  86944. * @param edge
  86945. * @param faceNormals
  86946. * @param p0
  86947. * @param p1
  86948. * @private
  86949. */
  86950. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86951. /**
  86952. * push line into the position, normal and index buffer
  86953. * @protected
  86954. */
  86955. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86956. /**
  86957. * Generates lines edges from adjacencjes
  86958. * @private
  86959. */
  86960. _generateEdgesLines(): void;
  86961. /**
  86962. * Checks wether or not the edges renderer is ready to render.
  86963. * @return true if ready, otherwise false.
  86964. */
  86965. isReady(): boolean;
  86966. /**
  86967. * Renders the edges of the attached mesh,
  86968. */
  86969. render(): void;
  86970. }
  86971. /**
  86972. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86973. */
  86974. export class LineEdgesRenderer extends EdgesRenderer {
  86975. /**
  86976. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86977. * @param source LineMesh used to generate edges
  86978. * @param epsilon not important (specified angle for edge detection)
  86979. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86980. */
  86981. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86982. /**
  86983. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86984. */
  86985. _generateEdgesLines(): void;
  86986. }
  86987. }
  86988. declare module BABYLON {
  86989. /**
  86990. * This represents the object necessary to create a rendering group.
  86991. * This is exclusively used and created by the rendering manager.
  86992. * To modify the behavior, you use the available helpers in your scene or meshes.
  86993. * @hidden
  86994. */
  86995. export class RenderingGroup {
  86996. index: number;
  86997. private static _zeroVector;
  86998. private _scene;
  86999. private _opaqueSubMeshes;
  87000. private _transparentSubMeshes;
  87001. private _alphaTestSubMeshes;
  87002. private _depthOnlySubMeshes;
  87003. private _particleSystems;
  87004. private _spriteManagers;
  87005. private _opaqueSortCompareFn;
  87006. private _alphaTestSortCompareFn;
  87007. private _transparentSortCompareFn;
  87008. private _renderOpaque;
  87009. private _renderAlphaTest;
  87010. private _renderTransparent;
  87011. /** @hidden */
  87012. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87013. onBeforeTransparentRendering: () => void;
  87014. /**
  87015. * Set the opaque sort comparison function.
  87016. * If null the sub meshes will be render in the order they were created
  87017. */
  87018. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87019. /**
  87020. * Set the alpha test sort comparison function.
  87021. * If null the sub meshes will be render in the order they were created
  87022. */
  87023. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87024. /**
  87025. * Set the transparent sort comparison function.
  87026. * If null the sub meshes will be render in the order they were created
  87027. */
  87028. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87029. /**
  87030. * Creates a new rendering group.
  87031. * @param index The rendering group index
  87032. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87033. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87034. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87035. */
  87036. 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>);
  87037. /**
  87038. * Render all the sub meshes contained in the group.
  87039. * @param customRenderFunction Used to override the default render behaviour of the group.
  87040. * @returns true if rendered some submeshes.
  87041. */
  87042. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87043. /**
  87044. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87045. * @param subMeshes The submeshes to render
  87046. */
  87047. private renderOpaqueSorted;
  87048. /**
  87049. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87050. * @param subMeshes The submeshes to render
  87051. */
  87052. private renderAlphaTestSorted;
  87053. /**
  87054. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87055. * @param subMeshes The submeshes to render
  87056. */
  87057. private renderTransparentSorted;
  87058. /**
  87059. * Renders the submeshes in a specified order.
  87060. * @param subMeshes The submeshes to sort before render
  87061. * @param sortCompareFn The comparison function use to sort
  87062. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87063. * @param transparent Specifies to activate blending if true
  87064. */
  87065. private static renderSorted;
  87066. /**
  87067. * Renders the submeshes in the order they were dispatched (no sort applied).
  87068. * @param subMeshes The submeshes to render
  87069. */
  87070. private static renderUnsorted;
  87071. /**
  87072. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87073. * are rendered back to front if in the same alpha index.
  87074. *
  87075. * @param a The first submesh
  87076. * @param b The second submesh
  87077. * @returns The result of the comparison
  87078. */
  87079. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87080. /**
  87081. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87082. * are rendered back to front.
  87083. *
  87084. * @param a The first submesh
  87085. * @param b The second submesh
  87086. * @returns The result of the comparison
  87087. */
  87088. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87089. /**
  87090. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87091. * are rendered front to back (prevent overdraw).
  87092. *
  87093. * @param a The first submesh
  87094. * @param b The second submesh
  87095. * @returns The result of the comparison
  87096. */
  87097. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  87098. /**
  87099. * Resets the different lists of submeshes to prepare a new frame.
  87100. */
  87101. prepare(): void;
  87102. dispose(): void;
  87103. /**
  87104. * Inserts the submesh in its correct queue depending on its material.
  87105. * @param subMesh The submesh to dispatch
  87106. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87107. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87108. */
  87109. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87110. dispatchSprites(spriteManager: ISpriteManager): void;
  87111. dispatchParticles(particleSystem: IParticleSystem): void;
  87112. private _renderParticles;
  87113. private _renderSprites;
  87114. }
  87115. }
  87116. declare module BABYLON {
  87117. /**
  87118. * Interface describing the different options available in the rendering manager
  87119. * regarding Auto Clear between groups.
  87120. */
  87121. export interface IRenderingManagerAutoClearSetup {
  87122. /**
  87123. * Defines whether or not autoclear is enable.
  87124. */
  87125. autoClear: boolean;
  87126. /**
  87127. * Defines whether or not to autoclear the depth buffer.
  87128. */
  87129. depth: boolean;
  87130. /**
  87131. * Defines whether or not to autoclear the stencil buffer.
  87132. */
  87133. stencil: boolean;
  87134. }
  87135. /**
  87136. * This class is used by the onRenderingGroupObservable
  87137. */
  87138. export class RenderingGroupInfo {
  87139. /**
  87140. * The Scene that being rendered
  87141. */
  87142. scene: Scene;
  87143. /**
  87144. * The camera currently used for the rendering pass
  87145. */
  87146. camera: Nullable<Camera>;
  87147. /**
  87148. * The ID of the renderingGroup being processed
  87149. */
  87150. renderingGroupId: number;
  87151. }
  87152. /**
  87153. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87154. * It is enable to manage the different groups as well as the different necessary sort functions.
  87155. * This should not be used directly aside of the few static configurations
  87156. */
  87157. export class RenderingManager {
  87158. /**
  87159. * The max id used for rendering groups (not included)
  87160. */
  87161. static MAX_RENDERINGGROUPS: number;
  87162. /**
  87163. * The min id used for rendering groups (included)
  87164. */
  87165. static MIN_RENDERINGGROUPS: number;
  87166. /**
  87167. * Used to globally prevent autoclearing scenes.
  87168. */
  87169. static AUTOCLEAR: boolean;
  87170. /**
  87171. * @hidden
  87172. */
  87173. _useSceneAutoClearSetup: boolean;
  87174. private _scene;
  87175. private _renderingGroups;
  87176. private _depthStencilBufferAlreadyCleaned;
  87177. private _autoClearDepthStencil;
  87178. private _customOpaqueSortCompareFn;
  87179. private _customAlphaTestSortCompareFn;
  87180. private _customTransparentSortCompareFn;
  87181. private _renderingGroupInfo;
  87182. /**
  87183. * Instantiates a new rendering group for a particular scene
  87184. * @param scene Defines the scene the groups belongs to
  87185. */
  87186. constructor(scene: Scene);
  87187. private _clearDepthStencilBuffer;
  87188. /**
  87189. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87190. * @hidden
  87191. */
  87192. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87193. /**
  87194. * Resets the different information of the group to prepare a new frame
  87195. * @hidden
  87196. */
  87197. reset(): void;
  87198. /**
  87199. * Dispose and release the group and its associated resources.
  87200. * @hidden
  87201. */
  87202. dispose(): void;
  87203. /**
  87204. * Clear the info related to rendering groups preventing retention points during dispose.
  87205. */
  87206. freeRenderingGroups(): void;
  87207. private _prepareRenderingGroup;
  87208. /**
  87209. * Add a sprite manager to the rendering manager in order to render it this frame.
  87210. * @param spriteManager Define the sprite manager to render
  87211. */
  87212. dispatchSprites(spriteManager: ISpriteManager): void;
  87213. /**
  87214. * Add a particle system to the rendering manager in order to render it this frame.
  87215. * @param particleSystem Define the particle system to render
  87216. */
  87217. dispatchParticles(particleSystem: IParticleSystem): void;
  87218. /**
  87219. * Add a submesh to the manager in order to render it this frame
  87220. * @param subMesh The submesh to dispatch
  87221. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87222. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87223. */
  87224. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87225. /**
  87226. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87227. * This allowed control for front to back rendering or reversly depending of the special needs.
  87228. *
  87229. * @param renderingGroupId The rendering group id corresponding to its index
  87230. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87231. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87232. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87233. */
  87234. 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;
  87235. /**
  87236. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87237. *
  87238. * @param renderingGroupId The rendering group id corresponding to its index
  87239. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87240. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87241. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87242. */
  87243. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87244. /**
  87245. * Gets the current auto clear configuration for one rendering group of the rendering
  87246. * manager.
  87247. * @param index the rendering group index to get the information for
  87248. * @returns The auto clear setup for the requested rendering group
  87249. */
  87250. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87251. }
  87252. }
  87253. declare module BABYLON {
  87254. /**
  87255. * This Helps creating a texture that will be created from a camera in your scene.
  87256. * It is basically a dynamic texture that could be used to create special effects for instance.
  87257. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87258. */
  87259. export class RenderTargetTexture extends Texture {
  87260. isCube: boolean;
  87261. /**
  87262. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87263. */
  87264. static readonly REFRESHRATE_RENDER_ONCE: number;
  87265. /**
  87266. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87267. */
  87268. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87269. /**
  87270. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87271. * the central point of your effect and can save a lot of performances.
  87272. */
  87273. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87274. /**
  87275. * Use this predicate to dynamically define the list of mesh you want to render.
  87276. * If set, the renderList property will be overwritten.
  87277. */
  87278. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87279. private _renderList;
  87280. /**
  87281. * Use this list to define the list of mesh you want to render.
  87282. */
  87283. renderList: Nullable<Array<AbstractMesh>>;
  87284. private _hookArray;
  87285. /**
  87286. * Define if particles should be rendered in your texture.
  87287. */
  87288. renderParticles: boolean;
  87289. /**
  87290. * Define if sprites should be rendered in your texture.
  87291. */
  87292. renderSprites: boolean;
  87293. /**
  87294. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87295. */
  87296. coordinatesMode: number;
  87297. /**
  87298. * Define the camera used to render the texture.
  87299. */
  87300. activeCamera: Nullable<Camera>;
  87301. /**
  87302. * Override the render function of the texture with your own one.
  87303. */
  87304. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87305. /**
  87306. * Define if camera post processes should be use while rendering the texture.
  87307. */
  87308. useCameraPostProcesses: boolean;
  87309. /**
  87310. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87311. */
  87312. ignoreCameraViewport: boolean;
  87313. private _postProcessManager;
  87314. private _postProcesses;
  87315. private _resizeObserver;
  87316. /**
  87317. * An event triggered when the texture is unbind.
  87318. */
  87319. onBeforeBindObservable: Observable<RenderTargetTexture>;
  87320. /**
  87321. * An event triggered when the texture is unbind.
  87322. */
  87323. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  87324. private _onAfterUnbindObserver;
  87325. /**
  87326. * Set a after unbind callback in the texture.
  87327. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  87328. */
  87329. onAfterUnbind: () => void;
  87330. /**
  87331. * An event triggered before rendering the texture
  87332. */
  87333. onBeforeRenderObservable: Observable<number>;
  87334. private _onBeforeRenderObserver;
  87335. /**
  87336. * Set a before render callback in the texture.
  87337. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  87338. */
  87339. onBeforeRender: (faceIndex: number) => void;
  87340. /**
  87341. * An event triggered after rendering the texture
  87342. */
  87343. onAfterRenderObservable: Observable<number>;
  87344. private _onAfterRenderObserver;
  87345. /**
  87346. * Set a after render callback in the texture.
  87347. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  87348. */
  87349. onAfterRender: (faceIndex: number) => void;
  87350. /**
  87351. * An event triggered after the texture clear
  87352. */
  87353. onClearObservable: Observable<Engine>;
  87354. private _onClearObserver;
  87355. /**
  87356. * Set a clear callback in the texture.
  87357. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  87358. */
  87359. onClear: (Engine: Engine) => void;
  87360. /**
  87361. * An event triggered when the texture is resized.
  87362. */
  87363. onResizeObservable: Observable<RenderTargetTexture>;
  87364. /**
  87365. * Define the clear color of the Render Target if it should be different from the scene.
  87366. */
  87367. clearColor: Color4;
  87368. protected _size: number | {
  87369. width: number;
  87370. height: number;
  87371. };
  87372. protected _initialSizeParameter: number | {
  87373. width: number;
  87374. height: number;
  87375. } | {
  87376. ratio: number;
  87377. };
  87378. protected _sizeRatio: Nullable<number>;
  87379. /** @hidden */
  87380. _generateMipMaps: boolean;
  87381. protected _renderingManager: RenderingManager;
  87382. /** @hidden */
  87383. _waitingRenderList: string[];
  87384. protected _doNotChangeAspectRatio: boolean;
  87385. protected _currentRefreshId: number;
  87386. protected _refreshRate: number;
  87387. protected _textureMatrix: Matrix;
  87388. protected _samples: number;
  87389. protected _renderTargetOptions: RenderTargetCreationOptions;
  87390. /**
  87391. * Gets render target creation options that were used.
  87392. */
  87393. readonly renderTargetOptions: RenderTargetCreationOptions;
  87394. protected _engine: Engine;
  87395. protected _onRatioRescale(): void;
  87396. /**
  87397. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  87398. * It must define where the camera used to render the texture is set
  87399. */
  87400. boundingBoxPosition: Vector3;
  87401. private _boundingBoxSize;
  87402. /**
  87403. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  87404. * When defined, the cubemap will switch to local mode
  87405. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87406. * @example https://www.babylonjs-playground.com/#RNASML
  87407. */
  87408. boundingBoxSize: Vector3;
  87409. /**
  87410. * In case the RTT has been created with a depth texture, get the associated
  87411. * depth texture.
  87412. * Otherwise, return null.
  87413. */
  87414. depthStencilTexture: Nullable<InternalTexture>;
  87415. /**
  87416. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  87417. * or used a shadow, depth texture...
  87418. * @param name The friendly name of the texture
  87419. * @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)
  87420. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  87421. * @param generateMipMaps True if mip maps need to be generated after render.
  87422. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  87423. * @param type The type of the buffer in the RTT (int, half float, float...)
  87424. * @param isCube True if a cube texture needs to be created
  87425. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  87426. * @param generateDepthBuffer True to generate a depth buffer
  87427. * @param generateStencilBuffer True to generate a stencil buffer
  87428. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  87429. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  87430. * @param delayAllocation if the texture allocation should be delayed (default: false)
  87431. */
  87432. constructor(name: string, size: number | {
  87433. width: number;
  87434. height: number;
  87435. } | {
  87436. ratio: number;
  87437. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  87438. /**
  87439. * Creates a depth stencil texture.
  87440. * This is only available in WebGL 2 or with the depth texture extension available.
  87441. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  87442. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  87443. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  87444. */
  87445. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  87446. private _processSizeParameter;
  87447. /**
  87448. * Define the number of samples to use in case of MSAA.
  87449. * It defaults to one meaning no MSAA has been enabled.
  87450. */
  87451. samples: number;
  87452. /**
  87453. * Resets the refresh counter of the texture and start bak from scratch.
  87454. * Could be useful to regenerate the texture if it is setup to render only once.
  87455. */
  87456. resetRefreshCounter(): void;
  87457. /**
  87458. * Define the refresh rate of the texture or the rendering frequency.
  87459. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87460. */
  87461. refreshRate: number;
  87462. /**
  87463. * Adds a post process to the render target rendering passes.
  87464. * @param postProcess define the post process to add
  87465. */
  87466. addPostProcess(postProcess: PostProcess): void;
  87467. /**
  87468. * Clear all the post processes attached to the render target
  87469. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  87470. */
  87471. clearPostProcesses(dispose?: boolean): void;
  87472. /**
  87473. * Remove one of the post process from the list of attached post processes to the texture
  87474. * @param postProcess define the post process to remove from the list
  87475. */
  87476. removePostProcess(postProcess: PostProcess): void;
  87477. /** @hidden */
  87478. _shouldRender(): boolean;
  87479. /**
  87480. * Gets the actual render size of the texture.
  87481. * @returns the width of the render size
  87482. */
  87483. getRenderSize(): number;
  87484. /**
  87485. * Gets the actual render width of the texture.
  87486. * @returns the width of the render size
  87487. */
  87488. getRenderWidth(): number;
  87489. /**
  87490. * Gets the actual render height of the texture.
  87491. * @returns the height of the render size
  87492. */
  87493. getRenderHeight(): number;
  87494. /**
  87495. * Get if the texture can be rescaled or not.
  87496. */
  87497. readonly canRescale: boolean;
  87498. /**
  87499. * Resize the texture using a ratio.
  87500. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  87501. */
  87502. scale(ratio: number): void;
  87503. /**
  87504. * Get the texture reflection matrix used to rotate/transform the reflection.
  87505. * @returns the reflection matrix
  87506. */
  87507. getReflectionTextureMatrix(): Matrix;
  87508. /**
  87509. * Resize the texture to a new desired size.
  87510. * Be carrefull as it will recreate all the data in the new texture.
  87511. * @param size Define the new size. It can be:
  87512. * - a number for squared texture,
  87513. * - an object containing { width: number, height: number }
  87514. * - or an object containing a ratio { ratio: number }
  87515. */
  87516. resize(size: number | {
  87517. width: number;
  87518. height: number;
  87519. } | {
  87520. ratio: number;
  87521. }): void;
  87522. /**
  87523. * Renders all the objects from the render list into the texture.
  87524. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  87525. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  87526. */
  87527. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  87528. private _bestReflectionRenderTargetDimension;
  87529. /**
  87530. * @hidden
  87531. * @param faceIndex face index to bind to if this is a cubetexture
  87532. */
  87533. _bindFrameBuffer(faceIndex?: number): void;
  87534. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  87535. private renderToTarget;
  87536. /**
  87537. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87538. * This allowed control for front to back rendering or reversly depending of the special needs.
  87539. *
  87540. * @param renderingGroupId The rendering group id corresponding to its index
  87541. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87542. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87543. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87544. */
  87545. 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;
  87546. /**
  87547. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87548. *
  87549. * @param renderingGroupId The rendering group id corresponding to its index
  87550. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87551. */
  87552. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  87553. /**
  87554. * Clones the texture.
  87555. * @returns the cloned texture
  87556. */
  87557. clone(): RenderTargetTexture;
  87558. /**
  87559. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87560. * @returns The JSON representation of the texture
  87561. */
  87562. serialize(): any;
  87563. /**
  87564. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  87565. */
  87566. disposeFramebufferObjects(): void;
  87567. /**
  87568. * Dispose the texture and release its associated resources.
  87569. */
  87570. dispose(): void;
  87571. /** @hidden */
  87572. _rebuild(): void;
  87573. /**
  87574. * Clear the info related to rendering groups preventing retention point in material dispose.
  87575. */
  87576. freeRenderingGroups(): void;
  87577. /**
  87578. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87579. * @returns the view count
  87580. */
  87581. getViewCount(): number;
  87582. }
  87583. }
  87584. declare module BABYLON {
  87585. /**
  87586. * Options for compiling materials.
  87587. */
  87588. export interface IMaterialCompilationOptions {
  87589. /**
  87590. * Defines whether clip planes are enabled.
  87591. */
  87592. clipPlane: boolean;
  87593. /**
  87594. * Defines whether instances are enabled.
  87595. */
  87596. useInstances: boolean;
  87597. }
  87598. /**
  87599. * Base class for the main features of a material in Babylon.js
  87600. */
  87601. export class Material implements IAnimatable {
  87602. /**
  87603. * Returns the triangle fill mode
  87604. */
  87605. static readonly TriangleFillMode: number;
  87606. /**
  87607. * Returns the wireframe mode
  87608. */
  87609. static readonly WireFrameFillMode: number;
  87610. /**
  87611. * Returns the point fill mode
  87612. */
  87613. static readonly PointFillMode: number;
  87614. /**
  87615. * Returns the point list draw mode
  87616. */
  87617. static readonly PointListDrawMode: number;
  87618. /**
  87619. * Returns the line list draw mode
  87620. */
  87621. static readonly LineListDrawMode: number;
  87622. /**
  87623. * Returns the line loop draw mode
  87624. */
  87625. static readonly LineLoopDrawMode: number;
  87626. /**
  87627. * Returns the line strip draw mode
  87628. */
  87629. static readonly LineStripDrawMode: number;
  87630. /**
  87631. * Returns the triangle strip draw mode
  87632. */
  87633. static readonly TriangleStripDrawMode: number;
  87634. /**
  87635. * Returns the triangle fan draw mode
  87636. */
  87637. static readonly TriangleFanDrawMode: number;
  87638. /**
  87639. * Stores the clock-wise side orientation
  87640. */
  87641. static readonly ClockWiseSideOrientation: number;
  87642. /**
  87643. * Stores the counter clock-wise side orientation
  87644. */
  87645. static readonly CounterClockWiseSideOrientation: number;
  87646. /**
  87647. * The dirty texture flag value
  87648. */
  87649. static readonly TextureDirtyFlag: number;
  87650. /**
  87651. * The dirty light flag value
  87652. */
  87653. static readonly LightDirtyFlag: number;
  87654. /**
  87655. * The dirty fresnel flag value
  87656. */
  87657. static readonly FresnelDirtyFlag: number;
  87658. /**
  87659. * The dirty attribute flag value
  87660. */
  87661. static readonly AttributesDirtyFlag: number;
  87662. /**
  87663. * The dirty misc flag value
  87664. */
  87665. static readonly MiscDirtyFlag: number;
  87666. /**
  87667. * The all dirty flag value
  87668. */
  87669. static readonly AllDirtyFlag: number;
  87670. /**
  87671. * The ID of the material
  87672. */
  87673. id: string;
  87674. /**
  87675. * Gets or sets the unique id of the material
  87676. */
  87677. uniqueId: number;
  87678. /**
  87679. * The name of the material
  87680. */
  87681. name: string;
  87682. /**
  87683. * Gets or sets user defined metadata
  87684. */
  87685. metadata: any;
  87686. /**
  87687. * For internal use only. Please do not use.
  87688. */
  87689. reservedDataStore: any;
  87690. /**
  87691. * Specifies if the ready state should be checked on each call
  87692. */
  87693. checkReadyOnEveryCall: boolean;
  87694. /**
  87695. * Specifies if the ready state should be checked once
  87696. */
  87697. checkReadyOnlyOnce: boolean;
  87698. /**
  87699. * The state of the material
  87700. */
  87701. state: string;
  87702. /**
  87703. * The alpha value of the material
  87704. */
  87705. protected _alpha: number;
  87706. /**
  87707. * List of inspectable custom properties (used by the Inspector)
  87708. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87709. */
  87710. inspectableCustomProperties: IInspectable[];
  87711. /**
  87712. * Sets the alpha value of the material
  87713. */
  87714. /**
  87715. * Gets the alpha value of the material
  87716. */
  87717. alpha: number;
  87718. /**
  87719. * Specifies if back face culling is enabled
  87720. */
  87721. protected _backFaceCulling: boolean;
  87722. /**
  87723. * Sets the back-face culling state
  87724. */
  87725. /**
  87726. * Gets the back-face culling state
  87727. */
  87728. backFaceCulling: boolean;
  87729. /**
  87730. * Stores the value for side orientation
  87731. */
  87732. sideOrientation: number;
  87733. /**
  87734. * Callback triggered when the material is compiled
  87735. */
  87736. onCompiled: Nullable<(effect: Effect) => void>;
  87737. /**
  87738. * Callback triggered when an error occurs
  87739. */
  87740. onError: Nullable<(effect: Effect, errors: string) => void>;
  87741. /**
  87742. * Callback triggered to get the render target textures
  87743. */
  87744. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87745. /**
  87746. * Gets a boolean indicating that current material needs to register RTT
  87747. */
  87748. readonly hasRenderTargetTextures: boolean;
  87749. /**
  87750. * Specifies if the material should be serialized
  87751. */
  87752. doNotSerialize: boolean;
  87753. /**
  87754. * @hidden
  87755. */
  87756. _storeEffectOnSubMeshes: boolean;
  87757. /**
  87758. * Stores the animations for the material
  87759. */
  87760. animations: Nullable<Array<Animation>>;
  87761. /**
  87762. * An event triggered when the material is disposed
  87763. */
  87764. onDisposeObservable: Observable<Material>;
  87765. /**
  87766. * An observer which watches for dispose events
  87767. */
  87768. private _onDisposeObserver;
  87769. private _onUnBindObservable;
  87770. /**
  87771. * Called during a dispose event
  87772. */
  87773. onDispose: () => void;
  87774. private _onBindObservable;
  87775. /**
  87776. * An event triggered when the material is bound
  87777. */
  87778. readonly onBindObservable: Observable<AbstractMesh>;
  87779. /**
  87780. * An observer which watches for bind events
  87781. */
  87782. private _onBindObserver;
  87783. /**
  87784. * Called during a bind event
  87785. */
  87786. onBind: (Mesh: AbstractMesh) => void;
  87787. /**
  87788. * An event triggered when the material is unbound
  87789. */
  87790. readonly onUnBindObservable: Observable<Material>;
  87791. /**
  87792. * Stores the value of the alpha mode
  87793. */
  87794. private _alphaMode;
  87795. /**
  87796. * Sets the value of the alpha mode.
  87797. *
  87798. * | Value | Type | Description |
  87799. * | --- | --- | --- |
  87800. * | 0 | ALPHA_DISABLE | |
  87801. * | 1 | ALPHA_ADD | |
  87802. * | 2 | ALPHA_COMBINE | |
  87803. * | 3 | ALPHA_SUBTRACT | |
  87804. * | 4 | ALPHA_MULTIPLY | |
  87805. * | 5 | ALPHA_MAXIMIZED | |
  87806. * | 6 | ALPHA_ONEONE | |
  87807. * | 7 | ALPHA_PREMULTIPLIED | |
  87808. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87809. * | 9 | ALPHA_INTERPOLATE | |
  87810. * | 10 | ALPHA_SCREENMODE | |
  87811. *
  87812. */
  87813. /**
  87814. * Gets the value of the alpha mode
  87815. */
  87816. alphaMode: number;
  87817. /**
  87818. * Stores the state of the need depth pre-pass value
  87819. */
  87820. private _needDepthPrePass;
  87821. /**
  87822. * Sets the need depth pre-pass value
  87823. */
  87824. /**
  87825. * Gets the depth pre-pass value
  87826. */
  87827. needDepthPrePass: boolean;
  87828. /**
  87829. * Specifies if depth writing should be disabled
  87830. */
  87831. disableDepthWrite: boolean;
  87832. /**
  87833. * Specifies if depth writing should be forced
  87834. */
  87835. forceDepthWrite: boolean;
  87836. /**
  87837. * Specifies if there should be a separate pass for culling
  87838. */
  87839. separateCullingPass: boolean;
  87840. /**
  87841. * Stores the state specifing if fog should be enabled
  87842. */
  87843. private _fogEnabled;
  87844. /**
  87845. * Sets the state for enabling fog
  87846. */
  87847. /**
  87848. * Gets the value of the fog enabled state
  87849. */
  87850. fogEnabled: boolean;
  87851. /**
  87852. * Stores the size of points
  87853. */
  87854. pointSize: number;
  87855. /**
  87856. * Stores the z offset value
  87857. */
  87858. zOffset: number;
  87859. /**
  87860. * Gets a value specifying if wireframe mode is enabled
  87861. */
  87862. /**
  87863. * Sets the state of wireframe mode
  87864. */
  87865. wireframe: boolean;
  87866. /**
  87867. * Gets the value specifying if point clouds are enabled
  87868. */
  87869. /**
  87870. * Sets the state of point cloud mode
  87871. */
  87872. pointsCloud: boolean;
  87873. /**
  87874. * Gets the material fill mode
  87875. */
  87876. /**
  87877. * Sets the material fill mode
  87878. */
  87879. fillMode: number;
  87880. /**
  87881. * @hidden
  87882. * Stores the effects for the material
  87883. */
  87884. _effect: Nullable<Effect>;
  87885. /**
  87886. * @hidden
  87887. * Specifies if the material was previously ready
  87888. */
  87889. _wasPreviouslyReady: boolean;
  87890. /**
  87891. * Specifies if uniform buffers should be used
  87892. */
  87893. private _useUBO;
  87894. /**
  87895. * Stores a reference to the scene
  87896. */
  87897. private _scene;
  87898. /**
  87899. * Stores the fill mode state
  87900. */
  87901. private _fillMode;
  87902. /**
  87903. * Specifies if the depth write state should be cached
  87904. */
  87905. private _cachedDepthWriteState;
  87906. /**
  87907. * Stores the uniform buffer
  87908. */
  87909. protected _uniformBuffer: UniformBuffer;
  87910. /** @hidden */
  87911. _indexInSceneMaterialArray: number;
  87912. /** @hidden */
  87913. meshMap: Nullable<{
  87914. [id: string]: AbstractMesh | undefined;
  87915. }>;
  87916. /**
  87917. * Creates a material instance
  87918. * @param name defines the name of the material
  87919. * @param scene defines the scene to reference
  87920. * @param doNotAdd specifies if the material should be added to the scene
  87921. */
  87922. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87923. /**
  87924. * Returns a string representation of the current material
  87925. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87926. * @returns a string with material information
  87927. */
  87928. toString(fullDetails?: boolean): string;
  87929. /**
  87930. * Gets the class name of the material
  87931. * @returns a string with the class name of the material
  87932. */
  87933. getClassName(): string;
  87934. /**
  87935. * Specifies if updates for the material been locked
  87936. */
  87937. readonly isFrozen: boolean;
  87938. /**
  87939. * Locks updates for the material
  87940. */
  87941. freeze(): void;
  87942. /**
  87943. * Unlocks updates for the material
  87944. */
  87945. unfreeze(): void;
  87946. /**
  87947. * Specifies if the material is ready to be used
  87948. * @param mesh defines the mesh to check
  87949. * @param useInstances specifies if instances should be used
  87950. * @returns a boolean indicating if the material is ready to be used
  87951. */
  87952. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87953. /**
  87954. * Specifies that the submesh is ready to be used
  87955. * @param mesh defines the mesh to check
  87956. * @param subMesh defines which submesh to check
  87957. * @param useInstances specifies that instances should be used
  87958. * @returns a boolean indicating that the submesh is ready or not
  87959. */
  87960. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87961. /**
  87962. * Returns the material effect
  87963. * @returns the effect associated with the material
  87964. */
  87965. getEffect(): Nullable<Effect>;
  87966. /**
  87967. * Returns the current scene
  87968. * @returns a Scene
  87969. */
  87970. getScene(): Scene;
  87971. /**
  87972. * Specifies if the material will require alpha blending
  87973. * @returns a boolean specifying if alpha blending is needed
  87974. */
  87975. needAlphaBlending(): boolean;
  87976. /**
  87977. * Specifies if the mesh will require alpha blending
  87978. * @param mesh defines the mesh to check
  87979. * @returns a boolean specifying if alpha blending is needed for the mesh
  87980. */
  87981. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87982. /**
  87983. * Specifies if this material should be rendered in alpha test mode
  87984. * @returns a boolean specifying if an alpha test is needed.
  87985. */
  87986. needAlphaTesting(): boolean;
  87987. /**
  87988. * Gets the texture used for the alpha test
  87989. * @returns the texture to use for alpha testing
  87990. */
  87991. getAlphaTestTexture(): Nullable<BaseTexture>;
  87992. /**
  87993. * Marks the material to indicate that it needs to be re-calculated
  87994. */
  87995. markDirty(): void;
  87996. /** @hidden */
  87997. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87998. /**
  87999. * Binds the material to the mesh
  88000. * @param world defines the world transformation matrix
  88001. * @param mesh defines the mesh to bind the material to
  88002. */
  88003. bind(world: Matrix, mesh?: Mesh): void;
  88004. /**
  88005. * Binds the submesh to the material
  88006. * @param world defines the world transformation matrix
  88007. * @param mesh defines the mesh containing the submesh
  88008. * @param subMesh defines the submesh to bind the material to
  88009. */
  88010. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88011. /**
  88012. * Binds the world matrix to the material
  88013. * @param world defines the world transformation matrix
  88014. */
  88015. bindOnlyWorldMatrix(world: Matrix): void;
  88016. /**
  88017. * Binds the scene's uniform buffer to the effect.
  88018. * @param effect defines the effect to bind to the scene uniform buffer
  88019. * @param sceneUbo defines the uniform buffer storing scene data
  88020. */
  88021. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88022. /**
  88023. * Binds the view matrix to the effect
  88024. * @param effect defines the effect to bind the view matrix to
  88025. */
  88026. bindView(effect: Effect): void;
  88027. /**
  88028. * Binds the view projection matrix to the effect
  88029. * @param effect defines the effect to bind the view projection matrix to
  88030. */
  88031. bindViewProjection(effect: Effect): void;
  88032. /**
  88033. * Specifies if material alpha testing should be turned on for the mesh
  88034. * @param mesh defines the mesh to check
  88035. */
  88036. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88037. /**
  88038. * Processes to execute after binding the material to a mesh
  88039. * @param mesh defines the rendered mesh
  88040. */
  88041. protected _afterBind(mesh?: Mesh): void;
  88042. /**
  88043. * Unbinds the material from the mesh
  88044. */
  88045. unbind(): void;
  88046. /**
  88047. * Gets the active textures from the material
  88048. * @returns an array of textures
  88049. */
  88050. getActiveTextures(): BaseTexture[];
  88051. /**
  88052. * Specifies if the material uses a texture
  88053. * @param texture defines the texture to check against the material
  88054. * @returns a boolean specifying if the material uses the texture
  88055. */
  88056. hasTexture(texture: BaseTexture): boolean;
  88057. /**
  88058. * Makes a duplicate of the material, and gives it a new name
  88059. * @param name defines the new name for the duplicated material
  88060. * @returns the cloned material
  88061. */
  88062. clone(name: string): Nullable<Material>;
  88063. /**
  88064. * Gets the meshes bound to the material
  88065. * @returns an array of meshes bound to the material
  88066. */
  88067. getBindedMeshes(): AbstractMesh[];
  88068. /**
  88069. * Force shader compilation
  88070. * @param mesh defines the mesh associated with this material
  88071. * @param onCompiled defines a function to execute once the material is compiled
  88072. * @param options defines the options to configure the compilation
  88073. * @param onError defines a function to execute if the material fails compiling
  88074. */
  88075. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88076. /**
  88077. * Force shader compilation
  88078. * @param mesh defines the mesh that will use this material
  88079. * @param options defines additional options for compiling the shaders
  88080. * @returns a promise that resolves when the compilation completes
  88081. */
  88082. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  88083. private static readonly _AllDirtyCallBack;
  88084. private static readonly _ImageProcessingDirtyCallBack;
  88085. private static readonly _TextureDirtyCallBack;
  88086. private static readonly _FresnelDirtyCallBack;
  88087. private static readonly _MiscDirtyCallBack;
  88088. private static readonly _LightsDirtyCallBack;
  88089. private static readonly _AttributeDirtyCallBack;
  88090. private static _FresnelAndMiscDirtyCallBack;
  88091. private static _TextureAndMiscDirtyCallBack;
  88092. private static readonly _DirtyCallbackArray;
  88093. private static readonly _RunDirtyCallBacks;
  88094. /**
  88095. * Marks a define in the material to indicate that it needs to be re-computed
  88096. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  88097. */
  88098. markAsDirty(flag: number): void;
  88099. /**
  88100. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  88101. * @param func defines a function which checks material defines against the submeshes
  88102. */
  88103. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  88104. /**
  88105. * Indicates that we need to re-calculated for all submeshes
  88106. */
  88107. protected _markAllSubMeshesAsAllDirty(): void;
  88108. /**
  88109. * Indicates that image processing needs to be re-calculated for all submeshes
  88110. */
  88111. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  88112. /**
  88113. * Indicates that textures need to be re-calculated for all submeshes
  88114. */
  88115. protected _markAllSubMeshesAsTexturesDirty(): void;
  88116. /**
  88117. * Indicates that fresnel needs to be re-calculated for all submeshes
  88118. */
  88119. protected _markAllSubMeshesAsFresnelDirty(): void;
  88120. /**
  88121. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  88122. */
  88123. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  88124. /**
  88125. * Indicates that lights need to be re-calculated for all submeshes
  88126. */
  88127. protected _markAllSubMeshesAsLightsDirty(): void;
  88128. /**
  88129. * Indicates that attributes need to be re-calculated for all submeshes
  88130. */
  88131. protected _markAllSubMeshesAsAttributesDirty(): void;
  88132. /**
  88133. * Indicates that misc needs to be re-calculated for all submeshes
  88134. */
  88135. protected _markAllSubMeshesAsMiscDirty(): void;
  88136. /**
  88137. * Indicates that textures and misc need to be re-calculated for all submeshes
  88138. */
  88139. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88140. /**
  88141. * Disposes the material
  88142. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88143. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88144. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88145. */
  88146. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88147. /** @hidden */
  88148. private releaseVertexArrayObject;
  88149. /**
  88150. * Serializes this material
  88151. * @returns the serialized material object
  88152. */
  88153. serialize(): any;
  88154. /**
  88155. * Creates a material from parsed material data
  88156. * @param parsedMaterial defines parsed material data
  88157. * @param scene defines the hosting scene
  88158. * @param rootUrl defines the root URL to use to load textures
  88159. * @returns a new material
  88160. */
  88161. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88162. }
  88163. }
  88164. declare module BABYLON {
  88165. /**
  88166. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88167. * separate meshes. This can be use to improve performances.
  88168. * @see http://doc.babylonjs.com/how_to/multi_materials
  88169. */
  88170. export class MultiMaterial extends Material {
  88171. private _subMaterials;
  88172. /**
  88173. * Gets or Sets the list of Materials used within the multi material.
  88174. * They need to be ordered according to the submeshes order in the associated mesh
  88175. */
  88176. subMaterials: Nullable<Material>[];
  88177. /**
  88178. * Function used to align with Node.getChildren()
  88179. * @returns the list of Materials used within the multi material
  88180. */
  88181. getChildren(): Nullable<Material>[];
  88182. /**
  88183. * Instantiates a new Multi Material
  88184. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88185. * separate meshes. This can be use to improve performances.
  88186. * @see http://doc.babylonjs.com/how_to/multi_materials
  88187. * @param name Define the name in the scene
  88188. * @param scene Define the scene the material belongs to
  88189. */
  88190. constructor(name: string, scene: Scene);
  88191. private _hookArray;
  88192. /**
  88193. * Get one of the submaterial by its index in the submaterials array
  88194. * @param index The index to look the sub material at
  88195. * @returns The Material if the index has been defined
  88196. */
  88197. getSubMaterial(index: number): Nullable<Material>;
  88198. /**
  88199. * Get the list of active textures for the whole sub materials list.
  88200. * @returns All the textures that will be used during the rendering
  88201. */
  88202. getActiveTextures(): BaseTexture[];
  88203. /**
  88204. * Gets the current class name of the material e.g. "MultiMaterial"
  88205. * Mainly use in serialization.
  88206. * @returns the class name
  88207. */
  88208. getClassName(): string;
  88209. /**
  88210. * Checks if the material is ready to render the requested sub mesh
  88211. * @param mesh Define the mesh the submesh belongs to
  88212. * @param subMesh Define the sub mesh to look readyness for
  88213. * @param useInstances Define whether or not the material is used with instances
  88214. * @returns true if ready, otherwise false
  88215. */
  88216. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88217. /**
  88218. * Clones the current material and its related sub materials
  88219. * @param name Define the name of the newly cloned material
  88220. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88221. * @returns the cloned material
  88222. */
  88223. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88224. /**
  88225. * Serializes the materials into a JSON representation.
  88226. * @returns the JSON representation
  88227. */
  88228. serialize(): any;
  88229. /**
  88230. * Dispose the material and release its associated resources
  88231. * @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)
  88232. * @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)
  88233. * @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)
  88234. */
  88235. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88236. /**
  88237. * Creates a MultiMaterial from parsed MultiMaterial data.
  88238. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88239. * @param scene defines the hosting scene
  88240. * @returns a new MultiMaterial
  88241. */
  88242. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88243. }
  88244. }
  88245. declare module BABYLON {
  88246. /**
  88247. * Base class for submeshes
  88248. */
  88249. export class BaseSubMesh {
  88250. /** @hidden */
  88251. _materialDefines: Nullable<MaterialDefines>;
  88252. /** @hidden */
  88253. _materialEffect: Nullable<Effect>;
  88254. /**
  88255. * Gets associated effect
  88256. */
  88257. readonly effect: Nullable<Effect>;
  88258. /**
  88259. * Sets associated effect (effect used to render this submesh)
  88260. * @param effect defines the effect to associate with
  88261. * @param defines defines the set of defines used to compile this effect
  88262. */
  88263. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88264. }
  88265. /**
  88266. * Defines a subdivision inside a mesh
  88267. */
  88268. export class SubMesh extends BaseSubMesh implements ICullable {
  88269. /** the material index to use */
  88270. materialIndex: number;
  88271. /** vertex index start */
  88272. verticesStart: number;
  88273. /** vertices count */
  88274. verticesCount: number;
  88275. /** index start */
  88276. indexStart: number;
  88277. /** indices count */
  88278. indexCount: number;
  88279. /** @hidden */
  88280. _linesIndexCount: number;
  88281. private _mesh;
  88282. private _renderingMesh;
  88283. private _boundingInfo;
  88284. private _linesIndexBuffer;
  88285. /** @hidden */
  88286. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88287. /** @hidden */
  88288. _trianglePlanes: Plane[];
  88289. /** @hidden */
  88290. _lastColliderTransformMatrix: Nullable<Matrix>;
  88291. /** @hidden */
  88292. _renderId: number;
  88293. /** @hidden */
  88294. _alphaIndex: number;
  88295. /** @hidden */
  88296. _distanceToCamera: number;
  88297. /** @hidden */
  88298. _id: number;
  88299. private _currentMaterial;
  88300. /**
  88301. * Add a new submesh to a mesh
  88302. * @param materialIndex defines the material index to use
  88303. * @param verticesStart defines vertex index start
  88304. * @param verticesCount defines vertices count
  88305. * @param indexStart defines index start
  88306. * @param indexCount defines indices count
  88307. * @param mesh defines the parent mesh
  88308. * @param renderingMesh defines an optional rendering mesh
  88309. * @param createBoundingBox defines if bounding box should be created for this submesh
  88310. * @returns the new submesh
  88311. */
  88312. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88313. /**
  88314. * Creates a new submesh
  88315. * @param materialIndex defines the material index to use
  88316. * @param verticesStart defines vertex index start
  88317. * @param verticesCount defines vertices count
  88318. * @param indexStart defines index start
  88319. * @param indexCount defines indices count
  88320. * @param mesh defines the parent mesh
  88321. * @param renderingMesh defines an optional rendering mesh
  88322. * @param createBoundingBox defines if bounding box should be created for this submesh
  88323. */
  88324. constructor(
  88325. /** the material index to use */
  88326. materialIndex: number,
  88327. /** vertex index start */
  88328. verticesStart: number,
  88329. /** vertices count */
  88330. verticesCount: number,
  88331. /** index start */
  88332. indexStart: number,
  88333. /** indices count */
  88334. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  88335. /**
  88336. * Returns true if this submesh covers the entire parent mesh
  88337. * @ignorenaming
  88338. */
  88339. readonly IsGlobal: boolean;
  88340. /**
  88341. * Returns the submesh BoudingInfo object
  88342. * @returns current bounding info (or mesh's one if the submesh is global)
  88343. */
  88344. getBoundingInfo(): BoundingInfo;
  88345. /**
  88346. * Sets the submesh BoundingInfo
  88347. * @param boundingInfo defines the new bounding info to use
  88348. * @returns the SubMesh
  88349. */
  88350. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  88351. /**
  88352. * Returns the mesh of the current submesh
  88353. * @return the parent mesh
  88354. */
  88355. getMesh(): AbstractMesh;
  88356. /**
  88357. * Returns the rendering mesh of the submesh
  88358. * @returns the rendering mesh (could be different from parent mesh)
  88359. */
  88360. getRenderingMesh(): Mesh;
  88361. /**
  88362. * Returns the submesh material
  88363. * @returns null or the current material
  88364. */
  88365. getMaterial(): Nullable<Material>;
  88366. /**
  88367. * Sets a new updated BoundingInfo object to the submesh
  88368. * @param data defines an optional position array to use to determine the bounding info
  88369. * @returns the SubMesh
  88370. */
  88371. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  88372. /** @hidden */
  88373. _checkCollision(collider: Collider): boolean;
  88374. /**
  88375. * Updates the submesh BoundingInfo
  88376. * @param world defines the world matrix to use to update the bounding info
  88377. * @returns the submesh
  88378. */
  88379. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  88380. /**
  88381. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88382. * @param frustumPlanes defines the frustum planes
  88383. * @returns true if the submesh is intersecting with the frustum
  88384. */
  88385. isInFrustum(frustumPlanes: Plane[]): boolean;
  88386. /**
  88387. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88388. * @param frustumPlanes defines the frustum planes
  88389. * @returns true if the submesh is inside the frustum
  88390. */
  88391. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88392. /**
  88393. * Renders the submesh
  88394. * @param enableAlphaMode defines if alpha needs to be used
  88395. * @returns the submesh
  88396. */
  88397. render(enableAlphaMode: boolean): SubMesh;
  88398. /**
  88399. * @hidden
  88400. */
  88401. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  88402. /**
  88403. * Checks if the submesh intersects with a ray
  88404. * @param ray defines the ray to test
  88405. * @returns true is the passed ray intersects the submesh bounding box
  88406. */
  88407. canIntersects(ray: Ray): boolean;
  88408. /**
  88409. * Intersects current submesh with a ray
  88410. * @param ray defines the ray to test
  88411. * @param positions defines mesh's positions array
  88412. * @param indices defines mesh's indices array
  88413. * @param fastCheck defines if only bounding info should be used
  88414. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88415. * @returns intersection info or null if no intersection
  88416. */
  88417. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  88418. /** @hidden */
  88419. private _intersectLines;
  88420. /** @hidden */
  88421. private _intersectUnIndexedLines;
  88422. /** @hidden */
  88423. private _intersectTriangles;
  88424. /** @hidden */
  88425. private _intersectUnIndexedTriangles;
  88426. /** @hidden */
  88427. _rebuild(): void;
  88428. /**
  88429. * Creates a new submesh from the passed mesh
  88430. * @param newMesh defines the new hosting mesh
  88431. * @param newRenderingMesh defines an optional rendering mesh
  88432. * @returns the new submesh
  88433. */
  88434. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  88435. /**
  88436. * Release associated resources
  88437. */
  88438. dispose(): void;
  88439. /**
  88440. * Gets the class name
  88441. * @returns the string "SubMesh".
  88442. */
  88443. getClassName(): string;
  88444. /**
  88445. * Creates a new submesh from indices data
  88446. * @param materialIndex the index of the main mesh material
  88447. * @param startIndex the index where to start the copy in the mesh indices array
  88448. * @param indexCount the number of indices to copy then from the startIndex
  88449. * @param mesh the main mesh to create the submesh from
  88450. * @param renderingMesh the optional rendering mesh
  88451. * @returns a new submesh
  88452. */
  88453. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  88454. }
  88455. }
  88456. declare module BABYLON {
  88457. /**
  88458. * Class used to represent data loading progression
  88459. */
  88460. export class SceneLoaderFlags {
  88461. private static _ForceFullSceneLoadingForIncremental;
  88462. private static _ShowLoadingScreen;
  88463. private static _CleanBoneMatrixWeights;
  88464. private static _loggingLevel;
  88465. /**
  88466. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  88467. */
  88468. static ForceFullSceneLoadingForIncremental: boolean;
  88469. /**
  88470. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  88471. */
  88472. static ShowLoadingScreen: boolean;
  88473. /**
  88474. * Defines the current logging level (while loading the scene)
  88475. * @ignorenaming
  88476. */
  88477. static loggingLevel: number;
  88478. /**
  88479. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  88480. */
  88481. static CleanBoneMatrixWeights: boolean;
  88482. }
  88483. }
  88484. declare module BABYLON {
  88485. /**
  88486. * Class used to store geometry data (vertex buffers + index buffer)
  88487. */
  88488. export class Geometry implements IGetSetVerticesData {
  88489. /**
  88490. * Gets or sets the ID of the geometry
  88491. */
  88492. id: string;
  88493. /**
  88494. * Gets or sets the unique ID of the geometry
  88495. */
  88496. uniqueId: number;
  88497. /**
  88498. * Gets the delay loading state of the geometry (none by default which means not delayed)
  88499. */
  88500. delayLoadState: number;
  88501. /**
  88502. * Gets the file containing the data to load when running in delay load state
  88503. */
  88504. delayLoadingFile: Nullable<string>;
  88505. /**
  88506. * Callback called when the geometry is updated
  88507. */
  88508. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  88509. private _scene;
  88510. private _engine;
  88511. private _meshes;
  88512. private _totalVertices;
  88513. /** @hidden */
  88514. _indices: IndicesArray;
  88515. /** @hidden */
  88516. _vertexBuffers: {
  88517. [key: string]: VertexBuffer;
  88518. };
  88519. private _isDisposed;
  88520. private _extend;
  88521. private _boundingBias;
  88522. /** @hidden */
  88523. _delayInfo: Array<string>;
  88524. private _indexBuffer;
  88525. private _indexBufferIsUpdatable;
  88526. /** @hidden */
  88527. _boundingInfo: Nullable<BoundingInfo>;
  88528. /** @hidden */
  88529. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  88530. /** @hidden */
  88531. _softwareSkinningFrameId: number;
  88532. private _vertexArrayObjects;
  88533. private _updatable;
  88534. /** @hidden */
  88535. _positions: Nullable<Vector3[]>;
  88536. /**
  88537. * 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
  88538. */
  88539. /**
  88540. * 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
  88541. */
  88542. boundingBias: Vector2;
  88543. /**
  88544. * Static function used to attach a new empty geometry to a mesh
  88545. * @param mesh defines the mesh to attach the geometry to
  88546. * @returns the new Geometry
  88547. */
  88548. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  88549. /**
  88550. * Creates a new geometry
  88551. * @param id defines the unique ID
  88552. * @param scene defines the hosting scene
  88553. * @param vertexData defines the VertexData used to get geometry data
  88554. * @param updatable defines if geometry must be updatable (false by default)
  88555. * @param mesh defines the mesh that will be associated with the geometry
  88556. */
  88557. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  88558. /**
  88559. * Gets the current extend of the geometry
  88560. */
  88561. readonly extend: {
  88562. minimum: Vector3;
  88563. maximum: Vector3;
  88564. };
  88565. /**
  88566. * Gets the hosting scene
  88567. * @returns the hosting Scene
  88568. */
  88569. getScene(): Scene;
  88570. /**
  88571. * Gets the hosting engine
  88572. * @returns the hosting Engine
  88573. */
  88574. getEngine(): Engine;
  88575. /**
  88576. * Defines if the geometry is ready to use
  88577. * @returns true if the geometry is ready to be used
  88578. */
  88579. isReady(): boolean;
  88580. /**
  88581. * Gets a value indicating that the geometry should not be serialized
  88582. */
  88583. readonly doNotSerialize: boolean;
  88584. /** @hidden */
  88585. _rebuild(): void;
  88586. /**
  88587. * Affects all geometry data in one call
  88588. * @param vertexData defines the geometry data
  88589. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  88590. */
  88591. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  88592. /**
  88593. * Set specific vertex data
  88594. * @param kind defines the data kind (Position, normal, etc...)
  88595. * @param data defines the vertex data to use
  88596. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88597. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88598. */
  88599. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  88600. /**
  88601. * Removes a specific vertex data
  88602. * @param kind defines the data kind (Position, normal, etc...)
  88603. */
  88604. removeVerticesData(kind: string): void;
  88605. /**
  88606. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  88607. * @param buffer defines the vertex buffer to use
  88608. * @param totalVertices defines the total number of vertices for position kind (could be null)
  88609. */
  88610. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  88611. /**
  88612. * Update a specific vertex buffer
  88613. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  88614. * It will do nothing if the buffer is not updatable
  88615. * @param kind defines the data kind (Position, normal, etc...)
  88616. * @param data defines the data to use
  88617. * @param offset defines the offset in the target buffer where to store the data
  88618. * @param useBytes set to true if the offset is in bytes
  88619. */
  88620. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  88621. /**
  88622. * Update a specific vertex buffer
  88623. * This function will create a new buffer if the current one is not updatable
  88624. * @param kind defines the data kind (Position, normal, etc...)
  88625. * @param data defines the data to use
  88626. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  88627. */
  88628. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  88629. private _updateBoundingInfo;
  88630. /** @hidden */
  88631. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  88632. /**
  88633. * Gets total number of vertices
  88634. * @returns the total number of vertices
  88635. */
  88636. getTotalVertices(): number;
  88637. /**
  88638. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88639. * @param kind defines the data kind (Position, normal, etc...)
  88640. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88641. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88642. * @returns a float array containing vertex data
  88643. */
  88644. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88645. /**
  88646. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  88647. * @param kind defines the data kind (Position, normal, etc...)
  88648. * @returns true if the vertex buffer with the specified kind is updatable
  88649. */
  88650. isVertexBufferUpdatable(kind: string): boolean;
  88651. /**
  88652. * Gets a specific vertex buffer
  88653. * @param kind defines the data kind (Position, normal, etc...)
  88654. * @returns a VertexBuffer
  88655. */
  88656. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88657. /**
  88658. * Returns all vertex buffers
  88659. * @return an object holding all vertex buffers indexed by kind
  88660. */
  88661. getVertexBuffers(): Nullable<{
  88662. [key: string]: VertexBuffer;
  88663. }>;
  88664. /**
  88665. * Gets a boolean indicating if specific vertex buffer is present
  88666. * @param kind defines the data kind (Position, normal, etc...)
  88667. * @returns true if data is present
  88668. */
  88669. isVerticesDataPresent(kind: string): boolean;
  88670. /**
  88671. * Gets a list of all attached data kinds (Position, normal, etc...)
  88672. * @returns a list of string containing all kinds
  88673. */
  88674. getVerticesDataKinds(): string[];
  88675. /**
  88676. * Update index buffer
  88677. * @param indices defines the indices to store in the index buffer
  88678. * @param offset defines the offset in the target buffer where to store the data
  88679. * @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)
  88680. */
  88681. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  88682. /**
  88683. * Creates a new index buffer
  88684. * @param indices defines the indices to store in the index buffer
  88685. * @param totalVertices defines the total number of vertices (could be null)
  88686. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88687. */
  88688. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  88689. /**
  88690. * Return the total number of indices
  88691. * @returns the total number of indices
  88692. */
  88693. getTotalIndices(): number;
  88694. /**
  88695. * Gets the index buffer array
  88696. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88697. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88698. * @returns the index buffer array
  88699. */
  88700. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88701. /**
  88702. * Gets the index buffer
  88703. * @return the index buffer
  88704. */
  88705. getIndexBuffer(): Nullable<DataBuffer>;
  88706. /** @hidden */
  88707. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88708. /**
  88709. * Release the associated resources for a specific mesh
  88710. * @param mesh defines the source mesh
  88711. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88712. */
  88713. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88714. /**
  88715. * Apply current geometry to a given mesh
  88716. * @param mesh defines the mesh to apply geometry to
  88717. */
  88718. applyToMesh(mesh: Mesh): void;
  88719. private _updateExtend;
  88720. private _applyToMesh;
  88721. private notifyUpdate;
  88722. /**
  88723. * Load the geometry if it was flagged as delay loaded
  88724. * @param scene defines the hosting scene
  88725. * @param onLoaded defines a callback called when the geometry is loaded
  88726. */
  88727. load(scene: Scene, onLoaded?: () => void): void;
  88728. private _queueLoad;
  88729. /**
  88730. * Invert the geometry to move from a right handed system to a left handed one.
  88731. */
  88732. toLeftHanded(): void;
  88733. /** @hidden */
  88734. _resetPointsArrayCache(): void;
  88735. /** @hidden */
  88736. _generatePointsArray(): boolean;
  88737. /**
  88738. * Gets a value indicating if the geometry is disposed
  88739. * @returns true if the geometry was disposed
  88740. */
  88741. isDisposed(): boolean;
  88742. private _disposeVertexArrayObjects;
  88743. /**
  88744. * Free all associated resources
  88745. */
  88746. dispose(): void;
  88747. /**
  88748. * Clone the current geometry into a new geometry
  88749. * @param id defines the unique ID of the new geometry
  88750. * @returns a new geometry object
  88751. */
  88752. copy(id: string): Geometry;
  88753. /**
  88754. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88755. * @return a JSON representation of the current geometry data (without the vertices data)
  88756. */
  88757. serialize(): any;
  88758. private toNumberArray;
  88759. /**
  88760. * Serialize all vertices data into a JSON oject
  88761. * @returns a JSON representation of the current geometry data
  88762. */
  88763. serializeVerticeData(): any;
  88764. /**
  88765. * Extracts a clone of a mesh geometry
  88766. * @param mesh defines the source mesh
  88767. * @param id defines the unique ID of the new geometry object
  88768. * @returns the new geometry object
  88769. */
  88770. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88771. /**
  88772. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88773. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88774. * Be aware Math.random() could cause collisions, but:
  88775. * "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"
  88776. * @returns a string containing a new GUID
  88777. */
  88778. static RandomId(): string;
  88779. /** @hidden */
  88780. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88781. private static _CleanMatricesWeights;
  88782. /**
  88783. * Create a new geometry from persisted data (Using .babylon file format)
  88784. * @param parsedVertexData defines the persisted data
  88785. * @param scene defines the hosting scene
  88786. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88787. * @returns the new geometry object
  88788. */
  88789. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88790. }
  88791. }
  88792. declare module BABYLON {
  88793. /**
  88794. * Define an interface for all classes that will get and set the data on vertices
  88795. */
  88796. export interface IGetSetVerticesData {
  88797. /**
  88798. * Gets a boolean indicating if specific vertex data is present
  88799. * @param kind defines the vertex data kind to use
  88800. * @returns true is data kind is present
  88801. */
  88802. isVerticesDataPresent(kind: string): boolean;
  88803. /**
  88804. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88805. * @param kind defines the data kind (Position, normal, etc...)
  88806. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88807. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88808. * @returns a float array containing vertex data
  88809. */
  88810. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88811. /**
  88812. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88813. * @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.
  88814. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88815. * @returns the indices array or an empty array if the mesh has no geometry
  88816. */
  88817. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88818. /**
  88819. * Set specific vertex data
  88820. * @param kind defines the data kind (Position, normal, etc...)
  88821. * @param data defines the vertex data to use
  88822. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88823. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88824. */
  88825. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88826. /**
  88827. * Update a specific associated vertex buffer
  88828. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88829. * - VertexBuffer.PositionKind
  88830. * - VertexBuffer.UVKind
  88831. * - VertexBuffer.UV2Kind
  88832. * - VertexBuffer.UV3Kind
  88833. * - VertexBuffer.UV4Kind
  88834. * - VertexBuffer.UV5Kind
  88835. * - VertexBuffer.UV6Kind
  88836. * - VertexBuffer.ColorKind
  88837. * - VertexBuffer.MatricesIndicesKind
  88838. * - VertexBuffer.MatricesIndicesExtraKind
  88839. * - VertexBuffer.MatricesWeightsKind
  88840. * - VertexBuffer.MatricesWeightsExtraKind
  88841. * @param data defines the data source
  88842. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88843. * @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)
  88844. */
  88845. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88846. /**
  88847. * Creates a new index buffer
  88848. * @param indices defines the indices to store in the index buffer
  88849. * @param totalVertices defines the total number of vertices (could be null)
  88850. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88851. */
  88852. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88853. }
  88854. /**
  88855. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88856. */
  88857. export class VertexData {
  88858. /**
  88859. * Mesh side orientation : usually the external or front surface
  88860. */
  88861. static readonly FRONTSIDE: number;
  88862. /**
  88863. * Mesh side orientation : usually the internal or back surface
  88864. */
  88865. static readonly BACKSIDE: number;
  88866. /**
  88867. * Mesh side orientation : both internal and external or front and back surfaces
  88868. */
  88869. static readonly DOUBLESIDE: number;
  88870. /**
  88871. * Mesh side orientation : by default, `FRONTSIDE`
  88872. */
  88873. static readonly DEFAULTSIDE: number;
  88874. /**
  88875. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88876. */
  88877. positions: Nullable<FloatArray>;
  88878. /**
  88879. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88880. */
  88881. normals: Nullable<FloatArray>;
  88882. /**
  88883. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88884. */
  88885. tangents: Nullable<FloatArray>;
  88886. /**
  88887. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88888. */
  88889. uvs: Nullable<FloatArray>;
  88890. /**
  88891. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88892. */
  88893. uvs2: Nullable<FloatArray>;
  88894. /**
  88895. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88896. */
  88897. uvs3: Nullable<FloatArray>;
  88898. /**
  88899. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88900. */
  88901. uvs4: Nullable<FloatArray>;
  88902. /**
  88903. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88904. */
  88905. uvs5: Nullable<FloatArray>;
  88906. /**
  88907. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88908. */
  88909. uvs6: Nullable<FloatArray>;
  88910. /**
  88911. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88912. */
  88913. colors: Nullable<FloatArray>;
  88914. /**
  88915. * 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).
  88916. */
  88917. matricesIndices: Nullable<FloatArray>;
  88918. /**
  88919. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88920. */
  88921. matricesWeights: Nullable<FloatArray>;
  88922. /**
  88923. * An array extending the number of possible indices
  88924. */
  88925. matricesIndicesExtra: Nullable<FloatArray>;
  88926. /**
  88927. * An array extending the number of possible weights when the number of indices is extended
  88928. */
  88929. matricesWeightsExtra: Nullable<FloatArray>;
  88930. /**
  88931. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88932. */
  88933. indices: Nullable<IndicesArray>;
  88934. /**
  88935. * Uses the passed data array to set the set the values for the specified kind of data
  88936. * @param data a linear array of floating numbers
  88937. * @param kind the type of data that is being set, eg positions, colors etc
  88938. */
  88939. set(data: FloatArray, kind: string): void;
  88940. /**
  88941. * Associates the vertexData to the passed Mesh.
  88942. * Sets it as updatable or not (default `false`)
  88943. * @param mesh the mesh the vertexData is applied to
  88944. * @param updatable when used and having the value true allows new data to update the vertexData
  88945. * @returns the VertexData
  88946. */
  88947. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88948. /**
  88949. * Associates the vertexData to the passed Geometry.
  88950. * Sets it as updatable or not (default `false`)
  88951. * @param geometry the geometry the vertexData is applied to
  88952. * @param updatable when used and having the value true allows new data to update the vertexData
  88953. * @returns VertexData
  88954. */
  88955. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88956. /**
  88957. * Updates the associated mesh
  88958. * @param mesh the mesh to be updated
  88959. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88960. * @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
  88961. * @returns VertexData
  88962. */
  88963. updateMesh(mesh: Mesh): VertexData;
  88964. /**
  88965. * Updates the associated geometry
  88966. * @param geometry the geometry to be updated
  88967. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88968. * @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
  88969. * @returns VertexData.
  88970. */
  88971. updateGeometry(geometry: Geometry): VertexData;
  88972. private _applyTo;
  88973. private _update;
  88974. /**
  88975. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88976. * @param matrix the transforming matrix
  88977. * @returns the VertexData
  88978. */
  88979. transform(matrix: Matrix): VertexData;
  88980. /**
  88981. * Merges the passed VertexData into the current one
  88982. * @param other the VertexData to be merged into the current one
  88983. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88984. * @returns the modified VertexData
  88985. */
  88986. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88987. private _mergeElement;
  88988. private _validate;
  88989. /**
  88990. * Serializes the VertexData
  88991. * @returns a serialized object
  88992. */
  88993. serialize(): any;
  88994. /**
  88995. * Extracts the vertexData from a mesh
  88996. * @param mesh the mesh from which to extract the VertexData
  88997. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88998. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88999. * @returns the object VertexData associated to the passed mesh
  89000. */
  89001. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89002. /**
  89003. * Extracts the vertexData from the geometry
  89004. * @param geometry the geometry from which to extract the VertexData
  89005. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89006. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89007. * @returns the object VertexData associated to the passed mesh
  89008. */
  89009. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89010. private static _ExtractFrom;
  89011. /**
  89012. * Creates the VertexData for a Ribbon
  89013. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89014. * * pathArray array of paths, each of which an array of successive Vector3
  89015. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89016. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89017. * * 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
  89018. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89019. * * 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)
  89020. * * 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)
  89021. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89022. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89023. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89024. * @returns the VertexData of the ribbon
  89025. */
  89026. static CreateRibbon(options: {
  89027. pathArray: Vector3[][];
  89028. closeArray?: boolean;
  89029. closePath?: boolean;
  89030. offset?: number;
  89031. sideOrientation?: number;
  89032. frontUVs?: Vector4;
  89033. backUVs?: Vector4;
  89034. invertUV?: boolean;
  89035. uvs?: Vector2[];
  89036. colors?: Color4[];
  89037. }): VertexData;
  89038. /**
  89039. * Creates the VertexData for a box
  89040. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89041. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89042. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89043. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89044. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89045. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89046. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89047. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89048. * * 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)
  89049. * * 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)
  89050. * @returns the VertexData of the box
  89051. */
  89052. static CreateBox(options: {
  89053. size?: number;
  89054. width?: number;
  89055. height?: number;
  89056. depth?: number;
  89057. faceUV?: Vector4[];
  89058. faceColors?: Color4[];
  89059. sideOrientation?: number;
  89060. frontUVs?: Vector4;
  89061. backUVs?: Vector4;
  89062. }): VertexData;
  89063. /**
  89064. * Creates the VertexData for a tiled box
  89065. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89066. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89067. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89068. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89069. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89070. * @returns the VertexData of the box
  89071. */
  89072. static CreateTiledBox(options: {
  89073. pattern?: number;
  89074. width?: number;
  89075. height?: number;
  89076. depth?: number;
  89077. tileSize?: number;
  89078. tileWidth?: number;
  89079. tileHeight?: number;
  89080. alignHorizontal?: number;
  89081. alignVertical?: number;
  89082. faceUV?: Vector4[];
  89083. faceColors?: Color4[];
  89084. sideOrientation?: number;
  89085. }): VertexData;
  89086. /**
  89087. * Creates the VertexData for a tiled plane
  89088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89089. * * pattern a limited pattern arrangement depending on the number
  89090. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89091. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89092. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89094. * * 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)
  89095. * * 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)
  89096. * @returns the VertexData of the tiled plane
  89097. */
  89098. static CreateTiledPlane(options: {
  89099. pattern?: number;
  89100. tileSize?: number;
  89101. tileWidth?: number;
  89102. tileHeight?: number;
  89103. size?: number;
  89104. width?: number;
  89105. height?: number;
  89106. alignHorizontal?: number;
  89107. alignVertical?: number;
  89108. sideOrientation?: number;
  89109. frontUVs?: Vector4;
  89110. backUVs?: Vector4;
  89111. }): VertexData;
  89112. /**
  89113. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89114. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89115. * * segments sets the number of horizontal strips optional, default 32
  89116. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89117. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89118. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89119. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89120. * * 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
  89121. * * 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
  89122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89123. * * 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)
  89124. * * 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)
  89125. * @returns the VertexData of the ellipsoid
  89126. */
  89127. static CreateSphere(options: {
  89128. segments?: number;
  89129. diameter?: number;
  89130. diameterX?: number;
  89131. diameterY?: number;
  89132. diameterZ?: number;
  89133. arc?: number;
  89134. slice?: number;
  89135. sideOrientation?: number;
  89136. frontUVs?: Vector4;
  89137. backUVs?: Vector4;
  89138. }): VertexData;
  89139. /**
  89140. * Creates the VertexData for a cylinder, cone or prism
  89141. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89142. * * height sets the height (y direction) of the cylinder, optional, default 2
  89143. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89144. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89145. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89146. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89147. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89148. * * 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
  89149. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89150. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89151. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89152. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89154. * * 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)
  89155. * * 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)
  89156. * @returns the VertexData of the cylinder, cone or prism
  89157. */
  89158. static CreateCylinder(options: {
  89159. height?: number;
  89160. diameterTop?: number;
  89161. diameterBottom?: number;
  89162. diameter?: number;
  89163. tessellation?: number;
  89164. subdivisions?: number;
  89165. arc?: number;
  89166. faceColors?: Color4[];
  89167. faceUV?: Vector4[];
  89168. hasRings?: boolean;
  89169. enclose?: boolean;
  89170. sideOrientation?: number;
  89171. frontUVs?: Vector4;
  89172. backUVs?: Vector4;
  89173. }): VertexData;
  89174. /**
  89175. * Creates the VertexData for a torus
  89176. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89177. * * diameter the diameter of the torus, optional default 1
  89178. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89179. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89181. * * 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)
  89182. * * 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)
  89183. * @returns the VertexData of the torus
  89184. */
  89185. static CreateTorus(options: {
  89186. diameter?: number;
  89187. thickness?: number;
  89188. tessellation?: number;
  89189. sideOrientation?: number;
  89190. frontUVs?: Vector4;
  89191. backUVs?: Vector4;
  89192. }): VertexData;
  89193. /**
  89194. * Creates the VertexData of the LineSystem
  89195. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89196. * - lines an array of lines, each line being an array of successive Vector3
  89197. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89198. * @returns the VertexData of the LineSystem
  89199. */
  89200. static CreateLineSystem(options: {
  89201. lines: Vector3[][];
  89202. colors?: Nullable<Color4[][]>;
  89203. }): VertexData;
  89204. /**
  89205. * Create the VertexData for a DashedLines
  89206. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89207. * - points an array successive Vector3
  89208. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89209. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89210. * - dashNb the intended total number of dashes, optional, default 200
  89211. * @returns the VertexData for the DashedLines
  89212. */
  89213. static CreateDashedLines(options: {
  89214. points: Vector3[];
  89215. dashSize?: number;
  89216. gapSize?: number;
  89217. dashNb?: number;
  89218. }): VertexData;
  89219. /**
  89220. * Creates the VertexData for a Ground
  89221. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89222. * - width the width (x direction) of the ground, optional, default 1
  89223. * - height the height (z direction) of the ground, optional, default 1
  89224. * - subdivisions the number of subdivisions per side, optional, default 1
  89225. * @returns the VertexData of the Ground
  89226. */
  89227. static CreateGround(options: {
  89228. width?: number;
  89229. height?: number;
  89230. subdivisions?: number;
  89231. subdivisionsX?: number;
  89232. subdivisionsY?: number;
  89233. }): VertexData;
  89234. /**
  89235. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89236. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89237. * * xmin the ground minimum X coordinate, optional, default -1
  89238. * * zmin the ground minimum Z coordinate, optional, default -1
  89239. * * xmax the ground maximum X coordinate, optional, default 1
  89240. * * zmax the ground maximum Z coordinate, optional, default 1
  89241. * * 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}
  89242. * * 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}
  89243. * @returns the VertexData of the TiledGround
  89244. */
  89245. static CreateTiledGround(options: {
  89246. xmin: number;
  89247. zmin: number;
  89248. xmax: number;
  89249. zmax: number;
  89250. subdivisions?: {
  89251. w: number;
  89252. h: number;
  89253. };
  89254. precision?: {
  89255. w: number;
  89256. h: number;
  89257. };
  89258. }): VertexData;
  89259. /**
  89260. * Creates the VertexData of the Ground designed from a heightmap
  89261. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89262. * * width the width (x direction) of the ground
  89263. * * height the height (z direction) of the ground
  89264. * * subdivisions the number of subdivisions per side
  89265. * * minHeight the minimum altitude on the ground, optional, default 0
  89266. * * maxHeight the maximum altitude on the ground, optional default 1
  89267. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89268. * * buffer the array holding the image color data
  89269. * * bufferWidth the width of image
  89270. * * bufferHeight the height of image
  89271. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89272. * @returns the VertexData of the Ground designed from a heightmap
  89273. */
  89274. static CreateGroundFromHeightMap(options: {
  89275. width: number;
  89276. height: number;
  89277. subdivisions: number;
  89278. minHeight: number;
  89279. maxHeight: number;
  89280. colorFilter: Color3;
  89281. buffer: Uint8Array;
  89282. bufferWidth: number;
  89283. bufferHeight: number;
  89284. alphaFilter: number;
  89285. }): VertexData;
  89286. /**
  89287. * Creates the VertexData for a Plane
  89288. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89289. * * size sets the width and height of the plane to the value of size, optional default 1
  89290. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89291. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89292. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89293. * * 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)
  89294. * * 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)
  89295. * @returns the VertexData of the box
  89296. */
  89297. static CreatePlane(options: {
  89298. size?: number;
  89299. width?: number;
  89300. height?: number;
  89301. sideOrientation?: number;
  89302. frontUVs?: Vector4;
  89303. backUVs?: Vector4;
  89304. }): VertexData;
  89305. /**
  89306. * Creates the VertexData of the Disc or regular Polygon
  89307. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89308. * * radius the radius of the disc, optional default 0.5
  89309. * * tessellation the number of polygon sides, optional, default 64
  89310. * * 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
  89311. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89312. * * 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)
  89313. * * 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)
  89314. * @returns the VertexData of the box
  89315. */
  89316. static CreateDisc(options: {
  89317. radius?: number;
  89318. tessellation?: number;
  89319. arc?: number;
  89320. sideOrientation?: number;
  89321. frontUVs?: Vector4;
  89322. backUVs?: Vector4;
  89323. }): VertexData;
  89324. /**
  89325. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89326. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89327. * @param polygon a mesh built from polygonTriangulation.build()
  89328. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89329. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89330. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89331. * @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)
  89332. * @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)
  89333. * @returns the VertexData of the Polygon
  89334. */
  89335. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  89336. /**
  89337. * Creates the VertexData of the IcoSphere
  89338. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89339. * * radius the radius of the IcoSphere, optional default 1
  89340. * * radiusX allows stretching in the x direction, optional, default radius
  89341. * * radiusY allows stretching in the y direction, optional, default radius
  89342. * * radiusZ allows stretching in the z direction, optional, default radius
  89343. * * flat when true creates a flat shaded mesh, optional, default true
  89344. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89346. * * 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)
  89347. * * 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)
  89348. * @returns the VertexData of the IcoSphere
  89349. */
  89350. static CreateIcoSphere(options: {
  89351. radius?: number;
  89352. radiusX?: number;
  89353. radiusY?: number;
  89354. radiusZ?: number;
  89355. flat?: boolean;
  89356. subdivisions?: number;
  89357. sideOrientation?: number;
  89358. frontUVs?: Vector4;
  89359. backUVs?: Vector4;
  89360. }): VertexData;
  89361. /**
  89362. * Creates the VertexData for a Polyhedron
  89363. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89364. * * type provided types are:
  89365. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89366. * * 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)
  89367. * * size the size of the IcoSphere, optional default 1
  89368. * * sizeX allows stretching in the x direction, optional, default size
  89369. * * sizeY allows stretching in the y direction, optional, default size
  89370. * * sizeZ allows stretching in the z direction, optional, default size
  89371. * * 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
  89372. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89373. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89374. * * flat when true creates a flat shaded mesh, optional, default true
  89375. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89377. * * 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)
  89378. * * 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)
  89379. * @returns the VertexData of the Polyhedron
  89380. */
  89381. static CreatePolyhedron(options: {
  89382. type?: number;
  89383. size?: number;
  89384. sizeX?: number;
  89385. sizeY?: number;
  89386. sizeZ?: number;
  89387. custom?: any;
  89388. faceUV?: Vector4[];
  89389. faceColors?: Color4[];
  89390. flat?: boolean;
  89391. sideOrientation?: number;
  89392. frontUVs?: Vector4;
  89393. backUVs?: Vector4;
  89394. }): VertexData;
  89395. /**
  89396. * Creates the VertexData for a TorusKnot
  89397. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89398. * * radius the radius of the torus knot, optional, default 2
  89399. * * tube the thickness of the tube, optional, default 0.5
  89400. * * radialSegments the number of sides on each tube segments, optional, default 32
  89401. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89402. * * p the number of windings around the z axis, optional, default 2
  89403. * * q the number of windings around the x axis, optional, default 3
  89404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89405. * * 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)
  89406. * * 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)
  89407. * @returns the VertexData of the Torus Knot
  89408. */
  89409. static CreateTorusKnot(options: {
  89410. radius?: number;
  89411. tube?: number;
  89412. radialSegments?: number;
  89413. tubularSegments?: number;
  89414. p?: number;
  89415. q?: number;
  89416. sideOrientation?: number;
  89417. frontUVs?: Vector4;
  89418. backUVs?: Vector4;
  89419. }): VertexData;
  89420. /**
  89421. * Compute normals for given positions and indices
  89422. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89423. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89424. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89425. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89426. * * facetNormals : optional array of facet normals (vector3)
  89427. * * facetPositions : optional array of facet positions (vector3)
  89428. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89429. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89430. * * bInfo : optional bounding info, required for facetPartitioning computation
  89431. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89432. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89433. * * useRightHandedSystem: optional boolean to for right handed system computation
  89434. * * depthSort : optional boolean to enable the facet depth sort computation
  89435. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89436. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89437. */
  89438. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  89439. facetNormals?: any;
  89440. facetPositions?: any;
  89441. facetPartitioning?: any;
  89442. ratio?: number;
  89443. bInfo?: any;
  89444. bbSize?: Vector3;
  89445. subDiv?: any;
  89446. useRightHandedSystem?: boolean;
  89447. depthSort?: boolean;
  89448. distanceTo?: Vector3;
  89449. depthSortedFacets?: any;
  89450. }): void;
  89451. /** @hidden */
  89452. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  89453. /**
  89454. * Applies VertexData created from the imported parameters to the geometry
  89455. * @param parsedVertexData the parsed data from an imported file
  89456. * @param geometry the geometry to apply the VertexData to
  89457. */
  89458. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  89459. }
  89460. }
  89461. declare module BABYLON {
  89462. /**
  89463. * Defines a target to use with MorphTargetManager
  89464. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89465. */
  89466. export class MorphTarget implements IAnimatable {
  89467. /** defines the name of the target */
  89468. name: string;
  89469. /**
  89470. * Gets or sets the list of animations
  89471. */
  89472. animations: Animation[];
  89473. private _scene;
  89474. private _positions;
  89475. private _normals;
  89476. private _tangents;
  89477. private _uvs;
  89478. private _influence;
  89479. /**
  89480. * Observable raised when the influence changes
  89481. */
  89482. onInfluenceChanged: Observable<boolean>;
  89483. /** @hidden */
  89484. _onDataLayoutChanged: Observable<void>;
  89485. /**
  89486. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  89487. */
  89488. influence: number;
  89489. /**
  89490. * Gets or sets the id of the morph Target
  89491. */
  89492. id: string;
  89493. private _animationPropertiesOverride;
  89494. /**
  89495. * Gets or sets the animation properties override
  89496. */
  89497. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89498. /**
  89499. * Creates a new MorphTarget
  89500. * @param name defines the name of the target
  89501. * @param influence defines the influence to use
  89502. * @param scene defines the scene the morphtarget belongs to
  89503. */
  89504. constructor(
  89505. /** defines the name of the target */
  89506. name: string, influence?: number, scene?: Nullable<Scene>);
  89507. /**
  89508. * Gets a boolean defining if the target contains position data
  89509. */
  89510. readonly hasPositions: boolean;
  89511. /**
  89512. * Gets a boolean defining if the target contains normal data
  89513. */
  89514. readonly hasNormals: boolean;
  89515. /**
  89516. * Gets a boolean defining if the target contains tangent data
  89517. */
  89518. readonly hasTangents: boolean;
  89519. /**
  89520. * Gets a boolean defining if the target contains texture coordinates data
  89521. */
  89522. readonly hasUVs: boolean;
  89523. /**
  89524. * Affects position data to this target
  89525. * @param data defines the position data to use
  89526. */
  89527. setPositions(data: Nullable<FloatArray>): void;
  89528. /**
  89529. * Gets the position data stored in this target
  89530. * @returns a FloatArray containing the position data (or null if not present)
  89531. */
  89532. getPositions(): Nullable<FloatArray>;
  89533. /**
  89534. * Affects normal data to this target
  89535. * @param data defines the normal data to use
  89536. */
  89537. setNormals(data: Nullable<FloatArray>): void;
  89538. /**
  89539. * Gets the normal data stored in this target
  89540. * @returns a FloatArray containing the normal data (or null if not present)
  89541. */
  89542. getNormals(): Nullable<FloatArray>;
  89543. /**
  89544. * Affects tangent data to this target
  89545. * @param data defines the tangent data to use
  89546. */
  89547. setTangents(data: Nullable<FloatArray>): void;
  89548. /**
  89549. * Gets the tangent data stored in this target
  89550. * @returns a FloatArray containing the tangent data (or null if not present)
  89551. */
  89552. getTangents(): Nullable<FloatArray>;
  89553. /**
  89554. * Affects texture coordinates data to this target
  89555. * @param data defines the texture coordinates data to use
  89556. */
  89557. setUVs(data: Nullable<FloatArray>): void;
  89558. /**
  89559. * Gets the texture coordinates data stored in this target
  89560. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  89561. */
  89562. getUVs(): Nullable<FloatArray>;
  89563. /**
  89564. * Serializes the current target into a Serialization object
  89565. * @returns the serialized object
  89566. */
  89567. serialize(): any;
  89568. /**
  89569. * Returns the string "MorphTarget"
  89570. * @returns "MorphTarget"
  89571. */
  89572. getClassName(): string;
  89573. /**
  89574. * Creates a new target from serialized data
  89575. * @param serializationObject defines the serialized data to use
  89576. * @returns a new MorphTarget
  89577. */
  89578. static Parse(serializationObject: any): MorphTarget;
  89579. /**
  89580. * Creates a MorphTarget from mesh data
  89581. * @param mesh defines the source mesh
  89582. * @param name defines the name to use for the new target
  89583. * @param influence defines the influence to attach to the target
  89584. * @returns a new MorphTarget
  89585. */
  89586. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  89587. }
  89588. }
  89589. declare module BABYLON {
  89590. /**
  89591. * This class is used to deform meshes using morphing between different targets
  89592. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89593. */
  89594. export class MorphTargetManager {
  89595. private _targets;
  89596. private _targetInfluenceChangedObservers;
  89597. private _targetDataLayoutChangedObservers;
  89598. private _activeTargets;
  89599. private _scene;
  89600. private _influences;
  89601. private _supportsNormals;
  89602. private _supportsTangents;
  89603. private _supportsUVs;
  89604. private _vertexCount;
  89605. private _uniqueId;
  89606. private _tempInfluences;
  89607. /**
  89608. * Gets or sets a boolean indicating if normals must be morphed
  89609. */
  89610. enableNormalMorphing: boolean;
  89611. /**
  89612. * Gets or sets a boolean indicating if tangents must be morphed
  89613. */
  89614. enableTangentMorphing: boolean;
  89615. /**
  89616. * Gets or sets a boolean indicating if UV must be morphed
  89617. */
  89618. enableUVMorphing: boolean;
  89619. /**
  89620. * Creates a new MorphTargetManager
  89621. * @param scene defines the current scene
  89622. */
  89623. constructor(scene?: Nullable<Scene>);
  89624. /**
  89625. * Gets the unique ID of this manager
  89626. */
  89627. readonly uniqueId: number;
  89628. /**
  89629. * Gets the number of vertices handled by this manager
  89630. */
  89631. readonly vertexCount: number;
  89632. /**
  89633. * Gets a boolean indicating if this manager supports morphing of normals
  89634. */
  89635. readonly supportsNormals: boolean;
  89636. /**
  89637. * Gets a boolean indicating if this manager supports morphing of tangents
  89638. */
  89639. readonly supportsTangents: boolean;
  89640. /**
  89641. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  89642. */
  89643. readonly supportsUVs: boolean;
  89644. /**
  89645. * Gets the number of targets stored in this manager
  89646. */
  89647. readonly numTargets: number;
  89648. /**
  89649. * Gets the number of influencers (ie. the number of targets with influences > 0)
  89650. */
  89651. readonly numInfluencers: number;
  89652. /**
  89653. * Gets the list of influences (one per target)
  89654. */
  89655. readonly influences: Float32Array;
  89656. /**
  89657. * Gets the active target at specified index. An active target is a target with an influence > 0
  89658. * @param index defines the index to check
  89659. * @returns the requested target
  89660. */
  89661. getActiveTarget(index: number): MorphTarget;
  89662. /**
  89663. * Gets the target at specified index
  89664. * @param index defines the index to check
  89665. * @returns the requested target
  89666. */
  89667. getTarget(index: number): MorphTarget;
  89668. /**
  89669. * Add a new target to this manager
  89670. * @param target defines the target to add
  89671. */
  89672. addTarget(target: MorphTarget): void;
  89673. /**
  89674. * Removes a target from the manager
  89675. * @param target defines the target to remove
  89676. */
  89677. removeTarget(target: MorphTarget): void;
  89678. /**
  89679. * Serializes the current manager into a Serialization object
  89680. * @returns the serialized object
  89681. */
  89682. serialize(): any;
  89683. private _syncActiveTargets;
  89684. /**
  89685. * Syncrhonize the targets with all the meshes using this morph target manager
  89686. */
  89687. synchronize(): void;
  89688. /**
  89689. * Creates a new MorphTargetManager from serialized data
  89690. * @param serializationObject defines the serialized data
  89691. * @param scene defines the hosting scene
  89692. * @returns the new MorphTargetManager
  89693. */
  89694. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89695. }
  89696. }
  89697. declare module BABYLON {
  89698. /**
  89699. * Class used to represent a specific level of detail of a mesh
  89700. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89701. */
  89702. export class MeshLODLevel {
  89703. /** Defines the distance where this level should start being displayed */
  89704. distance: number;
  89705. /** Defines the mesh to use to render this level */
  89706. mesh: Nullable<Mesh>;
  89707. /**
  89708. * Creates a new LOD level
  89709. * @param distance defines the distance where this level should star being displayed
  89710. * @param mesh defines the mesh to use to render this level
  89711. */
  89712. constructor(
  89713. /** Defines the distance where this level should start being displayed */
  89714. distance: number,
  89715. /** Defines the mesh to use to render this level */
  89716. mesh: Nullable<Mesh>);
  89717. }
  89718. }
  89719. declare module BABYLON {
  89720. /**
  89721. * Mesh representing the gorund
  89722. */
  89723. export class GroundMesh extends Mesh {
  89724. /** If octree should be generated */
  89725. generateOctree: boolean;
  89726. private _heightQuads;
  89727. /** @hidden */
  89728. _subdivisionsX: number;
  89729. /** @hidden */
  89730. _subdivisionsY: number;
  89731. /** @hidden */
  89732. _width: number;
  89733. /** @hidden */
  89734. _height: number;
  89735. /** @hidden */
  89736. _minX: number;
  89737. /** @hidden */
  89738. _maxX: number;
  89739. /** @hidden */
  89740. _minZ: number;
  89741. /** @hidden */
  89742. _maxZ: number;
  89743. constructor(name: string, scene: Scene);
  89744. /**
  89745. * "GroundMesh"
  89746. * @returns "GroundMesh"
  89747. */
  89748. getClassName(): string;
  89749. /**
  89750. * The minimum of x and y subdivisions
  89751. */
  89752. readonly subdivisions: number;
  89753. /**
  89754. * X subdivisions
  89755. */
  89756. readonly subdivisionsX: number;
  89757. /**
  89758. * Y subdivisions
  89759. */
  89760. readonly subdivisionsY: number;
  89761. /**
  89762. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89763. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89764. * @param chunksCount the number of subdivisions for x and y
  89765. * @param octreeBlocksSize (Default: 32)
  89766. */
  89767. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89768. /**
  89769. * Returns a height (y) value in the Worl system :
  89770. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89771. * @param x x coordinate
  89772. * @param z z coordinate
  89773. * @returns the ground y position if (x, z) are outside the ground surface.
  89774. */
  89775. getHeightAtCoordinates(x: number, z: number): number;
  89776. /**
  89777. * Returns a normalized vector (Vector3) orthogonal to the ground
  89778. * at the ground coordinates (x, z) expressed in the World system.
  89779. * @param x x coordinate
  89780. * @param z z coordinate
  89781. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89782. */
  89783. getNormalAtCoordinates(x: number, z: number): Vector3;
  89784. /**
  89785. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89786. * at the ground coordinates (x, z) expressed in the World system.
  89787. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89788. * @param x x coordinate
  89789. * @param z z coordinate
  89790. * @param ref vector to store the result
  89791. * @returns the GroundMesh.
  89792. */
  89793. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89794. /**
  89795. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89796. * if the ground has been updated.
  89797. * This can be used in the render loop.
  89798. * @returns the GroundMesh.
  89799. */
  89800. updateCoordinateHeights(): GroundMesh;
  89801. private _getFacetAt;
  89802. private _initHeightQuads;
  89803. private _computeHeightQuads;
  89804. /**
  89805. * Serializes this ground mesh
  89806. * @param serializationObject object to write serialization to
  89807. */
  89808. serialize(serializationObject: any): void;
  89809. /**
  89810. * Parses a serialized ground mesh
  89811. * @param parsedMesh the serialized mesh
  89812. * @param scene the scene to create the ground mesh in
  89813. * @returns the created ground mesh
  89814. */
  89815. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89816. }
  89817. }
  89818. declare module BABYLON {
  89819. /**
  89820. * Interface for Physics-Joint data
  89821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89822. */
  89823. export interface PhysicsJointData {
  89824. /**
  89825. * The main pivot of the joint
  89826. */
  89827. mainPivot?: Vector3;
  89828. /**
  89829. * The connected pivot of the joint
  89830. */
  89831. connectedPivot?: Vector3;
  89832. /**
  89833. * The main axis of the joint
  89834. */
  89835. mainAxis?: Vector3;
  89836. /**
  89837. * The connected axis of the joint
  89838. */
  89839. connectedAxis?: Vector3;
  89840. /**
  89841. * The collision of the joint
  89842. */
  89843. collision?: boolean;
  89844. /**
  89845. * Native Oimo/Cannon/Energy data
  89846. */
  89847. nativeParams?: any;
  89848. }
  89849. /**
  89850. * This is a holder class for the physics joint created by the physics plugin
  89851. * It holds a set of functions to control the underlying joint
  89852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89853. */
  89854. export class PhysicsJoint {
  89855. /**
  89856. * The type of the physics joint
  89857. */
  89858. type: number;
  89859. /**
  89860. * The data for the physics joint
  89861. */
  89862. jointData: PhysicsJointData;
  89863. private _physicsJoint;
  89864. protected _physicsPlugin: IPhysicsEnginePlugin;
  89865. /**
  89866. * Initializes the physics joint
  89867. * @param type The type of the physics joint
  89868. * @param jointData The data for the physics joint
  89869. */
  89870. constructor(
  89871. /**
  89872. * The type of the physics joint
  89873. */
  89874. type: number,
  89875. /**
  89876. * The data for the physics joint
  89877. */
  89878. jointData: PhysicsJointData);
  89879. /**
  89880. * Gets the physics joint
  89881. */
  89882. /**
  89883. * Sets the physics joint
  89884. */
  89885. physicsJoint: any;
  89886. /**
  89887. * Sets the physics plugin
  89888. */
  89889. physicsPlugin: IPhysicsEnginePlugin;
  89890. /**
  89891. * Execute a function that is physics-plugin specific.
  89892. * @param {Function} func the function that will be executed.
  89893. * It accepts two parameters: the physics world and the physics joint
  89894. */
  89895. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89896. /**
  89897. * Distance-Joint type
  89898. */
  89899. static DistanceJoint: number;
  89900. /**
  89901. * Hinge-Joint type
  89902. */
  89903. static HingeJoint: number;
  89904. /**
  89905. * Ball-and-Socket joint type
  89906. */
  89907. static BallAndSocketJoint: number;
  89908. /**
  89909. * Wheel-Joint type
  89910. */
  89911. static WheelJoint: number;
  89912. /**
  89913. * Slider-Joint type
  89914. */
  89915. static SliderJoint: number;
  89916. /**
  89917. * Prismatic-Joint type
  89918. */
  89919. static PrismaticJoint: number;
  89920. /**
  89921. * Universal-Joint type
  89922. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89923. */
  89924. static UniversalJoint: number;
  89925. /**
  89926. * Hinge-Joint 2 type
  89927. */
  89928. static Hinge2Joint: number;
  89929. /**
  89930. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89931. */
  89932. static PointToPointJoint: number;
  89933. /**
  89934. * Spring-Joint type
  89935. */
  89936. static SpringJoint: number;
  89937. /**
  89938. * Lock-Joint type
  89939. */
  89940. static LockJoint: number;
  89941. }
  89942. /**
  89943. * A class representing a physics distance joint
  89944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89945. */
  89946. export class DistanceJoint extends PhysicsJoint {
  89947. /**
  89948. *
  89949. * @param jointData The data for the Distance-Joint
  89950. */
  89951. constructor(jointData: DistanceJointData);
  89952. /**
  89953. * Update the predefined distance.
  89954. * @param maxDistance The maximum preferred distance
  89955. * @param minDistance The minimum preferred distance
  89956. */
  89957. updateDistance(maxDistance: number, minDistance?: number): void;
  89958. }
  89959. /**
  89960. * Represents a Motor-Enabled Joint
  89961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89962. */
  89963. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89964. /**
  89965. * Initializes the Motor-Enabled Joint
  89966. * @param type The type of the joint
  89967. * @param jointData The physica joint data for the joint
  89968. */
  89969. constructor(type: number, jointData: PhysicsJointData);
  89970. /**
  89971. * Set the motor values.
  89972. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89973. * @param force the force to apply
  89974. * @param maxForce max force for this motor.
  89975. */
  89976. setMotor(force?: number, maxForce?: number): void;
  89977. /**
  89978. * Set the motor's limits.
  89979. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89980. * @param upperLimit The upper limit of the motor
  89981. * @param lowerLimit The lower limit of the motor
  89982. */
  89983. setLimit(upperLimit: number, lowerLimit?: number): void;
  89984. }
  89985. /**
  89986. * This class represents a single physics Hinge-Joint
  89987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89988. */
  89989. export class HingeJoint extends MotorEnabledJoint {
  89990. /**
  89991. * Initializes the Hinge-Joint
  89992. * @param jointData The joint data for the Hinge-Joint
  89993. */
  89994. constructor(jointData: PhysicsJointData);
  89995. /**
  89996. * Set the motor values.
  89997. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89998. * @param {number} force the force to apply
  89999. * @param {number} maxForce max force for this motor.
  90000. */
  90001. setMotor(force?: number, maxForce?: number): void;
  90002. /**
  90003. * Set the motor's limits.
  90004. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90005. * @param upperLimit The upper limit of the motor
  90006. * @param lowerLimit The lower limit of the motor
  90007. */
  90008. setLimit(upperLimit: number, lowerLimit?: number): void;
  90009. }
  90010. /**
  90011. * This class represents a dual hinge physics joint (same as wheel joint)
  90012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90013. */
  90014. export class Hinge2Joint extends MotorEnabledJoint {
  90015. /**
  90016. * Initializes the Hinge2-Joint
  90017. * @param jointData The joint data for the Hinge2-Joint
  90018. */
  90019. constructor(jointData: PhysicsJointData);
  90020. /**
  90021. * Set the motor values.
  90022. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90023. * @param {number} targetSpeed the speed the motor is to reach
  90024. * @param {number} maxForce max force for this motor.
  90025. * @param {motorIndex} the motor's index, 0 or 1.
  90026. */
  90027. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90028. /**
  90029. * Set the motor limits.
  90030. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90031. * @param {number} upperLimit the upper limit
  90032. * @param {number} lowerLimit lower limit
  90033. * @param {motorIndex} the motor's index, 0 or 1.
  90034. */
  90035. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90036. }
  90037. /**
  90038. * Interface for a motor enabled joint
  90039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90040. */
  90041. export interface IMotorEnabledJoint {
  90042. /**
  90043. * Physics joint
  90044. */
  90045. physicsJoint: any;
  90046. /**
  90047. * Sets the motor of the motor-enabled joint
  90048. * @param force The force of the motor
  90049. * @param maxForce The maximum force of the motor
  90050. * @param motorIndex The index of the motor
  90051. */
  90052. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90053. /**
  90054. * Sets the limit of the motor
  90055. * @param upperLimit The upper limit of the motor
  90056. * @param lowerLimit The lower limit of the motor
  90057. * @param motorIndex The index of the motor
  90058. */
  90059. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90060. }
  90061. /**
  90062. * Joint data for a Distance-Joint
  90063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90064. */
  90065. export interface DistanceJointData extends PhysicsJointData {
  90066. /**
  90067. * Max distance the 2 joint objects can be apart
  90068. */
  90069. maxDistance: number;
  90070. }
  90071. /**
  90072. * Joint data from a spring joint
  90073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90074. */
  90075. export interface SpringJointData extends PhysicsJointData {
  90076. /**
  90077. * Length of the spring
  90078. */
  90079. length: number;
  90080. /**
  90081. * Stiffness of the spring
  90082. */
  90083. stiffness: number;
  90084. /**
  90085. * Damping of the spring
  90086. */
  90087. damping: number;
  90088. /** this callback will be called when applying the force to the impostors. */
  90089. forceApplicationCallback: () => void;
  90090. }
  90091. }
  90092. declare module BABYLON {
  90093. /**
  90094. * Holds the data for the raycast result
  90095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90096. */
  90097. export class PhysicsRaycastResult {
  90098. private _hasHit;
  90099. private _hitDistance;
  90100. private _hitNormalWorld;
  90101. private _hitPointWorld;
  90102. private _rayFromWorld;
  90103. private _rayToWorld;
  90104. /**
  90105. * Gets if there was a hit
  90106. */
  90107. readonly hasHit: boolean;
  90108. /**
  90109. * Gets the distance from the hit
  90110. */
  90111. readonly hitDistance: number;
  90112. /**
  90113. * Gets the hit normal/direction in the world
  90114. */
  90115. readonly hitNormalWorld: Vector3;
  90116. /**
  90117. * Gets the hit point in the world
  90118. */
  90119. readonly hitPointWorld: Vector3;
  90120. /**
  90121. * Gets the ray "start point" of the ray in the world
  90122. */
  90123. readonly rayFromWorld: Vector3;
  90124. /**
  90125. * Gets the ray "end point" of the ray in the world
  90126. */
  90127. readonly rayToWorld: Vector3;
  90128. /**
  90129. * Sets the hit data (normal & point in world space)
  90130. * @param hitNormalWorld defines the normal in world space
  90131. * @param hitPointWorld defines the point in world space
  90132. */
  90133. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  90134. /**
  90135. * Sets the distance from the start point to the hit point
  90136. * @param distance
  90137. */
  90138. setHitDistance(distance: number): void;
  90139. /**
  90140. * Calculates the distance manually
  90141. */
  90142. calculateHitDistance(): void;
  90143. /**
  90144. * Resets all the values to default
  90145. * @param from The from point on world space
  90146. * @param to The to point on world space
  90147. */
  90148. reset(from?: Vector3, to?: Vector3): void;
  90149. }
  90150. /**
  90151. * Interface for the size containing width and height
  90152. */
  90153. interface IXYZ {
  90154. /**
  90155. * X
  90156. */
  90157. x: number;
  90158. /**
  90159. * Y
  90160. */
  90161. y: number;
  90162. /**
  90163. * Z
  90164. */
  90165. z: number;
  90166. }
  90167. }
  90168. declare module BABYLON {
  90169. /**
  90170. * Interface used to describe a physics joint
  90171. */
  90172. export interface PhysicsImpostorJoint {
  90173. /** Defines the main impostor to which the joint is linked */
  90174. mainImpostor: PhysicsImpostor;
  90175. /** Defines the impostor that is connected to the main impostor using this joint */
  90176. connectedImpostor: PhysicsImpostor;
  90177. /** Defines the joint itself */
  90178. joint: PhysicsJoint;
  90179. }
  90180. /** @hidden */
  90181. export interface IPhysicsEnginePlugin {
  90182. world: any;
  90183. name: string;
  90184. setGravity(gravity: Vector3): void;
  90185. setTimeStep(timeStep: number): void;
  90186. getTimeStep(): number;
  90187. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90188. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90189. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90190. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90191. removePhysicsBody(impostor: PhysicsImpostor): void;
  90192. generateJoint(joint: PhysicsImpostorJoint): void;
  90193. removeJoint(joint: PhysicsImpostorJoint): void;
  90194. isSupported(): boolean;
  90195. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90196. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90197. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90198. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90199. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90200. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90201. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90202. getBodyMass(impostor: PhysicsImpostor): number;
  90203. getBodyFriction(impostor: PhysicsImpostor): number;
  90204. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90205. getBodyRestitution(impostor: PhysicsImpostor): number;
  90206. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90207. getBodyPressure?(impostor: PhysicsImpostor): number;
  90208. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90209. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90210. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90211. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90212. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90213. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90214. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90215. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90216. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90217. sleepBody(impostor: PhysicsImpostor): void;
  90218. wakeUpBody(impostor: PhysicsImpostor): void;
  90219. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90220. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90221. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90222. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90223. getRadius(impostor: PhysicsImpostor): number;
  90224. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90225. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90226. dispose(): void;
  90227. }
  90228. /**
  90229. * Interface used to define a physics engine
  90230. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90231. */
  90232. export interface IPhysicsEngine {
  90233. /**
  90234. * Gets the gravity vector used by the simulation
  90235. */
  90236. gravity: Vector3;
  90237. /**
  90238. * Sets the gravity vector used by the simulation
  90239. * @param gravity defines the gravity vector to use
  90240. */
  90241. setGravity(gravity: Vector3): void;
  90242. /**
  90243. * Set the time step of the physics engine.
  90244. * Default is 1/60.
  90245. * To slow it down, enter 1/600 for example.
  90246. * To speed it up, 1/30
  90247. * @param newTimeStep the new timestep to apply to this world.
  90248. */
  90249. setTimeStep(newTimeStep: number): void;
  90250. /**
  90251. * Get the time step of the physics engine.
  90252. * @returns the current time step
  90253. */
  90254. getTimeStep(): number;
  90255. /**
  90256. * Release all resources
  90257. */
  90258. dispose(): void;
  90259. /**
  90260. * Gets the name of the current physics plugin
  90261. * @returns the name of the plugin
  90262. */
  90263. getPhysicsPluginName(): string;
  90264. /**
  90265. * Adding a new impostor for the impostor tracking.
  90266. * This will be done by the impostor itself.
  90267. * @param impostor the impostor to add
  90268. */
  90269. addImpostor(impostor: PhysicsImpostor): void;
  90270. /**
  90271. * Remove an impostor from the engine.
  90272. * This impostor and its mesh will not longer be updated by the physics engine.
  90273. * @param impostor the impostor to remove
  90274. */
  90275. removeImpostor(impostor: PhysicsImpostor): void;
  90276. /**
  90277. * Add a joint to the physics engine
  90278. * @param mainImpostor defines the main impostor to which the joint is added.
  90279. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  90280. * @param joint defines the joint that will connect both impostors.
  90281. */
  90282. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90283. /**
  90284. * Removes a joint from the simulation
  90285. * @param mainImpostor defines the impostor used with the joint
  90286. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90287. * @param joint defines the joint to remove
  90288. */
  90289. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90290. /**
  90291. * Gets the current plugin used to run the simulation
  90292. * @returns current plugin
  90293. */
  90294. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90295. /**
  90296. * Gets the list of physic impostors
  90297. * @returns an array of PhysicsImpostor
  90298. */
  90299. getImpostors(): Array<PhysicsImpostor>;
  90300. /**
  90301. * Gets the impostor for a physics enabled object
  90302. * @param object defines the object impersonated by the impostor
  90303. * @returns the PhysicsImpostor or null if not found
  90304. */
  90305. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90306. /**
  90307. * Gets the impostor for a physics body object
  90308. * @param body defines physics body used by the impostor
  90309. * @returns the PhysicsImpostor or null if not found
  90310. */
  90311. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  90312. /**
  90313. * Does a raycast in the physics world
  90314. * @param from when should the ray start?
  90315. * @param to when should the ray end?
  90316. * @returns PhysicsRaycastResult
  90317. */
  90318. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90319. /**
  90320. * Called by the scene. No need to call it.
  90321. * @param delta defines the timespam between frames
  90322. */
  90323. _step(delta: number): void;
  90324. }
  90325. }
  90326. declare module BABYLON {
  90327. /**
  90328. * The interface for the physics imposter parameters
  90329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90330. */
  90331. export interface PhysicsImpostorParameters {
  90332. /**
  90333. * The mass of the physics imposter
  90334. */
  90335. mass: number;
  90336. /**
  90337. * The friction of the physics imposter
  90338. */
  90339. friction?: number;
  90340. /**
  90341. * The coefficient of restitution of the physics imposter
  90342. */
  90343. restitution?: number;
  90344. /**
  90345. * The native options of the physics imposter
  90346. */
  90347. nativeOptions?: any;
  90348. /**
  90349. * Specifies if the parent should be ignored
  90350. */
  90351. ignoreParent?: boolean;
  90352. /**
  90353. * Specifies if bi-directional transformations should be disabled
  90354. */
  90355. disableBidirectionalTransformation?: boolean;
  90356. /**
  90357. * The pressure inside the physics imposter, soft object only
  90358. */
  90359. pressure?: number;
  90360. /**
  90361. * The stiffness the physics imposter, soft object only
  90362. */
  90363. stiffness?: number;
  90364. /**
  90365. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  90366. */
  90367. velocityIterations?: number;
  90368. /**
  90369. * The number of iterations used in maintaining consistent vertex positions, soft object only
  90370. */
  90371. positionIterations?: number;
  90372. /**
  90373. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  90374. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  90375. * Add to fix multiple points
  90376. */
  90377. fixedPoints?: number;
  90378. /**
  90379. * The collision margin around a soft object
  90380. */
  90381. margin?: number;
  90382. /**
  90383. * The collision margin around a soft object
  90384. */
  90385. damping?: number;
  90386. /**
  90387. * The path for a rope based on an extrusion
  90388. */
  90389. path?: any;
  90390. /**
  90391. * The shape of an extrusion used for a rope based on an extrusion
  90392. */
  90393. shape?: any;
  90394. }
  90395. /**
  90396. * Interface for a physics-enabled object
  90397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90398. */
  90399. export interface IPhysicsEnabledObject {
  90400. /**
  90401. * The position of the physics-enabled object
  90402. */
  90403. position: Vector3;
  90404. /**
  90405. * The rotation of the physics-enabled object
  90406. */
  90407. rotationQuaternion: Nullable<Quaternion>;
  90408. /**
  90409. * The scale of the physics-enabled object
  90410. */
  90411. scaling: Vector3;
  90412. /**
  90413. * The rotation of the physics-enabled object
  90414. */
  90415. rotation?: Vector3;
  90416. /**
  90417. * The parent of the physics-enabled object
  90418. */
  90419. parent?: any;
  90420. /**
  90421. * The bounding info of the physics-enabled object
  90422. * @returns The bounding info of the physics-enabled object
  90423. */
  90424. getBoundingInfo(): BoundingInfo;
  90425. /**
  90426. * Computes the world matrix
  90427. * @param force Specifies if the world matrix should be computed by force
  90428. * @returns A world matrix
  90429. */
  90430. computeWorldMatrix(force: boolean): Matrix;
  90431. /**
  90432. * Gets the world matrix
  90433. * @returns A world matrix
  90434. */
  90435. getWorldMatrix?(): Matrix;
  90436. /**
  90437. * Gets the child meshes
  90438. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  90439. * @returns An array of abstract meshes
  90440. */
  90441. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  90442. /**
  90443. * Gets the vertex data
  90444. * @param kind The type of vertex data
  90445. * @returns A nullable array of numbers, or a float32 array
  90446. */
  90447. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  90448. /**
  90449. * Gets the indices from the mesh
  90450. * @returns A nullable array of index arrays
  90451. */
  90452. getIndices?(): Nullable<IndicesArray>;
  90453. /**
  90454. * Gets the scene from the mesh
  90455. * @returns the indices array or null
  90456. */
  90457. getScene?(): Scene;
  90458. /**
  90459. * Gets the absolute position from the mesh
  90460. * @returns the absolute position
  90461. */
  90462. getAbsolutePosition(): Vector3;
  90463. /**
  90464. * Gets the absolute pivot point from the mesh
  90465. * @returns the absolute pivot point
  90466. */
  90467. getAbsolutePivotPoint(): Vector3;
  90468. /**
  90469. * Rotates the mesh
  90470. * @param axis The axis of rotation
  90471. * @param amount The amount of rotation
  90472. * @param space The space of the rotation
  90473. * @returns The rotation transform node
  90474. */
  90475. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  90476. /**
  90477. * Translates the mesh
  90478. * @param axis The axis of translation
  90479. * @param distance The distance of translation
  90480. * @param space The space of the translation
  90481. * @returns The transform node
  90482. */
  90483. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90484. /**
  90485. * Sets the absolute position of the mesh
  90486. * @param absolutePosition The absolute position of the mesh
  90487. * @returns The transform node
  90488. */
  90489. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  90490. /**
  90491. * Gets the class name of the mesh
  90492. * @returns The class name
  90493. */
  90494. getClassName(): string;
  90495. }
  90496. /**
  90497. * Represents a physics imposter
  90498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90499. */
  90500. export class PhysicsImpostor {
  90501. /**
  90502. * The physics-enabled object used as the physics imposter
  90503. */
  90504. object: IPhysicsEnabledObject;
  90505. /**
  90506. * The type of the physics imposter
  90507. */
  90508. type: number;
  90509. private _options;
  90510. private _scene?;
  90511. /**
  90512. * The default object size of the imposter
  90513. */
  90514. static DEFAULT_OBJECT_SIZE: Vector3;
  90515. /**
  90516. * The identity quaternion of the imposter
  90517. */
  90518. static IDENTITY_QUATERNION: Quaternion;
  90519. /** @hidden */
  90520. _pluginData: any;
  90521. private _physicsEngine;
  90522. private _physicsBody;
  90523. private _bodyUpdateRequired;
  90524. private _onBeforePhysicsStepCallbacks;
  90525. private _onAfterPhysicsStepCallbacks;
  90526. /** @hidden */
  90527. _onPhysicsCollideCallbacks: Array<{
  90528. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  90529. otherImpostors: Array<PhysicsImpostor>;
  90530. }>;
  90531. private _deltaPosition;
  90532. private _deltaRotation;
  90533. private _deltaRotationConjugated;
  90534. /** @hidden */
  90535. _isFromLine: boolean;
  90536. private _parent;
  90537. private _isDisposed;
  90538. private static _tmpVecs;
  90539. private static _tmpQuat;
  90540. /**
  90541. * Specifies if the physics imposter is disposed
  90542. */
  90543. readonly isDisposed: boolean;
  90544. /**
  90545. * Gets the mass of the physics imposter
  90546. */
  90547. mass: number;
  90548. /**
  90549. * Gets the coefficient of friction
  90550. */
  90551. /**
  90552. * Sets the coefficient of friction
  90553. */
  90554. friction: number;
  90555. /**
  90556. * Gets the coefficient of restitution
  90557. */
  90558. /**
  90559. * Sets the coefficient of restitution
  90560. */
  90561. restitution: number;
  90562. /**
  90563. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  90564. */
  90565. /**
  90566. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  90567. */
  90568. pressure: number;
  90569. /**
  90570. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90571. */
  90572. /**
  90573. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90574. */
  90575. stiffness: number;
  90576. /**
  90577. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90578. */
  90579. /**
  90580. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90581. */
  90582. velocityIterations: number;
  90583. /**
  90584. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90585. */
  90586. /**
  90587. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90588. */
  90589. positionIterations: number;
  90590. /**
  90591. * The unique id of the physics imposter
  90592. * set by the physics engine when adding this impostor to the array
  90593. */
  90594. uniqueId: number;
  90595. /**
  90596. * @hidden
  90597. */
  90598. soft: boolean;
  90599. /**
  90600. * @hidden
  90601. */
  90602. segments: number;
  90603. private _joints;
  90604. /**
  90605. * Initializes the physics imposter
  90606. * @param object The physics-enabled object used as the physics imposter
  90607. * @param type The type of the physics imposter
  90608. * @param _options The options for the physics imposter
  90609. * @param _scene The Babylon scene
  90610. */
  90611. constructor(
  90612. /**
  90613. * The physics-enabled object used as the physics imposter
  90614. */
  90615. object: IPhysicsEnabledObject,
  90616. /**
  90617. * The type of the physics imposter
  90618. */
  90619. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  90620. /**
  90621. * This function will completly initialize this impostor.
  90622. * It will create a new body - but only if this mesh has no parent.
  90623. * If it has, this impostor will not be used other than to define the impostor
  90624. * of the child mesh.
  90625. * @hidden
  90626. */
  90627. _init(): void;
  90628. private _getPhysicsParent;
  90629. /**
  90630. * Should a new body be generated.
  90631. * @returns boolean specifying if body initialization is required
  90632. */
  90633. isBodyInitRequired(): boolean;
  90634. /**
  90635. * Sets the updated scaling
  90636. * @param updated Specifies if the scaling is updated
  90637. */
  90638. setScalingUpdated(): void;
  90639. /**
  90640. * Force a regeneration of this or the parent's impostor's body.
  90641. * Use under cautious - This will remove all joints already implemented.
  90642. */
  90643. forceUpdate(): void;
  90644. /**
  90645. * Gets the body that holds this impostor. Either its own, or its parent.
  90646. */
  90647. /**
  90648. * Set the physics body. Used mainly by the physics engine/plugin
  90649. */
  90650. physicsBody: any;
  90651. /**
  90652. * Get the parent of the physics imposter
  90653. * @returns Physics imposter or null
  90654. */
  90655. /**
  90656. * Sets the parent of the physics imposter
  90657. */
  90658. parent: Nullable<PhysicsImpostor>;
  90659. /**
  90660. * Resets the update flags
  90661. */
  90662. resetUpdateFlags(): void;
  90663. /**
  90664. * Gets the object extend size
  90665. * @returns the object extend size
  90666. */
  90667. getObjectExtendSize(): Vector3;
  90668. /**
  90669. * Gets the object center
  90670. * @returns The object center
  90671. */
  90672. getObjectCenter(): Vector3;
  90673. /**
  90674. * Get a specific parametes from the options parameter
  90675. * @param paramName The object parameter name
  90676. * @returns The object parameter
  90677. */
  90678. getParam(paramName: string): any;
  90679. /**
  90680. * Sets a specific parameter in the options given to the physics plugin
  90681. * @param paramName The parameter name
  90682. * @param value The value of the parameter
  90683. */
  90684. setParam(paramName: string, value: number): void;
  90685. /**
  90686. * Specifically change the body's mass option. Won't recreate the physics body object
  90687. * @param mass The mass of the physics imposter
  90688. */
  90689. setMass(mass: number): void;
  90690. /**
  90691. * Gets the linear velocity
  90692. * @returns linear velocity or null
  90693. */
  90694. getLinearVelocity(): Nullable<Vector3>;
  90695. /**
  90696. * Sets the linear velocity
  90697. * @param velocity linear velocity or null
  90698. */
  90699. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90700. /**
  90701. * Gets the angular velocity
  90702. * @returns angular velocity or null
  90703. */
  90704. getAngularVelocity(): Nullable<Vector3>;
  90705. /**
  90706. * Sets the angular velocity
  90707. * @param velocity The velocity or null
  90708. */
  90709. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90710. /**
  90711. * Execute a function with the physics plugin native code
  90712. * Provide a function the will have two variables - the world object and the physics body object
  90713. * @param func The function to execute with the physics plugin native code
  90714. */
  90715. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90716. /**
  90717. * Register a function that will be executed before the physics world is stepping forward
  90718. * @param func The function to execute before the physics world is stepped forward
  90719. */
  90720. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90721. /**
  90722. * Unregister a function that will be executed before the physics world is stepping forward
  90723. * @param func The function to execute before the physics world is stepped forward
  90724. */
  90725. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90726. /**
  90727. * Register a function that will be executed after the physics step
  90728. * @param func The function to execute after physics step
  90729. */
  90730. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90731. /**
  90732. * Unregisters a function that will be executed after the physics step
  90733. * @param func The function to execute after physics step
  90734. */
  90735. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90736. /**
  90737. * register a function that will be executed when this impostor collides against a different body
  90738. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90739. * @param func Callback that is executed on collision
  90740. */
  90741. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90742. /**
  90743. * Unregisters the physics imposter on contact
  90744. * @param collideAgainst The physics object to collide against
  90745. * @param func Callback to execute on collision
  90746. */
  90747. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90748. private _tmpQuat;
  90749. private _tmpQuat2;
  90750. /**
  90751. * Get the parent rotation
  90752. * @returns The parent rotation
  90753. */
  90754. getParentsRotation(): Quaternion;
  90755. /**
  90756. * this function is executed by the physics engine.
  90757. */
  90758. beforeStep: () => void;
  90759. /**
  90760. * this function is executed by the physics engine
  90761. */
  90762. afterStep: () => void;
  90763. /**
  90764. * Legacy collision detection event support
  90765. */
  90766. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90767. /**
  90768. * event and body object due to cannon's event-based architecture.
  90769. */
  90770. onCollide: (e: {
  90771. body: any;
  90772. }) => void;
  90773. /**
  90774. * Apply a force
  90775. * @param force The force to apply
  90776. * @param contactPoint The contact point for the force
  90777. * @returns The physics imposter
  90778. */
  90779. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90780. /**
  90781. * Apply an impulse
  90782. * @param force The impulse force
  90783. * @param contactPoint The contact point for the impulse force
  90784. * @returns The physics imposter
  90785. */
  90786. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90787. /**
  90788. * A help function to create a joint
  90789. * @param otherImpostor A physics imposter used to create a joint
  90790. * @param jointType The type of joint
  90791. * @param jointData The data for the joint
  90792. * @returns The physics imposter
  90793. */
  90794. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90795. /**
  90796. * Add a joint to this impostor with a different impostor
  90797. * @param otherImpostor A physics imposter used to add a joint
  90798. * @param joint The joint to add
  90799. * @returns The physics imposter
  90800. */
  90801. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90802. /**
  90803. * Add an anchor to a cloth impostor
  90804. * @param otherImpostor rigid impostor to anchor to
  90805. * @param width ratio across width from 0 to 1
  90806. * @param height ratio up height from 0 to 1
  90807. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90808. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90809. * @returns impostor the soft imposter
  90810. */
  90811. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90812. /**
  90813. * Add a hook to a rope impostor
  90814. * @param otherImpostor rigid impostor to anchor to
  90815. * @param length ratio across rope from 0 to 1
  90816. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90817. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90818. * @returns impostor the rope imposter
  90819. */
  90820. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90821. /**
  90822. * Will keep this body still, in a sleep mode.
  90823. * @returns the physics imposter
  90824. */
  90825. sleep(): PhysicsImpostor;
  90826. /**
  90827. * Wake the body up.
  90828. * @returns The physics imposter
  90829. */
  90830. wakeUp(): PhysicsImpostor;
  90831. /**
  90832. * Clones the physics imposter
  90833. * @param newObject The physics imposter clones to this physics-enabled object
  90834. * @returns A nullable physics imposter
  90835. */
  90836. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90837. /**
  90838. * Disposes the physics imposter
  90839. */
  90840. dispose(): void;
  90841. /**
  90842. * Sets the delta position
  90843. * @param position The delta position amount
  90844. */
  90845. setDeltaPosition(position: Vector3): void;
  90846. /**
  90847. * Sets the delta rotation
  90848. * @param rotation The delta rotation amount
  90849. */
  90850. setDeltaRotation(rotation: Quaternion): void;
  90851. /**
  90852. * Gets the box size of the physics imposter and stores the result in the input parameter
  90853. * @param result Stores the box size
  90854. * @returns The physics imposter
  90855. */
  90856. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90857. /**
  90858. * Gets the radius of the physics imposter
  90859. * @returns Radius of the physics imposter
  90860. */
  90861. getRadius(): number;
  90862. /**
  90863. * Sync a bone with this impostor
  90864. * @param bone The bone to sync to the impostor.
  90865. * @param boneMesh The mesh that the bone is influencing.
  90866. * @param jointPivot The pivot of the joint / bone in local space.
  90867. * @param distToJoint Optional distance from the impostor to the joint.
  90868. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90869. */
  90870. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90871. /**
  90872. * Sync impostor to a bone
  90873. * @param bone The bone that the impostor will be synced to.
  90874. * @param boneMesh The mesh that the bone is influencing.
  90875. * @param jointPivot The pivot of the joint / bone in local space.
  90876. * @param distToJoint Optional distance from the impostor to the joint.
  90877. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90878. * @param boneAxis Optional vector3 axis the bone is aligned with
  90879. */
  90880. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90881. /**
  90882. * No-Imposter type
  90883. */
  90884. static NoImpostor: number;
  90885. /**
  90886. * Sphere-Imposter type
  90887. */
  90888. static SphereImpostor: number;
  90889. /**
  90890. * Box-Imposter type
  90891. */
  90892. static BoxImpostor: number;
  90893. /**
  90894. * Plane-Imposter type
  90895. */
  90896. static PlaneImpostor: number;
  90897. /**
  90898. * Mesh-imposter type
  90899. */
  90900. static MeshImpostor: number;
  90901. /**
  90902. * Capsule-Impostor type (Ammo.js plugin only)
  90903. */
  90904. static CapsuleImpostor: number;
  90905. /**
  90906. * Cylinder-Imposter type
  90907. */
  90908. static CylinderImpostor: number;
  90909. /**
  90910. * Particle-Imposter type
  90911. */
  90912. static ParticleImpostor: number;
  90913. /**
  90914. * Heightmap-Imposter type
  90915. */
  90916. static HeightmapImpostor: number;
  90917. /**
  90918. * ConvexHull-Impostor type (Ammo.js plugin only)
  90919. */
  90920. static ConvexHullImpostor: number;
  90921. /**
  90922. * Rope-Imposter type
  90923. */
  90924. static RopeImpostor: number;
  90925. /**
  90926. * Cloth-Imposter type
  90927. */
  90928. static ClothImpostor: number;
  90929. /**
  90930. * Softbody-Imposter type
  90931. */
  90932. static SoftbodyImpostor: number;
  90933. }
  90934. }
  90935. declare module BABYLON {
  90936. /**
  90937. * @hidden
  90938. **/
  90939. export class _CreationDataStorage {
  90940. closePath?: boolean;
  90941. closeArray?: boolean;
  90942. idx: number[];
  90943. dashSize: number;
  90944. gapSize: number;
  90945. path3D: Path3D;
  90946. pathArray: Vector3[][];
  90947. arc: number;
  90948. radius: number;
  90949. cap: number;
  90950. tessellation: number;
  90951. }
  90952. /**
  90953. * @hidden
  90954. **/
  90955. class _InstanceDataStorage {
  90956. visibleInstances: any;
  90957. batchCache: _InstancesBatch;
  90958. instancesBufferSize: number;
  90959. instancesBuffer: Nullable<Buffer>;
  90960. instancesData: Float32Array;
  90961. overridenInstanceCount: number;
  90962. isFrozen: boolean;
  90963. previousBatch: Nullable<_InstancesBatch>;
  90964. hardwareInstancedRendering: boolean;
  90965. sideOrientation: number;
  90966. }
  90967. /**
  90968. * @hidden
  90969. **/
  90970. export class _InstancesBatch {
  90971. mustReturn: boolean;
  90972. visibleInstances: Nullable<InstancedMesh[]>[];
  90973. renderSelf: boolean[];
  90974. hardwareInstancedRendering: boolean[];
  90975. }
  90976. /**
  90977. * Class used to represent renderable models
  90978. */
  90979. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90980. /**
  90981. * Mesh side orientation : usually the external or front surface
  90982. */
  90983. static readonly FRONTSIDE: number;
  90984. /**
  90985. * Mesh side orientation : usually the internal or back surface
  90986. */
  90987. static readonly BACKSIDE: number;
  90988. /**
  90989. * Mesh side orientation : both internal and external or front and back surfaces
  90990. */
  90991. static readonly DOUBLESIDE: number;
  90992. /**
  90993. * Mesh side orientation : by default, `FRONTSIDE`
  90994. */
  90995. static readonly DEFAULTSIDE: number;
  90996. /**
  90997. * Mesh cap setting : no cap
  90998. */
  90999. static readonly NO_CAP: number;
  91000. /**
  91001. * Mesh cap setting : one cap at the beginning of the mesh
  91002. */
  91003. static readonly CAP_START: number;
  91004. /**
  91005. * Mesh cap setting : one cap at the end of the mesh
  91006. */
  91007. static readonly CAP_END: number;
  91008. /**
  91009. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91010. */
  91011. static readonly CAP_ALL: number;
  91012. /**
  91013. * Mesh pattern setting : no flip or rotate
  91014. */
  91015. static readonly NO_FLIP: number;
  91016. /**
  91017. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91018. */
  91019. static readonly FLIP_TILE: number;
  91020. /**
  91021. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91022. */
  91023. static readonly ROTATE_TILE: number;
  91024. /**
  91025. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91026. */
  91027. static readonly FLIP_ROW: number;
  91028. /**
  91029. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91030. */
  91031. static readonly ROTATE_ROW: number;
  91032. /**
  91033. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91034. */
  91035. static readonly FLIP_N_ROTATE_TILE: number;
  91036. /**
  91037. * Mesh pattern setting : rotate pattern and rotate
  91038. */
  91039. static readonly FLIP_N_ROTATE_ROW: number;
  91040. /**
  91041. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91042. */
  91043. static readonly CENTER: number;
  91044. /**
  91045. * Mesh tile positioning : part tiles on left
  91046. */
  91047. static readonly LEFT: number;
  91048. /**
  91049. * Mesh tile positioning : part tiles on right
  91050. */
  91051. static readonly RIGHT: number;
  91052. /**
  91053. * Mesh tile positioning : part tiles on top
  91054. */
  91055. static readonly TOP: number;
  91056. /**
  91057. * Mesh tile positioning : part tiles on bottom
  91058. */
  91059. static readonly BOTTOM: number;
  91060. /**
  91061. * Gets the default side orientation.
  91062. * @param orientation the orientation to value to attempt to get
  91063. * @returns the default orientation
  91064. * @hidden
  91065. */
  91066. static _GetDefaultSideOrientation(orientation?: number): number;
  91067. private _internalMeshDataInfo;
  91068. /**
  91069. * An event triggered before rendering the mesh
  91070. */
  91071. readonly onBeforeRenderObservable: Observable<Mesh>;
  91072. /**
  91073. * An event triggered before binding the mesh
  91074. */
  91075. readonly onBeforeBindObservable: Observable<Mesh>;
  91076. /**
  91077. * An event triggered after rendering the mesh
  91078. */
  91079. readonly onAfterRenderObservable: Observable<Mesh>;
  91080. /**
  91081. * An event triggered before drawing the mesh
  91082. */
  91083. readonly onBeforeDrawObservable: Observable<Mesh>;
  91084. private _onBeforeDrawObserver;
  91085. /**
  91086. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  91087. */
  91088. onBeforeDraw: () => void;
  91089. readonly hasInstances: boolean;
  91090. /**
  91091. * Gets the delay loading state of the mesh (when delay loading is turned on)
  91092. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  91093. */
  91094. delayLoadState: number;
  91095. /**
  91096. * Gets the list of instances created from this mesh
  91097. * it is not supposed to be modified manually.
  91098. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  91099. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91100. */
  91101. instances: InstancedMesh[];
  91102. /**
  91103. * Gets the file containing delay loading data for this mesh
  91104. */
  91105. delayLoadingFile: string;
  91106. /** @hidden */
  91107. _binaryInfo: any;
  91108. /**
  91109. * User defined function used to change how LOD level selection is done
  91110. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91111. */
  91112. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  91113. /**
  91114. * Gets or sets the morph target manager
  91115. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91116. */
  91117. morphTargetManager: Nullable<MorphTargetManager>;
  91118. /** @hidden */
  91119. _creationDataStorage: Nullable<_CreationDataStorage>;
  91120. /** @hidden */
  91121. _geometry: Nullable<Geometry>;
  91122. /** @hidden */
  91123. _delayInfo: Array<string>;
  91124. /** @hidden */
  91125. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  91126. /** @hidden */
  91127. _instanceDataStorage: _InstanceDataStorage;
  91128. private _effectiveMaterial;
  91129. /** @hidden */
  91130. _shouldGenerateFlatShading: boolean;
  91131. /** @hidden */
  91132. _originalBuilderSideOrientation: number;
  91133. /**
  91134. * Use this property to change the original side orientation defined at construction time
  91135. */
  91136. overrideMaterialSideOrientation: Nullable<number>;
  91137. /**
  91138. * Gets the source mesh (the one used to clone this one from)
  91139. */
  91140. readonly source: Nullable<Mesh>;
  91141. /**
  91142. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91143. */
  91144. isUnIndexed: boolean;
  91145. /**
  91146. * @constructor
  91147. * @param name The value used by scene.getMeshByName() to do a lookup.
  91148. * @param scene The scene to add this mesh to.
  91149. * @param parent The parent of this mesh, if it has one
  91150. * @param source An optional Mesh from which geometry is shared, cloned.
  91151. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91152. * When false, achieved by calling a clone(), also passing False.
  91153. * This will make creation of children, recursive.
  91154. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91155. */
  91156. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91157. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  91158. /**
  91159. * Gets the class name
  91160. * @returns the string "Mesh".
  91161. */
  91162. getClassName(): string;
  91163. /** @hidden */
  91164. readonly _isMesh: boolean;
  91165. /**
  91166. * Returns a description of this mesh
  91167. * @param fullDetails define if full details about this mesh must be used
  91168. * @returns a descriptive string representing this mesh
  91169. */
  91170. toString(fullDetails?: boolean): string;
  91171. /** @hidden */
  91172. _unBindEffect(): void;
  91173. /**
  91174. * Gets a boolean indicating if this mesh has LOD
  91175. */
  91176. readonly hasLODLevels: boolean;
  91177. /**
  91178. * Gets the list of MeshLODLevel associated with the current mesh
  91179. * @returns an array of MeshLODLevel
  91180. */
  91181. getLODLevels(): MeshLODLevel[];
  91182. private _sortLODLevels;
  91183. /**
  91184. * Add a mesh as LOD level triggered at the given distance.
  91185. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91186. * @param distance The distance from the center of the object to show this level
  91187. * @param mesh The mesh to be added as LOD level (can be null)
  91188. * @return This mesh (for chaining)
  91189. */
  91190. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91191. /**
  91192. * Returns the LOD level mesh at the passed distance or null if not found.
  91193. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91194. * @param distance The distance from the center of the object to show this level
  91195. * @returns a Mesh or `null`
  91196. */
  91197. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91198. /**
  91199. * Remove a mesh from the LOD array
  91200. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91201. * @param mesh defines the mesh to be removed
  91202. * @return This mesh (for chaining)
  91203. */
  91204. removeLODLevel(mesh: Mesh): Mesh;
  91205. /**
  91206. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91207. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91208. * @param camera defines the camera to use to compute distance
  91209. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91210. * @return This mesh (for chaining)
  91211. */
  91212. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91213. /**
  91214. * Gets the mesh internal Geometry object
  91215. */
  91216. readonly geometry: Nullable<Geometry>;
  91217. /**
  91218. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91219. * @returns the total number of vertices
  91220. */
  91221. getTotalVertices(): number;
  91222. /**
  91223. * Returns the content of an associated vertex buffer
  91224. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91225. * - VertexBuffer.PositionKind
  91226. * - VertexBuffer.UVKind
  91227. * - VertexBuffer.UV2Kind
  91228. * - VertexBuffer.UV3Kind
  91229. * - VertexBuffer.UV4Kind
  91230. * - VertexBuffer.UV5Kind
  91231. * - VertexBuffer.UV6Kind
  91232. * - VertexBuffer.ColorKind
  91233. * - VertexBuffer.MatricesIndicesKind
  91234. * - VertexBuffer.MatricesIndicesExtraKind
  91235. * - VertexBuffer.MatricesWeightsKind
  91236. * - VertexBuffer.MatricesWeightsExtraKind
  91237. * @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
  91238. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91239. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91240. */
  91241. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91242. /**
  91243. * Returns the mesh VertexBuffer object from the requested `kind`
  91244. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91245. * - VertexBuffer.PositionKind
  91246. * - VertexBuffer.NormalKind
  91247. * - VertexBuffer.UVKind
  91248. * - VertexBuffer.UV2Kind
  91249. * - VertexBuffer.UV3Kind
  91250. * - VertexBuffer.UV4Kind
  91251. * - VertexBuffer.UV5Kind
  91252. * - VertexBuffer.UV6Kind
  91253. * - VertexBuffer.ColorKind
  91254. * - VertexBuffer.MatricesIndicesKind
  91255. * - VertexBuffer.MatricesIndicesExtraKind
  91256. * - VertexBuffer.MatricesWeightsKind
  91257. * - VertexBuffer.MatricesWeightsExtraKind
  91258. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91259. */
  91260. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91261. /**
  91262. * Tests if a specific vertex buffer is associated with this mesh
  91263. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91264. * - VertexBuffer.PositionKind
  91265. * - VertexBuffer.NormalKind
  91266. * - VertexBuffer.UVKind
  91267. * - VertexBuffer.UV2Kind
  91268. * - VertexBuffer.UV3Kind
  91269. * - VertexBuffer.UV4Kind
  91270. * - VertexBuffer.UV5Kind
  91271. * - VertexBuffer.UV6Kind
  91272. * - VertexBuffer.ColorKind
  91273. * - VertexBuffer.MatricesIndicesKind
  91274. * - VertexBuffer.MatricesIndicesExtraKind
  91275. * - VertexBuffer.MatricesWeightsKind
  91276. * - VertexBuffer.MatricesWeightsExtraKind
  91277. * @returns a boolean
  91278. */
  91279. isVerticesDataPresent(kind: string): boolean;
  91280. /**
  91281. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  91282. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91283. * - VertexBuffer.PositionKind
  91284. * - VertexBuffer.UVKind
  91285. * - VertexBuffer.UV2Kind
  91286. * - VertexBuffer.UV3Kind
  91287. * - VertexBuffer.UV4Kind
  91288. * - VertexBuffer.UV5Kind
  91289. * - VertexBuffer.UV6Kind
  91290. * - VertexBuffer.ColorKind
  91291. * - VertexBuffer.MatricesIndicesKind
  91292. * - VertexBuffer.MatricesIndicesExtraKind
  91293. * - VertexBuffer.MatricesWeightsKind
  91294. * - VertexBuffer.MatricesWeightsExtraKind
  91295. * @returns a boolean
  91296. */
  91297. isVertexBufferUpdatable(kind: string): boolean;
  91298. /**
  91299. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91300. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91301. * - VertexBuffer.PositionKind
  91302. * - VertexBuffer.NormalKind
  91303. * - VertexBuffer.UVKind
  91304. * - VertexBuffer.UV2Kind
  91305. * - VertexBuffer.UV3Kind
  91306. * - VertexBuffer.UV4Kind
  91307. * - VertexBuffer.UV5Kind
  91308. * - VertexBuffer.UV6Kind
  91309. * - VertexBuffer.ColorKind
  91310. * - VertexBuffer.MatricesIndicesKind
  91311. * - VertexBuffer.MatricesIndicesExtraKind
  91312. * - VertexBuffer.MatricesWeightsKind
  91313. * - VertexBuffer.MatricesWeightsExtraKind
  91314. * @returns an array of strings
  91315. */
  91316. getVerticesDataKinds(): string[];
  91317. /**
  91318. * Returns a positive integer : the total number of indices in this mesh geometry.
  91319. * @returns the numner of indices or zero if the mesh has no geometry.
  91320. */
  91321. getTotalIndices(): number;
  91322. /**
  91323. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91324. * @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.
  91325. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91326. * @returns the indices array or an empty array if the mesh has no geometry
  91327. */
  91328. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91329. readonly isBlocked: boolean;
  91330. /**
  91331. * Determine if the current mesh is ready to be rendered
  91332. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91333. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  91334. * @returns true if all associated assets are ready (material, textures, shaders)
  91335. */
  91336. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  91337. /**
  91338. * 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.
  91339. */
  91340. readonly areNormalsFrozen: boolean;
  91341. /**
  91342. * 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.
  91343. * @returns the current mesh
  91344. */
  91345. freezeNormals(): Mesh;
  91346. /**
  91347. * 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
  91348. * @returns the current mesh
  91349. */
  91350. unfreezeNormals(): Mesh;
  91351. /**
  91352. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  91353. */
  91354. overridenInstanceCount: number;
  91355. /** @hidden */
  91356. _preActivate(): Mesh;
  91357. /** @hidden */
  91358. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91359. /** @hidden */
  91360. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  91361. /**
  91362. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91363. * This means the mesh underlying bounding box and sphere are recomputed.
  91364. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91365. * @returns the current mesh
  91366. */
  91367. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  91368. /** @hidden */
  91369. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  91370. /**
  91371. * This function will subdivide the mesh into multiple submeshes
  91372. * @param count defines the expected number of submeshes
  91373. */
  91374. subdivide(count: number): void;
  91375. /**
  91376. * Copy a FloatArray into a specific associated vertex buffer
  91377. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91378. * - VertexBuffer.PositionKind
  91379. * - VertexBuffer.UVKind
  91380. * - VertexBuffer.UV2Kind
  91381. * - VertexBuffer.UV3Kind
  91382. * - VertexBuffer.UV4Kind
  91383. * - VertexBuffer.UV5Kind
  91384. * - VertexBuffer.UV6Kind
  91385. * - VertexBuffer.ColorKind
  91386. * - VertexBuffer.MatricesIndicesKind
  91387. * - VertexBuffer.MatricesIndicesExtraKind
  91388. * - VertexBuffer.MatricesWeightsKind
  91389. * - VertexBuffer.MatricesWeightsExtraKind
  91390. * @param data defines the data source
  91391. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91392. * @param stride defines the data stride size (can be null)
  91393. * @returns the current mesh
  91394. */
  91395. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91396. /**
  91397. * Delete a vertex buffer associated with this mesh
  91398. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  91399. * - VertexBuffer.PositionKind
  91400. * - VertexBuffer.UVKind
  91401. * - VertexBuffer.UV2Kind
  91402. * - VertexBuffer.UV3Kind
  91403. * - VertexBuffer.UV4Kind
  91404. * - VertexBuffer.UV5Kind
  91405. * - VertexBuffer.UV6Kind
  91406. * - VertexBuffer.ColorKind
  91407. * - VertexBuffer.MatricesIndicesKind
  91408. * - VertexBuffer.MatricesIndicesExtraKind
  91409. * - VertexBuffer.MatricesWeightsKind
  91410. * - VertexBuffer.MatricesWeightsExtraKind
  91411. */
  91412. removeVerticesData(kind: string): void;
  91413. /**
  91414. * Flags an associated vertex buffer as updatable
  91415. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  91416. * - VertexBuffer.PositionKind
  91417. * - VertexBuffer.UVKind
  91418. * - VertexBuffer.UV2Kind
  91419. * - VertexBuffer.UV3Kind
  91420. * - VertexBuffer.UV4Kind
  91421. * - VertexBuffer.UV5Kind
  91422. * - VertexBuffer.UV6Kind
  91423. * - VertexBuffer.ColorKind
  91424. * - VertexBuffer.MatricesIndicesKind
  91425. * - VertexBuffer.MatricesIndicesExtraKind
  91426. * - VertexBuffer.MatricesWeightsKind
  91427. * - VertexBuffer.MatricesWeightsExtraKind
  91428. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91429. */
  91430. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  91431. /**
  91432. * Sets the mesh global Vertex Buffer
  91433. * @param buffer defines the buffer to use
  91434. * @returns the current mesh
  91435. */
  91436. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  91437. /**
  91438. * Update a specific associated vertex buffer
  91439. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91440. * - VertexBuffer.PositionKind
  91441. * - VertexBuffer.UVKind
  91442. * - VertexBuffer.UV2Kind
  91443. * - VertexBuffer.UV3Kind
  91444. * - VertexBuffer.UV4Kind
  91445. * - VertexBuffer.UV5Kind
  91446. * - VertexBuffer.UV6Kind
  91447. * - VertexBuffer.ColorKind
  91448. * - VertexBuffer.MatricesIndicesKind
  91449. * - VertexBuffer.MatricesIndicesExtraKind
  91450. * - VertexBuffer.MatricesWeightsKind
  91451. * - VertexBuffer.MatricesWeightsExtraKind
  91452. * @param data defines the data source
  91453. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91454. * @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)
  91455. * @returns the current mesh
  91456. */
  91457. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91458. /**
  91459. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  91460. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  91461. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  91462. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  91463. * @returns the current mesh
  91464. */
  91465. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  91466. /**
  91467. * Creates a un-shared specific occurence of the geometry for the mesh.
  91468. * @returns the current mesh
  91469. */
  91470. makeGeometryUnique(): Mesh;
  91471. /**
  91472. * Set the index buffer of this mesh
  91473. * @param indices defines the source data
  91474. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  91475. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  91476. * @returns the current mesh
  91477. */
  91478. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  91479. /**
  91480. * Update the current index buffer
  91481. * @param indices defines the source data
  91482. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91483. * @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)
  91484. * @returns the current mesh
  91485. */
  91486. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91487. /**
  91488. * Invert the geometry to move from a right handed system to a left handed one.
  91489. * @returns the current mesh
  91490. */
  91491. toLeftHanded(): Mesh;
  91492. /** @hidden */
  91493. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91494. /** @hidden */
  91495. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91496. /**
  91497. * Registers for this mesh a javascript function called just before the rendering process
  91498. * @param func defines the function to call before rendering this mesh
  91499. * @returns the current mesh
  91500. */
  91501. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91502. /**
  91503. * Disposes a previously registered javascript function called before the rendering
  91504. * @param func defines the function to remove
  91505. * @returns the current mesh
  91506. */
  91507. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91508. /**
  91509. * Registers for this mesh a javascript function called just after the rendering is complete
  91510. * @param func defines the function to call after rendering this mesh
  91511. * @returns the current mesh
  91512. */
  91513. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91514. /**
  91515. * Disposes a previously registered javascript function called after the rendering.
  91516. * @param func defines the function to remove
  91517. * @returns the current mesh
  91518. */
  91519. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91520. /** @hidden */
  91521. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  91522. /** @hidden */
  91523. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  91524. /** @hidden */
  91525. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  91526. /** @hidden */
  91527. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  91528. /** @hidden */
  91529. _rebuild(): void;
  91530. /** @hidden */
  91531. _freeze(): void;
  91532. /** @hidden */
  91533. _unFreeze(): void;
  91534. /**
  91535. * 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
  91536. * @param subMesh defines the subMesh to render
  91537. * @param enableAlphaMode defines if alpha mode can be changed
  91538. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  91539. * @returns the current mesh
  91540. */
  91541. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  91542. private _onBeforeDraw;
  91543. /**
  91544. * Renormalize the mesh and patch it up if there are no weights
  91545. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  91546. * However in the case of zero weights then we set just a single influence to 1.
  91547. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  91548. */
  91549. cleanMatrixWeights(): void;
  91550. private normalizeSkinFourWeights;
  91551. private normalizeSkinWeightsAndExtra;
  91552. /**
  91553. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  91554. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  91555. * the user know there was an issue with importing the mesh
  91556. * @returns a validation object with skinned, valid and report string
  91557. */
  91558. validateSkinning(): {
  91559. skinned: boolean;
  91560. valid: boolean;
  91561. report: string;
  91562. };
  91563. /** @hidden */
  91564. _checkDelayState(): Mesh;
  91565. private _queueLoad;
  91566. /**
  91567. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91568. * A mesh is in the frustum if its bounding box intersects the frustum
  91569. * @param frustumPlanes defines the frustum to test
  91570. * @returns true if the mesh is in the frustum planes
  91571. */
  91572. isInFrustum(frustumPlanes: Plane[]): boolean;
  91573. /**
  91574. * Sets the mesh material by the material or multiMaterial `id` property
  91575. * @param id is a string identifying the material or the multiMaterial
  91576. * @returns the current mesh
  91577. */
  91578. setMaterialByID(id: string): Mesh;
  91579. /**
  91580. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  91581. * @returns an array of IAnimatable
  91582. */
  91583. getAnimatables(): IAnimatable[];
  91584. /**
  91585. * Modifies the mesh geometry according to the passed transformation matrix.
  91586. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  91587. * The mesh normals are modified using the same transformation.
  91588. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91589. * @param transform defines the transform matrix to use
  91590. * @see http://doc.babylonjs.com/resources/baking_transformations
  91591. * @returns the current mesh
  91592. */
  91593. bakeTransformIntoVertices(transform: Matrix): Mesh;
  91594. /**
  91595. * Modifies the mesh geometry according to its own current World Matrix.
  91596. * The mesh World Matrix is then reset.
  91597. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  91598. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91599. * @see http://doc.babylonjs.com/resources/baking_transformations
  91600. * @returns the current mesh
  91601. */
  91602. bakeCurrentTransformIntoVertices(): Mesh;
  91603. /** @hidden */
  91604. readonly _positions: Nullable<Vector3[]>;
  91605. /** @hidden */
  91606. _resetPointsArrayCache(): Mesh;
  91607. /** @hidden */
  91608. _generatePointsArray(): boolean;
  91609. /**
  91610. * Returns a new Mesh object generated from the current mesh properties.
  91611. * This method must not get confused with createInstance()
  91612. * @param name is a string, the name given to the new mesh
  91613. * @param newParent can be any Node object (default `null`)
  91614. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  91615. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  91616. * @returns a new mesh
  91617. */
  91618. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  91619. /**
  91620. * Releases resources associated with this mesh.
  91621. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91622. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91623. */
  91624. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91625. /** @hidden */
  91626. _disposeInstanceSpecificData(): void;
  91627. /**
  91628. * Modifies the mesh geometry according to a displacement map.
  91629. * 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.
  91630. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91631. * @param url is a string, the URL from the image file is to be downloaded.
  91632. * @param minHeight is the lower limit of the displacement.
  91633. * @param maxHeight is the upper limit of the displacement.
  91634. * @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.
  91635. * @param uvOffset is an optional vector2 used to offset UV.
  91636. * @param uvScale is an optional vector2 used to scale UV.
  91637. * @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.
  91638. * @returns the Mesh.
  91639. */
  91640. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91641. /**
  91642. * Modifies the mesh geometry according to a displacementMap buffer.
  91643. * 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.
  91644. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91645. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  91646. * @param heightMapWidth is the width of the buffer image.
  91647. * @param heightMapHeight is the height of the buffer image.
  91648. * @param minHeight is the lower limit of the displacement.
  91649. * @param maxHeight is the upper limit of the displacement.
  91650. * @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.
  91651. * @param uvOffset is an optional vector2 used to offset UV.
  91652. * @param uvScale is an optional vector2 used to scale UV.
  91653. * @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.
  91654. * @returns the Mesh.
  91655. */
  91656. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91657. /**
  91658. * Modify the mesh to get a flat shading rendering.
  91659. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  91660. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  91661. * @returns current mesh
  91662. */
  91663. convertToFlatShadedMesh(): Mesh;
  91664. /**
  91665. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  91666. * In other words, more vertices, no more indices and a single bigger VBO.
  91667. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  91668. * @returns current mesh
  91669. */
  91670. convertToUnIndexedMesh(): Mesh;
  91671. /**
  91672. * Inverses facet orientations.
  91673. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91674. * @param flipNormals will also inverts the normals
  91675. * @returns current mesh
  91676. */
  91677. flipFaces(flipNormals?: boolean): Mesh;
  91678. /**
  91679. * Increase the number of facets and hence vertices in a mesh
  91680. * Vertex normals are interpolated from existing vertex normals
  91681. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91682. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91683. */
  91684. increaseVertices(numberPerEdge: number): void;
  91685. /**
  91686. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91687. * This will undo any application of covertToFlatShadedMesh
  91688. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91689. */
  91690. forceSharedVertices(): void;
  91691. /** @hidden */
  91692. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  91693. /** @hidden */
  91694. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  91695. /**
  91696. * Creates a new InstancedMesh object from the mesh model.
  91697. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91698. * @param name defines the name of the new instance
  91699. * @returns a new InstancedMesh
  91700. */
  91701. createInstance(name: string): InstancedMesh;
  91702. /**
  91703. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91704. * After this call, all the mesh instances have the same submeshes than the current mesh.
  91705. * @returns the current mesh
  91706. */
  91707. synchronizeInstances(): Mesh;
  91708. /**
  91709. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  91710. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  91711. * This should be used together with the simplification to avoid disappearing triangles.
  91712. * @param successCallback an optional success callback to be called after the optimization finished.
  91713. * @returns the current mesh
  91714. */
  91715. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  91716. /**
  91717. * Serialize current mesh
  91718. * @param serializationObject defines the object which will receive the serialization data
  91719. */
  91720. serialize(serializationObject: any): void;
  91721. /** @hidden */
  91722. _syncGeometryWithMorphTargetManager(): void;
  91723. /** @hidden */
  91724. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91725. /**
  91726. * Returns a new Mesh object parsed from the source provided.
  91727. * @param parsedMesh is the source
  91728. * @param scene defines the hosting scene
  91729. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91730. * @returns a new Mesh
  91731. */
  91732. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91733. /**
  91734. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91735. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91736. * @param name defines the name of the mesh to create
  91737. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91738. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91739. * @param closePath creates a seam between the first and the last points of each path of the path array
  91740. * @param offset is taken in account only if the `pathArray` is containing a single path
  91741. * @param scene defines the hosting scene
  91742. * @param updatable defines if the mesh must be flagged as updatable
  91743. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91744. * @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)
  91745. * @returns a new Mesh
  91746. */
  91747. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91748. /**
  91749. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91750. * @param name defines the name of the mesh to create
  91751. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91752. * @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
  91753. * @param scene defines the hosting scene
  91754. * @param updatable defines if the mesh must be flagged as updatable
  91755. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91756. * @returns a new Mesh
  91757. */
  91758. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91759. /**
  91760. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91761. * @param name defines the name of the mesh to create
  91762. * @param size sets the size (float) of each box side (default 1)
  91763. * @param scene defines the hosting scene
  91764. * @param updatable defines if the mesh must be flagged as updatable
  91765. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91766. * @returns a new Mesh
  91767. */
  91768. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91769. /**
  91770. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91771. * @param name defines the name of the mesh to create
  91772. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91773. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91774. * @param scene defines the hosting scene
  91775. * @param updatable defines if the mesh must be flagged as updatable
  91776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91777. * @returns a new Mesh
  91778. */
  91779. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91780. /**
  91781. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91782. * @param name defines the name of the mesh to create
  91783. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91784. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91785. * @param scene defines the hosting scene
  91786. * @returns a new Mesh
  91787. */
  91788. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91789. /**
  91790. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91791. * @param name defines the name of the mesh to create
  91792. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91793. * @param diameterTop set the top cap diameter (floats, default 1)
  91794. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91795. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91796. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91797. * @param scene defines the hosting scene
  91798. * @param updatable defines if the mesh must be flagged as updatable
  91799. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91800. * @returns a new Mesh
  91801. */
  91802. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91803. /**
  91804. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91805. * @param name defines the name of the mesh to create
  91806. * @param diameter sets the diameter size (float) of the torus (default 1)
  91807. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91808. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91809. * @param scene defines the hosting scene
  91810. * @param updatable defines if the mesh must be flagged as updatable
  91811. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91812. * @returns a new Mesh
  91813. */
  91814. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91815. /**
  91816. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91817. * @param name defines the name of the mesh to create
  91818. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91819. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91820. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91821. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91822. * @param p the number of windings on X axis (positive integers, default 2)
  91823. * @param q the number of windings on Y axis (positive integers, default 3)
  91824. * @param scene defines the hosting scene
  91825. * @param updatable defines if the mesh must be flagged as updatable
  91826. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91827. * @returns a new Mesh
  91828. */
  91829. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91830. /**
  91831. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91832. * @param name defines the name of the mesh to create
  91833. * @param points is an array successive Vector3
  91834. * @param scene defines the hosting scene
  91835. * @param updatable defines if the mesh must be flagged as updatable
  91836. * @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).
  91837. * @returns a new Mesh
  91838. */
  91839. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91840. /**
  91841. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91842. * @param name defines the name of the mesh to create
  91843. * @param points is an array successive Vector3
  91844. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91845. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91846. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91847. * @param scene defines the hosting scene
  91848. * @param updatable defines if the mesh must be flagged as updatable
  91849. * @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)
  91850. * @returns a new Mesh
  91851. */
  91852. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91853. /**
  91854. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91855. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91856. * 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.
  91857. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91858. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91859. * Remember you can only change the shape positions, not their number when updating a polygon.
  91860. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91861. * @param name defines the name of the mesh to create
  91862. * @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
  91863. * @param scene defines the hosting scene
  91864. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91865. * @param updatable defines if the mesh must be flagged as updatable
  91866. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91867. * @param earcutInjection can be used to inject your own earcut reference
  91868. * @returns a new Mesh
  91869. */
  91870. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91871. /**
  91872. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91873. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91874. * @param name defines the name of the mesh to create
  91875. * @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
  91876. * @param depth defines the height of extrusion
  91877. * @param scene defines the hosting scene
  91878. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91879. * @param updatable defines if the mesh must be flagged as updatable
  91880. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91881. * @param earcutInjection can be used to inject your own earcut reference
  91882. * @returns a new Mesh
  91883. */
  91884. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91885. /**
  91886. * Creates an extruded shape mesh.
  91887. * 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
  91888. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91889. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91890. * @param name defines the name of the mesh to create
  91891. * @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
  91892. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91893. * @param scale is the value to scale the shape
  91894. * @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
  91895. * @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
  91896. * @param scene defines the hosting scene
  91897. * @param updatable defines if the mesh must be flagged as updatable
  91898. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91899. * @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)
  91900. * @returns a new Mesh
  91901. */
  91902. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91903. /**
  91904. * Creates an custom extruded shape mesh.
  91905. * The custom extrusion is a parametric shape.
  91906. * It has no predefined shape. Its final shape will depend on the input parameters.
  91907. * Please consider using the same method from the MeshBuilder class instead
  91908. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91909. * @param name defines the name of the mesh to create
  91910. * @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
  91911. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91912. * @param scaleFunction is a custom Javascript function called on each path point
  91913. * @param rotationFunction is a custom Javascript function called on each path point
  91914. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91915. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91916. * @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
  91917. * @param scene defines the hosting scene
  91918. * @param updatable defines if the mesh must be flagged as updatable
  91919. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91920. * @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)
  91921. * @returns a new Mesh
  91922. */
  91923. 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;
  91924. /**
  91925. * Creates lathe mesh.
  91926. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91927. * Please consider using the same method from the MeshBuilder class instead
  91928. * @param name defines the name of the mesh to create
  91929. * @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
  91930. * @param radius is the radius value of the lathe
  91931. * @param tessellation is the side number of the lathe.
  91932. * @param scene defines the hosting scene
  91933. * @param updatable defines if the mesh must be flagged as updatable
  91934. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91935. * @returns a new Mesh
  91936. */
  91937. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91938. /**
  91939. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91940. * @param name defines the name of the mesh to create
  91941. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91942. * @param scene defines the hosting scene
  91943. * @param updatable defines if the mesh must be flagged as updatable
  91944. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91945. * @returns a new Mesh
  91946. */
  91947. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91948. /**
  91949. * Creates a ground mesh.
  91950. * Please consider using the same method from the MeshBuilder class instead
  91951. * @param name defines the name of the mesh to create
  91952. * @param width set the width of the ground
  91953. * @param height set the height of the ground
  91954. * @param subdivisions sets the number of subdivisions per side
  91955. * @param scene defines the hosting scene
  91956. * @param updatable defines if the mesh must be flagged as updatable
  91957. * @returns a new Mesh
  91958. */
  91959. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91960. /**
  91961. * Creates a tiled ground mesh.
  91962. * Please consider using the same method from the MeshBuilder class instead
  91963. * @param name defines the name of the mesh to create
  91964. * @param xmin set the ground minimum X coordinate
  91965. * @param zmin set the ground minimum Y coordinate
  91966. * @param xmax set the ground maximum X coordinate
  91967. * @param zmax set the ground maximum Z coordinate
  91968. * @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
  91969. * @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
  91970. * @param scene defines the hosting scene
  91971. * @param updatable defines if the mesh must be flagged as updatable
  91972. * @returns a new Mesh
  91973. */
  91974. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91975. w: number;
  91976. h: number;
  91977. }, precision: {
  91978. w: number;
  91979. h: number;
  91980. }, scene: Scene, updatable?: boolean): Mesh;
  91981. /**
  91982. * Creates a ground mesh from a height map.
  91983. * Please consider using the same method from the MeshBuilder class instead
  91984. * @see http://doc.babylonjs.com/babylon101/height_map
  91985. * @param name defines the name of the mesh to create
  91986. * @param url sets the URL of the height map image resource
  91987. * @param width set the ground width size
  91988. * @param height set the ground height size
  91989. * @param subdivisions sets the number of subdivision per side
  91990. * @param minHeight is the minimum altitude on the ground
  91991. * @param maxHeight is the maximum altitude on the ground
  91992. * @param scene defines the hosting scene
  91993. * @param updatable defines if the mesh must be flagged as updatable
  91994. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91995. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91996. * @returns a new Mesh
  91997. */
  91998. 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;
  91999. /**
  92000. * Creates a tube mesh.
  92001. * The tube is a parametric shape.
  92002. * It has no predefined shape. Its final shape will depend on the input parameters.
  92003. * Please consider using the same method from the MeshBuilder class instead
  92004. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92005. * @param name defines the name of the mesh to create
  92006. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92007. * @param radius sets the tube radius size
  92008. * @param tessellation is the number of sides on the tubular surface
  92009. * @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
  92010. * @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
  92011. * @param scene defines the hosting scene
  92012. * @param updatable defines if the mesh must be flagged as updatable
  92013. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92014. * @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)
  92015. * @returns a new Mesh
  92016. */
  92017. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92018. (i: number, distance: number): number;
  92019. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92020. /**
  92021. * Creates a polyhedron mesh.
  92022. * Please consider using the same method from the MeshBuilder class instead.
  92023. * * 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
  92024. * * The parameter `size` (positive float, default 1) sets the polygon size
  92025. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92026. * * 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`
  92027. * * 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
  92028. * * 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)`)
  92029. * * 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
  92030. * * 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
  92031. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or 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 : http://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 to create
  92035. * @param options defines the options used to create the mesh
  92036. * @param scene defines the hosting scene
  92037. * @returns a new Mesh
  92038. */
  92039. static CreatePolyhedron(name: string, options: {
  92040. type?: number;
  92041. size?: number;
  92042. sizeX?: number;
  92043. sizeY?: number;
  92044. sizeZ?: number;
  92045. custom?: any;
  92046. faceUV?: Vector4[];
  92047. faceColors?: Color4[];
  92048. updatable?: boolean;
  92049. sideOrientation?: number;
  92050. }, scene: Scene): Mesh;
  92051. /**
  92052. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92053. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92054. * * 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`)
  92055. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92056. * * 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
  92057. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92058. * * If you create a double-sided mesh, you can choose what parts of 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
  92059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92060. * @param name defines the name of the mesh
  92061. * @param options defines the options used to create the mesh
  92062. * @param scene defines the hosting scene
  92063. * @returns a new Mesh
  92064. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92065. */
  92066. static CreateIcoSphere(name: string, options: {
  92067. radius?: number;
  92068. flat?: boolean;
  92069. subdivisions?: number;
  92070. sideOrientation?: number;
  92071. updatable?: boolean;
  92072. }, scene: Scene): Mesh;
  92073. /**
  92074. * Creates a decal mesh.
  92075. * Please consider using the same method from the MeshBuilder class instead.
  92076. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92077. * @param name defines the name of the mesh
  92078. * @param sourceMesh defines the mesh receiving the decal
  92079. * @param position sets the position of the decal in world coordinates
  92080. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92081. * @param size sets the decal scaling
  92082. * @param angle sets the angle to rotate the decal
  92083. * @returns a new Mesh
  92084. */
  92085. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  92086. /**
  92087. * Prepare internal position array for software CPU skinning
  92088. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92089. */
  92090. setPositionsForCPUSkinning(): Float32Array;
  92091. /**
  92092. * Prepare internal normal array for software CPU skinning
  92093. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92094. */
  92095. setNormalsForCPUSkinning(): Float32Array;
  92096. /**
  92097. * Updates the vertex buffer by applying transformation from the bones
  92098. * @param skeleton defines the skeleton to apply to current mesh
  92099. * @returns the current mesh
  92100. */
  92101. applySkeleton(skeleton: Skeleton): Mesh;
  92102. /**
  92103. * 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
  92104. * @param meshes defines the list of meshes to scan
  92105. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92106. */
  92107. static MinMax(meshes: AbstractMesh[]): {
  92108. min: Vector3;
  92109. max: Vector3;
  92110. };
  92111. /**
  92112. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92113. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92114. * @returns a vector3
  92115. */
  92116. static Center(meshesOrMinMaxVector: {
  92117. min: Vector3;
  92118. max: Vector3;
  92119. } | AbstractMesh[]): Vector3;
  92120. /**
  92121. * Merge the array of meshes into a single mesh for performance reasons.
  92122. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92123. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92124. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92125. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92126. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92127. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92128. * @returns a new mesh
  92129. */
  92130. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  92131. /** @hidden */
  92132. addInstance(instance: InstancedMesh): void;
  92133. /** @hidden */
  92134. removeInstance(instance: InstancedMesh): void;
  92135. }
  92136. }
  92137. declare module BABYLON {
  92138. /**
  92139. * This is the base class of all the camera used in the application.
  92140. * @see http://doc.babylonjs.com/features/cameras
  92141. */
  92142. export class Camera extends Node {
  92143. /** @hidden */
  92144. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92145. /**
  92146. * This is the default projection mode used by the cameras.
  92147. * It helps recreating a feeling of perspective and better appreciate depth.
  92148. * This is the best way to simulate real life cameras.
  92149. */
  92150. static readonly PERSPECTIVE_CAMERA: number;
  92151. /**
  92152. * This helps creating camera with an orthographic mode.
  92153. * 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.
  92154. */
  92155. static readonly ORTHOGRAPHIC_CAMERA: number;
  92156. /**
  92157. * This is the default FOV mode for perspective cameras.
  92158. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92159. */
  92160. static readonly FOVMODE_VERTICAL_FIXED: number;
  92161. /**
  92162. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92163. */
  92164. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92165. /**
  92166. * This specifies ther is no need for a camera rig.
  92167. * Basically only one eye is rendered corresponding to the camera.
  92168. */
  92169. static readonly RIG_MODE_NONE: number;
  92170. /**
  92171. * Simulates a camera Rig with one blue eye and one red eye.
  92172. * This can be use with 3d blue and red glasses.
  92173. */
  92174. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92175. /**
  92176. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92177. */
  92178. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92179. /**
  92180. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92181. */
  92182. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92183. /**
  92184. * Defines that both eyes of the camera will be rendered over under each other.
  92185. */
  92186. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92187. /**
  92188. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92189. */
  92190. static readonly RIG_MODE_VR: number;
  92191. /**
  92192. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92193. */
  92194. static readonly RIG_MODE_WEBVR: number;
  92195. /**
  92196. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92197. */
  92198. static readonly RIG_MODE_CUSTOM: number;
  92199. /**
  92200. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92201. */
  92202. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92203. /**
  92204. * Define the input manager associated with the camera.
  92205. */
  92206. inputs: CameraInputsManager<Camera>;
  92207. /** @hidden */
  92208. _position: Vector3;
  92209. /**
  92210. * Define the current local position of the camera in the scene
  92211. */
  92212. position: Vector3;
  92213. /**
  92214. * The vector the camera should consider as up.
  92215. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92216. */
  92217. upVector: Vector3;
  92218. /**
  92219. * Define the current limit on the left side for an orthographic camera
  92220. * In scene unit
  92221. */
  92222. orthoLeft: Nullable<number>;
  92223. /**
  92224. * Define the current limit on the right side for an orthographic camera
  92225. * In scene unit
  92226. */
  92227. orthoRight: Nullable<number>;
  92228. /**
  92229. * Define the current limit on the bottom side for an orthographic camera
  92230. * In scene unit
  92231. */
  92232. orthoBottom: Nullable<number>;
  92233. /**
  92234. * Define the current limit on the top side for an orthographic camera
  92235. * In scene unit
  92236. */
  92237. orthoTop: Nullable<number>;
  92238. /**
  92239. * Field Of View is set in Radians. (default is 0.8)
  92240. */
  92241. fov: number;
  92242. /**
  92243. * Define the minimum distance the camera can see from.
  92244. * This is important to note that the depth buffer are not infinite and the closer it starts
  92245. * the more your scene might encounter depth fighting issue.
  92246. */
  92247. minZ: number;
  92248. /**
  92249. * Define the maximum distance the camera can see to.
  92250. * This is important to note that the depth buffer are not infinite and the further it end
  92251. * the more your scene might encounter depth fighting issue.
  92252. */
  92253. maxZ: number;
  92254. /**
  92255. * Define the default inertia of the camera.
  92256. * This helps giving a smooth feeling to the camera movement.
  92257. */
  92258. inertia: number;
  92259. /**
  92260. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92261. */
  92262. mode: number;
  92263. /**
  92264. * Define wether the camera is intermediate.
  92265. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92266. */
  92267. isIntermediate: boolean;
  92268. /**
  92269. * Define the viewport of the camera.
  92270. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92271. */
  92272. viewport: Viewport;
  92273. /**
  92274. * Restricts the camera to viewing objects with the same layerMask.
  92275. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92276. */
  92277. layerMask: number;
  92278. /**
  92279. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92280. */
  92281. fovMode: number;
  92282. /**
  92283. * Rig mode of the camera.
  92284. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92285. * This is normally controlled byt the camera themselves as internal use.
  92286. */
  92287. cameraRigMode: number;
  92288. /**
  92289. * Defines the distance between both "eyes" in case of a RIG
  92290. */
  92291. interaxialDistance: number;
  92292. /**
  92293. * Defines if stereoscopic rendering is done side by side or over under.
  92294. */
  92295. isStereoscopicSideBySide: boolean;
  92296. /**
  92297. * 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
  92298. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92299. * else in the scene. (Eg. security camera)
  92300. *
  92301. * 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)
  92302. */
  92303. customRenderTargets: RenderTargetTexture[];
  92304. /**
  92305. * When set, the camera will render to this render target instead of the default canvas
  92306. *
  92307. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  92308. */
  92309. outputRenderTarget: Nullable<RenderTargetTexture>;
  92310. /**
  92311. * Observable triggered when the camera view matrix has changed.
  92312. */
  92313. onViewMatrixChangedObservable: Observable<Camera>;
  92314. /**
  92315. * Observable triggered when the camera Projection matrix has changed.
  92316. */
  92317. onProjectionMatrixChangedObservable: Observable<Camera>;
  92318. /**
  92319. * Observable triggered when the inputs have been processed.
  92320. */
  92321. onAfterCheckInputsObservable: Observable<Camera>;
  92322. /**
  92323. * Observable triggered when reset has been called and applied to the camera.
  92324. */
  92325. onRestoreStateObservable: Observable<Camera>;
  92326. /** @hidden */
  92327. _cameraRigParams: any;
  92328. /** @hidden */
  92329. _rigCameras: Camera[];
  92330. /** @hidden */
  92331. _rigPostProcess: Nullable<PostProcess>;
  92332. protected _webvrViewMatrix: Matrix;
  92333. /** @hidden */
  92334. _skipRendering: boolean;
  92335. /** @hidden */
  92336. _projectionMatrix: Matrix;
  92337. /** @hidden */
  92338. _postProcesses: Nullable<PostProcess>[];
  92339. /** @hidden */
  92340. _activeMeshes: SmartArray<AbstractMesh>;
  92341. protected _globalPosition: Vector3;
  92342. /** @hidden */
  92343. _computedViewMatrix: Matrix;
  92344. private _doNotComputeProjectionMatrix;
  92345. private _transformMatrix;
  92346. private _frustumPlanes;
  92347. private _refreshFrustumPlanes;
  92348. private _storedFov;
  92349. private _stateStored;
  92350. /**
  92351. * Instantiates a new camera object.
  92352. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92353. * @see http://doc.babylonjs.com/features/cameras
  92354. * @param name Defines the name of the camera in the scene
  92355. * @param position Defines the position of the camera
  92356. * @param scene Defines the scene the camera belongs too
  92357. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92358. */
  92359. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92360. /**
  92361. * Store current camera state (fov, position, etc..)
  92362. * @returns the camera
  92363. */
  92364. storeState(): Camera;
  92365. /**
  92366. * Restores the camera state values if it has been stored. You must call storeState() first
  92367. */
  92368. protected _restoreStateValues(): boolean;
  92369. /**
  92370. * Restored camera state. You must call storeState() first.
  92371. * @returns true if restored and false otherwise
  92372. */
  92373. restoreState(): boolean;
  92374. /**
  92375. * Gets the class name of the camera.
  92376. * @returns the class name
  92377. */
  92378. getClassName(): string;
  92379. /** @hidden */
  92380. readonly _isCamera: boolean;
  92381. /**
  92382. * Gets a string representation of the camera useful for debug purpose.
  92383. * @param fullDetails Defines that a more verboe level of logging is required
  92384. * @returns the string representation
  92385. */
  92386. toString(fullDetails?: boolean): string;
  92387. /**
  92388. * Gets the current world space position of the camera.
  92389. */
  92390. readonly globalPosition: Vector3;
  92391. /**
  92392. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92393. * @returns the active meshe list
  92394. */
  92395. getActiveMeshes(): SmartArray<AbstractMesh>;
  92396. /**
  92397. * Check wether a mesh is part of the current active mesh list of the camera
  92398. * @param mesh Defines the mesh to check
  92399. * @returns true if active, false otherwise
  92400. */
  92401. isActiveMesh(mesh: Mesh): boolean;
  92402. /**
  92403. * Is this camera ready to be used/rendered
  92404. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92405. * @return true if the camera is ready
  92406. */
  92407. isReady(completeCheck?: boolean): boolean;
  92408. /** @hidden */
  92409. _initCache(): void;
  92410. /** @hidden */
  92411. _updateCache(ignoreParentClass?: boolean): void;
  92412. /** @hidden */
  92413. _isSynchronized(): boolean;
  92414. /** @hidden */
  92415. _isSynchronizedViewMatrix(): boolean;
  92416. /** @hidden */
  92417. _isSynchronizedProjectionMatrix(): boolean;
  92418. /**
  92419. * Attach the input controls to a specific dom element to get the input from.
  92420. * @param element Defines the element the controls should be listened from
  92421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92422. */
  92423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92424. /**
  92425. * Detach the current controls from the specified dom element.
  92426. * @param element Defines the element to stop listening the inputs from
  92427. */
  92428. detachControl(element: HTMLElement): void;
  92429. /**
  92430. * Update the camera state according to the different inputs gathered during the frame.
  92431. */
  92432. update(): void;
  92433. /** @hidden */
  92434. _checkInputs(): void;
  92435. /** @hidden */
  92436. readonly rigCameras: Camera[];
  92437. /**
  92438. * Gets the post process used by the rig cameras
  92439. */
  92440. readonly rigPostProcess: Nullable<PostProcess>;
  92441. /**
  92442. * Internal, gets the first post proces.
  92443. * @returns the first post process to be run on this camera.
  92444. */
  92445. _getFirstPostProcess(): Nullable<PostProcess>;
  92446. private _cascadePostProcessesToRigCams;
  92447. /**
  92448. * Attach a post process to the camera.
  92449. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92450. * @param postProcess The post process to attach to the camera
  92451. * @param insertAt The position of the post process in case several of them are in use in the scene
  92452. * @returns the position the post process has been inserted at
  92453. */
  92454. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  92455. /**
  92456. * Detach a post process to the camera.
  92457. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92458. * @param postProcess The post process to detach from the camera
  92459. */
  92460. detachPostProcess(postProcess: PostProcess): void;
  92461. /**
  92462. * Gets the current world matrix of the camera
  92463. */
  92464. getWorldMatrix(): Matrix;
  92465. /** @hidden */
  92466. _getViewMatrix(): Matrix;
  92467. /**
  92468. * Gets the current view matrix of the camera.
  92469. * @param force forces the camera to recompute the matrix without looking at the cached state
  92470. * @returns the view matrix
  92471. */
  92472. getViewMatrix(force?: boolean): Matrix;
  92473. /**
  92474. * Freeze the projection matrix.
  92475. * It will prevent the cache check of the camera projection compute and can speed up perf
  92476. * if no parameter of the camera are meant to change
  92477. * @param projection Defines manually a projection if necessary
  92478. */
  92479. freezeProjectionMatrix(projection?: Matrix): void;
  92480. /**
  92481. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  92482. */
  92483. unfreezeProjectionMatrix(): void;
  92484. /**
  92485. * Gets the current projection matrix of the camera.
  92486. * @param force forces the camera to recompute the matrix without looking at the cached state
  92487. * @returns the projection matrix
  92488. */
  92489. getProjectionMatrix(force?: boolean): Matrix;
  92490. /**
  92491. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  92492. * @returns a Matrix
  92493. */
  92494. getTransformationMatrix(): Matrix;
  92495. private _updateFrustumPlanes;
  92496. /**
  92497. * Checks if a cullable object (mesh...) is in the camera frustum
  92498. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  92499. * @param target The object to check
  92500. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  92501. * @returns true if the object is in frustum otherwise false
  92502. */
  92503. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  92504. /**
  92505. * Checks if a cullable object (mesh...) is in the camera frustum
  92506. * Unlike isInFrustum this cheks the full bounding box
  92507. * @param target The object to check
  92508. * @returns true if the object is in frustum otherwise false
  92509. */
  92510. isCompletelyInFrustum(target: ICullable): boolean;
  92511. /**
  92512. * Gets a ray in the forward direction from the camera.
  92513. * @param length Defines the length of the ray to create
  92514. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  92515. * @param origin Defines the start point of the ray which defaults to the camera position
  92516. * @returns the forward ray
  92517. */
  92518. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  92519. /**
  92520. * Releases resources associated with this node.
  92521. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92522. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92523. */
  92524. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92525. /** @hidden */
  92526. _isLeftCamera: boolean;
  92527. /**
  92528. * Gets the left camera of a rig setup in case of Rigged Camera
  92529. */
  92530. readonly isLeftCamera: boolean;
  92531. /** @hidden */
  92532. _isRightCamera: boolean;
  92533. /**
  92534. * Gets the right camera of a rig setup in case of Rigged Camera
  92535. */
  92536. readonly isRightCamera: boolean;
  92537. /**
  92538. * Gets the left camera of a rig setup in case of Rigged Camera
  92539. */
  92540. readonly leftCamera: Nullable<FreeCamera>;
  92541. /**
  92542. * Gets the right camera of a rig setup in case of Rigged Camera
  92543. */
  92544. readonly rightCamera: Nullable<FreeCamera>;
  92545. /**
  92546. * Gets the left camera target of a rig setup in case of Rigged Camera
  92547. * @returns the target position
  92548. */
  92549. getLeftTarget(): Nullable<Vector3>;
  92550. /**
  92551. * Gets the right camera target of a rig setup in case of Rigged Camera
  92552. * @returns the target position
  92553. */
  92554. getRightTarget(): Nullable<Vector3>;
  92555. /**
  92556. * @hidden
  92557. */
  92558. setCameraRigMode(mode: number, rigParams: any): void;
  92559. /** @hidden */
  92560. static _setStereoscopicRigMode(camera: Camera): void;
  92561. /** @hidden */
  92562. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  92563. /** @hidden */
  92564. static _setVRRigMode(camera: Camera, rigParams: any): void;
  92565. /** @hidden */
  92566. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  92567. /** @hidden */
  92568. _getVRProjectionMatrix(): Matrix;
  92569. protected _updateCameraRotationMatrix(): void;
  92570. protected _updateWebVRCameraRotationMatrix(): void;
  92571. /**
  92572. * This function MUST be overwritten by the different WebVR cameras available.
  92573. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92574. * @hidden
  92575. */
  92576. _getWebVRProjectionMatrix(): Matrix;
  92577. /**
  92578. * This function MUST be overwritten by the different WebVR cameras available.
  92579. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92580. * @hidden
  92581. */
  92582. _getWebVRViewMatrix(): Matrix;
  92583. /** @hidden */
  92584. setCameraRigParameter(name: string, value: any): void;
  92585. /**
  92586. * needs to be overridden by children so sub has required properties to be copied
  92587. * @hidden
  92588. */
  92589. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  92590. /**
  92591. * May need to be overridden by children
  92592. * @hidden
  92593. */
  92594. _updateRigCameras(): void;
  92595. /** @hidden */
  92596. _setupInputs(): void;
  92597. /**
  92598. * Serialiaze the camera setup to a json represention
  92599. * @returns the JSON representation
  92600. */
  92601. serialize(): any;
  92602. /**
  92603. * Clones the current camera.
  92604. * @param name The cloned camera name
  92605. * @returns the cloned camera
  92606. */
  92607. clone(name: string): Camera;
  92608. /**
  92609. * Gets the direction of the camera relative to a given local axis.
  92610. * @param localAxis Defines the reference axis to provide a relative direction.
  92611. * @return the direction
  92612. */
  92613. getDirection(localAxis: Vector3): Vector3;
  92614. /**
  92615. * Returns the current camera absolute rotation
  92616. */
  92617. readonly absoluteRotation: Quaternion;
  92618. /**
  92619. * Gets the direction of the camera relative to a given local axis into a passed vector.
  92620. * @param localAxis Defines the reference axis to provide a relative direction.
  92621. * @param result Defines the vector to store the result in
  92622. */
  92623. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  92624. /**
  92625. * Gets a camera constructor for a given camera type
  92626. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92627. * @param name The name of the camera the result will be able to instantiate
  92628. * @param scene The scene the result will construct the camera in
  92629. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92630. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92631. * @returns a factory method to construc the camera
  92632. */
  92633. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92634. /**
  92635. * Compute the world matrix of the camera.
  92636. * @returns the camera workd matrix
  92637. */
  92638. computeWorldMatrix(): Matrix;
  92639. /**
  92640. * Parse a JSON and creates the camera from the parsed information
  92641. * @param parsedCamera The JSON to parse
  92642. * @param scene The scene to instantiate the camera in
  92643. * @returns the newly constructed camera
  92644. */
  92645. static Parse(parsedCamera: any, scene: Scene): Camera;
  92646. }
  92647. }
  92648. declare module BABYLON {
  92649. /**
  92650. * Class containing static functions to help procedurally build meshes
  92651. */
  92652. export class DiscBuilder {
  92653. /**
  92654. * Creates a plane polygonal mesh. By default, this is a disc
  92655. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92656. * * 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
  92657. * * 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
  92658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92661. * @param name defines the name of the mesh
  92662. * @param options defines the options used to create the mesh
  92663. * @param scene defines the hosting scene
  92664. * @returns the plane polygonal mesh
  92665. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92666. */
  92667. static CreateDisc(name: string, options: {
  92668. radius?: number;
  92669. tessellation?: number;
  92670. arc?: number;
  92671. updatable?: boolean;
  92672. sideOrientation?: number;
  92673. frontUVs?: Vector4;
  92674. backUVs?: Vector4;
  92675. }, scene?: Nullable<Scene>): Mesh;
  92676. }
  92677. }
  92678. declare module BABYLON {
  92679. /**
  92680. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  92681. *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.
  92682. * The SPS is also a particle system. It provides some methods to manage the particles.
  92683. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  92684. *
  92685. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  92686. */
  92687. export class SolidParticleSystem implements IDisposable {
  92688. /**
  92689. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  92690. * Example : var p = SPS.particles[i];
  92691. */
  92692. particles: SolidParticle[];
  92693. /**
  92694. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  92695. */
  92696. nbParticles: number;
  92697. /**
  92698. * If the particles must ever face the camera (default false). Useful for planar particles.
  92699. */
  92700. billboard: boolean;
  92701. /**
  92702. * Recompute normals when adding a shape
  92703. */
  92704. recomputeNormals: boolean;
  92705. /**
  92706. * This a counter ofr your own usage. It's not set by any SPS functions.
  92707. */
  92708. counter: number;
  92709. /**
  92710. * The SPS name. This name is also given to the underlying mesh.
  92711. */
  92712. name: string;
  92713. /**
  92714. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  92715. */
  92716. mesh: Mesh;
  92717. /**
  92718. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92719. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92720. */
  92721. vars: any;
  92722. /**
  92723. * This array is populated when the SPS is set as 'pickable'.
  92724. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92725. * Each element of this array is an object `{idx: int, faceId: int}`.
  92726. * `idx` is the picked particle index in the `SPS.particles` array
  92727. * `faceId` is the picked face index counted within this particle.
  92728. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92729. */
  92730. pickedParticles: {
  92731. idx: number;
  92732. faceId: number;
  92733. }[];
  92734. /**
  92735. * This array is populated when `enableDepthSort` is set to true.
  92736. * Each element of this array is an instance of the class DepthSortedParticle.
  92737. */
  92738. depthSortedParticles: DepthSortedParticle[];
  92739. /**
  92740. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92741. * @hidden
  92742. */
  92743. _bSphereOnly: boolean;
  92744. /**
  92745. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92746. * @hidden
  92747. */
  92748. _bSphereRadiusFactor: number;
  92749. private _scene;
  92750. private _positions;
  92751. private _indices;
  92752. private _normals;
  92753. private _colors;
  92754. private _uvs;
  92755. private _indices32;
  92756. private _positions32;
  92757. private _normals32;
  92758. private _fixedNormal32;
  92759. private _colors32;
  92760. private _uvs32;
  92761. private _index;
  92762. private _updatable;
  92763. private _pickable;
  92764. private _isVisibilityBoxLocked;
  92765. private _alwaysVisible;
  92766. private _depthSort;
  92767. private _expandable;
  92768. private _shapeCounter;
  92769. private _copy;
  92770. private _color;
  92771. private _computeParticleColor;
  92772. private _computeParticleTexture;
  92773. private _computeParticleRotation;
  92774. private _computeParticleVertex;
  92775. private _computeBoundingBox;
  92776. private _depthSortParticles;
  92777. private _camera;
  92778. private _mustUnrotateFixedNormals;
  92779. private _particlesIntersect;
  92780. private _needs32Bits;
  92781. private _isNotBuilt;
  92782. /**
  92783. * Creates a SPS (Solid Particle System) object.
  92784. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92785. * @param scene (Scene) is the scene in which the SPS is added.
  92786. * @param options defines the options of the sps e.g.
  92787. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92788. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92789. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92790. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92791. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92792. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92793. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92794. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92795. */
  92796. constructor(name: string, scene: Scene, options?: {
  92797. updatable?: boolean;
  92798. isPickable?: boolean;
  92799. enableDepthSort?: boolean;
  92800. particleIntersection?: boolean;
  92801. boundingSphereOnly?: boolean;
  92802. bSphereRadiusFactor?: number;
  92803. expandable?: boolean;
  92804. });
  92805. /**
  92806. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92807. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92808. * @returns the created mesh
  92809. */
  92810. buildMesh(): Mesh;
  92811. /**
  92812. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92813. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92814. * Thus the particles generated from `digest()` have their property `position` set yet.
  92815. * @param mesh ( Mesh ) is the mesh to be digested
  92816. * @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
  92817. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92818. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92819. * @returns the current SPS
  92820. */
  92821. digest(mesh: Mesh, options?: {
  92822. facetNb?: number;
  92823. number?: number;
  92824. delta?: number;
  92825. }): SolidParticleSystem;
  92826. private _unrotateFixedNormals;
  92827. private _resetCopy;
  92828. private _meshBuilder;
  92829. private _posToShape;
  92830. private _uvsToShapeUV;
  92831. private _addParticle;
  92832. /**
  92833. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92834. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92835. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92836. * @param nb (positive integer) the number of particles to be created from this model
  92837. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92838. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92839. * @returns the number of shapes in the system
  92840. */
  92841. addShape(mesh: Mesh, nb: number, options?: {
  92842. positionFunction?: any;
  92843. vertexFunction?: any;
  92844. }): number;
  92845. private _rebuildParticle;
  92846. /**
  92847. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92848. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  92849. * @returns the SPS.
  92850. */
  92851. rebuildMesh(reset?: boolean): SolidParticleSystem;
  92852. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  92853. * Returns an array with the removed particles.
  92854. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  92855. * The SPS can't be empty so at least one particle needs to remain in place.
  92856. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  92857. * @param start index of the first particle to remove
  92858. * @param end index of the last particle to remove (included)
  92859. * @returns an array populated with the removed particles
  92860. */
  92861. removeParticles(start: number, end: number): SolidParticle[];
  92862. /**
  92863. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92864. * This method calls `updateParticle()` for each particle of the SPS.
  92865. * For an animated SPS, it is usually called within the render loop.
  92866. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  92867. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92868. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92869. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92870. * @returns the SPS.
  92871. */
  92872. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92873. /**
  92874. * Disposes the SPS.
  92875. */
  92876. dispose(): void;
  92877. /**
  92878. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92879. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92880. * @returns the SPS.
  92881. */
  92882. refreshVisibleSize(): SolidParticleSystem;
  92883. /**
  92884. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92885. * @param size the size (float) of the visibility box
  92886. * note : this doesn't lock the SPS mesh bounding box.
  92887. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92888. */
  92889. setVisibilityBox(size: number): void;
  92890. /**
  92891. * Gets whether the SPS as always visible or not
  92892. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92893. */
  92894. /**
  92895. * Sets the SPS as always visible or not
  92896. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92897. */
  92898. isAlwaysVisible: boolean;
  92899. /**
  92900. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92901. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92902. */
  92903. /**
  92904. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92905. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92906. */
  92907. isVisibilityBoxLocked: boolean;
  92908. /**
  92909. * Tells to `setParticles()` to compute the particle rotations or not.
  92910. * Default value : true. The SPS is faster when it's set to false.
  92911. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92912. */
  92913. /**
  92914. * Gets if `setParticles()` computes the particle rotations or not.
  92915. * Default value : true. The SPS is faster when it's set to false.
  92916. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92917. */
  92918. computeParticleRotation: boolean;
  92919. /**
  92920. * Tells to `setParticles()` to compute the particle colors or not.
  92921. * Default value : true. The SPS is faster when it's set to false.
  92922. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92923. */
  92924. /**
  92925. * Gets if `setParticles()` computes the particle colors or not.
  92926. * Default value : true. The SPS is faster when it's set to false.
  92927. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92928. */
  92929. computeParticleColor: boolean;
  92930. /**
  92931. * Gets if `setParticles()` computes the particle textures or not.
  92932. * Default value : true. The SPS is faster when it's set to false.
  92933. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92934. */
  92935. computeParticleTexture: boolean;
  92936. /**
  92937. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92938. * Default value : false. The SPS is faster when it's set to false.
  92939. * Note : the particle custom vertex positions aren't stored values.
  92940. */
  92941. /**
  92942. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92943. * Default value : false. The SPS is faster when it's set to false.
  92944. * Note : the particle custom vertex positions aren't stored values.
  92945. */
  92946. computeParticleVertex: boolean;
  92947. /**
  92948. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92949. */
  92950. /**
  92951. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92952. */
  92953. computeBoundingBox: boolean;
  92954. /**
  92955. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92956. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92957. * Default : `true`
  92958. */
  92959. /**
  92960. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92961. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92962. * Default : `true`
  92963. */
  92964. depthSortParticles: boolean;
  92965. /**
  92966. * Gets if the SPS is created as expandable at construction time.
  92967. * Default : `false`
  92968. */
  92969. readonly expandable: boolean;
  92970. /**
  92971. * This function does nothing. It may be overwritten to set all the particle first values.
  92972. * The SPS doesn't call this function, you may have to call it by your own.
  92973. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92974. */
  92975. initParticles(): void;
  92976. /**
  92977. * This function does nothing. It may be overwritten to recycle a particle.
  92978. * The SPS doesn't call this function, you may have to call it by your own.
  92979. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92980. * @param particle The particle to recycle
  92981. * @returns the recycled particle
  92982. */
  92983. recycleParticle(particle: SolidParticle): SolidParticle;
  92984. /**
  92985. * Updates a particle : this function should be overwritten by the user.
  92986. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92987. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92988. * @example : just set a particle position or velocity and recycle conditions
  92989. * @param particle The particle to update
  92990. * @returns the updated particle
  92991. */
  92992. updateParticle(particle: SolidParticle): SolidParticle;
  92993. /**
  92994. * Updates a vertex of a particle : it can be overwritten by the user.
  92995. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92996. * @param particle the current particle
  92997. * @param vertex the current index of the current particle
  92998. * @param pt the index of the current vertex in the particle shape
  92999. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  93000. * @example : just set a vertex particle position
  93001. * @returns the updated vertex
  93002. */
  93003. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  93004. /**
  93005. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  93006. * This does nothing and may be overwritten by the user.
  93007. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93008. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93009. * @param update the boolean update value actually passed to setParticles()
  93010. */
  93011. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93012. /**
  93013. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  93014. * This will be passed three parameters.
  93015. * This does nothing and may be overwritten by the user.
  93016. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93017. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93018. * @param update the boolean update value actually passed to setParticles()
  93019. */
  93020. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93021. }
  93022. }
  93023. declare module BABYLON {
  93024. /**
  93025. * Represents one particle of a solid particle system.
  93026. */
  93027. export class SolidParticle {
  93028. /**
  93029. * particle global index
  93030. */
  93031. idx: number;
  93032. /**
  93033. * The color of the particle
  93034. */
  93035. color: Nullable<Color4>;
  93036. /**
  93037. * The world space position of the particle.
  93038. */
  93039. position: Vector3;
  93040. /**
  93041. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  93042. */
  93043. rotation: Vector3;
  93044. /**
  93045. * The world space rotation quaternion of the particle.
  93046. */
  93047. rotationQuaternion: Nullable<Quaternion>;
  93048. /**
  93049. * The scaling of the particle.
  93050. */
  93051. scaling: Vector3;
  93052. /**
  93053. * The uvs of the particle.
  93054. */
  93055. uvs: Vector4;
  93056. /**
  93057. * The current speed of the particle.
  93058. */
  93059. velocity: Vector3;
  93060. /**
  93061. * The pivot point in the particle local space.
  93062. */
  93063. pivot: Vector3;
  93064. /**
  93065. * Must the particle be translated from its pivot point in its local space ?
  93066. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  93067. * Default : false
  93068. */
  93069. translateFromPivot: boolean;
  93070. /**
  93071. * Is the particle active or not ?
  93072. */
  93073. alive: boolean;
  93074. /**
  93075. * Is the particle visible or not ?
  93076. */
  93077. isVisible: boolean;
  93078. /**
  93079. * Index of this particle in the global "positions" array (Internal use)
  93080. * @hidden
  93081. */
  93082. _pos: number;
  93083. /**
  93084. * @hidden Index of this particle in the global "indices" array (Internal use)
  93085. */
  93086. _ind: number;
  93087. /**
  93088. * @hidden ModelShape of this particle (Internal use)
  93089. */
  93090. _model: ModelShape;
  93091. /**
  93092. * ModelShape id of this particle
  93093. */
  93094. shapeId: number;
  93095. /**
  93096. * Index of the particle in its shape id
  93097. */
  93098. idxInShape: number;
  93099. /**
  93100. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  93101. */
  93102. _modelBoundingInfo: BoundingInfo;
  93103. /**
  93104. * @hidden Particle BoundingInfo object (Internal use)
  93105. */
  93106. _boundingInfo: BoundingInfo;
  93107. /**
  93108. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  93109. */
  93110. _sps: SolidParticleSystem;
  93111. /**
  93112. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  93113. */
  93114. _stillInvisible: boolean;
  93115. /**
  93116. * @hidden Last computed particle rotation matrix
  93117. */
  93118. _rotationMatrix: number[];
  93119. /**
  93120. * Parent particle Id, if any.
  93121. * Default null.
  93122. */
  93123. parentId: Nullable<number>;
  93124. /**
  93125. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  93126. * The possible values are :
  93127. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93128. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93129. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93130. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93131. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93132. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  93133. * */
  93134. cullingStrategy: number;
  93135. /**
  93136. * @hidden Internal global position in the SPS.
  93137. */
  93138. _globalPosition: Vector3;
  93139. /**
  93140. * Creates a Solid Particle object.
  93141. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93142. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  93143. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93144. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93145. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  93146. * @param shapeId (integer) is the model shape identifier in the SPS.
  93147. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  93148. * @param sps defines the sps it is associated to
  93149. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  93150. */
  93151. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  93152. /**
  93153. * Legacy support, changed scale to scaling
  93154. */
  93155. /**
  93156. * Legacy support, changed scale to scaling
  93157. */
  93158. scale: Vector3;
  93159. /**
  93160. * Legacy support, changed quaternion to rotationQuaternion
  93161. */
  93162. /**
  93163. * Legacy support, changed quaternion to rotationQuaternion
  93164. */
  93165. quaternion: Nullable<Quaternion>;
  93166. /**
  93167. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  93168. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  93169. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  93170. * @returns true if it intersects
  93171. */
  93172. intersectsMesh(target: Mesh | SolidParticle): boolean;
  93173. /**
  93174. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  93175. * A particle is in the frustum if its bounding box intersects the frustum
  93176. * @param frustumPlanes defines the frustum to test
  93177. * @returns true if the particle is in the frustum planes
  93178. */
  93179. isInFrustum(frustumPlanes: Plane[]): boolean;
  93180. /**
  93181. * get the rotation matrix of the particle
  93182. * @hidden
  93183. */
  93184. getRotationMatrix(m: Matrix): void;
  93185. }
  93186. /**
  93187. * Represents the shape of the model used by one particle of a solid particle system.
  93188. * SPS internal tool, don't use it manually.
  93189. */
  93190. export class ModelShape {
  93191. /**
  93192. * The shape id
  93193. * @hidden
  93194. */
  93195. shapeID: number;
  93196. /**
  93197. * flat array of model positions (internal use)
  93198. * @hidden
  93199. */
  93200. _shape: Vector3[];
  93201. /**
  93202. * flat array of model UVs (internal use)
  93203. * @hidden
  93204. */
  93205. _shapeUV: number[];
  93206. /**
  93207. * color array of the model
  93208. * @hidden
  93209. */
  93210. _shapeColors: number[];
  93211. /**
  93212. * indices array of the model
  93213. * @hidden
  93214. */
  93215. _indices: number[];
  93216. /**
  93217. * normals array of the model
  93218. * @hidden
  93219. */
  93220. _normals: number[];
  93221. /**
  93222. * length of the shape in the model indices array (internal use)
  93223. * @hidden
  93224. */
  93225. _indicesLength: number;
  93226. /**
  93227. * Custom position function (internal use)
  93228. * @hidden
  93229. */
  93230. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  93231. /**
  93232. * Custom vertex function (internal use)
  93233. * @hidden
  93234. */
  93235. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  93236. /**
  93237. * 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.
  93238. * SPS internal tool, don't use it manually.
  93239. * @hidden
  93240. */
  93241. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  93242. }
  93243. /**
  93244. * Represents a Depth Sorted Particle in the solid particle system.
  93245. */
  93246. export class DepthSortedParticle {
  93247. /**
  93248. * Index of the particle in the "indices" array
  93249. */
  93250. ind: number;
  93251. /**
  93252. * Length of the particle shape in the "indices" array
  93253. */
  93254. indicesLength: number;
  93255. /**
  93256. * Squared distance from the particle to the camera
  93257. */
  93258. sqDistance: number;
  93259. }
  93260. }
  93261. declare module BABYLON {
  93262. /**
  93263. * @hidden
  93264. */
  93265. export class _MeshCollisionData {
  93266. _checkCollisions: boolean;
  93267. _collisionMask: number;
  93268. _collisionGroup: number;
  93269. _collider: Nullable<Collider>;
  93270. _oldPositionForCollisions: Vector3;
  93271. _diffPositionForCollisions: Vector3;
  93272. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  93273. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  93274. }
  93275. }
  93276. declare module BABYLON {
  93277. /** @hidden */
  93278. class _FacetDataStorage {
  93279. facetPositions: Vector3[];
  93280. facetNormals: Vector3[];
  93281. facetPartitioning: number[][];
  93282. facetNb: number;
  93283. partitioningSubdivisions: number;
  93284. partitioningBBoxRatio: number;
  93285. facetDataEnabled: boolean;
  93286. facetParameters: any;
  93287. bbSize: Vector3;
  93288. subDiv: {
  93289. max: number;
  93290. X: number;
  93291. Y: number;
  93292. Z: number;
  93293. };
  93294. facetDepthSort: boolean;
  93295. facetDepthSortEnabled: boolean;
  93296. depthSortedIndices: IndicesArray;
  93297. depthSortedFacets: {
  93298. ind: number;
  93299. sqDistance: number;
  93300. }[];
  93301. facetDepthSortFunction: (f1: {
  93302. ind: number;
  93303. sqDistance: number;
  93304. }, f2: {
  93305. ind: number;
  93306. sqDistance: number;
  93307. }) => number;
  93308. facetDepthSortFrom: Vector3;
  93309. facetDepthSortOrigin: Vector3;
  93310. invertedMatrix: Matrix;
  93311. }
  93312. /**
  93313. * @hidden
  93314. **/
  93315. class _InternalAbstractMeshDataInfo {
  93316. _hasVertexAlpha: boolean;
  93317. _useVertexColors: boolean;
  93318. _numBoneInfluencers: number;
  93319. _applyFog: boolean;
  93320. _receiveShadows: boolean;
  93321. _facetData: _FacetDataStorage;
  93322. _visibility: number;
  93323. _skeleton: Nullable<Skeleton>;
  93324. _layerMask: number;
  93325. _computeBonesUsingShaders: boolean;
  93326. _isActive: boolean;
  93327. _onlyForInstances: boolean;
  93328. _isActiveIntermediate: boolean;
  93329. _onlyForInstancesIntermediate: boolean;
  93330. _actAsRegularMesh: boolean;
  93331. }
  93332. /**
  93333. * Class used to store all common mesh properties
  93334. */
  93335. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  93336. /** No occlusion */
  93337. static OCCLUSION_TYPE_NONE: number;
  93338. /** Occlusion set to optimisitic */
  93339. static OCCLUSION_TYPE_OPTIMISTIC: number;
  93340. /** Occlusion set to strict */
  93341. static OCCLUSION_TYPE_STRICT: number;
  93342. /** Use an accurante occlusion algorithm */
  93343. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  93344. /** Use a conservative occlusion algorithm */
  93345. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  93346. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  93347. * Test order :
  93348. * Is the bounding sphere outside the frustum ?
  93349. * If not, are the bounding box vertices outside the frustum ?
  93350. * It not, then the cullable object is in the frustum.
  93351. */
  93352. static readonly CULLINGSTRATEGY_STANDARD: number;
  93353. /** Culling strategy : Bounding Sphere Only.
  93354. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  93355. * It's also less accurate than the standard because some not visible objects can still be selected.
  93356. * Test : is the bounding sphere outside the frustum ?
  93357. * If not, then the cullable object is in the frustum.
  93358. */
  93359. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  93360. /** Culling strategy : Optimistic Inclusion.
  93361. * This in an inclusion test first, then the standard exclusion test.
  93362. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  93363. * 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.
  93364. * Anyway, it's as accurate as the standard strategy.
  93365. * Test :
  93366. * Is the cullable object bounding sphere center in the frustum ?
  93367. * If not, apply the default culling strategy.
  93368. */
  93369. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  93370. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  93371. * This in an inclusion test first, then the bounding sphere only exclusion test.
  93372. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  93373. * 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.
  93374. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  93375. * Test :
  93376. * Is the cullable object bounding sphere center in the frustum ?
  93377. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  93378. */
  93379. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  93380. /**
  93381. * No billboard
  93382. */
  93383. static readonly BILLBOARDMODE_NONE: number;
  93384. /** Billboard on X axis */
  93385. static readonly BILLBOARDMODE_X: number;
  93386. /** Billboard on Y axis */
  93387. static readonly BILLBOARDMODE_Y: number;
  93388. /** Billboard on Z axis */
  93389. static readonly BILLBOARDMODE_Z: number;
  93390. /** Billboard on all axes */
  93391. static readonly BILLBOARDMODE_ALL: number;
  93392. /** Billboard on using position instead of orientation */
  93393. static readonly BILLBOARDMODE_USE_POSITION: number;
  93394. /** @hidden */
  93395. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  93396. /**
  93397. * The culling strategy to use to check whether the mesh must be rendered or not.
  93398. * This value can be changed at any time and will be used on the next render mesh selection.
  93399. * The possible values are :
  93400. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93401. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93402. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93403. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93404. * Please read each static variable documentation to get details about the culling process.
  93405. * */
  93406. cullingStrategy: number;
  93407. /**
  93408. * Gets the number of facets in the mesh
  93409. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93410. */
  93411. readonly facetNb: number;
  93412. /**
  93413. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  93414. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93415. */
  93416. partitioningSubdivisions: number;
  93417. /**
  93418. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  93419. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  93420. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93421. */
  93422. partitioningBBoxRatio: number;
  93423. /**
  93424. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  93425. * Works only for updatable meshes.
  93426. * Doesn't work with multi-materials
  93427. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93428. */
  93429. mustDepthSortFacets: boolean;
  93430. /**
  93431. * The location (Vector3) where the facet depth sort must be computed from.
  93432. * By default, the active camera position.
  93433. * Used only when facet depth sort is enabled
  93434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93435. */
  93436. facetDepthSortFrom: Vector3;
  93437. /**
  93438. * gets a boolean indicating if facetData is enabled
  93439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93440. */
  93441. readonly isFacetDataEnabled: boolean;
  93442. /** @hidden */
  93443. _updateNonUniformScalingState(value: boolean): boolean;
  93444. /**
  93445. * An event triggered when this mesh collides with another one
  93446. */
  93447. onCollideObservable: Observable<AbstractMesh>;
  93448. /** Set a function to call when this mesh collides with another one */
  93449. onCollide: () => void;
  93450. /**
  93451. * An event triggered when the collision's position changes
  93452. */
  93453. onCollisionPositionChangeObservable: Observable<Vector3>;
  93454. /** Set a function to call when the collision's position changes */
  93455. onCollisionPositionChange: () => void;
  93456. /**
  93457. * An event triggered when material is changed
  93458. */
  93459. onMaterialChangedObservable: Observable<AbstractMesh>;
  93460. /**
  93461. * Gets or sets the orientation for POV movement & rotation
  93462. */
  93463. definedFacingForward: boolean;
  93464. /** @hidden */
  93465. _occlusionQuery: Nullable<WebGLQuery>;
  93466. /** @hidden */
  93467. _renderingGroup: Nullable<RenderingGroup>;
  93468. /**
  93469. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93470. */
  93471. /**
  93472. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93473. */
  93474. visibility: number;
  93475. /** Gets or sets the alpha index used to sort transparent meshes
  93476. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  93477. */
  93478. alphaIndex: number;
  93479. /**
  93480. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  93481. */
  93482. isVisible: boolean;
  93483. /**
  93484. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  93485. */
  93486. isPickable: boolean;
  93487. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  93488. showSubMeshesBoundingBox: boolean;
  93489. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  93490. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  93491. */
  93492. isBlocker: boolean;
  93493. /**
  93494. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  93495. */
  93496. enablePointerMoveEvents: boolean;
  93497. /**
  93498. * Specifies the rendering group id for this mesh (0 by default)
  93499. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  93500. */
  93501. renderingGroupId: number;
  93502. private _material;
  93503. /** Gets or sets current material */
  93504. material: Nullable<Material>;
  93505. /**
  93506. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  93507. * @see http://doc.babylonjs.com/babylon101/shadows
  93508. */
  93509. receiveShadows: boolean;
  93510. /** Defines color to use when rendering outline */
  93511. outlineColor: Color3;
  93512. /** Define width to use when rendering outline */
  93513. outlineWidth: number;
  93514. /** Defines color to use when rendering overlay */
  93515. overlayColor: Color3;
  93516. /** Defines alpha to use when rendering overlay */
  93517. overlayAlpha: number;
  93518. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  93519. hasVertexAlpha: boolean;
  93520. /** 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) */
  93521. useVertexColors: boolean;
  93522. /**
  93523. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  93524. */
  93525. computeBonesUsingShaders: boolean;
  93526. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  93527. numBoneInfluencers: number;
  93528. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  93529. applyFog: boolean;
  93530. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  93531. useOctreeForRenderingSelection: boolean;
  93532. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  93533. useOctreeForPicking: boolean;
  93534. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  93535. useOctreeForCollisions: boolean;
  93536. /**
  93537. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  93538. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  93539. */
  93540. layerMask: number;
  93541. /**
  93542. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  93543. */
  93544. alwaysSelectAsActiveMesh: boolean;
  93545. /**
  93546. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  93547. */
  93548. doNotSyncBoundingInfo: boolean;
  93549. /**
  93550. * Gets or sets the current action manager
  93551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93552. */
  93553. actionManager: Nullable<AbstractActionManager>;
  93554. private _meshCollisionData;
  93555. /**
  93556. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  93557. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93558. */
  93559. ellipsoid: Vector3;
  93560. /**
  93561. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  93562. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93563. */
  93564. ellipsoidOffset: Vector3;
  93565. /**
  93566. * Gets or sets a collision mask used to mask collisions (default is -1).
  93567. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93568. */
  93569. collisionMask: number;
  93570. /**
  93571. * Gets or sets the current collision group mask (-1 by default).
  93572. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93573. */
  93574. collisionGroup: number;
  93575. /**
  93576. * Defines edge width used when edgesRenderer is enabled
  93577. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93578. */
  93579. edgesWidth: number;
  93580. /**
  93581. * Defines edge color used when edgesRenderer is enabled
  93582. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93583. */
  93584. edgesColor: Color4;
  93585. /** @hidden */
  93586. _edgesRenderer: Nullable<IEdgesRenderer>;
  93587. /** @hidden */
  93588. _masterMesh: Nullable<AbstractMesh>;
  93589. /** @hidden */
  93590. _boundingInfo: Nullable<BoundingInfo>;
  93591. /** @hidden */
  93592. _renderId: number;
  93593. /**
  93594. * Gets or sets the list of subMeshes
  93595. * @see http://doc.babylonjs.com/how_to/multi_materials
  93596. */
  93597. subMeshes: SubMesh[];
  93598. /** @hidden */
  93599. _intersectionsInProgress: AbstractMesh[];
  93600. /** @hidden */
  93601. _unIndexed: boolean;
  93602. /** @hidden */
  93603. _lightSources: Light[];
  93604. /** Gets the list of lights affecting that mesh */
  93605. readonly lightSources: Light[];
  93606. /** @hidden */
  93607. readonly _positions: Nullable<Vector3[]>;
  93608. /** @hidden */
  93609. _waitingData: {
  93610. lods: Nullable<any>;
  93611. actions: Nullable<any>;
  93612. freezeWorldMatrix: Nullable<boolean>;
  93613. };
  93614. /** @hidden */
  93615. _bonesTransformMatrices: Nullable<Float32Array>;
  93616. /** @hidden */
  93617. _transformMatrixTexture: Nullable<RawTexture>;
  93618. /**
  93619. * Gets or sets a skeleton to apply skining transformations
  93620. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93621. */
  93622. skeleton: Nullable<Skeleton>;
  93623. /**
  93624. * An event triggered when the mesh is rebuilt.
  93625. */
  93626. onRebuildObservable: Observable<AbstractMesh>;
  93627. /**
  93628. * Creates a new AbstractMesh
  93629. * @param name defines the name of the mesh
  93630. * @param scene defines the hosting scene
  93631. */
  93632. constructor(name: string, scene?: Nullable<Scene>);
  93633. /**
  93634. * Returns the string "AbstractMesh"
  93635. * @returns "AbstractMesh"
  93636. */
  93637. getClassName(): string;
  93638. /**
  93639. * Gets a string representation of the current mesh
  93640. * @param fullDetails defines a boolean indicating if full details must be included
  93641. * @returns a string representation of the current mesh
  93642. */
  93643. toString(fullDetails?: boolean): string;
  93644. /**
  93645. * @hidden
  93646. */
  93647. protected _getEffectiveParent(): Nullable<Node>;
  93648. /** @hidden */
  93649. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93650. /** @hidden */
  93651. _rebuild(): void;
  93652. /** @hidden */
  93653. _resyncLightSources(): void;
  93654. /** @hidden */
  93655. _resyncLighSource(light: Light): void;
  93656. /** @hidden */
  93657. _unBindEffect(): void;
  93658. /** @hidden */
  93659. _removeLightSource(light: Light, dispose: boolean): void;
  93660. private _markSubMeshesAsDirty;
  93661. /** @hidden */
  93662. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  93663. /** @hidden */
  93664. _markSubMeshesAsAttributesDirty(): void;
  93665. /** @hidden */
  93666. _markSubMeshesAsMiscDirty(): void;
  93667. /**
  93668. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  93669. */
  93670. scaling: Vector3;
  93671. /**
  93672. * Returns true if the mesh is blocked. Implemented by child classes
  93673. */
  93674. readonly isBlocked: boolean;
  93675. /**
  93676. * Returns the mesh itself by default. Implemented by child classes
  93677. * @param camera defines the camera to use to pick the right LOD level
  93678. * @returns the currentAbstractMesh
  93679. */
  93680. getLOD(camera: Camera): Nullable<AbstractMesh>;
  93681. /**
  93682. * Returns 0 by default. Implemented by child classes
  93683. * @returns an integer
  93684. */
  93685. getTotalVertices(): number;
  93686. /**
  93687. * Returns a positive integer : the total number of indices in this mesh geometry.
  93688. * @returns the numner of indices or zero if the mesh has no geometry.
  93689. */
  93690. getTotalIndices(): number;
  93691. /**
  93692. * Returns null by default. Implemented by child classes
  93693. * @returns null
  93694. */
  93695. getIndices(): Nullable<IndicesArray>;
  93696. /**
  93697. * Returns the array of the requested vertex data kind. Implemented by child classes
  93698. * @param kind defines the vertex data kind to use
  93699. * @returns null
  93700. */
  93701. getVerticesData(kind: string): Nullable<FloatArray>;
  93702. /**
  93703. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93704. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93705. * Note that a new underlying VertexBuffer object is created each call.
  93706. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93707. * @param kind defines vertex data kind:
  93708. * * VertexBuffer.PositionKind
  93709. * * VertexBuffer.UVKind
  93710. * * VertexBuffer.UV2Kind
  93711. * * VertexBuffer.UV3Kind
  93712. * * VertexBuffer.UV4Kind
  93713. * * VertexBuffer.UV5Kind
  93714. * * VertexBuffer.UV6Kind
  93715. * * VertexBuffer.ColorKind
  93716. * * VertexBuffer.MatricesIndicesKind
  93717. * * VertexBuffer.MatricesIndicesExtraKind
  93718. * * VertexBuffer.MatricesWeightsKind
  93719. * * VertexBuffer.MatricesWeightsExtraKind
  93720. * @param data defines the data source
  93721. * @param updatable defines if the data must be flagged as updatable (or static)
  93722. * @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
  93723. * @returns the current mesh
  93724. */
  93725. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93726. /**
  93727. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93728. * If the mesh has no geometry, it is simply returned as it is.
  93729. * @param kind defines vertex data kind:
  93730. * * VertexBuffer.PositionKind
  93731. * * VertexBuffer.UVKind
  93732. * * VertexBuffer.UV2Kind
  93733. * * VertexBuffer.UV3Kind
  93734. * * VertexBuffer.UV4Kind
  93735. * * VertexBuffer.UV5Kind
  93736. * * VertexBuffer.UV6Kind
  93737. * * VertexBuffer.ColorKind
  93738. * * VertexBuffer.MatricesIndicesKind
  93739. * * VertexBuffer.MatricesIndicesExtraKind
  93740. * * VertexBuffer.MatricesWeightsKind
  93741. * * VertexBuffer.MatricesWeightsExtraKind
  93742. * @param data defines the data source
  93743. * @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
  93744. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  93745. * @returns the current mesh
  93746. */
  93747. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93748. /**
  93749. * Sets the mesh indices,
  93750. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93751. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93752. * @param totalVertices Defines the total number of vertices
  93753. * @returns the current mesh
  93754. */
  93755. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93756. /**
  93757. * Gets a boolean indicating if specific vertex data is present
  93758. * @param kind defines the vertex data kind to use
  93759. * @returns true is data kind is present
  93760. */
  93761. isVerticesDataPresent(kind: string): boolean;
  93762. /**
  93763. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93764. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93765. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93766. * @returns a BoundingInfo
  93767. */
  93768. getBoundingInfo(): BoundingInfo;
  93769. /**
  93770. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93771. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93772. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93773. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93774. * @returns the current mesh
  93775. */
  93776. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93777. /**
  93778. * Overwrite the current bounding info
  93779. * @param boundingInfo defines the new bounding info
  93780. * @returns the current mesh
  93781. */
  93782. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93783. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93784. readonly useBones: boolean;
  93785. /** @hidden */
  93786. _preActivate(): void;
  93787. /** @hidden */
  93788. _preActivateForIntermediateRendering(renderId: number): void;
  93789. /** @hidden */
  93790. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93791. /** @hidden */
  93792. _postActivate(): void;
  93793. /** @hidden */
  93794. _freeze(): void;
  93795. /** @hidden */
  93796. _unFreeze(): void;
  93797. /**
  93798. * Gets the current world matrix
  93799. * @returns a Matrix
  93800. */
  93801. getWorldMatrix(): Matrix;
  93802. /** @hidden */
  93803. _getWorldMatrixDeterminant(): number;
  93804. /**
  93805. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93806. */
  93807. readonly isAnInstance: boolean;
  93808. /**
  93809. * Gets a boolean indicating if this mesh has instances
  93810. */
  93811. readonly hasInstances: boolean;
  93812. /**
  93813. * Perform relative position change from the point of view of behind the front of the mesh.
  93814. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93815. * Supports definition of mesh facing forward or backward
  93816. * @param amountRight defines the distance on the right axis
  93817. * @param amountUp defines the distance on the up axis
  93818. * @param amountForward defines the distance on the forward axis
  93819. * @returns the current mesh
  93820. */
  93821. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93822. /**
  93823. * Calculate relative position change from the point of view of behind the front of the mesh.
  93824. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93825. * Supports definition of mesh facing forward or backward
  93826. * @param amountRight defines the distance on the right axis
  93827. * @param amountUp defines the distance on the up axis
  93828. * @param amountForward defines the distance on the forward axis
  93829. * @returns the new displacement vector
  93830. */
  93831. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93832. /**
  93833. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93834. * Supports definition of mesh facing forward or backward
  93835. * @param flipBack defines the flip
  93836. * @param twirlClockwise defines the twirl
  93837. * @param tiltRight defines the tilt
  93838. * @returns the current mesh
  93839. */
  93840. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93841. /**
  93842. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93843. * Supports definition of mesh facing forward or backward.
  93844. * @param flipBack defines the flip
  93845. * @param twirlClockwise defines the twirl
  93846. * @param tiltRight defines the tilt
  93847. * @returns the new rotation vector
  93848. */
  93849. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93850. /**
  93851. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93852. * This means the mesh underlying bounding box and sphere are recomputed.
  93853. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93854. * @returns the current mesh
  93855. */
  93856. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93857. /** @hidden */
  93858. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93859. /** @hidden */
  93860. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93861. /** @hidden */
  93862. _updateBoundingInfo(): AbstractMesh;
  93863. /** @hidden */
  93864. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93865. /** @hidden */
  93866. protected _afterComputeWorldMatrix(): void;
  93867. /** @hidden */
  93868. readonly _effectiveMesh: AbstractMesh;
  93869. /**
  93870. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93871. * A mesh is in the frustum if its bounding box intersects the frustum
  93872. * @param frustumPlanes defines the frustum to test
  93873. * @returns true if the mesh is in the frustum planes
  93874. */
  93875. isInFrustum(frustumPlanes: Plane[]): boolean;
  93876. /**
  93877. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93878. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93879. * @param frustumPlanes defines the frustum to test
  93880. * @returns true if the mesh is completely in the frustum planes
  93881. */
  93882. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93883. /**
  93884. * True if the mesh intersects another mesh or a SolidParticle object
  93885. * @param mesh defines a target mesh or SolidParticle to test
  93886. * @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)
  93887. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93888. * @returns true if there is an intersection
  93889. */
  93890. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93891. /**
  93892. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93893. * @param point defines the point to test
  93894. * @returns true if there is an intersection
  93895. */
  93896. intersectsPoint(point: Vector3): boolean;
  93897. /**
  93898. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93899. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93900. */
  93901. checkCollisions: boolean;
  93902. /**
  93903. * Gets Collider object used to compute collisions (not physics)
  93904. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93905. */
  93906. readonly collider: Nullable<Collider>;
  93907. /**
  93908. * Move the mesh using collision engine
  93909. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93910. * @param displacement defines the requested displacement vector
  93911. * @returns the current mesh
  93912. */
  93913. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93914. private _onCollisionPositionChange;
  93915. /** @hidden */
  93916. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93917. /** @hidden */
  93918. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93919. /** @hidden */
  93920. _checkCollision(collider: Collider): AbstractMesh;
  93921. /** @hidden */
  93922. _generatePointsArray(): boolean;
  93923. /**
  93924. * Checks if the passed Ray intersects with the mesh
  93925. * @param ray defines the ray to use
  93926. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93927. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93928. * @returns the picking info
  93929. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93930. */
  93931. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93932. /**
  93933. * Clones the current mesh
  93934. * @param name defines the mesh name
  93935. * @param newParent defines the new mesh parent
  93936. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93937. * @returns the new mesh
  93938. */
  93939. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93940. /**
  93941. * Disposes all the submeshes of the current meshnp
  93942. * @returns the current mesh
  93943. */
  93944. releaseSubMeshes(): AbstractMesh;
  93945. /**
  93946. * Releases resources associated with this abstract mesh.
  93947. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93948. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93949. */
  93950. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93951. /**
  93952. * Adds the passed mesh as a child to the current mesh
  93953. * @param mesh defines the child mesh
  93954. * @returns the current mesh
  93955. */
  93956. addChild(mesh: AbstractMesh): AbstractMesh;
  93957. /**
  93958. * Removes the passed mesh from the current mesh children list
  93959. * @param mesh defines the child mesh
  93960. * @returns the current mesh
  93961. */
  93962. removeChild(mesh: AbstractMesh): AbstractMesh;
  93963. /** @hidden */
  93964. private _initFacetData;
  93965. /**
  93966. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93967. * This method can be called within the render loop.
  93968. * 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
  93969. * @returns the current mesh
  93970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93971. */
  93972. updateFacetData(): AbstractMesh;
  93973. /**
  93974. * Returns the facetLocalNormals array.
  93975. * The normals are expressed in the mesh local spac
  93976. * @returns an array of Vector3
  93977. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93978. */
  93979. getFacetLocalNormals(): Vector3[];
  93980. /**
  93981. * Returns the facetLocalPositions array.
  93982. * The facet positions are expressed in the mesh local space
  93983. * @returns an array of Vector3
  93984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93985. */
  93986. getFacetLocalPositions(): Vector3[];
  93987. /**
  93988. * Returns the facetLocalPartioning array
  93989. * @returns an array of array of numbers
  93990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93991. */
  93992. getFacetLocalPartitioning(): number[][];
  93993. /**
  93994. * Returns the i-th facet position in the world system.
  93995. * This method allocates a new Vector3 per call
  93996. * @param i defines the facet index
  93997. * @returns a new Vector3
  93998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93999. */
  94000. getFacetPosition(i: number): Vector3;
  94001. /**
  94002. * Sets the reference Vector3 with the i-th facet position in the world system
  94003. * @param i defines the facet index
  94004. * @param ref defines the target vector
  94005. * @returns the current mesh
  94006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94007. */
  94008. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  94009. /**
  94010. * Returns the i-th facet normal in the world system.
  94011. * This method allocates a new Vector3 per call
  94012. * @param i defines the facet index
  94013. * @returns a new Vector3
  94014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94015. */
  94016. getFacetNormal(i: number): Vector3;
  94017. /**
  94018. * Sets the reference Vector3 with the i-th facet normal in the world system
  94019. * @param i defines the facet index
  94020. * @param ref defines the target vector
  94021. * @returns the current mesh
  94022. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94023. */
  94024. getFacetNormalToRef(i: number, ref: Vector3): this;
  94025. /**
  94026. * 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)
  94027. * @param x defines x coordinate
  94028. * @param y defines y coordinate
  94029. * @param z defines z coordinate
  94030. * @returns the array of facet indexes
  94031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94032. */
  94033. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  94034. /**
  94035. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94036. * @param projected sets as the (x,y,z) world projection on the facet
  94037. * @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
  94038. * @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
  94039. * @param x defines x coordinate
  94040. * @param y defines y coordinate
  94041. * @param z defines z coordinate
  94042. * @returns the face index if found (or null instead)
  94043. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94044. */
  94045. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94046. /**
  94047. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94048. * @param projected sets as the (x,y,z) local projection on the facet
  94049. * @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
  94050. * @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
  94051. * @param x defines x coordinate
  94052. * @param y defines y coordinate
  94053. * @param z defines z coordinate
  94054. * @returns the face index if found (or null instead)
  94055. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94056. */
  94057. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94058. /**
  94059. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94060. * @returns the parameters
  94061. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94062. */
  94063. getFacetDataParameters(): any;
  94064. /**
  94065. * Disables the feature FacetData and frees the related memory
  94066. * @returns the current mesh
  94067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94068. */
  94069. disableFacetData(): AbstractMesh;
  94070. /**
  94071. * Updates the AbstractMesh indices array
  94072. * @param indices defines the data source
  94073. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94074. * @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)
  94075. * @returns the current mesh
  94076. */
  94077. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94078. /**
  94079. * Creates new normals data for the mesh
  94080. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94081. * @returns the current mesh
  94082. */
  94083. createNormals(updatable: boolean): AbstractMesh;
  94084. /**
  94085. * Align the mesh with a normal
  94086. * @param normal defines the normal to use
  94087. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94088. * @returns the current mesh
  94089. */
  94090. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  94091. /** @hidden */
  94092. _checkOcclusionQuery(): boolean;
  94093. /**
  94094. * Disables the mesh edge rendering mode
  94095. * @returns the currentAbstractMesh
  94096. */
  94097. disableEdgesRendering(): AbstractMesh;
  94098. /**
  94099. * Enables the edge rendering mode on the mesh.
  94100. * This mode makes the mesh edges visible
  94101. * @param epsilon defines the maximal distance between two angles to detect a face
  94102. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94103. * @returns the currentAbstractMesh
  94104. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94105. */
  94106. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94107. }
  94108. }
  94109. declare module BABYLON {
  94110. /**
  94111. * Interface used to define ActionEvent
  94112. */
  94113. export interface IActionEvent {
  94114. /** The mesh or sprite that triggered the action */
  94115. source: any;
  94116. /** The X mouse cursor position at the time of the event */
  94117. pointerX: number;
  94118. /** The Y mouse cursor position at the time of the event */
  94119. pointerY: number;
  94120. /** The mesh that is currently pointed at (can be null) */
  94121. meshUnderPointer: Nullable<AbstractMesh>;
  94122. /** the original (browser) event that triggered the ActionEvent */
  94123. sourceEvent?: any;
  94124. /** additional data for the event */
  94125. additionalData?: any;
  94126. }
  94127. /**
  94128. * ActionEvent is the event being sent when an action is triggered.
  94129. */
  94130. export class ActionEvent implements IActionEvent {
  94131. /** The mesh or sprite that triggered the action */
  94132. source: any;
  94133. /** The X mouse cursor position at the time of the event */
  94134. pointerX: number;
  94135. /** The Y mouse cursor position at the time of the event */
  94136. pointerY: number;
  94137. /** The mesh that is currently pointed at (can be null) */
  94138. meshUnderPointer: Nullable<AbstractMesh>;
  94139. /** the original (browser) event that triggered the ActionEvent */
  94140. sourceEvent?: any;
  94141. /** additional data for the event */
  94142. additionalData?: any;
  94143. /**
  94144. * Creates a new ActionEvent
  94145. * @param source The mesh or sprite that triggered the action
  94146. * @param pointerX The X mouse cursor position at the time of the event
  94147. * @param pointerY The Y mouse cursor position at the time of the event
  94148. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  94149. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  94150. * @param additionalData additional data for the event
  94151. */
  94152. constructor(
  94153. /** The mesh or sprite that triggered the action */
  94154. source: any,
  94155. /** The X mouse cursor position at the time of the event */
  94156. pointerX: number,
  94157. /** The Y mouse cursor position at the time of the event */
  94158. pointerY: number,
  94159. /** The mesh that is currently pointed at (can be null) */
  94160. meshUnderPointer: Nullable<AbstractMesh>,
  94161. /** the original (browser) event that triggered the ActionEvent */
  94162. sourceEvent?: any,
  94163. /** additional data for the event */
  94164. additionalData?: any);
  94165. /**
  94166. * Helper function to auto-create an ActionEvent from a source mesh.
  94167. * @param source The source mesh that triggered the event
  94168. * @param evt The original (browser) event
  94169. * @param additionalData additional data for the event
  94170. * @returns the new ActionEvent
  94171. */
  94172. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  94173. /**
  94174. * Helper function to auto-create an ActionEvent from a source sprite
  94175. * @param source The source sprite that triggered the event
  94176. * @param scene Scene associated with the sprite
  94177. * @param evt The original (browser) event
  94178. * @param additionalData additional data for the event
  94179. * @returns the new ActionEvent
  94180. */
  94181. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  94182. /**
  94183. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  94184. * @param scene the scene where the event occurred
  94185. * @param evt The original (browser) event
  94186. * @returns the new ActionEvent
  94187. */
  94188. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  94189. /**
  94190. * Helper function to auto-create an ActionEvent from a primitive
  94191. * @param prim defines the target primitive
  94192. * @param pointerPos defines the pointer position
  94193. * @param evt The original (browser) event
  94194. * @param additionalData additional data for the event
  94195. * @returns the new ActionEvent
  94196. */
  94197. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  94198. }
  94199. }
  94200. declare module BABYLON {
  94201. /**
  94202. * Abstract class used to decouple action Manager from scene and meshes.
  94203. * Do not instantiate.
  94204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94205. */
  94206. export abstract class AbstractActionManager implements IDisposable {
  94207. /** Gets the list of active triggers */
  94208. static Triggers: {
  94209. [key: string]: number;
  94210. };
  94211. /** Gets the cursor to use when hovering items */
  94212. hoverCursor: string;
  94213. /** Gets the list of actions */
  94214. actions: IAction[];
  94215. /**
  94216. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  94217. */
  94218. isRecursive: boolean;
  94219. /**
  94220. * Releases all associated resources
  94221. */
  94222. abstract dispose(): void;
  94223. /**
  94224. * Does this action manager has pointer triggers
  94225. */
  94226. abstract readonly hasPointerTriggers: boolean;
  94227. /**
  94228. * Does this action manager has pick triggers
  94229. */
  94230. abstract readonly hasPickTriggers: boolean;
  94231. /**
  94232. * Process a specific trigger
  94233. * @param trigger defines the trigger to process
  94234. * @param evt defines the event details to be processed
  94235. */
  94236. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  94237. /**
  94238. * Does this action manager handles actions of any of the given triggers
  94239. * @param triggers defines the triggers to be tested
  94240. * @return a boolean indicating whether one (or more) of the triggers is handled
  94241. */
  94242. abstract hasSpecificTriggers(triggers: number[]): boolean;
  94243. /**
  94244. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94245. * speed.
  94246. * @param triggerA defines the trigger to be tested
  94247. * @param triggerB defines the trigger to be tested
  94248. * @return a boolean indicating whether one (or more) of the triggers is handled
  94249. */
  94250. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94251. /**
  94252. * Does this action manager handles actions of a given trigger
  94253. * @param trigger defines the trigger to be tested
  94254. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94255. * @return whether the trigger is handled
  94256. */
  94257. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94258. /**
  94259. * Serialize this manager to a JSON object
  94260. * @param name defines the property name to store this manager
  94261. * @returns a JSON representation of this manager
  94262. */
  94263. abstract serialize(name: string): any;
  94264. /**
  94265. * Registers an action to this action manager
  94266. * @param action defines the action to be registered
  94267. * @return the action amended (prepared) after registration
  94268. */
  94269. abstract registerAction(action: IAction): Nullable<IAction>;
  94270. /**
  94271. * Unregisters an action to this action manager
  94272. * @param action defines the action to be unregistered
  94273. * @return a boolean indicating whether the action has been unregistered
  94274. */
  94275. abstract unregisterAction(action: IAction): Boolean;
  94276. /**
  94277. * Does exist one action manager with at least one trigger
  94278. **/
  94279. static readonly HasTriggers: boolean;
  94280. /**
  94281. * Does exist one action manager with at least one pick trigger
  94282. **/
  94283. static readonly HasPickTriggers: boolean;
  94284. /**
  94285. * Does exist one action manager that handles actions of a given trigger
  94286. * @param trigger defines the trigger to be tested
  94287. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  94288. **/
  94289. static HasSpecificTrigger(trigger: number): boolean;
  94290. }
  94291. }
  94292. declare module BABYLON {
  94293. /**
  94294. * Defines how a node can be built from a string name.
  94295. */
  94296. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  94297. /**
  94298. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  94299. */
  94300. export class Node implements IBehaviorAware<Node> {
  94301. /** @hidden */
  94302. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  94303. private static _NodeConstructors;
  94304. /**
  94305. * Add a new node constructor
  94306. * @param type defines the type name of the node to construct
  94307. * @param constructorFunc defines the constructor function
  94308. */
  94309. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  94310. /**
  94311. * Returns a node constructor based on type name
  94312. * @param type defines the type name
  94313. * @param name defines the new node name
  94314. * @param scene defines the hosting scene
  94315. * @param options defines optional options to transmit to constructors
  94316. * @returns the new constructor or null
  94317. */
  94318. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  94319. /**
  94320. * Gets or sets the name of the node
  94321. */
  94322. name: string;
  94323. /**
  94324. * Gets or sets the id of the node
  94325. */
  94326. id: string;
  94327. /**
  94328. * Gets or sets the unique id of the node
  94329. */
  94330. uniqueId: number;
  94331. /**
  94332. * Gets or sets a string used to store user defined state for the node
  94333. */
  94334. state: string;
  94335. /**
  94336. * Gets or sets an object used to store user defined information for the node
  94337. */
  94338. metadata: any;
  94339. /**
  94340. * For internal use only. Please do not use.
  94341. */
  94342. reservedDataStore: any;
  94343. /**
  94344. * List of inspectable custom properties (used by the Inspector)
  94345. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94346. */
  94347. inspectableCustomProperties: IInspectable[];
  94348. private _doNotSerialize;
  94349. /**
  94350. * Gets or sets a boolean used to define if the node must be serialized
  94351. */
  94352. doNotSerialize: boolean;
  94353. /** @hidden */
  94354. _isDisposed: boolean;
  94355. /**
  94356. * Gets a list of Animations associated with the node
  94357. */
  94358. animations: Animation[];
  94359. protected _ranges: {
  94360. [name: string]: Nullable<AnimationRange>;
  94361. };
  94362. /**
  94363. * Callback raised when the node is ready to be used
  94364. */
  94365. onReady: Nullable<(node: Node) => void>;
  94366. private _isEnabled;
  94367. private _isParentEnabled;
  94368. private _isReady;
  94369. /** @hidden */
  94370. _currentRenderId: number;
  94371. private _parentUpdateId;
  94372. /** @hidden */
  94373. _childUpdateId: number;
  94374. /** @hidden */
  94375. _waitingParentId: Nullable<string>;
  94376. /** @hidden */
  94377. _scene: Scene;
  94378. /** @hidden */
  94379. _cache: any;
  94380. private _parentNode;
  94381. private _children;
  94382. /** @hidden */
  94383. _worldMatrix: Matrix;
  94384. /** @hidden */
  94385. _worldMatrixDeterminant: number;
  94386. /** @hidden */
  94387. _worldMatrixDeterminantIsDirty: boolean;
  94388. /** @hidden */
  94389. private _sceneRootNodesIndex;
  94390. /**
  94391. * Gets a boolean indicating if the node has been disposed
  94392. * @returns true if the node was disposed
  94393. */
  94394. isDisposed(): boolean;
  94395. /**
  94396. * Gets or sets the parent of the node (without keeping the current position in the scene)
  94397. * @see https://doc.babylonjs.com/how_to/parenting
  94398. */
  94399. parent: Nullable<Node>;
  94400. private addToSceneRootNodes;
  94401. private removeFromSceneRootNodes;
  94402. private _animationPropertiesOverride;
  94403. /**
  94404. * Gets or sets the animation properties override
  94405. */
  94406. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94407. /**
  94408. * Gets a string idenfifying the name of the class
  94409. * @returns "Node" string
  94410. */
  94411. getClassName(): string;
  94412. /** @hidden */
  94413. readonly _isNode: boolean;
  94414. /**
  94415. * An event triggered when the mesh is disposed
  94416. */
  94417. onDisposeObservable: Observable<Node>;
  94418. private _onDisposeObserver;
  94419. /**
  94420. * Sets a callback that will be raised when the node will be disposed
  94421. */
  94422. onDispose: () => void;
  94423. /**
  94424. * Creates a new Node
  94425. * @param name the name and id to be given to this node
  94426. * @param scene the scene this node will be added to
  94427. * @param addToRootNodes the node will be added to scene.rootNodes
  94428. */
  94429. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  94430. /**
  94431. * Gets the scene of the node
  94432. * @returns a scene
  94433. */
  94434. getScene(): Scene;
  94435. /**
  94436. * Gets the engine of the node
  94437. * @returns a Engine
  94438. */
  94439. getEngine(): Engine;
  94440. private _behaviors;
  94441. /**
  94442. * Attach a behavior to the node
  94443. * @see http://doc.babylonjs.com/features/behaviour
  94444. * @param behavior defines the behavior to attach
  94445. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  94446. * @returns the current Node
  94447. */
  94448. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  94449. /**
  94450. * Remove an attached behavior
  94451. * @see http://doc.babylonjs.com/features/behaviour
  94452. * @param behavior defines the behavior to attach
  94453. * @returns the current Node
  94454. */
  94455. removeBehavior(behavior: Behavior<Node>): Node;
  94456. /**
  94457. * Gets the list of attached behaviors
  94458. * @see http://doc.babylonjs.com/features/behaviour
  94459. */
  94460. readonly behaviors: Behavior<Node>[];
  94461. /**
  94462. * Gets an attached behavior by name
  94463. * @param name defines the name of the behavior to look for
  94464. * @see http://doc.babylonjs.com/features/behaviour
  94465. * @returns null if behavior was not found else the requested behavior
  94466. */
  94467. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  94468. /**
  94469. * Returns the latest update of the World matrix
  94470. * @returns a Matrix
  94471. */
  94472. getWorldMatrix(): Matrix;
  94473. /** @hidden */
  94474. _getWorldMatrixDeterminant(): number;
  94475. /**
  94476. * Returns directly the latest state of the mesh World matrix.
  94477. * A Matrix is returned.
  94478. */
  94479. readonly worldMatrixFromCache: Matrix;
  94480. /** @hidden */
  94481. _initCache(): void;
  94482. /** @hidden */
  94483. updateCache(force?: boolean): void;
  94484. /** @hidden */
  94485. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94486. /** @hidden */
  94487. _updateCache(ignoreParentClass?: boolean): void;
  94488. /** @hidden */
  94489. _isSynchronized(): boolean;
  94490. /** @hidden */
  94491. _markSyncedWithParent(): void;
  94492. /** @hidden */
  94493. isSynchronizedWithParent(): boolean;
  94494. /** @hidden */
  94495. isSynchronized(): boolean;
  94496. /**
  94497. * Is this node ready to be used/rendered
  94498. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94499. * @return true if the node is ready
  94500. */
  94501. isReady(completeCheck?: boolean): boolean;
  94502. /**
  94503. * Is this node enabled?
  94504. * 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
  94505. * @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
  94506. * @return whether this node (and its parent) is enabled
  94507. */
  94508. isEnabled(checkAncestors?: boolean): boolean;
  94509. /** @hidden */
  94510. protected _syncParentEnabledState(): void;
  94511. /**
  94512. * Set the enabled state of this node
  94513. * @param value defines the new enabled state
  94514. */
  94515. setEnabled(value: boolean): void;
  94516. /**
  94517. * Is this node a descendant of the given node?
  94518. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  94519. * @param ancestor defines the parent node to inspect
  94520. * @returns a boolean indicating if this node is a descendant of the given node
  94521. */
  94522. isDescendantOf(ancestor: Node): boolean;
  94523. /** @hidden */
  94524. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  94525. /**
  94526. * Will return all nodes that have this node as ascendant
  94527. * @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
  94528. * @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
  94529. * @return all children nodes of all types
  94530. */
  94531. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  94532. /**
  94533. * Get all child-meshes of this node
  94534. * @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)
  94535. * @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
  94536. * @returns an array of AbstractMesh
  94537. */
  94538. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  94539. /**
  94540. * Get all direct children of this node
  94541. * @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
  94542. * @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)
  94543. * @returns an array of Node
  94544. */
  94545. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  94546. /** @hidden */
  94547. _setReady(state: boolean): void;
  94548. /**
  94549. * Get an animation by name
  94550. * @param name defines the name of the animation to look for
  94551. * @returns null if not found else the requested animation
  94552. */
  94553. getAnimationByName(name: string): Nullable<Animation>;
  94554. /**
  94555. * Creates an animation range for this node
  94556. * @param name defines the name of the range
  94557. * @param from defines the starting key
  94558. * @param to defines the end key
  94559. */
  94560. createAnimationRange(name: string, from: number, to: number): void;
  94561. /**
  94562. * Delete a specific animation range
  94563. * @param name defines the name of the range to delete
  94564. * @param deleteFrames defines if animation frames from the range must be deleted as well
  94565. */
  94566. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94567. /**
  94568. * Get an animation range by name
  94569. * @param name defines the name of the animation range to look for
  94570. * @returns null if not found else the requested animation range
  94571. */
  94572. getAnimationRange(name: string): Nullable<AnimationRange>;
  94573. /**
  94574. * Gets the list of all animation ranges defined on this node
  94575. * @returns an array
  94576. */
  94577. getAnimationRanges(): Nullable<AnimationRange>[];
  94578. /**
  94579. * Will start the animation sequence
  94580. * @param name defines the range frames for animation sequence
  94581. * @param loop defines if the animation should loop (false by default)
  94582. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  94583. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  94584. * @returns the object created for this animation. If range does not exist, it will return null
  94585. */
  94586. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94587. /**
  94588. * Serialize animation ranges into a JSON compatible object
  94589. * @returns serialization object
  94590. */
  94591. serializeAnimationRanges(): any;
  94592. /**
  94593. * Computes the world matrix of the node
  94594. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94595. * @returns the world matrix
  94596. */
  94597. computeWorldMatrix(force?: boolean): Matrix;
  94598. /**
  94599. * Releases resources associated with this node.
  94600. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94601. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94602. */
  94603. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94604. /**
  94605. * Parse animation range data from a serialization object and store them into a given node
  94606. * @param node defines where to store the animation ranges
  94607. * @param parsedNode defines the serialization object to read data from
  94608. * @param scene defines the hosting scene
  94609. */
  94610. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  94611. /**
  94612. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  94613. * @param includeDescendants Include bounding info from descendants as well (true by default)
  94614. * @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
  94615. * @returns the new bounding vectors
  94616. */
  94617. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  94618. min: Vector3;
  94619. max: Vector3;
  94620. };
  94621. }
  94622. }
  94623. declare module BABYLON {
  94624. /**
  94625. * @hidden
  94626. */
  94627. export class _IAnimationState {
  94628. key: number;
  94629. repeatCount: number;
  94630. workValue?: any;
  94631. loopMode?: number;
  94632. offsetValue?: any;
  94633. highLimitValue?: any;
  94634. }
  94635. /**
  94636. * Class used to store any kind of animation
  94637. */
  94638. export class Animation {
  94639. /**Name of the animation */
  94640. name: string;
  94641. /**Property to animate */
  94642. targetProperty: string;
  94643. /**The frames per second of the animation */
  94644. framePerSecond: number;
  94645. /**The data type of the animation */
  94646. dataType: number;
  94647. /**The loop mode of the animation */
  94648. loopMode?: number | undefined;
  94649. /**Specifies if blending should be enabled */
  94650. enableBlending?: boolean | undefined;
  94651. /**
  94652. * Use matrix interpolation instead of using direct key value when animating matrices
  94653. */
  94654. static AllowMatricesInterpolation: boolean;
  94655. /**
  94656. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  94657. */
  94658. static AllowMatrixDecomposeForInterpolation: boolean;
  94659. /**
  94660. * Stores the key frames of the animation
  94661. */
  94662. private _keys;
  94663. /**
  94664. * Stores the easing function of the animation
  94665. */
  94666. private _easingFunction;
  94667. /**
  94668. * @hidden Internal use only
  94669. */
  94670. _runtimeAnimations: RuntimeAnimation[];
  94671. /**
  94672. * The set of event that will be linked to this animation
  94673. */
  94674. private _events;
  94675. /**
  94676. * Stores an array of target property paths
  94677. */
  94678. targetPropertyPath: string[];
  94679. /**
  94680. * Stores the blending speed of the animation
  94681. */
  94682. blendingSpeed: number;
  94683. /**
  94684. * Stores the animation ranges for the animation
  94685. */
  94686. private _ranges;
  94687. /**
  94688. * @hidden Internal use
  94689. */
  94690. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  94691. /**
  94692. * Sets up an animation
  94693. * @param property The property to animate
  94694. * @param animationType The animation type to apply
  94695. * @param framePerSecond The frames per second of the animation
  94696. * @param easingFunction The easing function used in the animation
  94697. * @returns The created animation
  94698. */
  94699. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  94700. /**
  94701. * Create and start an animation on a node
  94702. * @param name defines the name of the global animation that will be run on all nodes
  94703. * @param node defines the root node where the animation will take place
  94704. * @param targetProperty defines property to animate
  94705. * @param framePerSecond defines the number of frame per second yo use
  94706. * @param totalFrame defines the number of frames in total
  94707. * @param from defines the initial value
  94708. * @param to defines the final value
  94709. * @param loopMode defines which loop mode you want to use (off by default)
  94710. * @param easingFunction defines the easing function to use (linear by default)
  94711. * @param onAnimationEnd defines the callback to call when animation end
  94712. * @returns the animatable created for this animation
  94713. */
  94714. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94715. /**
  94716. * Create and start an animation on a node and its descendants
  94717. * @param name defines the name of the global animation that will be run on all nodes
  94718. * @param node defines the root node where the animation will take place
  94719. * @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
  94720. * @param targetProperty defines property to animate
  94721. * @param framePerSecond defines the number of frame per second to use
  94722. * @param totalFrame defines the number of frames in total
  94723. * @param from defines the initial value
  94724. * @param to defines the final value
  94725. * @param loopMode defines which loop mode you want to use (off by default)
  94726. * @param easingFunction defines the easing function to use (linear by default)
  94727. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94728. * @returns the list of animatables created for all nodes
  94729. * @example https://www.babylonjs-playground.com/#MH0VLI
  94730. */
  94731. 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[]>;
  94732. /**
  94733. * Creates a new animation, merges it with the existing animations and starts it
  94734. * @param name Name of the animation
  94735. * @param node Node which contains the scene that begins the animations
  94736. * @param targetProperty Specifies which property to animate
  94737. * @param framePerSecond The frames per second of the animation
  94738. * @param totalFrame The total number of frames
  94739. * @param from The frame at the beginning of the animation
  94740. * @param to The frame at the end of the animation
  94741. * @param loopMode Specifies the loop mode of the animation
  94742. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  94743. * @param onAnimationEnd Callback to run once the animation is complete
  94744. * @returns Nullable animation
  94745. */
  94746. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94747. /**
  94748. * Transition property of an host to the target Value
  94749. * @param property The property to transition
  94750. * @param targetValue The target Value of the property
  94751. * @param host The object where the property to animate belongs
  94752. * @param scene Scene used to run the animation
  94753. * @param frameRate Framerate (in frame/s) to use
  94754. * @param transition The transition type we want to use
  94755. * @param duration The duration of the animation, in milliseconds
  94756. * @param onAnimationEnd Callback trigger at the end of the animation
  94757. * @returns Nullable animation
  94758. */
  94759. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94760. /**
  94761. * Return the array of runtime animations currently using this animation
  94762. */
  94763. readonly runtimeAnimations: RuntimeAnimation[];
  94764. /**
  94765. * Specifies if any of the runtime animations are currently running
  94766. */
  94767. readonly hasRunningRuntimeAnimations: boolean;
  94768. /**
  94769. * Initializes the animation
  94770. * @param name Name of the animation
  94771. * @param targetProperty Property to animate
  94772. * @param framePerSecond The frames per second of the animation
  94773. * @param dataType The data type of the animation
  94774. * @param loopMode The loop mode of the animation
  94775. * @param enableBlending Specifies if blending should be enabled
  94776. */
  94777. constructor(
  94778. /**Name of the animation */
  94779. name: string,
  94780. /**Property to animate */
  94781. targetProperty: string,
  94782. /**The frames per second of the animation */
  94783. framePerSecond: number,
  94784. /**The data type of the animation */
  94785. dataType: number,
  94786. /**The loop mode of the animation */
  94787. loopMode?: number | undefined,
  94788. /**Specifies if blending should be enabled */
  94789. enableBlending?: boolean | undefined);
  94790. /**
  94791. * Converts the animation to a string
  94792. * @param fullDetails support for multiple levels of logging within scene loading
  94793. * @returns String form of the animation
  94794. */
  94795. toString(fullDetails?: boolean): string;
  94796. /**
  94797. * Add an event to this animation
  94798. * @param event Event to add
  94799. */
  94800. addEvent(event: AnimationEvent): void;
  94801. /**
  94802. * Remove all events found at the given frame
  94803. * @param frame The frame to remove events from
  94804. */
  94805. removeEvents(frame: number): void;
  94806. /**
  94807. * Retrieves all the events from the animation
  94808. * @returns Events from the animation
  94809. */
  94810. getEvents(): AnimationEvent[];
  94811. /**
  94812. * Creates an animation range
  94813. * @param name Name of the animation range
  94814. * @param from Starting frame of the animation range
  94815. * @param to Ending frame of the animation
  94816. */
  94817. createRange(name: string, from: number, to: number): void;
  94818. /**
  94819. * Deletes an animation range by name
  94820. * @param name Name of the animation range to delete
  94821. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94822. */
  94823. deleteRange(name: string, deleteFrames?: boolean): void;
  94824. /**
  94825. * Gets the animation range by name, or null if not defined
  94826. * @param name Name of the animation range
  94827. * @returns Nullable animation range
  94828. */
  94829. getRange(name: string): Nullable<AnimationRange>;
  94830. /**
  94831. * Gets the key frames from the animation
  94832. * @returns The key frames of the animation
  94833. */
  94834. getKeys(): Array<IAnimationKey>;
  94835. /**
  94836. * Gets the highest frame rate of the animation
  94837. * @returns Highest frame rate of the animation
  94838. */
  94839. getHighestFrame(): number;
  94840. /**
  94841. * Gets the easing function of the animation
  94842. * @returns Easing function of the animation
  94843. */
  94844. getEasingFunction(): IEasingFunction;
  94845. /**
  94846. * Sets the easing function of the animation
  94847. * @param easingFunction A custom mathematical formula for animation
  94848. */
  94849. setEasingFunction(easingFunction: EasingFunction): void;
  94850. /**
  94851. * Interpolates a scalar linearly
  94852. * @param startValue Start value of the animation curve
  94853. * @param endValue End value of the animation curve
  94854. * @param gradient Scalar amount to interpolate
  94855. * @returns Interpolated scalar value
  94856. */
  94857. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94858. /**
  94859. * Interpolates a scalar cubically
  94860. * @param startValue Start value of the animation curve
  94861. * @param outTangent End tangent of the animation
  94862. * @param endValue End value of the animation curve
  94863. * @param inTangent Start tangent of the animation curve
  94864. * @param gradient Scalar amount to interpolate
  94865. * @returns Interpolated scalar value
  94866. */
  94867. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94868. /**
  94869. * Interpolates a quaternion using a spherical linear interpolation
  94870. * @param startValue Start value of the animation curve
  94871. * @param endValue End value of the animation curve
  94872. * @param gradient Scalar amount to interpolate
  94873. * @returns Interpolated quaternion value
  94874. */
  94875. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94876. /**
  94877. * Interpolates a quaternion cubically
  94878. * @param startValue Start value of the animation curve
  94879. * @param outTangent End tangent of the animation curve
  94880. * @param endValue End value of the animation curve
  94881. * @param inTangent Start tangent of the animation curve
  94882. * @param gradient Scalar amount to interpolate
  94883. * @returns Interpolated quaternion value
  94884. */
  94885. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94886. /**
  94887. * Interpolates a Vector3 linearl
  94888. * @param startValue Start value of the animation curve
  94889. * @param endValue End value of the animation curve
  94890. * @param gradient Scalar amount to interpolate
  94891. * @returns Interpolated scalar value
  94892. */
  94893. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94894. /**
  94895. * Interpolates a Vector3 cubically
  94896. * @param startValue Start value of the animation curve
  94897. * @param outTangent End tangent of the animation
  94898. * @param endValue End value of the animation curve
  94899. * @param inTangent Start tangent of the animation curve
  94900. * @param gradient Scalar amount to interpolate
  94901. * @returns InterpolatedVector3 value
  94902. */
  94903. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94904. /**
  94905. * Interpolates a Vector2 linearly
  94906. * @param startValue Start value of the animation curve
  94907. * @param endValue End value of the animation curve
  94908. * @param gradient Scalar amount to interpolate
  94909. * @returns Interpolated Vector2 value
  94910. */
  94911. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94912. /**
  94913. * Interpolates a Vector2 cubically
  94914. * @param startValue Start value of the animation curve
  94915. * @param outTangent End tangent of the animation
  94916. * @param endValue End value of the animation curve
  94917. * @param inTangent Start tangent of the animation curve
  94918. * @param gradient Scalar amount to interpolate
  94919. * @returns Interpolated Vector2 value
  94920. */
  94921. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94922. /**
  94923. * Interpolates a size linearly
  94924. * @param startValue Start value of the animation curve
  94925. * @param endValue End value of the animation curve
  94926. * @param gradient Scalar amount to interpolate
  94927. * @returns Interpolated Size value
  94928. */
  94929. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94930. /**
  94931. * Interpolates a Color3 linearly
  94932. * @param startValue Start value of the animation curve
  94933. * @param endValue End value of the animation curve
  94934. * @param gradient Scalar amount to interpolate
  94935. * @returns Interpolated Color3 value
  94936. */
  94937. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94938. /**
  94939. * Interpolates a Color4 linearly
  94940. * @param startValue Start value of the animation curve
  94941. * @param endValue End value of the animation curve
  94942. * @param gradient Scalar amount to interpolate
  94943. * @returns Interpolated Color3 value
  94944. */
  94945. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  94946. /**
  94947. * @hidden Internal use only
  94948. */
  94949. _getKeyValue(value: any): any;
  94950. /**
  94951. * @hidden Internal use only
  94952. */
  94953. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94954. /**
  94955. * Defines the function to use to interpolate matrices
  94956. * @param startValue defines the start matrix
  94957. * @param endValue defines the end matrix
  94958. * @param gradient defines the gradient between both matrices
  94959. * @param result defines an optional target matrix where to store the interpolation
  94960. * @returns the interpolated matrix
  94961. */
  94962. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94963. /**
  94964. * Makes a copy of the animation
  94965. * @returns Cloned animation
  94966. */
  94967. clone(): Animation;
  94968. /**
  94969. * Sets the key frames of the animation
  94970. * @param values The animation key frames to set
  94971. */
  94972. setKeys(values: Array<IAnimationKey>): void;
  94973. /**
  94974. * Serializes the animation to an object
  94975. * @returns Serialized object
  94976. */
  94977. serialize(): any;
  94978. /**
  94979. * Float animation type
  94980. */
  94981. static readonly ANIMATIONTYPE_FLOAT: number;
  94982. /**
  94983. * Vector3 animation type
  94984. */
  94985. static readonly ANIMATIONTYPE_VECTOR3: number;
  94986. /**
  94987. * Quaternion animation type
  94988. */
  94989. static readonly ANIMATIONTYPE_QUATERNION: number;
  94990. /**
  94991. * Matrix animation type
  94992. */
  94993. static readonly ANIMATIONTYPE_MATRIX: number;
  94994. /**
  94995. * Color3 animation type
  94996. */
  94997. static readonly ANIMATIONTYPE_COLOR3: number;
  94998. /**
  94999. * Color3 animation type
  95000. */
  95001. static readonly ANIMATIONTYPE_COLOR4: number;
  95002. /**
  95003. * Vector2 animation type
  95004. */
  95005. static readonly ANIMATIONTYPE_VECTOR2: number;
  95006. /**
  95007. * Size animation type
  95008. */
  95009. static readonly ANIMATIONTYPE_SIZE: number;
  95010. /**
  95011. * Relative Loop Mode
  95012. */
  95013. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  95014. /**
  95015. * Cycle Loop Mode
  95016. */
  95017. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  95018. /**
  95019. * Constant Loop Mode
  95020. */
  95021. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  95022. /** @hidden */
  95023. static _UniversalLerp(left: any, right: any, amount: number): any;
  95024. /**
  95025. * Parses an animation object and creates an animation
  95026. * @param parsedAnimation Parsed animation object
  95027. * @returns Animation object
  95028. */
  95029. static Parse(parsedAnimation: any): Animation;
  95030. /**
  95031. * Appends the serialized animations from the source animations
  95032. * @param source Source containing the animations
  95033. * @param destination Target to store the animations
  95034. */
  95035. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95036. }
  95037. }
  95038. declare module BABYLON {
  95039. /**
  95040. * Interface containing an array of animations
  95041. */
  95042. export interface IAnimatable {
  95043. /**
  95044. * Array of animations
  95045. */
  95046. animations: Nullable<Array<Animation>>;
  95047. }
  95048. }
  95049. declare module BABYLON {
  95050. /**
  95051. * This represents all the required information to add a fresnel effect on a material:
  95052. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95053. */
  95054. export class FresnelParameters {
  95055. private _isEnabled;
  95056. /**
  95057. * Define if the fresnel effect is enable or not.
  95058. */
  95059. isEnabled: boolean;
  95060. /**
  95061. * Define the color used on edges (grazing angle)
  95062. */
  95063. leftColor: Color3;
  95064. /**
  95065. * Define the color used on center
  95066. */
  95067. rightColor: Color3;
  95068. /**
  95069. * Define bias applied to computed fresnel term
  95070. */
  95071. bias: number;
  95072. /**
  95073. * Defined the power exponent applied to fresnel term
  95074. */
  95075. power: number;
  95076. /**
  95077. * Clones the current fresnel and its valuues
  95078. * @returns a clone fresnel configuration
  95079. */
  95080. clone(): FresnelParameters;
  95081. /**
  95082. * Serializes the current fresnel parameters to a JSON representation.
  95083. * @return the JSON serialization
  95084. */
  95085. serialize(): any;
  95086. /**
  95087. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95088. * @param parsedFresnelParameters Define the JSON representation
  95089. * @returns the parsed parameters
  95090. */
  95091. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95092. }
  95093. }
  95094. declare module BABYLON {
  95095. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  95096. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95097. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95098. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95099. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95100. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95101. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95102. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95103. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95104. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95105. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95106. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95107. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95108. /**
  95109. * Decorator used to define property that can be serialized as reference to a camera
  95110. * @param sourceName defines the name of the property to decorate
  95111. */
  95112. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95113. /**
  95114. * Class used to help serialization objects
  95115. */
  95116. export class SerializationHelper {
  95117. /** @hidden */
  95118. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95119. /** @hidden */
  95120. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95121. /** @hidden */
  95122. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95123. /** @hidden */
  95124. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95125. /**
  95126. * Appends the serialized animations from the source animations
  95127. * @param source Source containing the animations
  95128. * @param destination Target to store the animations
  95129. */
  95130. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95131. /**
  95132. * Static function used to serialized a specific entity
  95133. * @param entity defines the entity to serialize
  95134. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95135. * @returns a JSON compatible object representing the serialization of the entity
  95136. */
  95137. static Serialize<T>(entity: T, serializationObject?: any): any;
  95138. /**
  95139. * Creates a new entity from a serialization data object
  95140. * @param creationFunction defines a function used to instanciated the new entity
  95141. * @param source defines the source serialization data
  95142. * @param scene defines the hosting scene
  95143. * @param rootUrl defines the root url for resources
  95144. * @returns a new entity
  95145. */
  95146. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  95147. /**
  95148. * Clones an object
  95149. * @param creationFunction defines the function used to instanciate the new object
  95150. * @param source defines the source object
  95151. * @returns the cloned object
  95152. */
  95153. static Clone<T>(creationFunction: () => T, source: T): T;
  95154. /**
  95155. * Instanciates a new object based on a source one (some data will be shared between both object)
  95156. * @param creationFunction defines the function used to instanciate the new object
  95157. * @param source defines the source object
  95158. * @returns the new object
  95159. */
  95160. static Instanciate<T>(creationFunction: () => T, source: T): T;
  95161. }
  95162. }
  95163. declare module BABYLON {
  95164. /**
  95165. * Class used to manipulate GUIDs
  95166. */
  95167. export class GUID {
  95168. /**
  95169. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95170. * Be aware Math.random() could cause collisions, but:
  95171. * "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"
  95172. * @returns a pseudo random id
  95173. */
  95174. static RandomId(): string;
  95175. }
  95176. }
  95177. declare module BABYLON {
  95178. /**
  95179. * Base class of all the textures in babylon.
  95180. * It groups all the common properties the materials, post process, lights... might need
  95181. * in order to make a correct use of the texture.
  95182. */
  95183. export class BaseTexture implements IAnimatable {
  95184. /**
  95185. * Default anisotropic filtering level for the application.
  95186. * It is set to 4 as a good tradeoff between perf and quality.
  95187. */
  95188. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  95189. /**
  95190. * Gets or sets the unique id of the texture
  95191. */
  95192. uniqueId: number;
  95193. /**
  95194. * Define the name of the texture.
  95195. */
  95196. name: string;
  95197. /**
  95198. * Gets or sets an object used to store user defined information.
  95199. */
  95200. metadata: any;
  95201. /**
  95202. * For internal use only. Please do not use.
  95203. */
  95204. reservedDataStore: any;
  95205. private _hasAlpha;
  95206. /**
  95207. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  95208. */
  95209. hasAlpha: boolean;
  95210. /**
  95211. * Defines if the alpha value should be determined via the rgb values.
  95212. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  95213. */
  95214. getAlphaFromRGB: boolean;
  95215. /**
  95216. * Intensity or strength of the texture.
  95217. * It is commonly used by materials to fine tune the intensity of the texture
  95218. */
  95219. level: number;
  95220. /**
  95221. * Define the UV chanel to use starting from 0 and defaulting to 0.
  95222. * This is part of the texture as textures usually maps to one uv set.
  95223. */
  95224. coordinatesIndex: number;
  95225. private _coordinatesMode;
  95226. /**
  95227. * How a texture is mapped.
  95228. *
  95229. * | Value | Type | Description |
  95230. * | ----- | ----------------------------------- | ----------- |
  95231. * | 0 | EXPLICIT_MODE | |
  95232. * | 1 | SPHERICAL_MODE | |
  95233. * | 2 | PLANAR_MODE | |
  95234. * | 3 | CUBIC_MODE | |
  95235. * | 4 | PROJECTION_MODE | |
  95236. * | 5 | SKYBOX_MODE | |
  95237. * | 6 | INVCUBIC_MODE | |
  95238. * | 7 | EQUIRECTANGULAR_MODE | |
  95239. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  95240. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  95241. */
  95242. coordinatesMode: number;
  95243. /**
  95244. * | Value | Type | Description |
  95245. * | ----- | ------------------ | ----------- |
  95246. * | 0 | CLAMP_ADDRESSMODE | |
  95247. * | 1 | WRAP_ADDRESSMODE | |
  95248. * | 2 | MIRROR_ADDRESSMODE | |
  95249. */
  95250. wrapU: number;
  95251. /**
  95252. * | Value | Type | Description |
  95253. * | ----- | ------------------ | ----------- |
  95254. * | 0 | CLAMP_ADDRESSMODE | |
  95255. * | 1 | WRAP_ADDRESSMODE | |
  95256. * | 2 | MIRROR_ADDRESSMODE | |
  95257. */
  95258. wrapV: number;
  95259. /**
  95260. * | Value | Type | Description |
  95261. * | ----- | ------------------ | ----------- |
  95262. * | 0 | CLAMP_ADDRESSMODE | |
  95263. * | 1 | WRAP_ADDRESSMODE | |
  95264. * | 2 | MIRROR_ADDRESSMODE | |
  95265. */
  95266. wrapR: number;
  95267. /**
  95268. * With compliant hardware and browser (supporting anisotropic filtering)
  95269. * this defines the level of anisotropic filtering in the texture.
  95270. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  95271. */
  95272. anisotropicFilteringLevel: number;
  95273. /**
  95274. * Define if the texture is a cube texture or if false a 2d texture.
  95275. */
  95276. isCube: boolean;
  95277. /**
  95278. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  95279. */
  95280. is3D: boolean;
  95281. /**
  95282. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  95283. * HDR texture are usually stored in linear space.
  95284. * This only impacts the PBR and Background materials
  95285. */
  95286. gammaSpace: boolean;
  95287. /**
  95288. * Gets or sets whether or not the texture contains RGBD data.
  95289. */
  95290. isRGBD: boolean;
  95291. /**
  95292. * Is Z inverted in the texture (useful in a cube texture).
  95293. */
  95294. invertZ: boolean;
  95295. /**
  95296. * Are mip maps generated for this texture or not.
  95297. */
  95298. readonly noMipmap: boolean;
  95299. /**
  95300. * @hidden
  95301. */
  95302. lodLevelInAlpha: boolean;
  95303. /**
  95304. * With prefiltered texture, defined the offset used during the prefiltering steps.
  95305. */
  95306. lodGenerationOffset: number;
  95307. /**
  95308. * With prefiltered texture, defined the scale used during the prefiltering steps.
  95309. */
  95310. lodGenerationScale: number;
  95311. /**
  95312. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  95313. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  95314. * average roughness values.
  95315. */
  95316. linearSpecularLOD: boolean;
  95317. /**
  95318. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  95319. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  95320. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  95321. */
  95322. irradianceTexture: Nullable<BaseTexture>;
  95323. /**
  95324. * Define if the texture is a render target.
  95325. */
  95326. isRenderTarget: boolean;
  95327. /**
  95328. * Define the unique id of the texture in the scene.
  95329. */
  95330. readonly uid: string;
  95331. /**
  95332. * Return a string representation of the texture.
  95333. * @returns the texture as a string
  95334. */
  95335. toString(): string;
  95336. /**
  95337. * Get the class name of the texture.
  95338. * @returns "BaseTexture"
  95339. */
  95340. getClassName(): string;
  95341. /**
  95342. * Define the list of animation attached to the texture.
  95343. */
  95344. animations: Animation[];
  95345. /**
  95346. * An event triggered when the texture is disposed.
  95347. */
  95348. onDisposeObservable: Observable<BaseTexture>;
  95349. private _onDisposeObserver;
  95350. /**
  95351. * Callback triggered when the texture has been disposed.
  95352. * Kept for back compatibility, you can use the onDisposeObservable instead.
  95353. */
  95354. onDispose: () => void;
  95355. /**
  95356. * Define the current state of the loading sequence when in delayed load mode.
  95357. */
  95358. delayLoadState: number;
  95359. private _scene;
  95360. /** @hidden */
  95361. _texture: Nullable<InternalTexture>;
  95362. private _uid;
  95363. /**
  95364. * Define if the texture is preventinga material to render or not.
  95365. * If not and the texture is not ready, the engine will use a default black texture instead.
  95366. */
  95367. readonly isBlocking: boolean;
  95368. /**
  95369. * Instantiates a new BaseTexture.
  95370. * Base class of all the textures in babylon.
  95371. * It groups all the common properties the materials, post process, lights... might need
  95372. * in order to make a correct use of the texture.
  95373. * @param scene Define the scene the texture blongs to
  95374. */
  95375. constructor(scene: Nullable<Scene>);
  95376. /**
  95377. * Get the scene the texture belongs to.
  95378. * @returns the scene or null if undefined
  95379. */
  95380. getScene(): Nullable<Scene>;
  95381. /**
  95382. * Get the texture transform matrix used to offset tile the texture for istance.
  95383. * @returns the transformation matrix
  95384. */
  95385. getTextureMatrix(): Matrix;
  95386. /**
  95387. * Get the texture reflection matrix used to rotate/transform the reflection.
  95388. * @returns the reflection matrix
  95389. */
  95390. getReflectionTextureMatrix(): Matrix;
  95391. /**
  95392. * Get the underlying lower level texture from Babylon.
  95393. * @returns the insternal texture
  95394. */
  95395. getInternalTexture(): Nullable<InternalTexture>;
  95396. /**
  95397. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  95398. * @returns true if ready or not blocking
  95399. */
  95400. isReadyOrNotBlocking(): boolean;
  95401. /**
  95402. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  95403. * @returns true if fully ready
  95404. */
  95405. isReady(): boolean;
  95406. private _cachedSize;
  95407. /**
  95408. * Get the size of the texture.
  95409. * @returns the texture size.
  95410. */
  95411. getSize(): ISize;
  95412. /**
  95413. * Get the base size of the texture.
  95414. * It can be different from the size if the texture has been resized for POT for instance
  95415. * @returns the base size
  95416. */
  95417. getBaseSize(): ISize;
  95418. /**
  95419. * Update the sampling mode of the texture.
  95420. * Default is Trilinear mode.
  95421. *
  95422. * | Value | Type | Description |
  95423. * | ----- | ------------------ | ----------- |
  95424. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  95425. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  95426. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  95427. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  95428. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  95429. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  95430. * | 7 | NEAREST_LINEAR | |
  95431. * | 8 | NEAREST_NEAREST | |
  95432. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  95433. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  95434. * | 11 | LINEAR_LINEAR | |
  95435. * | 12 | LINEAR_NEAREST | |
  95436. *
  95437. * > _mag_: magnification filter (close to the viewer)
  95438. * > _min_: minification filter (far from the viewer)
  95439. * > _mip_: filter used between mip map levels
  95440. *@param samplingMode Define the new sampling mode of the texture
  95441. */
  95442. updateSamplingMode(samplingMode: number): void;
  95443. /**
  95444. * Scales the texture if is `canRescale()`
  95445. * @param ratio the resize factor we want to use to rescale
  95446. */
  95447. scale(ratio: number): void;
  95448. /**
  95449. * Get if the texture can rescale.
  95450. */
  95451. readonly canRescale: boolean;
  95452. /** @hidden */
  95453. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  95454. /** @hidden */
  95455. _rebuild(): void;
  95456. /**
  95457. * Triggers the load sequence in delayed load mode.
  95458. */
  95459. delayLoad(): void;
  95460. /**
  95461. * Clones the texture.
  95462. * @returns the cloned texture
  95463. */
  95464. clone(): Nullable<BaseTexture>;
  95465. /**
  95466. * Get the texture underlying type (INT, FLOAT...)
  95467. */
  95468. readonly textureType: number;
  95469. /**
  95470. * Get the texture underlying format (RGB, RGBA...)
  95471. */
  95472. readonly textureFormat: number;
  95473. /**
  95474. * Indicates that textures need to be re-calculated for all materials
  95475. */
  95476. protected _markAllSubMeshesAsTexturesDirty(): void;
  95477. /**
  95478. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  95479. * This will returns an RGBA array buffer containing either in values (0-255) or
  95480. * float values (0-1) depending of the underlying buffer type.
  95481. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  95482. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  95483. * @param buffer defines a user defined buffer to fill with data (can be null)
  95484. * @returns The Array buffer containing the pixels data.
  95485. */
  95486. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  95487. /**
  95488. * Release and destroy the underlying lower level texture aka internalTexture.
  95489. */
  95490. releaseInternalTexture(): void;
  95491. /** @hidden */
  95492. readonly _lodTextureHigh: Nullable<BaseTexture>;
  95493. /** @hidden */
  95494. readonly _lodTextureMid: Nullable<BaseTexture>;
  95495. /** @hidden */
  95496. readonly _lodTextureLow: Nullable<BaseTexture>;
  95497. /**
  95498. * Dispose the texture and release its associated resources.
  95499. */
  95500. dispose(): void;
  95501. /**
  95502. * Serialize the texture into a JSON representation that can be parsed later on.
  95503. * @returns the JSON representation of the texture
  95504. */
  95505. serialize(): any;
  95506. /**
  95507. * Helper function to be called back once a list of texture contains only ready textures.
  95508. * @param textures Define the list of textures to wait for
  95509. * @param callback Define the callback triggered once the entire list will be ready
  95510. */
  95511. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  95512. }
  95513. }
  95514. declare module BABYLON {
  95515. /**
  95516. * Options to be used when creating an effect.
  95517. */
  95518. export interface IEffectCreationOptions {
  95519. /**
  95520. * Atrributes that will be used in the shader.
  95521. */
  95522. attributes: string[];
  95523. /**
  95524. * Uniform varible names that will be set in the shader.
  95525. */
  95526. uniformsNames: string[];
  95527. /**
  95528. * Uniform buffer varible names that will be set in the shader.
  95529. */
  95530. uniformBuffersNames: string[];
  95531. /**
  95532. * Sampler texture variable names that will be set in the shader.
  95533. */
  95534. samplers: string[];
  95535. /**
  95536. * Define statements that will be set in the shader.
  95537. */
  95538. defines: any;
  95539. /**
  95540. * Possible fallbacks for this effect to improve performance when needed.
  95541. */
  95542. fallbacks: Nullable<IEffectFallbacks>;
  95543. /**
  95544. * Callback that will be called when the shader is compiled.
  95545. */
  95546. onCompiled: Nullable<(effect: Effect) => void>;
  95547. /**
  95548. * Callback that will be called if an error occurs during shader compilation.
  95549. */
  95550. onError: Nullable<(effect: Effect, errors: string) => void>;
  95551. /**
  95552. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95553. */
  95554. indexParameters?: any;
  95555. /**
  95556. * Max number of lights that can be used in the shader.
  95557. */
  95558. maxSimultaneousLights?: number;
  95559. /**
  95560. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  95561. */
  95562. transformFeedbackVaryings?: Nullable<string[]>;
  95563. }
  95564. /**
  95565. * Effect containing vertex and fragment shader that can be executed on an object.
  95566. */
  95567. export class Effect implements IDisposable {
  95568. /**
  95569. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95570. */
  95571. static ShadersRepository: string;
  95572. /**
  95573. * Name of the effect.
  95574. */
  95575. name: any;
  95576. /**
  95577. * String container all the define statements that should be set on the shader.
  95578. */
  95579. defines: string;
  95580. /**
  95581. * Callback that will be called when the shader is compiled.
  95582. */
  95583. onCompiled: Nullable<(effect: Effect) => void>;
  95584. /**
  95585. * Callback that will be called if an error occurs during shader compilation.
  95586. */
  95587. onError: Nullable<(effect: Effect, errors: string) => void>;
  95588. /**
  95589. * Callback that will be called when effect is bound.
  95590. */
  95591. onBind: Nullable<(effect: Effect) => void>;
  95592. /**
  95593. * Unique ID of the effect.
  95594. */
  95595. uniqueId: number;
  95596. /**
  95597. * Observable that will be called when the shader is compiled.
  95598. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  95599. */
  95600. onCompileObservable: Observable<Effect>;
  95601. /**
  95602. * Observable that will be called if an error occurs during shader compilation.
  95603. */
  95604. onErrorObservable: Observable<Effect>;
  95605. /** @hidden */
  95606. _onBindObservable: Nullable<Observable<Effect>>;
  95607. /**
  95608. * Observable that will be called when effect is bound.
  95609. */
  95610. readonly onBindObservable: Observable<Effect>;
  95611. /** @hidden */
  95612. _bonesComputationForcedToCPU: boolean;
  95613. private static _uniqueIdSeed;
  95614. private _engine;
  95615. private _uniformBuffersNames;
  95616. private _uniformsNames;
  95617. private _samplerList;
  95618. private _samplers;
  95619. private _isReady;
  95620. private _compilationError;
  95621. private _allFallbacksProcessed;
  95622. private _attributesNames;
  95623. private _attributes;
  95624. private _uniforms;
  95625. /**
  95626. * Key for the effect.
  95627. * @hidden
  95628. */
  95629. _key: string;
  95630. private _indexParameters;
  95631. private _fallbacks;
  95632. private _vertexSourceCode;
  95633. private _fragmentSourceCode;
  95634. private _vertexSourceCodeOverride;
  95635. private _fragmentSourceCodeOverride;
  95636. private _transformFeedbackVaryings;
  95637. /**
  95638. * Compiled shader to webGL program.
  95639. * @hidden
  95640. */
  95641. _pipelineContext: Nullable<IPipelineContext>;
  95642. private _valueCache;
  95643. private static _baseCache;
  95644. /**
  95645. * Instantiates an effect.
  95646. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95647. * @param baseName Name of the effect.
  95648. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95649. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95650. * @param samplers List of sampler variables that will be passed to the shader.
  95651. * @param engine Engine to be used to render the effect
  95652. * @param defines Define statements to be added to the shader.
  95653. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95654. * @param onCompiled Callback that will be called when the shader is compiled.
  95655. * @param onError Callback that will be called if an error occurs during shader compilation.
  95656. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95657. */
  95658. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, 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);
  95659. private _useFinalCode;
  95660. /**
  95661. * Unique key for this effect
  95662. */
  95663. readonly key: string;
  95664. /**
  95665. * If the effect has been compiled and prepared.
  95666. * @returns if the effect is compiled and prepared.
  95667. */
  95668. isReady(): boolean;
  95669. private _isReadyInternal;
  95670. /**
  95671. * The engine the effect was initialized with.
  95672. * @returns the engine.
  95673. */
  95674. getEngine(): Engine;
  95675. /**
  95676. * The pipeline context for this effect
  95677. * @returns the associated pipeline context
  95678. */
  95679. getPipelineContext(): Nullable<IPipelineContext>;
  95680. /**
  95681. * The set of names of attribute variables for the shader.
  95682. * @returns An array of attribute names.
  95683. */
  95684. getAttributesNames(): string[];
  95685. /**
  95686. * Returns the attribute at the given index.
  95687. * @param index The index of the attribute.
  95688. * @returns The location of the attribute.
  95689. */
  95690. getAttributeLocation(index: number): number;
  95691. /**
  95692. * Returns the attribute based on the name of the variable.
  95693. * @param name of the attribute to look up.
  95694. * @returns the attribute location.
  95695. */
  95696. getAttributeLocationByName(name: string): number;
  95697. /**
  95698. * The number of attributes.
  95699. * @returns the numnber of attributes.
  95700. */
  95701. getAttributesCount(): number;
  95702. /**
  95703. * Gets the index of a uniform variable.
  95704. * @param uniformName of the uniform to look up.
  95705. * @returns the index.
  95706. */
  95707. getUniformIndex(uniformName: string): number;
  95708. /**
  95709. * Returns the attribute based on the name of the variable.
  95710. * @param uniformName of the uniform to look up.
  95711. * @returns the location of the uniform.
  95712. */
  95713. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95714. /**
  95715. * Returns an array of sampler variable names
  95716. * @returns The array of sampler variable neames.
  95717. */
  95718. getSamplers(): string[];
  95719. /**
  95720. * The error from the last compilation.
  95721. * @returns the error string.
  95722. */
  95723. getCompilationError(): string;
  95724. /**
  95725. * Gets a boolean indicating that all fallbacks were used during compilation
  95726. * @returns true if all fallbacks were used
  95727. */
  95728. allFallbacksProcessed(): boolean;
  95729. /**
  95730. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95731. * @param func The callback to be used.
  95732. */
  95733. executeWhenCompiled(func: (effect: Effect) => void): void;
  95734. private _checkIsReady;
  95735. private _loadShader;
  95736. /**
  95737. * Recompiles the webGL program
  95738. * @param vertexSourceCode The source code for the vertex shader.
  95739. * @param fragmentSourceCode The source code for the fragment shader.
  95740. * @param onCompiled Callback called when completed.
  95741. * @param onError Callback called on error.
  95742. * @hidden
  95743. */
  95744. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95745. /**
  95746. * Prepares the effect
  95747. * @hidden
  95748. */
  95749. _prepareEffect(): void;
  95750. private _processCompilationErrors;
  95751. /**
  95752. * Checks if the effect is supported. (Must be called after compilation)
  95753. */
  95754. readonly isSupported: boolean;
  95755. /**
  95756. * Binds a texture to the engine to be used as output of the shader.
  95757. * @param channel Name of the output variable.
  95758. * @param texture Texture to bind.
  95759. * @hidden
  95760. */
  95761. _bindTexture(channel: string, texture: InternalTexture): void;
  95762. /**
  95763. * Sets a texture on the engine to be used in the shader.
  95764. * @param channel Name of the sampler variable.
  95765. * @param texture Texture to set.
  95766. */
  95767. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95768. /**
  95769. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95770. * @param channel Name of the sampler variable.
  95771. * @param texture Texture to set.
  95772. */
  95773. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95774. /**
  95775. * Sets an array of textures on the engine to be used in the shader.
  95776. * @param channel Name of the variable.
  95777. * @param textures Textures to set.
  95778. */
  95779. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95780. /**
  95781. * 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)
  95782. * @param channel Name of the sampler variable.
  95783. * @param postProcess Post process to get the input texture from.
  95784. */
  95785. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95786. /**
  95787. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95788. * 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)
  95789. * @param channel Name of the sampler variable.
  95790. * @param postProcess Post process to get the output texture from.
  95791. */
  95792. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95793. /** @hidden */
  95794. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95795. /** @hidden */
  95796. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95797. /** @hidden */
  95798. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95799. /** @hidden */
  95800. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95801. /**
  95802. * Binds a buffer to a uniform.
  95803. * @param buffer Buffer to bind.
  95804. * @param name Name of the uniform variable to bind to.
  95805. */
  95806. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95807. /**
  95808. * Binds block to a uniform.
  95809. * @param blockName Name of the block to bind.
  95810. * @param index Index to bind.
  95811. */
  95812. bindUniformBlock(blockName: string, index: number): void;
  95813. /**
  95814. * Sets an interger value on a uniform variable.
  95815. * @param uniformName Name of the variable.
  95816. * @param value Value to be set.
  95817. * @returns this effect.
  95818. */
  95819. setInt(uniformName: string, value: number): Effect;
  95820. /**
  95821. * Sets an int array on a uniform variable.
  95822. * @param uniformName Name of the variable.
  95823. * @param array array to be set.
  95824. * @returns this effect.
  95825. */
  95826. setIntArray(uniformName: string, array: Int32Array): Effect;
  95827. /**
  95828. * 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)
  95829. * @param uniformName Name of the variable.
  95830. * @param array array to be set.
  95831. * @returns this effect.
  95832. */
  95833. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95834. /**
  95835. * 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)
  95836. * @param uniformName Name of the variable.
  95837. * @param array array to be set.
  95838. * @returns this effect.
  95839. */
  95840. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95841. /**
  95842. * 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)
  95843. * @param uniformName Name of the variable.
  95844. * @param array array to be set.
  95845. * @returns this effect.
  95846. */
  95847. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95848. /**
  95849. * Sets an float array on a uniform variable.
  95850. * @param uniformName Name of the variable.
  95851. * @param array array to be set.
  95852. * @returns this effect.
  95853. */
  95854. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95855. /**
  95856. * 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)
  95857. * @param uniformName Name of the variable.
  95858. * @param array array to be set.
  95859. * @returns this effect.
  95860. */
  95861. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95862. /**
  95863. * 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)
  95864. * @param uniformName Name of the variable.
  95865. * @param array array to be set.
  95866. * @returns this effect.
  95867. */
  95868. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95869. /**
  95870. * 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)
  95871. * @param uniformName Name of the variable.
  95872. * @param array array to be set.
  95873. * @returns this effect.
  95874. */
  95875. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95876. /**
  95877. * Sets an array on a uniform variable.
  95878. * @param uniformName Name of the variable.
  95879. * @param array array to be set.
  95880. * @returns this effect.
  95881. */
  95882. setArray(uniformName: string, array: number[]): Effect;
  95883. /**
  95884. * 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)
  95885. * @param uniformName Name of the variable.
  95886. * @param array array to be set.
  95887. * @returns this effect.
  95888. */
  95889. setArray2(uniformName: string, array: number[]): Effect;
  95890. /**
  95891. * 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)
  95892. * @param uniformName Name of the variable.
  95893. * @param array array to be set.
  95894. * @returns this effect.
  95895. */
  95896. setArray3(uniformName: string, array: number[]): Effect;
  95897. /**
  95898. * 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)
  95899. * @param uniformName Name of the variable.
  95900. * @param array array to be set.
  95901. * @returns this effect.
  95902. */
  95903. setArray4(uniformName: string, array: number[]): Effect;
  95904. /**
  95905. * Sets matrices on a uniform variable.
  95906. * @param uniformName Name of the variable.
  95907. * @param matrices matrices to be set.
  95908. * @returns this effect.
  95909. */
  95910. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95911. /**
  95912. * Sets matrix on a uniform variable.
  95913. * @param uniformName Name of the variable.
  95914. * @param matrix matrix to be set.
  95915. * @returns this effect.
  95916. */
  95917. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95918. /**
  95919. * 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)
  95920. * @param uniformName Name of the variable.
  95921. * @param matrix matrix to be set.
  95922. * @returns this effect.
  95923. */
  95924. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95925. /**
  95926. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95927. * @param uniformName Name of the variable.
  95928. * @param matrix matrix to be set.
  95929. * @returns this effect.
  95930. */
  95931. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95932. /**
  95933. * Sets a float on a uniform variable.
  95934. * @param uniformName Name of the variable.
  95935. * @param value value to be set.
  95936. * @returns this effect.
  95937. */
  95938. setFloat(uniformName: string, value: number): Effect;
  95939. /**
  95940. * Sets a boolean on a uniform variable.
  95941. * @param uniformName Name of the variable.
  95942. * @param bool value to be set.
  95943. * @returns this effect.
  95944. */
  95945. setBool(uniformName: string, bool: boolean): Effect;
  95946. /**
  95947. * Sets a Vector2 on a uniform variable.
  95948. * @param uniformName Name of the variable.
  95949. * @param vector2 vector2 to be set.
  95950. * @returns this effect.
  95951. */
  95952. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95953. /**
  95954. * Sets a float2 on a uniform variable.
  95955. * @param uniformName Name of the variable.
  95956. * @param x First float in float2.
  95957. * @param y Second float in float2.
  95958. * @returns this effect.
  95959. */
  95960. setFloat2(uniformName: string, x: number, y: number): Effect;
  95961. /**
  95962. * Sets a Vector3 on a uniform variable.
  95963. * @param uniformName Name of the variable.
  95964. * @param vector3 Value to be set.
  95965. * @returns this effect.
  95966. */
  95967. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95968. /**
  95969. * Sets a float3 on a uniform variable.
  95970. * @param uniformName Name of the variable.
  95971. * @param x First float in float3.
  95972. * @param y Second float in float3.
  95973. * @param z Third float in float3.
  95974. * @returns this effect.
  95975. */
  95976. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95977. /**
  95978. * Sets a Vector4 on a uniform variable.
  95979. * @param uniformName Name of the variable.
  95980. * @param vector4 Value to be set.
  95981. * @returns this effect.
  95982. */
  95983. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95984. /**
  95985. * Sets a float4 on a uniform variable.
  95986. * @param uniformName Name of the variable.
  95987. * @param x First float in float4.
  95988. * @param y Second float in float4.
  95989. * @param z Third float in float4.
  95990. * @param w Fourth float in float4.
  95991. * @returns this effect.
  95992. */
  95993. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95994. /**
  95995. * Sets a Color3 on a uniform variable.
  95996. * @param uniformName Name of the variable.
  95997. * @param color3 Value to be set.
  95998. * @returns this effect.
  95999. */
  96000. setColor3(uniformName: string, color3: IColor3Like): Effect;
  96001. /**
  96002. * Sets a Color4 on a uniform variable.
  96003. * @param uniformName Name of the variable.
  96004. * @param color3 Value to be set.
  96005. * @param alpha Alpha value to be set.
  96006. * @returns this effect.
  96007. */
  96008. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  96009. /**
  96010. * Sets a Color4 on a uniform variable
  96011. * @param uniformName defines the name of the variable
  96012. * @param color4 defines the value to be set
  96013. * @returns this effect.
  96014. */
  96015. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  96016. /** Release all associated resources */
  96017. dispose(): void;
  96018. /**
  96019. * This function will add a new shader to the shader store
  96020. * @param name the name of the shader
  96021. * @param pixelShader optional pixel shader content
  96022. * @param vertexShader optional vertex shader content
  96023. */
  96024. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  96025. /**
  96026. * Store of each shader (The can be looked up using effect.key)
  96027. */
  96028. static ShadersStore: {
  96029. [key: string]: string;
  96030. };
  96031. /**
  96032. * Store of each included file for a shader (The can be looked up using effect.key)
  96033. */
  96034. static IncludesShadersStore: {
  96035. [key: string]: string;
  96036. };
  96037. /**
  96038. * Resets the cache of effects.
  96039. */
  96040. static ResetCache(): void;
  96041. }
  96042. }
  96043. declare module BABYLON {
  96044. /**
  96045. * Class used to describe the capabilities of the engine relatively to the current browser
  96046. */
  96047. export class EngineCapabilities {
  96048. /** Maximum textures units per fragment shader */
  96049. maxTexturesImageUnits: number;
  96050. /** Maximum texture units per vertex shader */
  96051. maxVertexTextureImageUnits: number;
  96052. /** Maximum textures units in the entire pipeline */
  96053. maxCombinedTexturesImageUnits: number;
  96054. /** Maximum texture size */
  96055. maxTextureSize: number;
  96056. /** Maximum cube texture size */
  96057. maxCubemapTextureSize: number;
  96058. /** Maximum render texture size */
  96059. maxRenderTextureSize: number;
  96060. /** Maximum number of vertex attributes */
  96061. maxVertexAttribs: number;
  96062. /** Maximum number of varyings */
  96063. maxVaryingVectors: number;
  96064. /** Maximum number of uniforms per vertex shader */
  96065. maxVertexUniformVectors: number;
  96066. /** Maximum number of uniforms per fragment shader */
  96067. maxFragmentUniformVectors: number;
  96068. /** Defines if standard derivates (dx/dy) are supported */
  96069. standardDerivatives: boolean;
  96070. /** Defines if s3tc texture compression is supported */
  96071. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  96072. /** Defines if pvrtc texture compression is supported */
  96073. pvrtc: any;
  96074. /** Defines if etc1 texture compression is supported */
  96075. etc1: any;
  96076. /** Defines if etc2 texture compression is supported */
  96077. etc2: any;
  96078. /** Defines if astc texture compression is supported */
  96079. astc: any;
  96080. /** Defines if float textures are supported */
  96081. textureFloat: boolean;
  96082. /** Defines if vertex array objects are supported */
  96083. vertexArrayObject: boolean;
  96084. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  96085. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  96086. /** Gets the maximum level of anisotropy supported */
  96087. maxAnisotropy: number;
  96088. /** Defines if instancing is supported */
  96089. instancedArrays: boolean;
  96090. /** Defines if 32 bits indices are supported */
  96091. uintIndices: boolean;
  96092. /** Defines if high precision shaders are supported */
  96093. highPrecisionShaderSupported: boolean;
  96094. /** Defines if depth reading in the fragment shader is supported */
  96095. fragmentDepthSupported: boolean;
  96096. /** Defines if float texture linear filtering is supported*/
  96097. textureFloatLinearFiltering: boolean;
  96098. /** Defines if rendering to float textures is supported */
  96099. textureFloatRender: boolean;
  96100. /** Defines if half float textures are supported*/
  96101. textureHalfFloat: boolean;
  96102. /** Defines if half float texture linear filtering is supported*/
  96103. textureHalfFloatLinearFiltering: boolean;
  96104. /** Defines if rendering to half float textures is supported */
  96105. textureHalfFloatRender: boolean;
  96106. /** Defines if textureLOD shader command is supported */
  96107. textureLOD: boolean;
  96108. /** Defines if draw buffers extension is supported */
  96109. drawBuffersExtension: boolean;
  96110. /** Defines if depth textures are supported */
  96111. depthTextureExtension: boolean;
  96112. /** Defines if float color buffer are supported */
  96113. colorBufferFloat: boolean;
  96114. /** Gets disjoint timer query extension (null if not supported) */
  96115. timerQuery: EXT_disjoint_timer_query;
  96116. /** Defines if timestamp can be used with timer query */
  96117. canUseTimestampForTimerQuery: boolean;
  96118. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96119. multiview: any;
  96120. /** Function used to let the system compiles shaders in background */
  96121. parallelShaderCompile: {
  96122. COMPLETION_STATUS_KHR: number;
  96123. };
  96124. /** Max number of texture samples for MSAA */
  96125. maxMSAASamples: number;
  96126. /** Defines if the blend min max extension is supported */
  96127. blendMinMax: boolean;
  96128. }
  96129. }
  96130. declare module BABYLON {
  96131. /**
  96132. * @hidden
  96133. **/
  96134. export class DepthCullingState {
  96135. private _isDepthTestDirty;
  96136. private _isDepthMaskDirty;
  96137. private _isDepthFuncDirty;
  96138. private _isCullFaceDirty;
  96139. private _isCullDirty;
  96140. private _isZOffsetDirty;
  96141. private _isFrontFaceDirty;
  96142. private _depthTest;
  96143. private _depthMask;
  96144. private _depthFunc;
  96145. private _cull;
  96146. private _cullFace;
  96147. private _zOffset;
  96148. private _frontFace;
  96149. /**
  96150. * Initializes the state.
  96151. */
  96152. constructor();
  96153. readonly isDirty: boolean;
  96154. zOffset: number;
  96155. cullFace: Nullable<number>;
  96156. cull: Nullable<boolean>;
  96157. depthFunc: Nullable<number>;
  96158. depthMask: boolean;
  96159. depthTest: boolean;
  96160. frontFace: Nullable<number>;
  96161. reset(): void;
  96162. apply(gl: WebGLRenderingContext): void;
  96163. }
  96164. }
  96165. declare module BABYLON {
  96166. /**
  96167. * @hidden
  96168. **/
  96169. export class StencilState {
  96170. /** 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 */
  96171. static readonly ALWAYS: number;
  96172. /** Passed to stencilOperation to specify that stencil value must be kept */
  96173. static readonly KEEP: number;
  96174. /** Passed to stencilOperation to specify that stencil value must be replaced */
  96175. static readonly REPLACE: number;
  96176. private _isStencilTestDirty;
  96177. private _isStencilMaskDirty;
  96178. private _isStencilFuncDirty;
  96179. private _isStencilOpDirty;
  96180. private _stencilTest;
  96181. private _stencilMask;
  96182. private _stencilFunc;
  96183. private _stencilFuncRef;
  96184. private _stencilFuncMask;
  96185. private _stencilOpStencilFail;
  96186. private _stencilOpDepthFail;
  96187. private _stencilOpStencilDepthPass;
  96188. readonly isDirty: boolean;
  96189. stencilFunc: number;
  96190. stencilFuncRef: number;
  96191. stencilFuncMask: number;
  96192. stencilOpStencilFail: number;
  96193. stencilOpDepthFail: number;
  96194. stencilOpStencilDepthPass: number;
  96195. stencilMask: number;
  96196. stencilTest: boolean;
  96197. constructor();
  96198. reset(): void;
  96199. apply(gl: WebGLRenderingContext): void;
  96200. }
  96201. }
  96202. declare module BABYLON {
  96203. /**
  96204. * @hidden
  96205. **/
  96206. export class AlphaState {
  96207. private _isAlphaBlendDirty;
  96208. private _isBlendFunctionParametersDirty;
  96209. private _isBlendEquationParametersDirty;
  96210. private _isBlendConstantsDirty;
  96211. private _alphaBlend;
  96212. private _blendFunctionParameters;
  96213. private _blendEquationParameters;
  96214. private _blendConstants;
  96215. /**
  96216. * Initializes the state.
  96217. */
  96218. constructor();
  96219. readonly isDirty: boolean;
  96220. alphaBlend: boolean;
  96221. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  96222. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  96223. setAlphaEquationParameters(rgb: number, alpha: number): void;
  96224. reset(): void;
  96225. apply(gl: WebGLRenderingContext): void;
  96226. }
  96227. }
  96228. declare module BABYLON {
  96229. /** @hidden */
  96230. export class WebGL2ShaderProcessor implements IShaderProcessor {
  96231. attributeProcessor(attribute: string): string;
  96232. varyingProcessor(varying: string, isFragment: boolean): string;
  96233. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  96234. }
  96235. }
  96236. declare module BABYLON {
  96237. /**
  96238. * Interface for attribute information associated with buffer instanciation
  96239. */
  96240. export class InstancingAttributeInfo {
  96241. /**
  96242. * Index/offset of the attribute in the vertex shader
  96243. */
  96244. index: number;
  96245. /**
  96246. * size of the attribute, 1, 2, 3 or 4
  96247. */
  96248. attributeSize: number;
  96249. /**
  96250. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  96251. * default is FLOAT
  96252. */
  96253. attribyteType: number;
  96254. /**
  96255. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  96256. */
  96257. normalized: boolean;
  96258. /**
  96259. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  96260. */
  96261. offset: number;
  96262. /**
  96263. * Name of the GLSL attribute, for debugging purpose only
  96264. */
  96265. attributeName: string;
  96266. }
  96267. }
  96268. declare module BABYLON {
  96269. interface ThinEngine {
  96270. /**
  96271. * Update a video texture
  96272. * @param texture defines the texture to update
  96273. * @param video defines the video element to use
  96274. * @param invertY defines if data must be stored with Y axis inverted
  96275. */
  96276. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96277. }
  96278. }
  96279. declare module BABYLON {
  96280. /**
  96281. * Settings for finer control over video usage
  96282. */
  96283. export interface VideoTextureSettings {
  96284. /**
  96285. * Applies `autoplay` to video, if specified
  96286. */
  96287. autoPlay?: boolean;
  96288. /**
  96289. * Applies `loop` to video, if specified
  96290. */
  96291. loop?: boolean;
  96292. /**
  96293. * Automatically updates internal texture from video at every frame in the render loop
  96294. */
  96295. autoUpdateTexture: boolean;
  96296. /**
  96297. * Image src displayed during the video loading or until the user interacts with the video.
  96298. */
  96299. poster?: string;
  96300. }
  96301. /**
  96302. * If you want to display a video in your scene, this is the special texture for that.
  96303. * This special texture works similar to other textures, with the exception of a few parameters.
  96304. * @see https://doc.babylonjs.com/how_to/video_texture
  96305. */
  96306. export class VideoTexture extends Texture {
  96307. /**
  96308. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  96309. */
  96310. readonly autoUpdateTexture: boolean;
  96311. /**
  96312. * The video instance used by the texture internally
  96313. */
  96314. readonly video: HTMLVideoElement;
  96315. private _onUserActionRequestedObservable;
  96316. /**
  96317. * Event triggerd when a dom action is required by the user to play the video.
  96318. * This happens due to recent changes in browser policies preventing video to auto start.
  96319. */
  96320. readonly onUserActionRequestedObservable: Observable<Texture>;
  96321. private _generateMipMaps;
  96322. private _engine;
  96323. private _stillImageCaptured;
  96324. private _displayingPosterTexture;
  96325. private _settings;
  96326. private _createInternalTextureOnEvent;
  96327. private _frameId;
  96328. /**
  96329. * Creates a video texture.
  96330. * If you want to display a video in your scene, this is the special texture for that.
  96331. * This special texture works similar to other textures, with the exception of a few parameters.
  96332. * @see https://doc.babylonjs.com/how_to/video_texture
  96333. * @param name optional name, will detect from video source, if not defined
  96334. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  96335. * @param scene is obviously the current scene.
  96336. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  96337. * @param invertY is false by default but can be used to invert video on Y axis
  96338. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  96339. * @param settings allows finer control over video usage
  96340. */
  96341. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  96342. private _getName;
  96343. private _getVideo;
  96344. private _createInternalTexture;
  96345. private reset;
  96346. /**
  96347. * @hidden Internal method to initiate `update`.
  96348. */
  96349. _rebuild(): void;
  96350. /**
  96351. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  96352. */
  96353. update(): void;
  96354. /**
  96355. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  96356. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  96357. */
  96358. updateTexture(isVisible: boolean): void;
  96359. protected _updateInternalTexture: () => void;
  96360. /**
  96361. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  96362. * @param url New url.
  96363. */
  96364. updateURL(url: string): void;
  96365. /**
  96366. * Dispose the texture and release its associated resources.
  96367. */
  96368. dispose(): void;
  96369. /**
  96370. * Creates a video texture straight from a stream.
  96371. * @param scene Define the scene the texture should be created in
  96372. * @param stream Define the stream the texture should be created from
  96373. * @returns The created video texture as a promise
  96374. */
  96375. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  96376. /**
  96377. * Creates a video texture straight from your WebCam video feed.
  96378. * @param scene Define the scene the texture should be created in
  96379. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96380. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96381. * @returns The created video texture as a promise
  96382. */
  96383. static CreateFromWebCamAsync(scene: Scene, constraints: {
  96384. minWidth: number;
  96385. maxWidth: number;
  96386. minHeight: number;
  96387. maxHeight: number;
  96388. deviceId: string;
  96389. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  96390. /**
  96391. * Creates a video texture straight from your WebCam video feed.
  96392. * @param scene Define the scene the texture should be created in
  96393. * @param onReady Define a callback to triggered once the texture will be ready
  96394. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96395. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96396. */
  96397. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  96398. minWidth: number;
  96399. maxWidth: number;
  96400. minHeight: number;
  96401. maxHeight: number;
  96402. deviceId: string;
  96403. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  96404. }
  96405. }
  96406. declare module BABYLON {
  96407. /**
  96408. * Defines the interface used by objects working like Scene
  96409. * @hidden
  96410. */
  96411. interface ISceneLike {
  96412. _addPendingData(data: any): void;
  96413. _removePendingData(data: any): void;
  96414. offlineProvider: IOfflineProvider;
  96415. }
  96416. /** Interface defining initialization parameters for Engine class */
  96417. export interface EngineOptions extends WebGLContextAttributes {
  96418. /**
  96419. * Defines if the engine should no exceed a specified device ratio
  96420. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  96421. */
  96422. limitDeviceRatio?: number;
  96423. /**
  96424. * Defines if webvr should be enabled automatically
  96425. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96426. */
  96427. autoEnableWebVR?: boolean;
  96428. /**
  96429. * Defines if webgl2 should be turned off even if supported
  96430. * @see http://doc.babylonjs.com/features/webgl2
  96431. */
  96432. disableWebGL2Support?: boolean;
  96433. /**
  96434. * Defines if webaudio should be initialized as well
  96435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96436. */
  96437. audioEngine?: boolean;
  96438. /**
  96439. * Defines if animations should run using a deterministic lock step
  96440. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96441. */
  96442. deterministicLockstep?: boolean;
  96443. /** Defines the maximum steps to use with deterministic lock step mode */
  96444. lockstepMaxSteps?: number;
  96445. /**
  96446. * Defines that engine should ignore context lost events
  96447. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  96448. */
  96449. doNotHandleContextLost?: boolean;
  96450. /**
  96451. * Defines that engine should ignore modifying touch action attribute and style
  96452. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  96453. */
  96454. doNotHandleTouchAction?: boolean;
  96455. /**
  96456. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  96457. */
  96458. useHighPrecisionFloats?: boolean;
  96459. }
  96460. /**
  96461. * The base engine class (root of all engines)
  96462. */
  96463. export class ThinEngine {
  96464. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  96465. static ExceptionList: ({
  96466. key: string;
  96467. capture: string;
  96468. captureConstraint: number;
  96469. targets: string[];
  96470. } | {
  96471. key: string;
  96472. capture: null;
  96473. captureConstraint: null;
  96474. targets: string[];
  96475. })[];
  96476. /** @hidden */
  96477. static _TextureLoaders: IInternalTextureLoader[];
  96478. /**
  96479. * Returns the current npm package of the sdk
  96480. */
  96481. static readonly NpmPackage: string;
  96482. /**
  96483. * Returns the current version of the framework
  96484. */
  96485. static readonly Version: string;
  96486. /**
  96487. * Returns a string describing the current engine
  96488. */
  96489. readonly description: string;
  96490. /**
  96491. * Gets or sets the epsilon value used by collision engine
  96492. */
  96493. static CollisionsEpsilon: number;
  96494. /**
  96495. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96496. */
  96497. static ShadersRepository: string;
  96498. /** @hidden */
  96499. _shaderProcessor: IShaderProcessor;
  96500. /**
  96501. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96502. */
  96503. forcePOTTextures: boolean;
  96504. /**
  96505. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96506. */
  96507. isFullscreen: boolean;
  96508. /**
  96509. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96510. */
  96511. cullBackFaces: boolean;
  96512. /**
  96513. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96514. */
  96515. renderEvenInBackground: boolean;
  96516. /**
  96517. * Gets or sets a boolean indicating that cache can be kept between frames
  96518. */
  96519. preventCacheWipeBetweenFrames: boolean;
  96520. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96521. validateShaderPrograms: boolean;
  96522. /**
  96523. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96524. */
  96525. disableUniformBuffers: boolean;
  96526. /** @hidden */
  96527. _uniformBuffers: UniformBuffer[];
  96528. /**
  96529. * Gets a boolean indicating that the engine supports uniform buffers
  96530. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96531. */
  96532. readonly supportsUniformBuffers: boolean;
  96533. /** @hidden */
  96534. _gl: WebGLRenderingContext;
  96535. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96536. protected _windowIsBackground: boolean;
  96537. protected _webGLVersion: number;
  96538. protected _highPrecisionShadersAllowed: boolean;
  96539. /** @hidden */
  96540. readonly _shouldUseHighPrecisionShader: boolean;
  96541. /**
  96542. * Gets a boolean indicating that only power of 2 textures are supported
  96543. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96544. */
  96545. readonly needPOTTextures: boolean;
  96546. /** @hidden */
  96547. _badOS: boolean;
  96548. /** @hidden */
  96549. _badDesktopOS: boolean;
  96550. private _hardwareScalingLevel;
  96551. /** @hidden */
  96552. _caps: EngineCapabilities;
  96553. private _isStencilEnable;
  96554. protected _colorWrite: boolean;
  96555. private _glVersion;
  96556. private _glRenderer;
  96557. private _glVendor;
  96558. /** @hidden */
  96559. _videoTextureSupported: boolean;
  96560. protected _renderingQueueLaunched: boolean;
  96561. protected _activeRenderLoops: (() => void)[];
  96562. /**
  96563. * Observable signaled when a context lost event is raised
  96564. */
  96565. onContextLostObservable: Observable<ThinEngine>;
  96566. /**
  96567. * Observable signaled when a context restored event is raised
  96568. */
  96569. onContextRestoredObservable: Observable<ThinEngine>;
  96570. private _onContextLost;
  96571. private _onContextRestored;
  96572. protected _contextWasLost: boolean;
  96573. /** @hidden */
  96574. _doNotHandleContextLost: boolean;
  96575. /**
  96576. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96577. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96578. */
  96579. doNotHandleContextLost: boolean;
  96580. /**
  96581. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96582. */
  96583. disableVertexArrayObjects: boolean;
  96584. /** @hidden */
  96585. protected _depthCullingState: DepthCullingState;
  96586. /** @hidden */
  96587. protected _stencilState: StencilState;
  96588. /** @hidden */
  96589. protected _alphaState: AlphaState;
  96590. /** @hidden */
  96591. _internalTexturesCache: InternalTexture[];
  96592. /** @hidden */
  96593. protected _activeChannel: number;
  96594. private _currentTextureChannel;
  96595. /** @hidden */
  96596. protected _boundTexturesCache: {
  96597. [key: string]: Nullable<InternalTexture>;
  96598. };
  96599. /** @hidden */
  96600. protected _currentEffect: Nullable<Effect>;
  96601. /** @hidden */
  96602. protected _currentProgram: Nullable<WebGLProgram>;
  96603. private _compiledEffects;
  96604. private _vertexAttribArraysEnabled;
  96605. /** @hidden */
  96606. protected _cachedViewport: Nullable<IViewportLike>;
  96607. private _cachedVertexArrayObject;
  96608. /** @hidden */
  96609. protected _cachedVertexBuffers: any;
  96610. /** @hidden */
  96611. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96612. /** @hidden */
  96613. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96614. /** @hidden */
  96615. _currentRenderTarget: Nullable<InternalTexture>;
  96616. private _uintIndicesCurrentlySet;
  96617. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  96618. /** @hidden */
  96619. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96620. private _currentBufferPointers;
  96621. private _currentInstanceLocations;
  96622. private _currentInstanceBuffers;
  96623. private _textureUnits;
  96624. /** @hidden */
  96625. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  96626. /** @hidden */
  96627. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  96628. /** @hidden */
  96629. _bindedRenderFunction: any;
  96630. private _vaoRecordInProgress;
  96631. private _mustWipeVertexAttributes;
  96632. private _emptyTexture;
  96633. private _emptyCubeTexture;
  96634. private _emptyTexture3D;
  96635. /** @hidden */
  96636. _frameHandler: number;
  96637. private _nextFreeTextureSlots;
  96638. private _maxSimultaneousTextures;
  96639. private _activeRequests;
  96640. protected _texturesSupported: string[];
  96641. /** @hidden */
  96642. _textureFormatInUse: Nullable<string>;
  96643. protected readonly _supportsHardwareTextureRescaling: boolean;
  96644. /**
  96645. * Gets the list of texture formats supported
  96646. */
  96647. readonly texturesSupported: Array<string>;
  96648. /**
  96649. * Gets the list of texture formats in use
  96650. */
  96651. readonly textureFormatInUse: Nullable<string>;
  96652. /**
  96653. * Gets the current viewport
  96654. */
  96655. readonly currentViewport: Nullable<IViewportLike>;
  96656. /**
  96657. * Gets the default empty texture
  96658. */
  96659. readonly emptyTexture: InternalTexture;
  96660. /**
  96661. * Gets the default empty 3D texture
  96662. */
  96663. readonly emptyTexture3D: InternalTexture;
  96664. /**
  96665. * Gets the default empty cube texture
  96666. */
  96667. readonly emptyCubeTexture: InternalTexture;
  96668. /**
  96669. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96670. */
  96671. readonly premultipliedAlpha: boolean;
  96672. /**
  96673. * Observable event triggered before each texture is initialized
  96674. */
  96675. onBeforeTextureInitObservable: Observable<Texture>;
  96676. /**
  96677. * Creates a new engine
  96678. * @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
  96679. * @param antialias defines enable antialiasing (default: false)
  96680. * @param options defines further options to be sent to the getContext() function
  96681. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96682. */
  96683. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96684. private _rebuildInternalTextures;
  96685. private _rebuildEffects;
  96686. /**
  96687. * Gets a boolean indicating if all created effects are ready
  96688. * @returns true if all effects are ready
  96689. */
  96690. areAllEffectsReady(): boolean;
  96691. protected _rebuildBuffers(): void;
  96692. private _initGLContext;
  96693. /**
  96694. * Gets version of the current webGL context
  96695. */
  96696. readonly webGLVersion: number;
  96697. /**
  96698. * Gets a string idenfifying the name of the class
  96699. * @returns "Engine" string
  96700. */
  96701. getClassName(): string;
  96702. /**
  96703. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96704. */
  96705. readonly isStencilEnable: boolean;
  96706. /** @hidden */
  96707. _prepareWorkingCanvas(): void;
  96708. /**
  96709. * Reset the texture cache to empty state
  96710. */
  96711. resetTextureCache(): void;
  96712. /**
  96713. * Gets an object containing information about the current webGL context
  96714. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96715. */
  96716. getGlInfo(): {
  96717. vendor: string;
  96718. renderer: string;
  96719. version: string;
  96720. };
  96721. /**
  96722. * Defines the hardware scaling level.
  96723. * By default the hardware scaling level is computed from the window device ratio.
  96724. * 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.
  96725. * @param level defines the level to use
  96726. */
  96727. setHardwareScalingLevel(level: number): void;
  96728. /**
  96729. * Gets the current hardware scaling level.
  96730. * By default the hardware scaling level is computed from the window device ratio.
  96731. * 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.
  96732. * @returns a number indicating the current hardware scaling level
  96733. */
  96734. getHardwareScalingLevel(): number;
  96735. /**
  96736. * Gets the list of loaded textures
  96737. * @returns an array containing all loaded textures
  96738. */
  96739. getLoadedTexturesCache(): InternalTexture[];
  96740. /**
  96741. * Gets the object containing all engine capabilities
  96742. * @returns the EngineCapabilities object
  96743. */
  96744. getCaps(): EngineCapabilities;
  96745. /**
  96746. * stop executing a render loop function and remove it from the execution array
  96747. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96748. */
  96749. stopRenderLoop(renderFunction?: () => void): void;
  96750. /** @hidden */
  96751. _renderLoop(): void;
  96752. /**
  96753. * Gets the HTML canvas attached with the current webGL context
  96754. * @returns a HTML canvas
  96755. */
  96756. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96757. /**
  96758. * Gets host window
  96759. * @returns the host window object
  96760. */
  96761. getHostWindow(): Nullable<Window>;
  96762. /**
  96763. * Gets the current render width
  96764. * @param useScreen defines if screen size must be used (or the current render target if any)
  96765. * @returns a number defining the current render width
  96766. */
  96767. getRenderWidth(useScreen?: boolean): number;
  96768. /**
  96769. * Gets the current render height
  96770. * @param useScreen defines if screen size must be used (or the current render target if any)
  96771. * @returns a number defining the current render height
  96772. */
  96773. getRenderHeight(useScreen?: boolean): number;
  96774. /**
  96775. * Can be used to override the current requestAnimationFrame requester.
  96776. * @hidden
  96777. */
  96778. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96779. /**
  96780. * Register and execute a render loop. The engine can have more than one render function
  96781. * @param renderFunction defines the function to continuously execute
  96782. */
  96783. runRenderLoop(renderFunction: () => void): void;
  96784. /**
  96785. * Clear the current render buffer or the current render target (if any is set up)
  96786. * @param color defines the color to use
  96787. * @param backBuffer defines if the back buffer must be cleared
  96788. * @param depth defines if the depth buffer must be cleared
  96789. * @param stencil defines if the stencil buffer must be cleared
  96790. */
  96791. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96792. private _viewportCached;
  96793. /** @hidden */
  96794. _viewport(x: number, y: number, width: number, height: number): void;
  96795. /**
  96796. * Set the WebGL's viewport
  96797. * @param viewport defines the viewport element to be used
  96798. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96799. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96800. */
  96801. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96802. /**
  96803. * Begin a new frame
  96804. */
  96805. beginFrame(): void;
  96806. /**
  96807. * Enf the current frame
  96808. */
  96809. endFrame(): void;
  96810. /**
  96811. * Resize the view according to the canvas' size
  96812. */
  96813. resize(): void;
  96814. /**
  96815. * Force a specific size of the canvas
  96816. * @param width defines the new canvas' width
  96817. * @param height defines the new canvas' height
  96818. */
  96819. setSize(width: number, height: number): void;
  96820. /**
  96821. * Binds the frame buffer to the specified texture.
  96822. * @param texture The texture to render to or null for the default canvas
  96823. * @param faceIndex The face of the texture to render to in case of cube texture
  96824. * @param requiredWidth The width of the target to render to
  96825. * @param requiredHeight The height of the target to render to
  96826. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96827. * @param depthStencilTexture The depth stencil texture to use to render
  96828. * @param lodLevel defines le lod level to bind to the frame buffer
  96829. */
  96830. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96831. /** @hidden */
  96832. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96833. /**
  96834. * Unbind the current render target texture from the webGL context
  96835. * @param texture defines the render target texture to unbind
  96836. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96837. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96838. */
  96839. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96840. /**
  96841. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96842. */
  96843. flushFramebuffer(): void;
  96844. /**
  96845. * Unbind the current render target and bind the default framebuffer
  96846. */
  96847. restoreDefaultFramebuffer(): void;
  96848. private _resetVertexBufferBinding;
  96849. /**
  96850. * Creates a vertex buffer
  96851. * @param data the data for the vertex buffer
  96852. * @returns the new WebGL static buffer
  96853. */
  96854. createVertexBuffer(data: DataArray): DataBuffer;
  96855. private _createVertexBuffer;
  96856. /**
  96857. * Creates a dynamic vertex buffer
  96858. * @param data the data for the dynamic vertex buffer
  96859. * @returns the new WebGL dynamic buffer
  96860. */
  96861. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96862. /**
  96863. * Updates a dynamic vertex buffer.
  96864. * @param vertexBuffer the vertex buffer to update
  96865. * @param data the data used to update the vertex buffer
  96866. * @param byteOffset the byte offset of the data
  96867. * @param byteLength the byte length of the data
  96868. */
  96869. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96870. protected _resetIndexBufferBinding(): void;
  96871. /**
  96872. * Creates a new index buffer
  96873. * @param indices defines the content of the index buffer
  96874. * @param updatable defines if the index buffer must be updatable
  96875. * @returns a new webGL buffer
  96876. */
  96877. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96878. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96879. /**
  96880. * Bind a webGL buffer to the webGL context
  96881. * @param buffer defines the buffer to bind
  96882. */
  96883. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96884. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96885. private bindBuffer;
  96886. /**
  96887. * update the bound buffer with the given data
  96888. * @param data defines the data to update
  96889. */
  96890. updateArrayBuffer(data: Float32Array): void;
  96891. private _vertexAttribPointer;
  96892. private _bindIndexBufferWithCache;
  96893. private _bindVertexBuffersAttributes;
  96894. /**
  96895. * Records a vertex array object
  96896. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96897. * @param vertexBuffers defines the list of vertex buffers to store
  96898. * @param indexBuffer defines the index buffer to store
  96899. * @param effect defines the effect to store
  96900. * @returns the new vertex array object
  96901. */
  96902. recordVertexArrayObject(vertexBuffers: {
  96903. [key: string]: VertexBuffer;
  96904. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96905. /**
  96906. * Bind a specific vertex array object
  96907. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96908. * @param vertexArrayObject defines the vertex array object to bind
  96909. * @param indexBuffer defines the index buffer to bind
  96910. */
  96911. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96912. /**
  96913. * Bind webGl buffers directly to the webGL context
  96914. * @param vertexBuffer defines the vertex buffer to bind
  96915. * @param indexBuffer defines the index buffer to bind
  96916. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96917. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96918. * @param effect defines the effect associated with the vertex buffer
  96919. */
  96920. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96921. private _unbindVertexArrayObject;
  96922. /**
  96923. * Bind a list of vertex buffers to the webGL context
  96924. * @param vertexBuffers defines the list of vertex buffers to bind
  96925. * @param indexBuffer defines the index buffer to bind
  96926. * @param effect defines the effect associated with the vertex buffers
  96927. */
  96928. bindBuffers(vertexBuffers: {
  96929. [key: string]: Nullable<VertexBuffer>;
  96930. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96931. /**
  96932. * Unbind all instance attributes
  96933. */
  96934. unbindInstanceAttributes(): void;
  96935. /**
  96936. * Release and free the memory of a vertex array object
  96937. * @param vao defines the vertex array object to delete
  96938. */
  96939. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96940. /** @hidden */
  96941. _releaseBuffer(buffer: DataBuffer): boolean;
  96942. protected _deleteBuffer(buffer: DataBuffer): void;
  96943. /**
  96944. * Creates a webGL buffer to use with instanciation
  96945. * @param capacity defines the size of the buffer
  96946. * @returns the webGL buffer
  96947. */
  96948. createInstancesBuffer(capacity: number): DataBuffer;
  96949. /**
  96950. * Delete a webGL buffer used with instanciation
  96951. * @param buffer defines the webGL buffer to delete
  96952. */
  96953. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96954. /**
  96955. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96956. * @param instancesBuffer defines the webGL buffer to update and bind
  96957. * @param data defines the data to store in the buffer
  96958. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96959. */
  96960. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96961. /**
  96962. * Apply all cached states (depth, culling, stencil and alpha)
  96963. */
  96964. applyStates(): void;
  96965. /**
  96966. * Send a draw order
  96967. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96968. * @param indexStart defines the starting index
  96969. * @param indexCount defines the number of index to draw
  96970. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96971. */
  96972. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96973. /**
  96974. * Draw a list of points
  96975. * @param verticesStart defines the index of first vertex to draw
  96976. * @param verticesCount defines the count of vertices to draw
  96977. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96978. */
  96979. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96980. /**
  96981. * Draw a list of unindexed primitives
  96982. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96983. * @param verticesStart defines the index of first vertex to draw
  96984. * @param verticesCount defines the count of vertices to draw
  96985. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96986. */
  96987. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96988. /**
  96989. * Draw a list of indexed primitives
  96990. * @param fillMode defines the primitive to use
  96991. * @param indexStart defines the starting index
  96992. * @param indexCount defines the number of index to draw
  96993. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96994. */
  96995. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96996. /**
  96997. * Draw a list of unindexed primitives
  96998. * @param fillMode defines the primitive to use
  96999. * @param verticesStart defines the index of first vertex to draw
  97000. * @param verticesCount defines the count of vertices to draw
  97001. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97002. */
  97003. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97004. private _drawMode;
  97005. /** @hidden */
  97006. protected _reportDrawCall(): void;
  97007. /** @hidden */
  97008. _releaseEffect(effect: Effect): void;
  97009. /** @hidden */
  97010. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  97011. /**
  97012. * Create a new effect (used to store vertex/fragment shaders)
  97013. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  97014. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  97015. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  97016. * @param samplers defines an array of string used to represent textures
  97017. * @param defines defines the string containing the defines to use to compile the shaders
  97018. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  97019. * @param onCompiled defines a function to call when the effect creation is successful
  97020. * @param onError defines a function to call when the effect creation has failed
  97021. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  97022. * @returns the new Effect
  97023. */
  97024. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  97025. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  97026. private _compileShader;
  97027. private _compileRawShader;
  97028. /**
  97029. * Directly creates a webGL program
  97030. * @param pipelineContext defines the pipeline context to attach to
  97031. * @param vertexCode defines the vertex shader code to use
  97032. * @param fragmentCode defines the fragment shader code to use
  97033. * @param context defines the webGL context to use (if not set, the current one will be used)
  97034. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97035. * @returns the new webGL program
  97036. */
  97037. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97038. /**
  97039. * Creates a webGL program
  97040. * @param pipelineContext defines the pipeline context to attach to
  97041. * @param vertexCode defines the vertex shader code to use
  97042. * @param fragmentCode defines the fragment shader code to use
  97043. * @param defines defines the string containing the defines to use to compile the shaders
  97044. * @param context defines the webGL context to use (if not set, the current one will be used)
  97045. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97046. * @returns the new webGL program
  97047. */
  97048. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97049. /**
  97050. * Creates a new pipeline context
  97051. * @returns the new pipeline
  97052. */
  97053. createPipelineContext(): IPipelineContext;
  97054. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97055. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  97056. /** @hidden */
  97057. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97058. /** @hidden */
  97059. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97060. /** @hidden */
  97061. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97062. /**
  97063. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97064. * @param pipelineContext defines the pipeline context to use
  97065. * @param uniformsNames defines the list of uniform names
  97066. * @returns an array of webGL uniform locations
  97067. */
  97068. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97069. /**
  97070. * Gets the lsit of active attributes for a given webGL program
  97071. * @param pipelineContext defines the pipeline context to use
  97072. * @param attributesNames defines the list of attribute names to get
  97073. * @returns an array of indices indicating the offset of each attribute
  97074. */
  97075. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97076. /**
  97077. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97078. * @param effect defines the effect to activate
  97079. */
  97080. enableEffect(effect: Nullable<Effect>): void;
  97081. /**
  97082. * Set the value of an uniform to an array of int32
  97083. * @param uniform defines the webGL uniform location where to store the value
  97084. * @param array defines the array of int32 to store
  97085. */
  97086. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97087. /**
  97088. * Set the value of an uniform to an array of int32 (stored as vec2)
  97089. * @param uniform defines the webGL uniform location where to store the value
  97090. * @param array defines the array of int32 to store
  97091. */
  97092. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97093. /**
  97094. * Set the value of an uniform to an array of int32 (stored as vec3)
  97095. * @param uniform defines the webGL uniform location where to store the value
  97096. * @param array defines the array of int32 to store
  97097. */
  97098. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97099. /**
  97100. * Set the value of an uniform to an array of int32 (stored as vec4)
  97101. * @param uniform defines the webGL uniform location where to store the value
  97102. * @param array defines the array of int32 to store
  97103. */
  97104. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97105. /**
  97106. * Set the value of an uniform to an array of float32
  97107. * @param uniform defines the webGL uniform location where to store the value
  97108. * @param array defines the array of float32 to store
  97109. */
  97110. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97111. /**
  97112. * Set the value of an uniform to an array of float32 (stored as vec2)
  97113. * @param uniform defines the webGL uniform location where to store the value
  97114. * @param array defines the array of float32 to store
  97115. */
  97116. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97117. /**
  97118. * Set the value of an uniform to an array of float32 (stored as vec3)
  97119. * @param uniform defines the webGL uniform location where to store the value
  97120. * @param array defines the array of float32 to store
  97121. */
  97122. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97123. /**
  97124. * Set the value of an uniform to an array of float32 (stored as vec4)
  97125. * @param uniform defines the webGL uniform location where to store the value
  97126. * @param array defines the array of float32 to store
  97127. */
  97128. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97129. /**
  97130. * Set the value of an uniform to an array of number
  97131. * @param uniform defines the webGL uniform location where to store the value
  97132. * @param array defines the array of number to store
  97133. */
  97134. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97135. /**
  97136. * Set the value of an uniform to an array of number (stored as vec2)
  97137. * @param uniform defines the webGL uniform location where to store the value
  97138. * @param array defines the array of number to store
  97139. */
  97140. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97141. /**
  97142. * Set the value of an uniform to an array of number (stored as vec3)
  97143. * @param uniform defines the webGL uniform location where to store the value
  97144. * @param array defines the array of number to store
  97145. */
  97146. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97147. /**
  97148. * Set the value of an uniform to an array of number (stored as vec4)
  97149. * @param uniform defines the webGL uniform location where to store the value
  97150. * @param array defines the array of number to store
  97151. */
  97152. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97153. /**
  97154. * Set the value of an uniform to an array of float32 (stored as matrices)
  97155. * @param uniform defines the webGL uniform location where to store the value
  97156. * @param matrices defines the array of float32 to store
  97157. */
  97158. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97159. /**
  97160. * Set the value of an uniform to a matrix (3x3)
  97161. * @param uniform defines the webGL uniform location where to store the value
  97162. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97163. */
  97164. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97165. /**
  97166. * Set the value of an uniform to a matrix (2x2)
  97167. * @param uniform defines the webGL uniform location where to store the value
  97168. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97169. */
  97170. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97171. /**
  97172. * Set the value of an uniform to a number (int)
  97173. * @param uniform defines the webGL uniform location where to store the value
  97174. * @param value defines the int number to store
  97175. */
  97176. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97177. /**
  97178. * Set the value of an uniform to a number (float)
  97179. * @param uniform defines the webGL uniform location where to store the value
  97180. * @param value defines the float number to store
  97181. */
  97182. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97183. /**
  97184. * Set the value of an uniform to a vec2
  97185. * @param uniform defines the webGL uniform location where to store the value
  97186. * @param x defines the 1st component of the value
  97187. * @param y defines the 2nd component of the value
  97188. */
  97189. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97190. /**
  97191. * Set the value of an uniform to a vec3
  97192. * @param uniform defines the webGL uniform location where to store the value
  97193. * @param x defines the 1st component of the value
  97194. * @param y defines the 2nd component of the value
  97195. * @param z defines the 3rd component of the value
  97196. */
  97197. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97198. /**
  97199. * Set the value of an uniform to a boolean
  97200. * @param uniform defines the webGL uniform location where to store the value
  97201. * @param bool defines the boolean to store
  97202. */
  97203. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97204. /**
  97205. * Set the value of an uniform to a vec4
  97206. * @param uniform defines the webGL uniform location where to store the value
  97207. * @param x defines the 1st component of the value
  97208. * @param y defines the 2nd component of the value
  97209. * @param z defines the 3rd component of the value
  97210. * @param w defines the 4th component of the value
  97211. */
  97212. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97213. /**
  97214. * Sets a Color4 on a uniform variable
  97215. * @param uniform defines the uniform location
  97216. * @param color4 defines the value to be set
  97217. */
  97218. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97219. /**
  97220. * Gets the depth culling state manager
  97221. */
  97222. readonly depthCullingState: DepthCullingState;
  97223. /**
  97224. * Gets the alpha state manager
  97225. */
  97226. readonly alphaState: AlphaState;
  97227. /**
  97228. * Gets the stencil state manager
  97229. */
  97230. readonly stencilState: StencilState;
  97231. /**
  97232. * Clears the list of texture accessible through engine.
  97233. * This can help preventing texture load conflict due to name collision.
  97234. */
  97235. clearInternalTexturesCache(): void;
  97236. /**
  97237. * Force the entire cache to be cleared
  97238. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97239. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97240. */
  97241. wipeCaches(bruteForce?: boolean): void;
  97242. /** @hidden */
  97243. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97244. min: number;
  97245. mag: number;
  97246. };
  97247. /** @hidden */
  97248. _createTexture(): WebGLTexture;
  97249. /**
  97250. * Usually called from Texture.ts.
  97251. * Passed information to create a WebGLTexture
  97252. * @param urlArg defines a value which contains one of the following:
  97253. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97254. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97255. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97256. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97257. * @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)
  97258. * @param scene needed for loading to the correct scene
  97259. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97260. * @param onLoad optional callback to be called upon successful completion
  97261. * @param onError optional callback to be called upon failure
  97262. * @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
  97263. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97264. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97265. * @param forcedExtension defines the extension to use to pick the right loader
  97266. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97267. * @param mimeType defines an optional mime type
  97268. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97269. */
  97270. 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 | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  97271. /**
  97272. * @hidden
  97273. */
  97274. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  97275. /**
  97276. * Creates a raw texture
  97277. * @param data defines the data to store in the texture
  97278. * @param width defines the width of the texture
  97279. * @param height defines the height of the texture
  97280. * @param format defines the format of the data
  97281. * @param generateMipMaps defines if the engine should generate the mip levels
  97282. * @param invertY defines if data must be stored with Y axis inverted
  97283. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97284. * @param compression defines the compression used (null by default)
  97285. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  97286. * @returns the raw texture inside an InternalTexture
  97287. */
  97288. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  97289. /**
  97290. * Creates a new raw cube texture
  97291. * @param data defines the array of data to use to create each face
  97292. * @param size defines the size of the textures
  97293. * @param format defines the format of the data
  97294. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  97295. * @param generateMipMaps defines if the engine should generate the mip levels
  97296. * @param invertY defines if data must be stored with Y axis inverted
  97297. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97298. * @param compression defines the compression used (null by default)
  97299. * @returns the cube texture as an InternalTexture
  97300. */
  97301. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  97302. /**
  97303. * Creates a new raw 3D texture
  97304. * @param data defines the data used to create the texture
  97305. * @param width defines the width of the texture
  97306. * @param height defines the height of the texture
  97307. * @param depth defines the depth of the texture
  97308. * @param format defines the format of the texture
  97309. * @param generateMipMaps defines if the engine must generate mip levels
  97310. * @param invertY defines if data must be stored with Y axis inverted
  97311. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97312. * @param compression defines the compressed used (can be null)
  97313. * @param textureType defines the compressed used (can be null)
  97314. * @returns a new raw 3D texture (stored in an InternalTexture)
  97315. */
  97316. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  97317. private _unpackFlipYCached;
  97318. /**
  97319. * In case you are sharing the context with other applications, it might
  97320. * be interested to not cache the unpack flip y state to ensure a consistent
  97321. * value would be set.
  97322. */
  97323. enableUnpackFlipYCached: boolean;
  97324. /** @hidden */
  97325. _unpackFlipY(value: boolean): void;
  97326. /** @hidden */
  97327. _getUnpackAlignement(): number;
  97328. /**
  97329. * Update the sampling mode of a given texture
  97330. * @param samplingMode defines the required sampling mode
  97331. * @param texture defines the texture to update
  97332. */
  97333. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97334. /**
  97335. * Updates a depth texture Comparison Mode and Function.
  97336. * If the comparison Function is equal to 0, the mode will be set to none.
  97337. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97338. * @param texture The texture to set the comparison function for
  97339. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97340. */
  97341. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97342. /** @hidden */
  97343. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97344. width: number;
  97345. height: number;
  97346. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97347. /**
  97348. * Creates a depth stencil texture.
  97349. * This is only available in WebGL 2 or with the depth texture extension available.
  97350. * @param size The size of face edge in the texture.
  97351. * @param options The options defining the texture.
  97352. * @returns The texture
  97353. */
  97354. createDepthStencilTexture(size: number | {
  97355. width: number;
  97356. height: number;
  97357. }, options: DepthTextureCreationOptions): InternalTexture;
  97358. /**
  97359. * Creates a depth stencil texture.
  97360. * This is only available in WebGL 2 or with the depth texture extension available.
  97361. * @param size The size of face edge in the texture.
  97362. * @param options The options defining the texture.
  97363. * @returns The texture
  97364. */
  97365. private _createDepthStencilTexture;
  97366. /** @hidden */
  97367. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97368. /** @hidden */
  97369. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97370. /** @hidden */
  97371. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97372. /** @hidden */
  97373. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  97374. /**
  97375. * @hidden
  97376. */
  97377. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97378. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97379. private _prepareWebGLTexture;
  97380. /** @hidden */
  97381. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97382. /** @hidden */
  97383. _releaseFramebufferObjects(texture: InternalTexture): void;
  97384. /** @hidden */
  97385. _releaseTexture(texture: InternalTexture): void;
  97386. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97387. protected _setProgram(program: WebGLProgram): void;
  97388. protected _boundUniforms: {
  97389. [key: number]: WebGLUniformLocation;
  97390. };
  97391. /**
  97392. * Binds an effect to the webGL context
  97393. * @param effect defines the effect to bind
  97394. */
  97395. bindSamplers(effect: Effect): void;
  97396. private _activateCurrentTexture;
  97397. /** @hidden */
  97398. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97399. /** @hidden */
  97400. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97401. /**
  97402. * Unbind all textures from the webGL context
  97403. */
  97404. unbindAllTextures(): void;
  97405. /**
  97406. * Sets a texture to the according uniform.
  97407. * @param channel The texture channel
  97408. * @param uniform The uniform to set
  97409. * @param texture The texture to apply
  97410. */
  97411. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97412. private _bindSamplerUniformToChannel;
  97413. private _getTextureWrapMode;
  97414. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97415. /**
  97416. * Sets an array of texture to the webGL context
  97417. * @param channel defines the channel where the texture array must be set
  97418. * @param uniform defines the associated uniform location
  97419. * @param textures defines the array of textures to bind
  97420. */
  97421. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97422. /** @hidden */
  97423. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97424. private _setTextureParameterFloat;
  97425. private _setTextureParameterInteger;
  97426. /**
  97427. * Unbind all vertex attributes from the webGL context
  97428. */
  97429. unbindAllAttributes(): void;
  97430. /**
  97431. * 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
  97432. */
  97433. releaseEffects(): void;
  97434. /**
  97435. * Dispose and release all associated resources
  97436. */
  97437. dispose(): void;
  97438. /**
  97439. * Attach a new callback raised when context lost event is fired
  97440. * @param callback defines the callback to call
  97441. */
  97442. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97443. /**
  97444. * Attach a new callback raised when context restored event is fired
  97445. * @param callback defines the callback to call
  97446. */
  97447. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97448. /**
  97449. * Get the current error code of the webGL context
  97450. * @returns the error code
  97451. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97452. */
  97453. getError(): number;
  97454. private _canRenderToFloatFramebuffer;
  97455. private _canRenderToHalfFloatFramebuffer;
  97456. private _canRenderToFramebuffer;
  97457. /** @hidden */
  97458. _getWebGLTextureType(type: number): number;
  97459. /** @hidden */
  97460. _getInternalFormat(format: number): number;
  97461. /** @hidden */
  97462. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97463. /** @hidden */
  97464. _getRGBAMultiSampleBufferFormat(type: number): number;
  97465. /** @hidden */
  97466. _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;
  97467. /**
  97468. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97469. * @returns true if the engine can be created
  97470. * @ignorenaming
  97471. */
  97472. static isSupported(): boolean;
  97473. /**
  97474. * Find the next highest power of two.
  97475. * @param x Number to start search from.
  97476. * @return Next highest power of two.
  97477. */
  97478. static CeilingPOT(x: number): number;
  97479. /**
  97480. * Find the next lowest power of two.
  97481. * @param x Number to start search from.
  97482. * @return Next lowest power of two.
  97483. */
  97484. static FloorPOT(x: number): number;
  97485. /**
  97486. * Find the nearest power of two.
  97487. * @param x Number to start search from.
  97488. * @return Next nearest power of two.
  97489. */
  97490. static NearestPOT(x: number): number;
  97491. /**
  97492. * Get the closest exponent of two
  97493. * @param value defines the value to approximate
  97494. * @param max defines the maximum value to return
  97495. * @param mode defines how to define the closest value
  97496. * @returns closest exponent of two of the given value
  97497. */
  97498. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97499. /**
  97500. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97501. * @param func - the function to be called
  97502. * @param requester - the object that will request the next frame. Falls back to window.
  97503. * @returns frame number
  97504. */
  97505. static QueueNewFrame(func: () => void, requester?: any): number;
  97506. }
  97507. }
  97508. declare module BABYLON {
  97509. /**
  97510. * Class representing spherical harmonics coefficients to the 3rd degree
  97511. */
  97512. export class SphericalHarmonics {
  97513. /**
  97514. * Defines whether or not the harmonics have been prescaled for rendering.
  97515. */
  97516. preScaled: boolean;
  97517. /**
  97518. * The l0,0 coefficients of the spherical harmonics
  97519. */
  97520. l00: Vector3;
  97521. /**
  97522. * The l1,-1 coefficients of the spherical harmonics
  97523. */
  97524. l1_1: Vector3;
  97525. /**
  97526. * The l1,0 coefficients of the spherical harmonics
  97527. */
  97528. l10: Vector3;
  97529. /**
  97530. * The l1,1 coefficients of the spherical harmonics
  97531. */
  97532. l11: Vector3;
  97533. /**
  97534. * The l2,-2 coefficients of the spherical harmonics
  97535. */
  97536. l2_2: Vector3;
  97537. /**
  97538. * The l2,-1 coefficients of the spherical harmonics
  97539. */
  97540. l2_1: Vector3;
  97541. /**
  97542. * The l2,0 coefficients of the spherical harmonics
  97543. */
  97544. l20: Vector3;
  97545. /**
  97546. * The l2,1 coefficients of the spherical harmonics
  97547. */
  97548. l21: Vector3;
  97549. /**
  97550. * The l2,2 coefficients of the spherical harmonics
  97551. */
  97552. l22: Vector3;
  97553. /**
  97554. * Adds a light to the spherical harmonics
  97555. * @param direction the direction of the light
  97556. * @param color the color of the light
  97557. * @param deltaSolidAngle the delta solid angle of the light
  97558. */
  97559. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  97560. /**
  97561. * Scales the spherical harmonics by the given amount
  97562. * @param scale the amount to scale
  97563. */
  97564. scaleInPlace(scale: number): void;
  97565. /**
  97566. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  97567. *
  97568. * ```
  97569. * E_lm = A_l * L_lm
  97570. * ```
  97571. *
  97572. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  97573. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  97574. * the scaling factors are given in equation 9.
  97575. */
  97576. convertIncidentRadianceToIrradiance(): void;
  97577. /**
  97578. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  97579. *
  97580. * ```
  97581. * L = (1/pi) * E * rho
  97582. * ```
  97583. *
  97584. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  97585. */
  97586. convertIrradianceToLambertianRadiance(): void;
  97587. /**
  97588. * Integrates the reconstruction coefficients directly in to the SH preventing further
  97589. * required operations at run time.
  97590. *
  97591. * This is simply done by scaling back the SH with Ylm constants parameter.
  97592. * The trigonometric part being applied by the shader at run time.
  97593. */
  97594. preScaleForRendering(): void;
  97595. /**
  97596. * Constructs a spherical harmonics from an array.
  97597. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  97598. * @returns the spherical harmonics
  97599. */
  97600. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  97601. /**
  97602. * Gets the spherical harmonics from polynomial
  97603. * @param polynomial the spherical polynomial
  97604. * @returns the spherical harmonics
  97605. */
  97606. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  97607. }
  97608. /**
  97609. * Class representing spherical polynomial coefficients to the 3rd degree
  97610. */
  97611. export class SphericalPolynomial {
  97612. private _harmonics;
  97613. /**
  97614. * The spherical harmonics used to create the polynomials.
  97615. */
  97616. readonly preScaledHarmonics: SphericalHarmonics;
  97617. /**
  97618. * The x coefficients of the spherical polynomial
  97619. */
  97620. x: Vector3;
  97621. /**
  97622. * The y coefficients of the spherical polynomial
  97623. */
  97624. y: Vector3;
  97625. /**
  97626. * The z coefficients of the spherical polynomial
  97627. */
  97628. z: Vector3;
  97629. /**
  97630. * The xx coefficients of the spherical polynomial
  97631. */
  97632. xx: Vector3;
  97633. /**
  97634. * The yy coefficients of the spherical polynomial
  97635. */
  97636. yy: Vector3;
  97637. /**
  97638. * The zz coefficients of the spherical polynomial
  97639. */
  97640. zz: Vector3;
  97641. /**
  97642. * The xy coefficients of the spherical polynomial
  97643. */
  97644. xy: Vector3;
  97645. /**
  97646. * The yz coefficients of the spherical polynomial
  97647. */
  97648. yz: Vector3;
  97649. /**
  97650. * The zx coefficients of the spherical polynomial
  97651. */
  97652. zx: Vector3;
  97653. /**
  97654. * Adds an ambient color to the spherical polynomial
  97655. * @param color the color to add
  97656. */
  97657. addAmbient(color: Color3): void;
  97658. /**
  97659. * Scales the spherical polynomial by the given amount
  97660. * @param scale the amount to scale
  97661. */
  97662. scaleInPlace(scale: number): void;
  97663. /**
  97664. * Gets the spherical polynomial from harmonics
  97665. * @param harmonics the spherical harmonics
  97666. * @returns the spherical polynomial
  97667. */
  97668. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  97669. /**
  97670. * Constructs a spherical polynomial from an array.
  97671. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  97672. * @returns the spherical polynomial
  97673. */
  97674. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  97675. }
  97676. }
  97677. declare module BABYLON {
  97678. /**
  97679. * Defines the source of the internal texture
  97680. */
  97681. export enum InternalTextureSource {
  97682. /**
  97683. * The source of the texture data is unknown
  97684. */
  97685. Unknown = 0,
  97686. /**
  97687. * Texture data comes from an URL
  97688. */
  97689. Url = 1,
  97690. /**
  97691. * Texture data is only used for temporary storage
  97692. */
  97693. Temp = 2,
  97694. /**
  97695. * Texture data comes from raw data (ArrayBuffer)
  97696. */
  97697. Raw = 3,
  97698. /**
  97699. * Texture content is dynamic (video or dynamic texture)
  97700. */
  97701. Dynamic = 4,
  97702. /**
  97703. * Texture content is generated by rendering to it
  97704. */
  97705. RenderTarget = 5,
  97706. /**
  97707. * Texture content is part of a multi render target process
  97708. */
  97709. MultiRenderTarget = 6,
  97710. /**
  97711. * Texture data comes from a cube data file
  97712. */
  97713. Cube = 7,
  97714. /**
  97715. * Texture data comes from a raw cube data
  97716. */
  97717. CubeRaw = 8,
  97718. /**
  97719. * Texture data come from a prefiltered cube data file
  97720. */
  97721. CubePrefiltered = 9,
  97722. /**
  97723. * Texture content is raw 3D data
  97724. */
  97725. Raw3D = 10,
  97726. /**
  97727. * Texture content is a depth texture
  97728. */
  97729. Depth = 11,
  97730. /**
  97731. * Texture data comes from a raw cube data encoded with RGBD
  97732. */
  97733. CubeRawRGBD = 12
  97734. }
  97735. /**
  97736. * Class used to store data associated with WebGL texture data for the engine
  97737. * This class should not be used directly
  97738. */
  97739. export class InternalTexture {
  97740. /** @hidden */
  97741. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97742. /**
  97743. * Defines if the texture is ready
  97744. */
  97745. isReady: boolean;
  97746. /**
  97747. * Defines if the texture is a cube texture
  97748. */
  97749. isCube: boolean;
  97750. /**
  97751. * Defines if the texture contains 3D data
  97752. */
  97753. is3D: boolean;
  97754. /**
  97755. * Defines if the texture contains multiview data
  97756. */
  97757. isMultiview: boolean;
  97758. /**
  97759. * Gets the URL used to load this texture
  97760. */
  97761. url: string;
  97762. /**
  97763. * Gets the sampling mode of the texture
  97764. */
  97765. samplingMode: number;
  97766. /**
  97767. * Gets a boolean indicating if the texture needs mipmaps generation
  97768. */
  97769. generateMipMaps: boolean;
  97770. /**
  97771. * Gets the number of samples used by the texture (WebGL2+ only)
  97772. */
  97773. samples: number;
  97774. /**
  97775. * Gets the type of the texture (int, float...)
  97776. */
  97777. type: number;
  97778. /**
  97779. * Gets the format of the texture (RGB, RGBA...)
  97780. */
  97781. format: number;
  97782. /**
  97783. * Observable called when the texture is loaded
  97784. */
  97785. onLoadedObservable: Observable<InternalTexture>;
  97786. /**
  97787. * Gets the width of the texture
  97788. */
  97789. width: number;
  97790. /**
  97791. * Gets the height of the texture
  97792. */
  97793. height: number;
  97794. /**
  97795. * Gets the depth of the texture
  97796. */
  97797. depth: number;
  97798. /**
  97799. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97800. */
  97801. baseWidth: number;
  97802. /**
  97803. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97804. */
  97805. baseHeight: number;
  97806. /**
  97807. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97808. */
  97809. baseDepth: number;
  97810. /**
  97811. * Gets a boolean indicating if the texture is inverted on Y axis
  97812. */
  97813. invertY: boolean;
  97814. /** @hidden */
  97815. _invertVScale: boolean;
  97816. /** @hidden */
  97817. _associatedChannel: number;
  97818. /** @hidden */
  97819. _source: InternalTextureSource;
  97820. /** @hidden */
  97821. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  97822. /** @hidden */
  97823. _bufferView: Nullable<ArrayBufferView>;
  97824. /** @hidden */
  97825. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97826. /** @hidden */
  97827. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97828. /** @hidden */
  97829. _size: number;
  97830. /** @hidden */
  97831. _extension: string;
  97832. /** @hidden */
  97833. _files: Nullable<string[]>;
  97834. /** @hidden */
  97835. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97836. /** @hidden */
  97837. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97838. /** @hidden */
  97839. _framebuffer: Nullable<WebGLFramebuffer>;
  97840. /** @hidden */
  97841. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97842. /** @hidden */
  97843. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97844. /** @hidden */
  97845. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97846. /** @hidden */
  97847. _attachments: Nullable<number[]>;
  97848. /** @hidden */
  97849. _cachedCoordinatesMode: Nullable<number>;
  97850. /** @hidden */
  97851. _cachedWrapU: Nullable<number>;
  97852. /** @hidden */
  97853. _cachedWrapV: Nullable<number>;
  97854. /** @hidden */
  97855. _cachedWrapR: Nullable<number>;
  97856. /** @hidden */
  97857. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97858. /** @hidden */
  97859. _isDisabled: boolean;
  97860. /** @hidden */
  97861. _compression: Nullable<string>;
  97862. /** @hidden */
  97863. _generateStencilBuffer: boolean;
  97864. /** @hidden */
  97865. _generateDepthBuffer: boolean;
  97866. /** @hidden */
  97867. _comparisonFunction: number;
  97868. /** @hidden */
  97869. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97870. /** @hidden */
  97871. _lodGenerationScale: number;
  97872. /** @hidden */
  97873. _lodGenerationOffset: number;
  97874. /** @hidden */
  97875. _colorTextureArray: Nullable<WebGLTexture>;
  97876. /** @hidden */
  97877. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97878. /** @hidden */
  97879. _lodTextureHigh: Nullable<BaseTexture>;
  97880. /** @hidden */
  97881. _lodTextureMid: Nullable<BaseTexture>;
  97882. /** @hidden */
  97883. _lodTextureLow: Nullable<BaseTexture>;
  97884. /** @hidden */
  97885. _isRGBD: boolean;
  97886. /** @hidden */
  97887. _linearSpecularLOD: boolean;
  97888. /** @hidden */
  97889. _irradianceTexture: Nullable<BaseTexture>;
  97890. /** @hidden */
  97891. _webGLTexture: Nullable<WebGLTexture>;
  97892. /** @hidden */
  97893. _references: number;
  97894. private _engine;
  97895. /**
  97896. * Gets the Engine the texture belongs to.
  97897. * @returns The babylon engine
  97898. */
  97899. getEngine(): ThinEngine;
  97900. /**
  97901. * Gets the data source type of the texture
  97902. */
  97903. readonly source: InternalTextureSource;
  97904. /**
  97905. * Creates a new InternalTexture
  97906. * @param engine defines the engine to use
  97907. * @param source defines the type of data that will be used
  97908. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97909. */
  97910. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97911. /**
  97912. * Increments the number of references (ie. the number of Texture that point to it)
  97913. */
  97914. incrementReferences(): void;
  97915. /**
  97916. * Change the size of the texture (not the size of the content)
  97917. * @param width defines the new width
  97918. * @param height defines the new height
  97919. * @param depth defines the new depth (1 by default)
  97920. */
  97921. updateSize(width: int, height: int, depth?: int): void;
  97922. /** @hidden */
  97923. _rebuild(): void;
  97924. /** @hidden */
  97925. _swapAndDie(target: InternalTexture): void;
  97926. /**
  97927. * Dispose the current allocated resources
  97928. */
  97929. dispose(): void;
  97930. }
  97931. }
  97932. declare module BABYLON {
  97933. /**
  97934. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97936. */
  97937. export class Analyser {
  97938. /**
  97939. * Gets or sets the smoothing
  97940. * @ignorenaming
  97941. */
  97942. SMOOTHING: number;
  97943. /**
  97944. * Gets or sets the FFT table size
  97945. * @ignorenaming
  97946. */
  97947. FFT_SIZE: number;
  97948. /**
  97949. * Gets or sets the bar graph amplitude
  97950. * @ignorenaming
  97951. */
  97952. BARGRAPHAMPLITUDE: number;
  97953. /**
  97954. * Gets or sets the position of the debug canvas
  97955. * @ignorenaming
  97956. */
  97957. DEBUGCANVASPOS: {
  97958. x: number;
  97959. y: number;
  97960. };
  97961. /**
  97962. * Gets or sets the debug canvas size
  97963. * @ignorenaming
  97964. */
  97965. DEBUGCANVASSIZE: {
  97966. width: number;
  97967. height: number;
  97968. };
  97969. private _byteFreqs;
  97970. private _byteTime;
  97971. private _floatFreqs;
  97972. private _webAudioAnalyser;
  97973. private _debugCanvas;
  97974. private _debugCanvasContext;
  97975. private _scene;
  97976. private _registerFunc;
  97977. private _audioEngine;
  97978. /**
  97979. * Creates a new analyser
  97980. * @param scene defines hosting scene
  97981. */
  97982. constructor(scene: Scene);
  97983. /**
  97984. * Get the number of data values you will have to play with for the visualization
  97985. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97986. * @returns a number
  97987. */
  97988. getFrequencyBinCount(): number;
  97989. /**
  97990. * Gets the current frequency data as a byte array
  97991. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97992. * @returns a Uint8Array
  97993. */
  97994. getByteFrequencyData(): Uint8Array;
  97995. /**
  97996. * Gets the current waveform as a byte array
  97997. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97998. * @returns a Uint8Array
  97999. */
  98000. getByteTimeDomainData(): Uint8Array;
  98001. /**
  98002. * Gets the current frequency data as a float array
  98003. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98004. * @returns a Float32Array
  98005. */
  98006. getFloatFrequencyData(): Float32Array;
  98007. /**
  98008. * Renders the debug canvas
  98009. */
  98010. drawDebugCanvas(): void;
  98011. /**
  98012. * Stops rendering the debug canvas and removes it
  98013. */
  98014. stopDebugCanvas(): void;
  98015. /**
  98016. * Connects two audio nodes
  98017. * @param inputAudioNode defines first node to connect
  98018. * @param outputAudioNode defines second node to connect
  98019. */
  98020. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  98021. /**
  98022. * Releases all associated resources
  98023. */
  98024. dispose(): void;
  98025. }
  98026. }
  98027. declare module BABYLON {
  98028. /**
  98029. * This represents an audio engine and it is responsible
  98030. * to play, synchronize and analyse sounds throughout the application.
  98031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98032. */
  98033. export interface IAudioEngine extends IDisposable {
  98034. /**
  98035. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98036. */
  98037. readonly canUseWebAudio: boolean;
  98038. /**
  98039. * Gets the current AudioContext if available.
  98040. */
  98041. readonly audioContext: Nullable<AudioContext>;
  98042. /**
  98043. * The master gain node defines the global audio volume of your audio engine.
  98044. */
  98045. readonly masterGain: GainNode;
  98046. /**
  98047. * Gets whether or not mp3 are supported by your browser.
  98048. */
  98049. readonly isMP3supported: boolean;
  98050. /**
  98051. * Gets whether or not ogg are supported by your browser.
  98052. */
  98053. readonly isOGGsupported: boolean;
  98054. /**
  98055. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98056. * @ignoreNaming
  98057. */
  98058. WarnedWebAudioUnsupported: boolean;
  98059. /**
  98060. * Defines if the audio engine relies on a custom unlocked button.
  98061. * In this case, the embedded button will not be displayed.
  98062. */
  98063. useCustomUnlockedButton: boolean;
  98064. /**
  98065. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  98066. */
  98067. readonly unlocked: boolean;
  98068. /**
  98069. * Event raised when audio has been unlocked on the browser.
  98070. */
  98071. onAudioUnlockedObservable: Observable<AudioEngine>;
  98072. /**
  98073. * Event raised when audio has been locked on the browser.
  98074. */
  98075. onAudioLockedObservable: Observable<AudioEngine>;
  98076. /**
  98077. * Flags the audio engine in Locked state.
  98078. * This happens due to new browser policies preventing audio to autoplay.
  98079. */
  98080. lock(): void;
  98081. /**
  98082. * Unlocks the audio engine once a user action has been done on the dom.
  98083. * This is helpful to resume play once browser policies have been satisfied.
  98084. */
  98085. unlock(): void;
  98086. }
  98087. /**
  98088. * This represents the default audio engine used in babylon.
  98089. * It is responsible to play, synchronize and analyse sounds throughout the application.
  98090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98091. */
  98092. export class AudioEngine implements IAudioEngine {
  98093. private _audioContext;
  98094. private _audioContextInitialized;
  98095. private _muteButton;
  98096. private _hostElement;
  98097. /**
  98098. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98099. */
  98100. canUseWebAudio: boolean;
  98101. /**
  98102. * The master gain node defines the global audio volume of your audio engine.
  98103. */
  98104. masterGain: GainNode;
  98105. /**
  98106. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98107. * @ignoreNaming
  98108. */
  98109. WarnedWebAudioUnsupported: boolean;
  98110. /**
  98111. * Gets whether or not mp3 are supported by your browser.
  98112. */
  98113. isMP3supported: boolean;
  98114. /**
  98115. * Gets whether or not ogg are supported by your browser.
  98116. */
  98117. isOGGsupported: boolean;
  98118. /**
  98119. * Gets whether audio has been unlocked on the device.
  98120. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98121. * a user interaction has happened.
  98122. */
  98123. unlocked: boolean;
  98124. /**
  98125. * Defines if the audio engine relies on a custom unlocked button.
  98126. * In this case, the embedded button will not be displayed.
  98127. */
  98128. useCustomUnlockedButton: boolean;
  98129. /**
  98130. * Event raised when audio has been unlocked on the browser.
  98131. */
  98132. onAudioUnlockedObservable: Observable<AudioEngine>;
  98133. /**
  98134. * Event raised when audio has been locked on the browser.
  98135. */
  98136. onAudioLockedObservable: Observable<AudioEngine>;
  98137. /**
  98138. * Gets the current AudioContext if available.
  98139. */
  98140. readonly audioContext: Nullable<AudioContext>;
  98141. private _connectedAnalyser;
  98142. /**
  98143. * Instantiates a new audio engine.
  98144. *
  98145. * There should be only one per page as some browsers restrict the number
  98146. * of audio contexts you can create.
  98147. * @param hostElement defines the host element where to display the mute icon if necessary
  98148. */
  98149. constructor(hostElement?: Nullable<HTMLElement>);
  98150. /**
  98151. * Flags the audio engine in Locked state.
  98152. * This happens due to new browser policies preventing audio to autoplay.
  98153. */
  98154. lock(): void;
  98155. /**
  98156. * Unlocks the audio engine once a user action has been done on the dom.
  98157. * This is helpful to resume play once browser policies have been satisfied.
  98158. */
  98159. unlock(): void;
  98160. private _resumeAudioContext;
  98161. private _initializeAudioContext;
  98162. private _tryToRun;
  98163. private _triggerRunningState;
  98164. private _triggerSuspendedState;
  98165. private _displayMuteButton;
  98166. private _moveButtonToTopLeft;
  98167. private _onResize;
  98168. private _hideMuteButton;
  98169. /**
  98170. * Destroy and release the resources associated with the audio ccontext.
  98171. */
  98172. dispose(): void;
  98173. /**
  98174. * Gets the global volume sets on the master gain.
  98175. * @returns the global volume if set or -1 otherwise
  98176. */
  98177. getGlobalVolume(): number;
  98178. /**
  98179. * Sets the global volume of your experience (sets on the master gain).
  98180. * @param newVolume Defines the new global volume of the application
  98181. */
  98182. setGlobalVolume(newVolume: number): void;
  98183. /**
  98184. * Connect the audio engine to an audio analyser allowing some amazing
  98185. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98187. * @param analyser The analyser to connect to the engine
  98188. */
  98189. connectToAnalyser(analyser: Analyser): void;
  98190. }
  98191. }
  98192. declare module BABYLON {
  98193. /**
  98194. * Interface used to present a loading screen while loading a scene
  98195. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98196. */
  98197. export interface ILoadingScreen {
  98198. /**
  98199. * Function called to display the loading screen
  98200. */
  98201. displayLoadingUI: () => void;
  98202. /**
  98203. * Function called to hide the loading screen
  98204. */
  98205. hideLoadingUI: () => void;
  98206. /**
  98207. * Gets or sets the color to use for the background
  98208. */
  98209. loadingUIBackgroundColor: string;
  98210. /**
  98211. * Gets or sets the text to display while loading
  98212. */
  98213. loadingUIText: string;
  98214. }
  98215. /**
  98216. * Class used for the default loading screen
  98217. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98218. */
  98219. export class DefaultLoadingScreen implements ILoadingScreen {
  98220. private _renderingCanvas;
  98221. private _loadingText;
  98222. private _loadingDivBackgroundColor;
  98223. private _loadingDiv;
  98224. private _loadingTextDiv;
  98225. /** Gets or sets the logo url to use for the default loading screen */
  98226. static DefaultLogoUrl: string;
  98227. /** Gets or sets the spinner url to use for the default loading screen */
  98228. static DefaultSpinnerUrl: string;
  98229. /**
  98230. * Creates a new default loading screen
  98231. * @param _renderingCanvas defines the canvas used to render the scene
  98232. * @param _loadingText defines the default text to display
  98233. * @param _loadingDivBackgroundColor defines the default background color
  98234. */
  98235. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  98236. /**
  98237. * Function called to display the loading screen
  98238. */
  98239. displayLoadingUI(): void;
  98240. /**
  98241. * Function called to hide the loading screen
  98242. */
  98243. hideLoadingUI(): void;
  98244. /**
  98245. * Gets or sets the text to display while loading
  98246. */
  98247. loadingUIText: string;
  98248. /**
  98249. * Gets or sets the color to use for the background
  98250. */
  98251. loadingUIBackgroundColor: string;
  98252. private _resizeLoadingUI;
  98253. }
  98254. }
  98255. declare module BABYLON {
  98256. /**
  98257. * Interface for any object that can request an animation frame
  98258. */
  98259. export interface ICustomAnimationFrameRequester {
  98260. /**
  98261. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  98262. */
  98263. renderFunction?: Function;
  98264. /**
  98265. * Called to request the next frame to render to
  98266. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  98267. */
  98268. requestAnimationFrame: Function;
  98269. /**
  98270. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  98271. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  98272. */
  98273. requestID?: number;
  98274. }
  98275. }
  98276. declare module BABYLON {
  98277. /**
  98278. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  98279. */
  98280. export class PerformanceMonitor {
  98281. private _enabled;
  98282. private _rollingFrameTime;
  98283. private _lastFrameTimeMs;
  98284. /**
  98285. * constructor
  98286. * @param frameSampleSize The number of samples required to saturate the sliding window
  98287. */
  98288. constructor(frameSampleSize?: number);
  98289. /**
  98290. * Samples current frame
  98291. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  98292. */
  98293. sampleFrame(timeMs?: number): void;
  98294. /**
  98295. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98296. */
  98297. readonly averageFrameTime: number;
  98298. /**
  98299. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98300. */
  98301. readonly averageFrameTimeVariance: number;
  98302. /**
  98303. * Returns the frame time of the most recent frame
  98304. */
  98305. readonly instantaneousFrameTime: number;
  98306. /**
  98307. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98308. */
  98309. readonly averageFPS: number;
  98310. /**
  98311. * Returns the average framerate in frames per second using the most recent frame time
  98312. */
  98313. readonly instantaneousFPS: number;
  98314. /**
  98315. * Returns true if enough samples have been taken to completely fill the sliding window
  98316. */
  98317. readonly isSaturated: boolean;
  98318. /**
  98319. * Enables contributions to the sliding window sample set
  98320. */
  98321. enable(): void;
  98322. /**
  98323. * Disables contributions to the sliding window sample set
  98324. * Samples will not be interpolated over the disabled period
  98325. */
  98326. disable(): void;
  98327. /**
  98328. * Returns true if sampling is enabled
  98329. */
  98330. readonly isEnabled: boolean;
  98331. /**
  98332. * Resets performance monitor
  98333. */
  98334. reset(): void;
  98335. }
  98336. /**
  98337. * RollingAverage
  98338. *
  98339. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98340. */
  98341. export class RollingAverage {
  98342. /**
  98343. * Current average
  98344. */
  98345. average: number;
  98346. /**
  98347. * Current variance
  98348. */
  98349. variance: number;
  98350. protected _samples: Array<number>;
  98351. protected _sampleCount: number;
  98352. protected _pos: number;
  98353. protected _m2: number;
  98354. /**
  98355. * constructor
  98356. * @param length The number of samples required to saturate the sliding window
  98357. */
  98358. constructor(length: number);
  98359. /**
  98360. * Adds a sample to the sample set
  98361. * @param v The sample value
  98362. */
  98363. add(v: number): void;
  98364. /**
  98365. * Returns previously added values or null if outside of history or outside the sliding window domain
  98366. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98367. * @return Value previously recorded with add() or null if outside of range
  98368. */
  98369. history(i: number): number;
  98370. /**
  98371. * Returns true if enough samples have been taken to completely fill the sliding window
  98372. * @return true if sample-set saturated
  98373. */
  98374. isSaturated(): boolean;
  98375. /**
  98376. * Resets the rolling average (equivalent to 0 samples taken so far)
  98377. */
  98378. reset(): void;
  98379. /**
  98380. * Wraps a value around the sample range boundaries
  98381. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98382. * @return Wrapped position in sample range
  98383. */
  98384. protected _wrapPosition(i: number): number;
  98385. }
  98386. }
  98387. declare module BABYLON {
  98388. /**
  98389. * This class is used to track a performance counter which is number based.
  98390. * The user has access to many properties which give statistics of different nature.
  98391. *
  98392. * The implementer can track two kinds of Performance Counter: time and count.
  98393. * 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.
  98394. * 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.
  98395. */
  98396. export class PerfCounter {
  98397. /**
  98398. * Gets or sets a global boolean to turn on and off all the counters
  98399. */
  98400. static Enabled: boolean;
  98401. /**
  98402. * Returns the smallest value ever
  98403. */
  98404. readonly min: number;
  98405. /**
  98406. * Returns the biggest value ever
  98407. */
  98408. readonly max: number;
  98409. /**
  98410. * Returns the average value since the performance counter is running
  98411. */
  98412. readonly average: number;
  98413. /**
  98414. * Returns the average value of the last second the counter was monitored
  98415. */
  98416. readonly lastSecAverage: number;
  98417. /**
  98418. * Returns the current value
  98419. */
  98420. readonly current: number;
  98421. /**
  98422. * Gets the accumulated total
  98423. */
  98424. readonly total: number;
  98425. /**
  98426. * Gets the total value count
  98427. */
  98428. readonly count: number;
  98429. /**
  98430. * Creates a new counter
  98431. */
  98432. constructor();
  98433. /**
  98434. * Call this method to start monitoring a new frame.
  98435. * 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.
  98436. */
  98437. fetchNewFrame(): void;
  98438. /**
  98439. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98440. * @param newCount the count value to add to the monitored count
  98441. * @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.
  98442. */
  98443. addCount(newCount: number, fetchResult: boolean): void;
  98444. /**
  98445. * Start monitoring this performance counter
  98446. */
  98447. beginMonitoring(): void;
  98448. /**
  98449. * Compute the time lapsed since the previous beginMonitoring() call.
  98450. * @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
  98451. */
  98452. endMonitoring(newFrame?: boolean): void;
  98453. private _fetchResult;
  98454. private _startMonitoringTime;
  98455. private _min;
  98456. private _max;
  98457. private _average;
  98458. private _current;
  98459. private _totalValueCount;
  98460. private _totalAccumulated;
  98461. private _lastSecAverage;
  98462. private _lastSecAccumulated;
  98463. private _lastSecTime;
  98464. private _lastSecValueCount;
  98465. }
  98466. }
  98467. declare module BABYLON {
  98468. /**
  98469. * Defines the interface used by display changed events
  98470. */
  98471. export interface IDisplayChangedEventArgs {
  98472. /** Gets the vrDisplay object (if any) */
  98473. vrDisplay: Nullable<any>;
  98474. /** Gets a boolean indicating if webVR is supported */
  98475. vrSupported: boolean;
  98476. }
  98477. /**
  98478. * Defines the interface used by objects containing a viewport (like a camera)
  98479. */
  98480. interface IViewportOwnerLike {
  98481. /**
  98482. * Gets or sets the viewport
  98483. */
  98484. viewport: IViewportLike;
  98485. }
  98486. /**
  98487. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  98488. */
  98489. export class Engine extends ThinEngine {
  98490. /** Defines that alpha blending is disabled */
  98491. static readonly ALPHA_DISABLE: number;
  98492. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  98493. static readonly ALPHA_ADD: number;
  98494. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  98495. static readonly ALPHA_COMBINE: number;
  98496. /** Defines that alpha blending to DEST - SRC * DEST */
  98497. static readonly ALPHA_SUBTRACT: number;
  98498. /** Defines that alpha blending to SRC * DEST */
  98499. static readonly ALPHA_MULTIPLY: number;
  98500. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  98501. static readonly ALPHA_MAXIMIZED: number;
  98502. /** Defines that alpha blending to SRC + DEST */
  98503. static readonly ALPHA_ONEONE: number;
  98504. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  98505. static readonly ALPHA_PREMULTIPLIED: number;
  98506. /**
  98507. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  98508. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  98509. */
  98510. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  98511. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  98512. static readonly ALPHA_INTERPOLATE: number;
  98513. /**
  98514. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  98515. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  98516. */
  98517. static readonly ALPHA_SCREENMODE: number;
  98518. /** Defines that the ressource is not delayed*/
  98519. static readonly DELAYLOADSTATE_NONE: number;
  98520. /** Defines that the ressource was successfully delay loaded */
  98521. static readonly DELAYLOADSTATE_LOADED: number;
  98522. /** Defines that the ressource is currently delay loading */
  98523. static readonly DELAYLOADSTATE_LOADING: number;
  98524. /** Defines that the ressource is delayed and has not started loading */
  98525. static readonly DELAYLOADSTATE_NOTLOADED: number;
  98526. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  98527. static readonly NEVER: number;
  98528. /** 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 */
  98529. static readonly ALWAYS: number;
  98530. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  98531. static readonly LESS: number;
  98532. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  98533. static readonly EQUAL: number;
  98534. /** 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 */
  98535. static readonly LEQUAL: number;
  98536. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  98537. static readonly GREATER: number;
  98538. /** 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 */
  98539. static readonly GEQUAL: number;
  98540. /** 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 */
  98541. static readonly NOTEQUAL: number;
  98542. /** Passed to stencilOperation to specify that stencil value must be kept */
  98543. static readonly KEEP: number;
  98544. /** Passed to stencilOperation to specify that stencil value must be replaced */
  98545. static readonly REPLACE: number;
  98546. /** Passed to stencilOperation to specify that stencil value must be incremented */
  98547. static readonly INCR: number;
  98548. /** Passed to stencilOperation to specify that stencil value must be decremented */
  98549. static readonly DECR: number;
  98550. /** Passed to stencilOperation to specify that stencil value must be inverted */
  98551. static readonly INVERT: number;
  98552. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  98553. static readonly INCR_WRAP: number;
  98554. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  98555. static readonly DECR_WRAP: number;
  98556. /** Texture is not repeating outside of 0..1 UVs */
  98557. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  98558. /** Texture is repeating outside of 0..1 UVs */
  98559. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  98560. /** Texture is repeating and mirrored */
  98561. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  98562. /** ALPHA */
  98563. static readonly TEXTUREFORMAT_ALPHA: number;
  98564. /** LUMINANCE */
  98565. static readonly TEXTUREFORMAT_LUMINANCE: number;
  98566. /** LUMINANCE_ALPHA */
  98567. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  98568. /** RGB */
  98569. static readonly TEXTUREFORMAT_RGB: number;
  98570. /** RGBA */
  98571. static readonly TEXTUREFORMAT_RGBA: number;
  98572. /** RED */
  98573. static readonly TEXTUREFORMAT_RED: number;
  98574. /** RED (2nd reference) */
  98575. static readonly TEXTUREFORMAT_R: number;
  98576. /** RG */
  98577. static readonly TEXTUREFORMAT_RG: number;
  98578. /** RED_INTEGER */
  98579. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  98580. /** RED_INTEGER (2nd reference) */
  98581. static readonly TEXTUREFORMAT_R_INTEGER: number;
  98582. /** RG_INTEGER */
  98583. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  98584. /** RGB_INTEGER */
  98585. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  98586. /** RGBA_INTEGER */
  98587. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  98588. /** UNSIGNED_BYTE */
  98589. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  98590. /** UNSIGNED_BYTE (2nd reference) */
  98591. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  98592. /** FLOAT */
  98593. static readonly TEXTURETYPE_FLOAT: number;
  98594. /** HALF_FLOAT */
  98595. static readonly TEXTURETYPE_HALF_FLOAT: number;
  98596. /** BYTE */
  98597. static readonly TEXTURETYPE_BYTE: number;
  98598. /** SHORT */
  98599. static readonly TEXTURETYPE_SHORT: number;
  98600. /** UNSIGNED_SHORT */
  98601. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  98602. /** INT */
  98603. static readonly TEXTURETYPE_INT: number;
  98604. /** UNSIGNED_INT */
  98605. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  98606. /** UNSIGNED_SHORT_4_4_4_4 */
  98607. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  98608. /** UNSIGNED_SHORT_5_5_5_1 */
  98609. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  98610. /** UNSIGNED_SHORT_5_6_5 */
  98611. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  98612. /** UNSIGNED_INT_2_10_10_10_REV */
  98613. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  98614. /** UNSIGNED_INT_24_8 */
  98615. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  98616. /** UNSIGNED_INT_10F_11F_11F_REV */
  98617. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  98618. /** UNSIGNED_INT_5_9_9_9_REV */
  98619. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  98620. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  98621. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  98622. /** nearest is mag = nearest and min = nearest and mip = linear */
  98623. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  98624. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98625. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  98626. /** Trilinear is mag = linear and min = linear and mip = linear */
  98627. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  98628. /** nearest is mag = nearest and min = nearest and mip = linear */
  98629. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  98630. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98631. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  98632. /** Trilinear is mag = linear and min = linear and mip = linear */
  98633. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  98634. /** mag = nearest and min = nearest and mip = nearest */
  98635. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  98636. /** mag = nearest and min = linear and mip = nearest */
  98637. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  98638. /** mag = nearest and min = linear and mip = linear */
  98639. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  98640. /** mag = nearest and min = linear and mip = none */
  98641. static readonly TEXTURE_NEAREST_LINEAR: number;
  98642. /** mag = nearest and min = nearest and mip = none */
  98643. static readonly TEXTURE_NEAREST_NEAREST: number;
  98644. /** mag = linear and min = nearest and mip = nearest */
  98645. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  98646. /** mag = linear and min = nearest and mip = linear */
  98647. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  98648. /** mag = linear and min = linear and mip = none */
  98649. static readonly TEXTURE_LINEAR_LINEAR: number;
  98650. /** mag = linear and min = nearest and mip = none */
  98651. static readonly TEXTURE_LINEAR_NEAREST: number;
  98652. /** Explicit coordinates mode */
  98653. static readonly TEXTURE_EXPLICIT_MODE: number;
  98654. /** Spherical coordinates mode */
  98655. static readonly TEXTURE_SPHERICAL_MODE: number;
  98656. /** Planar coordinates mode */
  98657. static readonly TEXTURE_PLANAR_MODE: number;
  98658. /** Cubic coordinates mode */
  98659. static readonly TEXTURE_CUBIC_MODE: number;
  98660. /** Projection coordinates mode */
  98661. static readonly TEXTURE_PROJECTION_MODE: number;
  98662. /** Skybox coordinates mode */
  98663. static readonly TEXTURE_SKYBOX_MODE: number;
  98664. /** Inverse Cubic coordinates mode */
  98665. static readonly TEXTURE_INVCUBIC_MODE: number;
  98666. /** Equirectangular coordinates mode */
  98667. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  98668. /** Equirectangular Fixed coordinates mode */
  98669. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  98670. /** Equirectangular Fixed Mirrored coordinates mode */
  98671. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  98672. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  98673. static readonly SCALEMODE_FLOOR: number;
  98674. /** Defines that texture rescaling will look for the nearest power of 2 size */
  98675. static readonly SCALEMODE_NEAREST: number;
  98676. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  98677. static readonly SCALEMODE_CEILING: number;
  98678. /**
  98679. * Returns the current npm package of the sdk
  98680. */
  98681. static readonly NpmPackage: string;
  98682. /**
  98683. * Returns the current version of the framework
  98684. */
  98685. static readonly Version: string;
  98686. /** Gets the list of created engines */
  98687. static readonly Instances: Engine[];
  98688. /**
  98689. * Gets the latest created engine
  98690. */
  98691. static readonly LastCreatedEngine: Nullable<Engine>;
  98692. /**
  98693. * Gets the latest created scene
  98694. */
  98695. static readonly LastCreatedScene: Nullable<Scene>;
  98696. /**
  98697. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  98698. * @param flag defines which part of the materials must be marked as dirty
  98699. * @param predicate defines a predicate used to filter which materials should be affected
  98700. */
  98701. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98702. /**
  98703. * Method called to create the default loading screen.
  98704. * This can be overriden in your own app.
  98705. * @param canvas The rendering canvas element
  98706. * @returns The loading screen
  98707. */
  98708. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  98709. /**
  98710. * Method called to create the default rescale post process on each engine.
  98711. */
  98712. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  98713. /**
  98714. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  98715. **/
  98716. enableOfflineSupport: boolean;
  98717. /**
  98718. * 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)
  98719. **/
  98720. disableManifestCheck: boolean;
  98721. /**
  98722. * Gets the list of created scenes
  98723. */
  98724. scenes: Scene[];
  98725. /**
  98726. * Event raised when a new scene is created
  98727. */
  98728. onNewSceneAddedObservable: Observable<Scene>;
  98729. /**
  98730. * Gets the list of created postprocesses
  98731. */
  98732. postProcesses: PostProcess[];
  98733. /**
  98734. * Gets a boolean indicating if the pointer is currently locked
  98735. */
  98736. isPointerLock: boolean;
  98737. /**
  98738. * Observable event triggered each time the rendering canvas is resized
  98739. */
  98740. onResizeObservable: Observable<Engine>;
  98741. /**
  98742. * Observable event triggered each time the canvas loses focus
  98743. */
  98744. onCanvasBlurObservable: Observable<Engine>;
  98745. /**
  98746. * Observable event triggered each time the canvas gains focus
  98747. */
  98748. onCanvasFocusObservable: Observable<Engine>;
  98749. /**
  98750. * Observable event triggered each time the canvas receives pointerout event
  98751. */
  98752. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98753. /**
  98754. * Observable raised when the engine begins a new frame
  98755. */
  98756. onBeginFrameObservable: Observable<Engine>;
  98757. /**
  98758. * If set, will be used to request the next animation frame for the render loop
  98759. */
  98760. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98761. /**
  98762. * Observable raised when the engine ends the current frame
  98763. */
  98764. onEndFrameObservable: Observable<Engine>;
  98765. /**
  98766. * Observable raised when the engine is about to compile a shader
  98767. */
  98768. onBeforeShaderCompilationObservable: Observable<Engine>;
  98769. /**
  98770. * Observable raised when the engine has jsut compiled a shader
  98771. */
  98772. onAfterShaderCompilationObservable: Observable<Engine>;
  98773. /**
  98774. * Gets the audio engine
  98775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98776. * @ignorenaming
  98777. */
  98778. static audioEngine: IAudioEngine;
  98779. /**
  98780. * Default AudioEngine factory responsible of creating the Audio Engine.
  98781. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98782. */
  98783. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98784. /**
  98785. * Default offline support factory responsible of creating a tool used to store data locally.
  98786. * By default, this will create a Database object if the workload has been embedded.
  98787. */
  98788. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98789. private _loadingScreen;
  98790. private _pointerLockRequested;
  98791. private _dummyFramebuffer;
  98792. private _rescalePostProcess;
  98793. /** @hidden */
  98794. protected _alphaMode: number;
  98795. /** @hidden */
  98796. protected _alphaEquation: number;
  98797. private _deterministicLockstep;
  98798. private _lockstepMaxSteps;
  98799. protected readonly _supportsHardwareTextureRescaling: boolean;
  98800. private _fps;
  98801. private _deltaTime;
  98802. /** @hidden */
  98803. _drawCalls: PerfCounter;
  98804. /**
  98805. * Turn this value on if you want to pause FPS computation when in background
  98806. */
  98807. disablePerformanceMonitorInBackground: boolean;
  98808. private _performanceMonitor;
  98809. /**
  98810. * Gets the performance monitor attached to this engine
  98811. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98812. */
  98813. readonly performanceMonitor: PerformanceMonitor;
  98814. private _onFocus;
  98815. private _onBlur;
  98816. private _onCanvasPointerOut;
  98817. private _onCanvasBlur;
  98818. private _onCanvasFocus;
  98819. private _onFullscreenChange;
  98820. private _onPointerLockChange;
  98821. /**
  98822. * Creates a new engine
  98823. * @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
  98824. * @param antialias defines enable antialiasing (default: false)
  98825. * @param options defines further options to be sent to the getContext() function
  98826. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98827. */
  98828. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98829. /**
  98830. * Gets current aspect ratio
  98831. * @param viewportOwner defines the camera to use to get the aspect ratio
  98832. * @param useScreen defines if screen size must be used (or the current render target if any)
  98833. * @returns a number defining the aspect ratio
  98834. */
  98835. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98836. /**
  98837. * Gets current screen aspect ratio
  98838. * @returns a number defining the aspect ratio
  98839. */
  98840. getScreenAspectRatio(): number;
  98841. /**
  98842. * Gets host document
  98843. * @returns the host document object
  98844. */
  98845. getHostDocument(): Document;
  98846. /**
  98847. * Gets the client rect of the HTML canvas attached with the current webGL context
  98848. * @returns a client rectanglee
  98849. */
  98850. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98851. /**
  98852. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98853. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98854. * @returns true if engine is in deterministic lock step mode
  98855. */
  98856. isDeterministicLockStep(): boolean;
  98857. /**
  98858. * Gets the max steps when engine is running in deterministic lock step
  98859. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98860. * @returns the max steps
  98861. */
  98862. getLockstepMaxSteps(): number;
  98863. /**
  98864. * Force the mipmap generation for the given render target texture
  98865. * @param texture defines the render target texture to use
  98866. */
  98867. generateMipMapsForCubemap(texture: InternalTexture): void;
  98868. /** States */
  98869. /**
  98870. * Set various states to the webGL context
  98871. * @param culling defines backface culling state
  98872. * @param zOffset defines the value to apply to zOffset (0 by default)
  98873. * @param force defines if states must be applied even if cache is up to date
  98874. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98875. */
  98876. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98877. /**
  98878. * Set the z offset to apply to current rendering
  98879. * @param value defines the offset to apply
  98880. */
  98881. setZOffset(value: number): void;
  98882. /**
  98883. * Gets the current value of the zOffset
  98884. * @returns the current zOffset state
  98885. */
  98886. getZOffset(): number;
  98887. /**
  98888. * Enable or disable depth buffering
  98889. * @param enable defines the state to set
  98890. */
  98891. setDepthBuffer(enable: boolean): void;
  98892. /**
  98893. * Gets a boolean indicating if depth writing is enabled
  98894. * @returns the current depth writing state
  98895. */
  98896. getDepthWrite(): boolean;
  98897. /**
  98898. * Enable or disable depth writing
  98899. * @param enable defines the state to set
  98900. */
  98901. setDepthWrite(enable: boolean): void;
  98902. /**
  98903. * Enable or disable color writing
  98904. * @param enable defines the state to set
  98905. */
  98906. setColorWrite(enable: boolean): void;
  98907. /**
  98908. * Gets a boolean indicating if color writing is enabled
  98909. * @returns the current color writing state
  98910. */
  98911. getColorWrite(): boolean;
  98912. /**
  98913. * Sets alpha constants used by some alpha blending modes
  98914. * @param r defines the red component
  98915. * @param g defines the green component
  98916. * @param b defines the blue component
  98917. * @param a defines the alpha component
  98918. */
  98919. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98920. /**
  98921. * Sets the current alpha mode
  98922. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98923. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98924. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98925. */
  98926. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98927. /**
  98928. * Gets the current alpha mode
  98929. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98930. * @returns the current alpha mode
  98931. */
  98932. getAlphaMode(): number;
  98933. /**
  98934. * Sets the current alpha equation
  98935. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98936. */
  98937. setAlphaEquation(equation: number): void;
  98938. /**
  98939. * Gets the current alpha equation.
  98940. * @returns the current alpha equation
  98941. */
  98942. getAlphaEquation(): number;
  98943. /**
  98944. * Gets a boolean indicating if stencil buffer is enabled
  98945. * @returns the current stencil buffer state
  98946. */
  98947. getStencilBuffer(): boolean;
  98948. /**
  98949. * Enable or disable the stencil buffer
  98950. * @param enable defines if the stencil buffer must be enabled or disabled
  98951. */
  98952. setStencilBuffer(enable: boolean): void;
  98953. /**
  98954. * Gets the current stencil mask
  98955. * @returns a number defining the new stencil mask to use
  98956. */
  98957. getStencilMask(): number;
  98958. /**
  98959. * Sets the current stencil mask
  98960. * @param mask defines the new stencil mask to use
  98961. */
  98962. setStencilMask(mask: number): void;
  98963. /**
  98964. * Gets the current stencil function
  98965. * @returns a number defining the stencil function to use
  98966. */
  98967. getStencilFunction(): number;
  98968. /**
  98969. * Gets the current stencil reference value
  98970. * @returns a number defining the stencil reference value to use
  98971. */
  98972. getStencilFunctionReference(): number;
  98973. /**
  98974. * Gets the current stencil mask
  98975. * @returns a number defining the stencil mask to use
  98976. */
  98977. getStencilFunctionMask(): number;
  98978. /**
  98979. * Sets the current stencil function
  98980. * @param stencilFunc defines the new stencil function to use
  98981. */
  98982. setStencilFunction(stencilFunc: number): void;
  98983. /**
  98984. * Sets the current stencil reference
  98985. * @param reference defines the new stencil reference to use
  98986. */
  98987. setStencilFunctionReference(reference: number): void;
  98988. /**
  98989. * Sets the current stencil mask
  98990. * @param mask defines the new stencil mask to use
  98991. */
  98992. setStencilFunctionMask(mask: number): void;
  98993. /**
  98994. * Gets the current stencil operation when stencil fails
  98995. * @returns a number defining stencil operation to use when stencil fails
  98996. */
  98997. getStencilOperationFail(): number;
  98998. /**
  98999. * Gets the current stencil operation when depth fails
  99000. * @returns a number defining stencil operation to use when depth fails
  99001. */
  99002. getStencilOperationDepthFail(): number;
  99003. /**
  99004. * Gets the current stencil operation when stencil passes
  99005. * @returns a number defining stencil operation to use when stencil passes
  99006. */
  99007. getStencilOperationPass(): number;
  99008. /**
  99009. * Sets the stencil operation to use when stencil fails
  99010. * @param operation defines the stencil operation to use when stencil fails
  99011. */
  99012. setStencilOperationFail(operation: number): void;
  99013. /**
  99014. * Sets the stencil operation to use when depth fails
  99015. * @param operation defines the stencil operation to use when depth fails
  99016. */
  99017. setStencilOperationDepthFail(operation: number): void;
  99018. /**
  99019. * Sets the stencil operation to use when stencil passes
  99020. * @param operation defines the stencil operation to use when stencil passes
  99021. */
  99022. setStencilOperationPass(operation: number): void;
  99023. /**
  99024. * Sets a boolean indicating if the dithering state is enabled or disabled
  99025. * @param value defines the dithering state
  99026. */
  99027. setDitheringState(value: boolean): void;
  99028. /**
  99029. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  99030. * @param value defines the rasterizer state
  99031. */
  99032. setRasterizerState(value: boolean): void;
  99033. /**
  99034. * Gets the current depth function
  99035. * @returns a number defining the depth function
  99036. */
  99037. getDepthFunction(): Nullable<number>;
  99038. /**
  99039. * Sets the current depth function
  99040. * @param depthFunc defines the function to use
  99041. */
  99042. setDepthFunction(depthFunc: number): void;
  99043. /**
  99044. * Sets the current depth function to GREATER
  99045. */
  99046. setDepthFunctionToGreater(): void;
  99047. /**
  99048. * Sets the current depth function to GEQUAL
  99049. */
  99050. setDepthFunctionToGreaterOrEqual(): void;
  99051. /**
  99052. * Sets the current depth function to LESS
  99053. */
  99054. setDepthFunctionToLess(): void;
  99055. /**
  99056. * Sets the current depth function to LEQUAL
  99057. */
  99058. setDepthFunctionToLessOrEqual(): void;
  99059. private _cachedStencilBuffer;
  99060. private _cachedStencilFunction;
  99061. private _cachedStencilMask;
  99062. private _cachedStencilOperationPass;
  99063. private _cachedStencilOperationFail;
  99064. private _cachedStencilOperationDepthFail;
  99065. private _cachedStencilReference;
  99066. /**
  99067. * Caches the the state of the stencil buffer
  99068. */
  99069. cacheStencilState(): void;
  99070. /**
  99071. * Restores the state of the stencil buffer
  99072. */
  99073. restoreStencilState(): void;
  99074. /**
  99075. * Directly set the WebGL Viewport
  99076. * @param x defines the x coordinate of the viewport (in screen space)
  99077. * @param y defines the y coordinate of the viewport (in screen space)
  99078. * @param width defines the width of the viewport (in screen space)
  99079. * @param height defines the height of the viewport (in screen space)
  99080. * @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
  99081. */
  99082. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  99083. /**
  99084. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  99085. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99086. * @param y defines the y-coordinate of the corner of the clear rectangle
  99087. * @param width defines the width of the clear rectangle
  99088. * @param height defines the height of the clear rectangle
  99089. * @param clearColor defines the clear color
  99090. */
  99091. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  99092. /**
  99093. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  99094. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99095. * @param y defines the y-coordinate of the corner of the clear rectangle
  99096. * @param width defines the width of the clear rectangle
  99097. * @param height defines the height of the clear rectangle
  99098. */
  99099. enableScissor(x: number, y: number, width: number, height: number): void;
  99100. /**
  99101. * Disable previously set scissor test rectangle
  99102. */
  99103. disableScissor(): void;
  99104. protected _reportDrawCall(): void;
  99105. /**
  99106. * Initializes a webVR display and starts listening to display change events
  99107. * The onVRDisplayChangedObservable will be notified upon these changes
  99108. * @returns The onVRDisplayChangedObservable
  99109. */
  99110. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99111. /** @hidden */
  99112. _prepareVRComponent(): void;
  99113. /** @hidden */
  99114. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99115. /** @hidden */
  99116. _submitVRFrame(): void;
  99117. /**
  99118. * Call this function to leave webVR mode
  99119. * Will do nothing if webVR is not supported or if there is no webVR device
  99120. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99121. */
  99122. disableVR(): void;
  99123. /**
  99124. * Gets a boolean indicating that the system is in VR mode and is presenting
  99125. * @returns true if VR mode is engaged
  99126. */
  99127. isVRPresenting(): boolean;
  99128. /** @hidden */
  99129. _requestVRFrame(): void;
  99130. /** @hidden */
  99131. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99132. /**
  99133. * Gets the source code of the vertex shader associated with a specific webGL program
  99134. * @param program defines the program to use
  99135. * @returns a string containing the source code of the vertex shader associated with the program
  99136. */
  99137. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99138. /**
  99139. * Gets the source code of the fragment shader associated with a specific webGL program
  99140. * @param program defines the program to use
  99141. * @returns a string containing the source code of the fragment shader associated with the program
  99142. */
  99143. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99144. /**
  99145. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99146. * @param x defines the x coordinate of the rectangle where pixels must be read
  99147. * @param y defines the y coordinate of the rectangle where pixels must be read
  99148. * @param width defines the width of the rectangle where pixels must be read
  99149. * @param height defines the height of the rectangle where pixels must be read
  99150. * @returns a Uint8Array containing RGBA colors
  99151. */
  99152. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99153. /**
  99154. * Sets a depth stencil texture from a render target to the according uniform.
  99155. * @param channel The texture channel
  99156. * @param uniform The uniform to set
  99157. * @param texture The render target texture containing the depth stencil texture to apply
  99158. */
  99159. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99160. /**
  99161. * Sets a texture to the webGL context from a postprocess
  99162. * @param channel defines the channel to use
  99163. * @param postProcess defines the source postprocess
  99164. */
  99165. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99166. /**
  99167. * Binds the output of the passed in post process to the texture channel specified
  99168. * @param channel The channel the texture should be bound to
  99169. * @param postProcess The post process which's output should be bound
  99170. */
  99171. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99172. /** @hidden */
  99173. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99174. protected _rebuildBuffers(): void;
  99175. _renderLoop(): void;
  99176. /**
  99177. * Toggle full screen mode
  99178. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99179. */
  99180. switchFullscreen(requestPointerLock: boolean): void;
  99181. /**
  99182. * Enters full screen mode
  99183. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99184. */
  99185. enterFullscreen(requestPointerLock: boolean): void;
  99186. /**
  99187. * Exits full screen mode
  99188. */
  99189. exitFullscreen(): void;
  99190. /**
  99191. * Enters Pointerlock mode
  99192. */
  99193. enterPointerlock(): void;
  99194. /**
  99195. * Exits Pointerlock mode
  99196. */
  99197. exitPointerlock(): void;
  99198. /**
  99199. * Begin a new frame
  99200. */
  99201. beginFrame(): void;
  99202. /**
  99203. * Enf the current frame
  99204. */
  99205. endFrame(): void;
  99206. resize(): void;
  99207. /**
  99208. * Set the compressed texture format to use, based on the formats you have, and the formats
  99209. * supported by the hardware / browser.
  99210. *
  99211. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  99212. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  99213. * to API arguments needed to compressed textures. This puts the burden on the container
  99214. * generator to house the arcane code for determining these for current & future formats.
  99215. *
  99216. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99217. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99218. *
  99219. * Note: The result of this call is not taken into account when a texture is base64.
  99220. *
  99221. * @param formatsAvailable defines the list of those format families you have created
  99222. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  99223. *
  99224. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  99225. * @returns The extension selected.
  99226. */
  99227. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  99228. /**
  99229. * Force a specific size of the canvas
  99230. * @param width defines the new canvas' width
  99231. * @param height defines the new canvas' height
  99232. */
  99233. setSize(width: number, height: number): void;
  99234. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99235. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99236. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99237. _releaseTexture(texture: InternalTexture): void;
  99238. /**
  99239. * @hidden
  99240. * Rescales a texture
  99241. * @param source input texutre
  99242. * @param destination destination texture
  99243. * @param scene scene to use to render the resize
  99244. * @param internalFormat format to use when resizing
  99245. * @param onComplete callback to be called when resize has completed
  99246. */
  99247. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  99248. /**
  99249. * Gets the current framerate
  99250. * @returns a number representing the framerate
  99251. */
  99252. getFps(): number;
  99253. /**
  99254. * Gets the time spent between current and previous frame
  99255. * @returns a number representing the delta time in ms
  99256. */
  99257. getDeltaTime(): number;
  99258. private _measureFps;
  99259. /**
  99260. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  99261. * @param renderTarget The render target to set the frame buffer for
  99262. */
  99263. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  99264. /**
  99265. * Update a dynamic index buffer
  99266. * @param indexBuffer defines the target index buffer
  99267. * @param indices defines the data to update
  99268. * @param offset defines the offset in the target index buffer where update should start
  99269. */
  99270. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99271. /**
  99272. * Updates the sample count of a render target texture
  99273. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99274. * @param texture defines the texture to update
  99275. * @param samples defines the sample count to set
  99276. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99277. */
  99278. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  99279. /** @hidden */
  99280. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  99281. dispose(): void;
  99282. private _disableTouchAction;
  99283. /**
  99284. * Display the loading screen
  99285. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99286. */
  99287. displayLoadingUI(): void;
  99288. /**
  99289. * Hide the loading screen
  99290. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99291. */
  99292. hideLoadingUI(): void;
  99293. /**
  99294. * Gets the current loading screen object
  99295. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99296. */
  99297. /**
  99298. * Sets the current loading screen object
  99299. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99300. */
  99301. loadingScreen: ILoadingScreen;
  99302. /**
  99303. * Sets the current loading screen text
  99304. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99305. */
  99306. loadingUIText: string;
  99307. /**
  99308. * Sets the current loading screen background color
  99309. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99310. */
  99311. loadingUIBackgroundColor: string;
  99312. /** Pointerlock and fullscreen */
  99313. /**
  99314. * Ask the browser to promote the current element to pointerlock mode
  99315. * @param element defines the DOM element to promote
  99316. */
  99317. static _RequestPointerlock(element: HTMLElement): void;
  99318. /**
  99319. * Asks the browser to exit pointerlock mode
  99320. */
  99321. static _ExitPointerlock(): void;
  99322. /**
  99323. * Ask the browser to promote the current element to fullscreen rendering mode
  99324. * @param element defines the DOM element to promote
  99325. */
  99326. static _RequestFullscreen(element: HTMLElement): void;
  99327. /**
  99328. * Asks the browser to exit fullscreen mode
  99329. */
  99330. static _ExitFullscreen(): void;
  99331. }
  99332. }
  99333. declare module BABYLON {
  99334. /**
  99335. * The engine store class is responsible to hold all the instances of Engine and Scene created
  99336. * during the life time of the application.
  99337. */
  99338. export class EngineStore {
  99339. /** Gets the list of created engines */
  99340. static Instances: Engine[];
  99341. /** @hidden */
  99342. static _LastCreatedScene: Nullable<Scene>;
  99343. /**
  99344. * Gets the latest created engine
  99345. */
  99346. static readonly LastCreatedEngine: Nullable<Engine>;
  99347. /**
  99348. * Gets the latest created scene
  99349. */
  99350. static readonly LastCreatedScene: Nullable<Scene>;
  99351. /**
  99352. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99353. * @ignorenaming
  99354. */
  99355. static UseFallbackTexture: boolean;
  99356. /**
  99357. * Texture content used if a texture cannot loaded
  99358. * @ignorenaming
  99359. */
  99360. static FallbackTexture: string;
  99361. }
  99362. }
  99363. declare module BABYLON {
  99364. /**
  99365. * Helper class that provides a small promise polyfill
  99366. */
  99367. export class PromisePolyfill {
  99368. /**
  99369. * Static function used to check if the polyfill is required
  99370. * If this is the case then the function will inject the polyfill to window.Promise
  99371. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99372. */
  99373. static Apply(force?: boolean): void;
  99374. }
  99375. }
  99376. declare module BABYLON {
  99377. /**
  99378. * Interface for screenshot methods with describe argument called `size` as object with options
  99379. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  99380. */
  99381. export interface IScreenshotSize {
  99382. /**
  99383. * number in pixels for canvas height
  99384. */
  99385. height?: number;
  99386. /**
  99387. * multiplier allowing render at a higher or lower resolution
  99388. * If value is defined then height and width will be ignored and taken from camera
  99389. */
  99390. precision?: number;
  99391. /**
  99392. * number in pixels for canvas width
  99393. */
  99394. width?: number;
  99395. }
  99396. }
  99397. declare module BABYLON {
  99398. interface IColor4Like {
  99399. r: float;
  99400. g: float;
  99401. b: float;
  99402. a: float;
  99403. }
  99404. /**
  99405. * Class containing a set of static utilities functions
  99406. */
  99407. export class Tools {
  99408. /**
  99409. * Gets or sets the base URL to use to load assets
  99410. */
  99411. static BaseUrl: string;
  99412. /**
  99413. * Enable/Disable Custom HTTP Request Headers globally.
  99414. * default = false
  99415. * @see CustomRequestHeaders
  99416. */
  99417. static UseCustomRequestHeaders: boolean;
  99418. /**
  99419. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99420. * i.e. when loading files, where the server/service expects an Authorization header
  99421. */
  99422. static CustomRequestHeaders: {
  99423. [key: string]: string;
  99424. };
  99425. /**
  99426. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99427. */
  99428. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  99429. /**
  99430. * Default behaviour for cors in the application.
  99431. * It can be a string if the expected behavior is identical in the entire app.
  99432. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99433. */
  99434. static CorsBehavior: string | ((url: string | string[]) => string);
  99435. /**
  99436. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99437. * @ignorenaming
  99438. */
  99439. static UseFallbackTexture: boolean;
  99440. /**
  99441. * Use this object to register external classes like custom textures or material
  99442. * to allow the laoders to instantiate them
  99443. */
  99444. static RegisteredExternalClasses: {
  99445. [key: string]: Object;
  99446. };
  99447. /**
  99448. * Texture content used if a texture cannot loaded
  99449. * @ignorenaming
  99450. */
  99451. static fallbackTexture: string;
  99452. /**
  99453. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  99454. * @param u defines the coordinate on X axis
  99455. * @param v defines the coordinate on Y axis
  99456. * @param width defines the width of the source data
  99457. * @param height defines the height of the source data
  99458. * @param pixels defines the source byte array
  99459. * @param color defines the output color
  99460. */
  99461. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  99462. /**
  99463. * Interpolates between a and b via alpha
  99464. * @param a The lower value (returned when alpha = 0)
  99465. * @param b The upper value (returned when alpha = 1)
  99466. * @param alpha The interpolation-factor
  99467. * @return The mixed value
  99468. */
  99469. static Mix(a: number, b: number, alpha: number): number;
  99470. /**
  99471. * Tries to instantiate a new object from a given class name
  99472. * @param className defines the class name to instantiate
  99473. * @returns the new object or null if the system was not able to do the instantiation
  99474. */
  99475. static Instantiate(className: string): any;
  99476. /**
  99477. * Provides a slice function that will work even on IE
  99478. * @param data defines the array to slice
  99479. * @param start defines the start of the data (optional)
  99480. * @param end defines the end of the data (optional)
  99481. * @returns the new sliced array
  99482. */
  99483. static Slice<T>(data: T, start?: number, end?: number): T;
  99484. /**
  99485. * Polyfill for setImmediate
  99486. * @param action defines the action to execute after the current execution block
  99487. */
  99488. static SetImmediate(action: () => void): void;
  99489. /**
  99490. * Function indicating if a number is an exponent of 2
  99491. * @param value defines the value to test
  99492. * @returns true if the value is an exponent of 2
  99493. */
  99494. static IsExponentOfTwo(value: number): boolean;
  99495. private static _tmpFloatArray;
  99496. /**
  99497. * Returns the nearest 32-bit single precision float representation of a Number
  99498. * @param value A Number. If the parameter is of a different type, it will get converted
  99499. * to a number or to NaN if it cannot be converted
  99500. * @returns number
  99501. */
  99502. static FloatRound(value: number): number;
  99503. /**
  99504. * Extracts the filename from a path
  99505. * @param path defines the path to use
  99506. * @returns the filename
  99507. */
  99508. static GetFilename(path: string): string;
  99509. /**
  99510. * Extracts the "folder" part of a path (everything before the filename).
  99511. * @param uri The URI to extract the info from
  99512. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  99513. * @returns The "folder" part of the path
  99514. */
  99515. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  99516. /**
  99517. * Extracts text content from a DOM element hierarchy
  99518. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99519. */
  99520. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  99521. /**
  99522. * Convert an angle in radians to degrees
  99523. * @param angle defines the angle to convert
  99524. * @returns the angle in degrees
  99525. */
  99526. static ToDegrees(angle: number): number;
  99527. /**
  99528. * Convert an angle in degrees to radians
  99529. * @param angle defines the angle to convert
  99530. * @returns the angle in radians
  99531. */
  99532. static ToRadians(angle: number): number;
  99533. /**
  99534. * Returns an array if obj is not an array
  99535. * @param obj defines the object to evaluate as an array
  99536. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  99537. * @returns either obj directly if obj is an array or a new array containing obj
  99538. */
  99539. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  99540. /**
  99541. * Gets the pointer prefix to use
  99542. * @returns "pointer" if touch is enabled. Else returns "mouse"
  99543. */
  99544. static GetPointerPrefix(): string;
  99545. /**
  99546. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  99547. * @param url define the url we are trying
  99548. * @param element define the dom element where to configure the cors policy
  99549. */
  99550. static SetCorsBehavior(url: string | string[], element: {
  99551. crossOrigin: string | null;
  99552. }): void;
  99553. /**
  99554. * Removes unwanted characters from an url
  99555. * @param url defines the url to clean
  99556. * @returns the cleaned url
  99557. */
  99558. static CleanUrl(url: string): string;
  99559. /**
  99560. * Gets or sets a function used to pre-process url before using them to load assets
  99561. */
  99562. static PreprocessUrl: (url: string) => string;
  99563. /**
  99564. * Loads an image as an HTMLImageElement.
  99565. * @param input url string, ArrayBuffer, or Blob to load
  99566. * @param onLoad callback called when the image successfully loads
  99567. * @param onError callback called when the image fails to load
  99568. * @param offlineProvider offline provider for caching
  99569. * @param mimeType optional mime type
  99570. * @returns the HTMLImageElement of the loaded image
  99571. */
  99572. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  99573. /**
  99574. * Loads a file from a url
  99575. * @param url url string, ArrayBuffer, or Blob to load
  99576. * @param onSuccess callback called when the file successfully loads
  99577. * @param onProgress callback called while file is loading (if the server supports this mode)
  99578. * @param offlineProvider defines the offline provider for caching
  99579. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  99580. * @param onError callback called when the file fails to load
  99581. * @returns a file request object
  99582. */
  99583. 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;
  99584. /**
  99585. * Loads a file from a url
  99586. * @param url the file url to load
  99587. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  99588. */
  99589. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  99590. /**
  99591. * Load a script (identified by an url). When the url returns, the
  99592. * content of this file is added into a new script element, attached to the DOM (body element)
  99593. * @param scriptUrl defines the url of the script to laod
  99594. * @param onSuccess defines the callback called when the script is loaded
  99595. * @param onError defines the callback to call if an error occurs
  99596. * @param scriptId defines the id of the script element
  99597. */
  99598. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  99599. /**
  99600. * Load an asynchronous script (identified by an url). When the url returns, the
  99601. * content of this file is added into a new script element, attached to the DOM (body element)
  99602. * @param scriptUrl defines the url of the script to laod
  99603. * @param scriptId defines the id of the script element
  99604. * @returns a promise request object
  99605. */
  99606. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  99607. /**
  99608. * Loads a file from a blob
  99609. * @param fileToLoad defines the blob to use
  99610. * @param callback defines the callback to call when data is loaded
  99611. * @param progressCallback defines the callback to call during loading process
  99612. * @returns a file request object
  99613. */
  99614. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  99615. /**
  99616. * Reads a file from a File object
  99617. * @param file defines the file to load
  99618. * @param onSuccess defines the callback to call when data is loaded
  99619. * @param onProgress defines the callback to call during loading process
  99620. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99621. * @param onError defines the callback to call when an error occurs
  99622. * @returns a file request object
  99623. */
  99624. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  99625. /**
  99626. * Creates a data url from a given string content
  99627. * @param content defines the content to convert
  99628. * @returns the new data url link
  99629. */
  99630. static FileAsURL(content: string): string;
  99631. /**
  99632. * Format the given number to a specific decimal format
  99633. * @param value defines the number to format
  99634. * @param decimals defines the number of decimals to use
  99635. * @returns the formatted string
  99636. */
  99637. static Format(value: number, decimals?: number): string;
  99638. /**
  99639. * Tries to copy an object by duplicating every property
  99640. * @param source defines the source object
  99641. * @param destination defines the target object
  99642. * @param doNotCopyList defines a list of properties to avoid
  99643. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99644. */
  99645. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  99646. /**
  99647. * Gets a boolean indicating if the given object has no own property
  99648. * @param obj defines the object to test
  99649. * @returns true if object has no own property
  99650. */
  99651. static IsEmpty(obj: any): boolean;
  99652. /**
  99653. * Function used to register events at window level
  99654. * @param windowElement defines the Window object to use
  99655. * @param events defines the events to register
  99656. */
  99657. static RegisterTopRootEvents(windowElement: Window, events: {
  99658. name: string;
  99659. handler: Nullable<(e: FocusEvent) => any>;
  99660. }[]): void;
  99661. /**
  99662. * Function used to unregister events from window level
  99663. * @param windowElement defines the Window object to use
  99664. * @param events defines the events to unregister
  99665. */
  99666. static UnregisterTopRootEvents(windowElement: Window, events: {
  99667. name: string;
  99668. handler: Nullable<(e: FocusEvent) => any>;
  99669. }[]): void;
  99670. /**
  99671. * @ignore
  99672. */
  99673. static _ScreenshotCanvas: HTMLCanvasElement;
  99674. /**
  99675. * Dumps the current bound framebuffer
  99676. * @param width defines the rendering width
  99677. * @param height defines the rendering height
  99678. * @param engine defines the hosting engine
  99679. * @param successCallback defines the callback triggered once the data are available
  99680. * @param mimeType defines the mime type of the result
  99681. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99682. */
  99683. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99684. /**
  99685. * Converts the canvas data to blob.
  99686. * This acts as a polyfill for browsers not supporting the to blob function.
  99687. * @param canvas Defines the canvas to extract the data from
  99688. * @param successCallback Defines the callback triggered once the data are available
  99689. * @param mimeType Defines the mime type of the result
  99690. */
  99691. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  99692. /**
  99693. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99694. * @param successCallback defines the callback triggered once the data are available
  99695. * @param mimeType defines the mime type of the result
  99696. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99697. */
  99698. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99699. /**
  99700. * Downloads a blob in the browser
  99701. * @param blob defines the blob to download
  99702. * @param fileName defines the name of the downloaded file
  99703. */
  99704. static Download(blob: Blob, fileName: string): void;
  99705. /**
  99706. * Captures a screenshot of the current rendering
  99707. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99708. * @param engine defines the rendering engine
  99709. * @param camera defines the source camera
  99710. * @param size This parameter can be set to a single number or to an object with the
  99711. * following (optional) properties: precision, width, height. If a single number is passed,
  99712. * it will be used for both width and height. If an object is passed, the screenshot size
  99713. * will be derived from the parameters. The precision property is a multiplier allowing
  99714. * rendering at a higher or lower resolution
  99715. * @param successCallback defines the callback receives a single parameter which contains the
  99716. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99717. * src parameter of an <img> to display it
  99718. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99719. * Check your browser for supported MIME types
  99720. */
  99721. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  99722. /**
  99723. * Captures a screenshot of the current rendering
  99724. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99725. * @param engine defines the rendering engine
  99726. * @param camera defines the source camera
  99727. * @param size This parameter can be set to a single number or to an object with the
  99728. * following (optional) properties: precision, width, height. If a single number is passed,
  99729. * it will be used for both width and height. If an object is passed, the screenshot size
  99730. * will be derived from the parameters. The precision property is a multiplier allowing
  99731. * rendering at a higher or lower resolution
  99732. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99733. * Check your browser for supported MIME types
  99734. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99735. * to the src parameter of an <img> to display it
  99736. */
  99737. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99738. /**
  99739. * Generates an image screenshot from the specified camera.
  99740. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99741. * @param engine The engine to use for rendering
  99742. * @param camera The camera to use for rendering
  99743. * @param size This parameter can be set to a single number or to an object with the
  99744. * following (optional) properties: precision, width, height. If a single number is passed,
  99745. * it will be used for both width and height. If an object is passed, the screenshot size
  99746. * will be derived from the parameters. The precision property is a multiplier allowing
  99747. * rendering at a higher or lower resolution
  99748. * @param successCallback The callback receives a single parameter which contains the
  99749. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99750. * src parameter of an <img> to display it
  99751. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99752. * Check your browser for supported MIME types
  99753. * @param samples Texture samples (default: 1)
  99754. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99755. * @param fileName A name for for the downloaded file.
  99756. */
  99757. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99758. /**
  99759. * Generates an image screenshot from the specified camera.
  99760. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99761. * @param engine The engine to use for rendering
  99762. * @param camera The camera to use for rendering
  99763. * @param size This parameter can be set to a single number or to an object with the
  99764. * following (optional) properties: precision, width, height. If a single number is passed,
  99765. * it will be used for both width and height. If an object is passed, the screenshot size
  99766. * will be derived from the parameters. The precision property is a multiplier allowing
  99767. * rendering at a higher or lower resolution
  99768. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99769. * Check your browser for supported MIME types
  99770. * @param samples Texture samples (default: 1)
  99771. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99772. * @param fileName A name for for the downloaded file.
  99773. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99774. * to the src parameter of an <img> to display it
  99775. */
  99776. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99777. /**
  99778. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99779. * Be aware Math.random() could cause collisions, but:
  99780. * "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"
  99781. * @returns a pseudo random id
  99782. */
  99783. static RandomId(): string;
  99784. /**
  99785. * Test if the given uri is a base64 string
  99786. * @param uri The uri to test
  99787. * @return True if the uri is a base64 string or false otherwise
  99788. */
  99789. static IsBase64(uri: string): boolean;
  99790. /**
  99791. * Decode the given base64 uri.
  99792. * @param uri The uri to decode
  99793. * @return The decoded base64 data.
  99794. */
  99795. static DecodeBase64(uri: string): ArrayBuffer;
  99796. /**
  99797. * Gets the absolute url.
  99798. * @param url the input url
  99799. * @return the absolute url
  99800. */
  99801. static GetAbsoluteUrl(url: string): string;
  99802. /**
  99803. * No log
  99804. */
  99805. static readonly NoneLogLevel: number;
  99806. /**
  99807. * Only message logs
  99808. */
  99809. static readonly MessageLogLevel: number;
  99810. /**
  99811. * Only warning logs
  99812. */
  99813. static readonly WarningLogLevel: number;
  99814. /**
  99815. * Only error logs
  99816. */
  99817. static readonly ErrorLogLevel: number;
  99818. /**
  99819. * All logs
  99820. */
  99821. static readonly AllLogLevel: number;
  99822. /**
  99823. * Gets a value indicating the number of loading errors
  99824. * @ignorenaming
  99825. */
  99826. static readonly errorsCount: number;
  99827. /**
  99828. * Callback called when a new log is added
  99829. */
  99830. static OnNewCacheEntry: (entry: string) => void;
  99831. /**
  99832. * Log a message to the console
  99833. * @param message defines the message to log
  99834. */
  99835. static Log(message: string): void;
  99836. /**
  99837. * Write a warning message to the console
  99838. * @param message defines the message to log
  99839. */
  99840. static Warn(message: string): void;
  99841. /**
  99842. * Write an error message to the console
  99843. * @param message defines the message to log
  99844. */
  99845. static Error(message: string): void;
  99846. /**
  99847. * Gets current log cache (list of logs)
  99848. */
  99849. static readonly LogCache: string;
  99850. /**
  99851. * Clears the log cache
  99852. */
  99853. static ClearLogCache(): void;
  99854. /**
  99855. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99856. */
  99857. static LogLevels: number;
  99858. /**
  99859. * Checks if the window object exists
  99860. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99861. */
  99862. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99863. /**
  99864. * No performance log
  99865. */
  99866. static readonly PerformanceNoneLogLevel: number;
  99867. /**
  99868. * Use user marks to log performance
  99869. */
  99870. static readonly PerformanceUserMarkLogLevel: number;
  99871. /**
  99872. * Log performance to the console
  99873. */
  99874. static readonly PerformanceConsoleLogLevel: number;
  99875. private static _performance;
  99876. /**
  99877. * Sets the current performance log level
  99878. */
  99879. static PerformanceLogLevel: number;
  99880. private static _StartPerformanceCounterDisabled;
  99881. private static _EndPerformanceCounterDisabled;
  99882. private static _StartUserMark;
  99883. private static _EndUserMark;
  99884. private static _StartPerformanceConsole;
  99885. private static _EndPerformanceConsole;
  99886. /**
  99887. * Starts a performance counter
  99888. */
  99889. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99890. /**
  99891. * Ends a specific performance coutner
  99892. */
  99893. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99894. /**
  99895. * Gets either window.performance.now() if supported or Date.now() else
  99896. */
  99897. static readonly Now: number;
  99898. /**
  99899. * This method will return the name of the class used to create the instance of the given object.
  99900. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99901. * @param object the object to get the class name from
  99902. * @param isType defines if the object is actually a type
  99903. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99904. */
  99905. static GetClassName(object: any, isType?: boolean): string;
  99906. /**
  99907. * Gets the first element of an array satisfying a given predicate
  99908. * @param array defines the array to browse
  99909. * @param predicate defines the predicate to use
  99910. * @returns null if not found or the element
  99911. */
  99912. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99913. /**
  99914. * This method will return the name of the full name of the class, including its owning module (if any).
  99915. * 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).
  99916. * @param object the object to get the class name from
  99917. * @param isType defines if the object is actually a type
  99918. * @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.
  99919. * @ignorenaming
  99920. */
  99921. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99922. /**
  99923. * Returns a promise that resolves after the given amount of time.
  99924. * @param delay Number of milliseconds to delay
  99925. * @returns Promise that resolves after the given amount of time
  99926. */
  99927. static DelayAsync(delay: number): Promise<void>;
  99928. }
  99929. /**
  99930. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99931. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99932. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99933. * @param name The name of the class, case should be preserved
  99934. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99935. */
  99936. export function className(name: string, module?: string): (target: Object) => void;
  99937. /**
  99938. * An implementation of a loop for asynchronous functions.
  99939. */
  99940. export class AsyncLoop {
  99941. /**
  99942. * Defines the number of iterations for the loop
  99943. */
  99944. iterations: number;
  99945. /**
  99946. * Defines the current index of the loop.
  99947. */
  99948. index: number;
  99949. private _done;
  99950. private _fn;
  99951. private _successCallback;
  99952. /**
  99953. * Constructor.
  99954. * @param iterations the number of iterations.
  99955. * @param func the function to run each iteration
  99956. * @param successCallback the callback that will be called upon succesful execution
  99957. * @param offset starting offset.
  99958. */
  99959. constructor(
  99960. /**
  99961. * Defines the number of iterations for the loop
  99962. */
  99963. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99964. /**
  99965. * Execute the next iteration. Must be called after the last iteration was finished.
  99966. */
  99967. executeNext(): void;
  99968. /**
  99969. * Break the loop and run the success callback.
  99970. */
  99971. breakLoop(): void;
  99972. /**
  99973. * Create and run an async loop.
  99974. * @param iterations the number of iterations.
  99975. * @param fn the function to run each iteration
  99976. * @param successCallback the callback that will be called upon succesful execution
  99977. * @param offset starting offset.
  99978. * @returns the created async loop object
  99979. */
  99980. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99981. /**
  99982. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99983. * @param iterations total number of iterations
  99984. * @param syncedIterations number of synchronous iterations in each async iteration.
  99985. * @param fn the function to call each iteration.
  99986. * @param callback a success call back that will be called when iterating stops.
  99987. * @param breakFunction a break condition (optional)
  99988. * @param timeout timeout settings for the setTimeout function. default - 0.
  99989. * @returns the created async loop object
  99990. */
  99991. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99992. }
  99993. }
  99994. declare module BABYLON {
  99995. /**
  99996. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99997. * The underlying implementation relies on an associative array to ensure the best performances.
  99998. * The value can be anything including 'null' but except 'undefined'
  99999. */
  100000. export class StringDictionary<T> {
  100001. /**
  100002. * This will clear this dictionary and copy the content from the 'source' one.
  100003. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100004. * @param source the dictionary to take the content from and copy to this dictionary
  100005. */
  100006. copyFrom(source: StringDictionary<T>): void;
  100007. /**
  100008. * Get a value based from its key
  100009. * @param key the given key to get the matching value from
  100010. * @return the value if found, otherwise undefined is returned
  100011. */
  100012. get(key: string): T | undefined;
  100013. /**
  100014. * Get a value from its key or add it if it doesn't exist.
  100015. * This method will ensure you that a given key/data will be present in the dictionary.
  100016. * @param key the given key to get the matching value from
  100017. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100018. * The factory will only be invoked if there's no data for the given key.
  100019. * @return the value corresponding to the key.
  100020. */
  100021. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  100022. /**
  100023. * Get a value from its key if present in the dictionary otherwise add it
  100024. * @param key the key to get the value from
  100025. * @param val if there's no such key/value pair in the dictionary add it with this value
  100026. * @return the value corresponding to the key
  100027. */
  100028. getOrAdd(key: string, val: T): T;
  100029. /**
  100030. * Check if there's a given key in the dictionary
  100031. * @param key the key to check for
  100032. * @return true if the key is present, false otherwise
  100033. */
  100034. contains(key: string): boolean;
  100035. /**
  100036. * Add a new key and its corresponding value
  100037. * @param key the key to add
  100038. * @param value the value corresponding to the key
  100039. * @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
  100040. */
  100041. add(key: string, value: T): boolean;
  100042. /**
  100043. * Update a specific value associated to a key
  100044. * @param key defines the key to use
  100045. * @param value defines the value to store
  100046. * @returns true if the value was updated (or false if the key was not found)
  100047. */
  100048. set(key: string, value: T): boolean;
  100049. /**
  100050. * Get the element of the given key and remove it from the dictionary
  100051. * @param key defines the key to search
  100052. * @returns the value associated with the key or null if not found
  100053. */
  100054. getAndRemove(key: string): Nullable<T>;
  100055. /**
  100056. * Remove a key/value from the dictionary.
  100057. * @param key the key to remove
  100058. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100059. */
  100060. remove(key: string): boolean;
  100061. /**
  100062. * Clear the whole content of the dictionary
  100063. */
  100064. clear(): void;
  100065. /**
  100066. * Gets the current count
  100067. */
  100068. readonly count: number;
  100069. /**
  100070. * Execute a callback on each key/val of the dictionary.
  100071. * Note that you can remove any element in this dictionary in the callback implementation
  100072. * @param callback the callback to execute on a given key/value pair
  100073. */
  100074. forEach(callback: (key: string, val: T) => void): void;
  100075. /**
  100076. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100077. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100078. * Note that you can remove any element in this dictionary in the callback implementation
  100079. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100080. * @returns the first item
  100081. */
  100082. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  100083. private _count;
  100084. private _data;
  100085. }
  100086. }
  100087. declare module BABYLON {
  100088. /** @hidden */
  100089. export interface ICollisionCoordinator {
  100090. createCollider(): Collider;
  100091. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100092. init(scene: Scene): void;
  100093. }
  100094. /** @hidden */
  100095. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  100096. private _scene;
  100097. private _scaledPosition;
  100098. private _scaledVelocity;
  100099. private _finalPosition;
  100100. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100101. createCollider(): Collider;
  100102. init(scene: Scene): void;
  100103. private _collideWithWorld;
  100104. }
  100105. }
  100106. declare module BABYLON {
  100107. /**
  100108. * Class used to manage all inputs for the scene.
  100109. */
  100110. export class InputManager {
  100111. /** The distance in pixel that you have to move to prevent some events */
  100112. static DragMovementThreshold: number;
  100113. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100114. static LongPressDelay: number;
  100115. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100116. static DoubleClickDelay: number;
  100117. /** If you need to check double click without raising a single click at first click, enable this flag */
  100118. static ExclusiveDoubleClickMode: boolean;
  100119. private _wheelEventName;
  100120. private _onPointerMove;
  100121. private _onPointerDown;
  100122. private _onPointerUp;
  100123. private _initClickEvent;
  100124. private _initActionManager;
  100125. private _delayedSimpleClick;
  100126. private _delayedSimpleClickTimeout;
  100127. private _previousDelayedSimpleClickTimeout;
  100128. private _meshPickProceed;
  100129. private _previousButtonPressed;
  100130. private _currentPickResult;
  100131. private _previousPickResult;
  100132. private _totalPointersPressed;
  100133. private _doubleClickOccured;
  100134. private _pointerOverMesh;
  100135. private _pickedDownMesh;
  100136. private _pickedUpMesh;
  100137. private _pointerX;
  100138. private _pointerY;
  100139. private _unTranslatedPointerX;
  100140. private _unTranslatedPointerY;
  100141. private _startingPointerPosition;
  100142. private _previousStartingPointerPosition;
  100143. private _startingPointerTime;
  100144. private _previousStartingPointerTime;
  100145. private _pointerCaptures;
  100146. private _onKeyDown;
  100147. private _onKeyUp;
  100148. private _onCanvasFocusObserver;
  100149. private _onCanvasBlurObserver;
  100150. private _scene;
  100151. /**
  100152. * Creates a new InputManager
  100153. * @param scene defines the hosting scene
  100154. */
  100155. constructor(scene: Scene);
  100156. /**
  100157. * Gets the mesh that is currently under the pointer
  100158. */
  100159. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100160. /**
  100161. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  100162. */
  100163. readonly unTranslatedPointer: Vector2;
  100164. /**
  100165. * Gets or sets the current on-screen X position of the pointer
  100166. */
  100167. pointerX: number;
  100168. /**
  100169. * Gets or sets the current on-screen Y position of the pointer
  100170. */
  100171. pointerY: number;
  100172. private _updatePointerPosition;
  100173. private _processPointerMove;
  100174. private _setRayOnPointerInfo;
  100175. private _checkPrePointerObservable;
  100176. /**
  100177. * Use this method to simulate a pointer move on a mesh
  100178. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100179. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100180. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100181. */
  100182. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100183. /**
  100184. * Use this method to simulate a pointer down on a mesh
  100185. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100186. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100187. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100188. */
  100189. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100190. private _processPointerDown;
  100191. /** @hidden */
  100192. _isPointerSwiping(): boolean;
  100193. /**
  100194. * Use this method to simulate a pointer up on a mesh
  100195. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100196. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100197. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100198. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100199. */
  100200. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  100201. private _processPointerUp;
  100202. /**
  100203. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100204. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100205. * @returns true if the pointer was captured
  100206. */
  100207. isPointerCaptured(pointerId?: number): boolean;
  100208. /**
  100209. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100210. * @param attachUp defines if you want to attach events to pointerup
  100211. * @param attachDown defines if you want to attach events to pointerdown
  100212. * @param attachMove defines if you want to attach events to pointermove
  100213. */
  100214. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100215. /**
  100216. * Detaches all event handlers
  100217. */
  100218. detachControl(): void;
  100219. /**
  100220. * Force the value of meshUnderPointer
  100221. * @param mesh defines the mesh to use
  100222. */
  100223. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100224. /**
  100225. * Gets the mesh under the pointer
  100226. * @returns a Mesh or null if no mesh is under the pointer
  100227. */
  100228. getPointerOverMesh(): Nullable<AbstractMesh>;
  100229. }
  100230. }
  100231. declare module BABYLON {
  100232. /**
  100233. * Helper class used to generate session unique ID
  100234. */
  100235. export class UniqueIdGenerator {
  100236. private static _UniqueIdCounter;
  100237. /**
  100238. * Gets an unique (relatively to the current scene) Id
  100239. */
  100240. static readonly UniqueId: number;
  100241. }
  100242. }
  100243. declare module BABYLON {
  100244. /**
  100245. * This class defines the direct association between an animation and a target
  100246. */
  100247. export class TargetedAnimation {
  100248. /**
  100249. * Animation to perform
  100250. */
  100251. animation: Animation;
  100252. /**
  100253. * Target to animate
  100254. */
  100255. target: any;
  100256. /**
  100257. * Serialize the object
  100258. * @returns the JSON object representing the current entity
  100259. */
  100260. serialize(): any;
  100261. }
  100262. /**
  100263. * Use this class to create coordinated animations on multiple targets
  100264. */
  100265. export class AnimationGroup implements IDisposable {
  100266. /** The name of the animation group */
  100267. name: string;
  100268. private _scene;
  100269. private _targetedAnimations;
  100270. private _animatables;
  100271. private _from;
  100272. private _to;
  100273. private _isStarted;
  100274. private _isPaused;
  100275. private _speedRatio;
  100276. private _loopAnimation;
  100277. /**
  100278. * Gets or sets the unique id of the node
  100279. */
  100280. uniqueId: number;
  100281. /**
  100282. * This observable will notify when one animation have ended
  100283. */
  100284. onAnimationEndObservable: Observable<TargetedAnimation>;
  100285. /**
  100286. * Observer raised when one animation loops
  100287. */
  100288. onAnimationLoopObservable: Observable<TargetedAnimation>;
  100289. /**
  100290. * This observable will notify when all animations have ended.
  100291. */
  100292. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  100293. /**
  100294. * This observable will notify when all animations have paused.
  100295. */
  100296. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  100297. /**
  100298. * This observable will notify when all animations are playing.
  100299. */
  100300. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  100301. /**
  100302. * Gets the first frame
  100303. */
  100304. readonly from: number;
  100305. /**
  100306. * Gets the last frame
  100307. */
  100308. readonly to: number;
  100309. /**
  100310. * Define if the animations are started
  100311. */
  100312. readonly isStarted: boolean;
  100313. /**
  100314. * Gets a value indicating that the current group is playing
  100315. */
  100316. readonly isPlaying: boolean;
  100317. /**
  100318. * Gets or sets the speed ratio to use for all animations
  100319. */
  100320. /**
  100321. * Gets or sets the speed ratio to use for all animations
  100322. */
  100323. speedRatio: number;
  100324. /**
  100325. * Gets or sets if all animations should loop or not
  100326. */
  100327. loopAnimation: boolean;
  100328. /**
  100329. * Gets the targeted animations for this animation group
  100330. */
  100331. readonly targetedAnimations: Array<TargetedAnimation>;
  100332. /**
  100333. * returning the list of animatables controlled by this animation group.
  100334. */
  100335. readonly animatables: Array<Animatable>;
  100336. /**
  100337. * Instantiates a new Animation Group.
  100338. * This helps managing several animations at once.
  100339. * @see http://doc.babylonjs.com/how_to/group
  100340. * @param name Defines the name of the group
  100341. * @param scene Defines the scene the group belongs to
  100342. */
  100343. constructor(
  100344. /** The name of the animation group */
  100345. name: string, scene?: Nullable<Scene>);
  100346. /**
  100347. * Add an animation (with its target) in the group
  100348. * @param animation defines the animation we want to add
  100349. * @param target defines the target of the animation
  100350. * @returns the TargetedAnimation object
  100351. */
  100352. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  100353. /**
  100354. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  100355. * It can add constant keys at begin or end
  100356. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  100357. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  100358. * @returns the animation group
  100359. */
  100360. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  100361. /**
  100362. * Start all animations on given targets
  100363. * @param loop defines if animations must loop
  100364. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  100365. * @param from defines the from key (optional)
  100366. * @param to defines the to key (optional)
  100367. * @returns the current animation group
  100368. */
  100369. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  100370. /**
  100371. * Pause all animations
  100372. * @returns the animation group
  100373. */
  100374. pause(): AnimationGroup;
  100375. /**
  100376. * Play all animations to initial state
  100377. * This function will start() the animations if they were not started or will restart() them if they were paused
  100378. * @param loop defines if animations must loop
  100379. * @returns the animation group
  100380. */
  100381. play(loop?: boolean): AnimationGroup;
  100382. /**
  100383. * Reset all animations to initial state
  100384. * @returns the animation group
  100385. */
  100386. reset(): AnimationGroup;
  100387. /**
  100388. * Restart animations from key 0
  100389. * @returns the animation group
  100390. */
  100391. restart(): AnimationGroup;
  100392. /**
  100393. * Stop all animations
  100394. * @returns the animation group
  100395. */
  100396. stop(): AnimationGroup;
  100397. /**
  100398. * Set animation weight for all animatables
  100399. * @param weight defines the weight to use
  100400. * @return the animationGroup
  100401. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100402. */
  100403. setWeightForAllAnimatables(weight: number): AnimationGroup;
  100404. /**
  100405. * Synchronize and normalize all animatables with a source animatable
  100406. * @param root defines the root animatable to synchronize with
  100407. * @return the animationGroup
  100408. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100409. */
  100410. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  100411. /**
  100412. * Goes to a specific frame in this animation group
  100413. * @param frame the frame number to go to
  100414. * @return the animationGroup
  100415. */
  100416. goToFrame(frame: number): AnimationGroup;
  100417. /**
  100418. * Dispose all associated resources
  100419. */
  100420. dispose(): void;
  100421. private _checkAnimationGroupEnded;
  100422. /**
  100423. * Clone the current animation group and returns a copy
  100424. * @param newName defines the name of the new group
  100425. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  100426. * @returns the new aniamtion group
  100427. */
  100428. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  100429. /**
  100430. * Serializes the animationGroup to an object
  100431. * @returns Serialized object
  100432. */
  100433. serialize(): any;
  100434. /**
  100435. * Returns a new AnimationGroup object parsed from the source provided.
  100436. * @param parsedAnimationGroup defines the source
  100437. * @param scene defines the scene that will receive the animationGroup
  100438. * @returns a new AnimationGroup
  100439. */
  100440. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  100441. /**
  100442. * Returns the string "AnimationGroup"
  100443. * @returns "AnimationGroup"
  100444. */
  100445. getClassName(): string;
  100446. /**
  100447. * Creates a detailled string about the object
  100448. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  100449. * @returns a string representing the object
  100450. */
  100451. toString(fullDetails?: boolean): string;
  100452. }
  100453. }
  100454. declare module BABYLON {
  100455. /**
  100456. * Define an interface for all classes that will hold resources
  100457. */
  100458. export interface IDisposable {
  100459. /**
  100460. * Releases all held resources
  100461. */
  100462. dispose(): void;
  100463. }
  100464. /** Interface defining initialization parameters for Scene class */
  100465. export interface SceneOptions {
  100466. /**
  100467. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  100468. * It will improve performance when the number of geometries becomes important.
  100469. */
  100470. useGeometryUniqueIdsMap?: boolean;
  100471. /**
  100472. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  100473. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100474. */
  100475. useMaterialMeshMap?: boolean;
  100476. /**
  100477. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  100478. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100479. */
  100480. useClonedMeshhMap?: boolean;
  100481. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  100482. virtual?: boolean;
  100483. }
  100484. /**
  100485. * Represents a scene to be rendered by the engine.
  100486. * @see http://doc.babylonjs.com/features/scene
  100487. */
  100488. export class Scene extends AbstractScene implements IAnimatable {
  100489. /** The fog is deactivated */
  100490. static readonly FOGMODE_NONE: number;
  100491. /** The fog density is following an exponential function */
  100492. static readonly FOGMODE_EXP: number;
  100493. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  100494. static readonly FOGMODE_EXP2: number;
  100495. /** The fog density is following a linear function. */
  100496. static readonly FOGMODE_LINEAR: number;
  100497. /**
  100498. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  100499. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100500. */
  100501. static MinDeltaTime: number;
  100502. /**
  100503. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  100504. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100505. */
  100506. static MaxDeltaTime: number;
  100507. /**
  100508. * Factory used to create the default material.
  100509. * @param name The name of the material to create
  100510. * @param scene The scene to create the material for
  100511. * @returns The default material
  100512. */
  100513. static DefaultMaterialFactory(scene: Scene): Material;
  100514. /**
  100515. * Factory used to create the a collision coordinator.
  100516. * @returns The collision coordinator
  100517. */
  100518. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  100519. /** @hidden */
  100520. _inputManager: InputManager;
  100521. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  100522. cameraToUseForPointers: Nullable<Camera>;
  100523. /** @hidden */
  100524. readonly _isScene: boolean;
  100525. /**
  100526. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  100527. */
  100528. autoClear: boolean;
  100529. /**
  100530. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  100531. */
  100532. autoClearDepthAndStencil: boolean;
  100533. /**
  100534. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  100535. */
  100536. clearColor: Color4;
  100537. /**
  100538. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  100539. */
  100540. ambientColor: Color3;
  100541. /**
  100542. * This is use to store the default BRDF lookup for PBR materials in your scene.
  100543. * It should only be one of the following (if not the default embedded one):
  100544. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  100545. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  100546. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  100547. * The material properties need to be setup according to the type of texture in use.
  100548. */
  100549. environmentBRDFTexture: BaseTexture;
  100550. /** @hidden */
  100551. protected _environmentTexture: Nullable<BaseTexture>;
  100552. /**
  100553. * Texture used in all pbr material as the reflection texture.
  100554. * As in the majority of the scene they are the same (exception for multi room and so on),
  100555. * this is easier to reference from here than from all the materials.
  100556. */
  100557. /**
  100558. * Texture used in all pbr material as the reflection texture.
  100559. * As in the majority of the scene they are the same (exception for multi room and so on),
  100560. * this is easier to set here than in all the materials.
  100561. */
  100562. environmentTexture: Nullable<BaseTexture>;
  100563. /** @hidden */
  100564. protected _environmentIntensity: number;
  100565. /**
  100566. * Intensity of the environment in all pbr material.
  100567. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100568. * As in the majority of the scene they are the same (exception for multi room and so on),
  100569. * this is easier to reference from here than from all the materials.
  100570. */
  100571. /**
  100572. * Intensity of the environment in all pbr material.
  100573. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100574. * As in the majority of the scene they are the same (exception for multi room and so on),
  100575. * this is easier to set here than in all the materials.
  100576. */
  100577. environmentIntensity: number;
  100578. /** @hidden */
  100579. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100580. /**
  100581. * Default image processing configuration used either in the rendering
  100582. * Forward main pass or through the imageProcessingPostProcess if present.
  100583. * As in the majority of the scene they are the same (exception for multi camera),
  100584. * this is easier to reference from here than from all the materials and post process.
  100585. *
  100586. * No setter as we it is a shared configuration, you can set the values instead.
  100587. */
  100588. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  100589. private _forceWireframe;
  100590. /**
  100591. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  100592. */
  100593. forceWireframe: boolean;
  100594. private _forcePointsCloud;
  100595. /**
  100596. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  100597. */
  100598. forcePointsCloud: boolean;
  100599. /**
  100600. * Gets or sets the active clipplane 1
  100601. */
  100602. clipPlane: Nullable<Plane>;
  100603. /**
  100604. * Gets or sets the active clipplane 2
  100605. */
  100606. clipPlane2: Nullable<Plane>;
  100607. /**
  100608. * Gets or sets the active clipplane 3
  100609. */
  100610. clipPlane3: Nullable<Plane>;
  100611. /**
  100612. * Gets or sets the active clipplane 4
  100613. */
  100614. clipPlane4: Nullable<Plane>;
  100615. /**
  100616. * Gets or sets a boolean indicating if animations are enabled
  100617. */
  100618. animationsEnabled: boolean;
  100619. private _animationPropertiesOverride;
  100620. /**
  100621. * Gets or sets the animation properties override
  100622. */
  100623. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  100624. /**
  100625. * Gets or sets a boolean indicating if a constant deltatime has to be used
  100626. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  100627. */
  100628. useConstantAnimationDeltaTime: boolean;
  100629. /**
  100630. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  100631. * Please note that it requires to run a ray cast through the scene on every frame
  100632. */
  100633. constantlyUpdateMeshUnderPointer: boolean;
  100634. /**
  100635. * Defines the HTML cursor to use when hovering over interactive elements
  100636. */
  100637. hoverCursor: string;
  100638. /**
  100639. * Defines the HTML default cursor to use (empty by default)
  100640. */
  100641. defaultCursor: string;
  100642. /**
  100643. * Defines wether cursors are handled by the scene.
  100644. */
  100645. doNotHandleCursors: boolean;
  100646. /**
  100647. * This is used to call preventDefault() on pointer down
  100648. * in order to block unwanted artifacts like system double clicks
  100649. */
  100650. preventDefaultOnPointerDown: boolean;
  100651. /**
  100652. * This is used to call preventDefault() on pointer up
  100653. * in order to block unwanted artifacts like system double clicks
  100654. */
  100655. preventDefaultOnPointerUp: boolean;
  100656. /**
  100657. * Gets or sets user defined metadata
  100658. */
  100659. metadata: any;
  100660. /**
  100661. * For internal use only. Please do not use.
  100662. */
  100663. reservedDataStore: any;
  100664. /**
  100665. * Gets the name of the plugin used to load this scene (null by default)
  100666. */
  100667. loadingPluginName: string;
  100668. /**
  100669. * Use this array to add regular expressions used to disable offline support for specific urls
  100670. */
  100671. disableOfflineSupportExceptionRules: RegExp[];
  100672. /**
  100673. * An event triggered when the scene is disposed.
  100674. */
  100675. onDisposeObservable: Observable<Scene>;
  100676. private _onDisposeObserver;
  100677. /** Sets a function to be executed when this scene is disposed. */
  100678. onDispose: () => void;
  100679. /**
  100680. * An event triggered before rendering the scene (right after animations and physics)
  100681. */
  100682. onBeforeRenderObservable: Observable<Scene>;
  100683. private _onBeforeRenderObserver;
  100684. /** Sets a function to be executed before rendering this scene */
  100685. beforeRender: Nullable<() => void>;
  100686. /**
  100687. * An event triggered after rendering the scene
  100688. */
  100689. onAfterRenderObservable: Observable<Scene>;
  100690. /**
  100691. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  100692. */
  100693. onAfterRenderCameraObservable: Observable<Camera>;
  100694. private _onAfterRenderObserver;
  100695. /** Sets a function to be executed after rendering this scene */
  100696. afterRender: Nullable<() => void>;
  100697. /**
  100698. * An event triggered before animating the scene
  100699. */
  100700. onBeforeAnimationsObservable: Observable<Scene>;
  100701. /**
  100702. * An event triggered after animations processing
  100703. */
  100704. onAfterAnimationsObservable: Observable<Scene>;
  100705. /**
  100706. * An event triggered before draw calls are ready to be sent
  100707. */
  100708. onBeforeDrawPhaseObservable: Observable<Scene>;
  100709. /**
  100710. * An event triggered after draw calls have been sent
  100711. */
  100712. onAfterDrawPhaseObservable: Observable<Scene>;
  100713. /**
  100714. * An event triggered when the scene is ready
  100715. */
  100716. onReadyObservable: Observable<Scene>;
  100717. /**
  100718. * An event triggered before rendering a camera
  100719. */
  100720. onBeforeCameraRenderObservable: Observable<Camera>;
  100721. private _onBeforeCameraRenderObserver;
  100722. /** Sets a function to be executed before rendering a camera*/
  100723. beforeCameraRender: () => void;
  100724. /**
  100725. * An event triggered after rendering a camera
  100726. */
  100727. onAfterCameraRenderObservable: Observable<Camera>;
  100728. private _onAfterCameraRenderObserver;
  100729. /** Sets a function to be executed after rendering a camera*/
  100730. afterCameraRender: () => void;
  100731. /**
  100732. * An event triggered when active meshes evaluation is about to start
  100733. */
  100734. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100735. /**
  100736. * An event triggered when active meshes evaluation is done
  100737. */
  100738. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100739. /**
  100740. * An event triggered when particles rendering is about to start
  100741. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100742. */
  100743. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100744. /**
  100745. * An event triggered when particles rendering is done
  100746. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100747. */
  100748. onAfterParticlesRenderingObservable: Observable<Scene>;
  100749. /**
  100750. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100751. */
  100752. onDataLoadedObservable: Observable<Scene>;
  100753. /**
  100754. * An event triggered when a camera is created
  100755. */
  100756. onNewCameraAddedObservable: Observable<Camera>;
  100757. /**
  100758. * An event triggered when a camera is removed
  100759. */
  100760. onCameraRemovedObservable: Observable<Camera>;
  100761. /**
  100762. * An event triggered when a light is created
  100763. */
  100764. onNewLightAddedObservable: Observable<Light>;
  100765. /**
  100766. * An event triggered when a light is removed
  100767. */
  100768. onLightRemovedObservable: Observable<Light>;
  100769. /**
  100770. * An event triggered when a geometry is created
  100771. */
  100772. onNewGeometryAddedObservable: Observable<Geometry>;
  100773. /**
  100774. * An event triggered when a geometry is removed
  100775. */
  100776. onGeometryRemovedObservable: Observable<Geometry>;
  100777. /**
  100778. * An event triggered when a transform node is created
  100779. */
  100780. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100781. /**
  100782. * An event triggered when a transform node is removed
  100783. */
  100784. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100785. /**
  100786. * An event triggered when a mesh is created
  100787. */
  100788. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100789. /**
  100790. * An event triggered when a mesh is removed
  100791. */
  100792. onMeshRemovedObservable: Observable<AbstractMesh>;
  100793. /**
  100794. * An event triggered when a skeleton is created
  100795. */
  100796. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100797. /**
  100798. * An event triggered when a skeleton is removed
  100799. */
  100800. onSkeletonRemovedObservable: Observable<Skeleton>;
  100801. /**
  100802. * An event triggered when a material is created
  100803. */
  100804. onNewMaterialAddedObservable: Observable<Material>;
  100805. /**
  100806. * An event triggered when a material is removed
  100807. */
  100808. onMaterialRemovedObservable: Observable<Material>;
  100809. /**
  100810. * An event triggered when a texture is created
  100811. */
  100812. onNewTextureAddedObservable: Observable<BaseTexture>;
  100813. /**
  100814. * An event triggered when a texture is removed
  100815. */
  100816. onTextureRemovedObservable: Observable<BaseTexture>;
  100817. /**
  100818. * An event triggered when render targets are about to be rendered
  100819. * Can happen multiple times per frame.
  100820. */
  100821. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100822. /**
  100823. * An event triggered when render targets were rendered.
  100824. * Can happen multiple times per frame.
  100825. */
  100826. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100827. /**
  100828. * An event triggered before calculating deterministic simulation step
  100829. */
  100830. onBeforeStepObservable: Observable<Scene>;
  100831. /**
  100832. * An event triggered after calculating deterministic simulation step
  100833. */
  100834. onAfterStepObservable: Observable<Scene>;
  100835. /**
  100836. * An event triggered when the activeCamera property is updated
  100837. */
  100838. onActiveCameraChanged: Observable<Scene>;
  100839. /**
  100840. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100841. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100842. * 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)
  100843. */
  100844. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100845. /**
  100846. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100847. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100848. * 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)
  100849. */
  100850. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100851. /**
  100852. * This Observable will when a mesh has been imported into the scene.
  100853. */
  100854. onMeshImportedObservable: Observable<AbstractMesh>;
  100855. /**
  100856. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100857. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100858. */
  100859. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100860. /** @hidden */
  100861. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100862. /**
  100863. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100864. */
  100865. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100866. /**
  100867. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100868. */
  100869. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100870. /**
  100871. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100872. */
  100873. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100874. /** Callback called when a pointer move is detected */
  100875. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100876. /** Callback called when a pointer down is detected */
  100877. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100878. /** Callback called when a pointer up is detected */
  100879. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100880. /** Callback called when a pointer pick is detected */
  100881. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100882. /**
  100883. * 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).
  100884. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100885. */
  100886. onPrePointerObservable: Observable<PointerInfoPre>;
  100887. /**
  100888. * Observable event triggered each time an input event is received from the rendering canvas
  100889. */
  100890. onPointerObservable: Observable<PointerInfo>;
  100891. /**
  100892. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100893. */
  100894. readonly unTranslatedPointer: Vector2;
  100895. /**
  100896. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100897. */
  100898. static DragMovementThreshold: number;
  100899. /**
  100900. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100901. */
  100902. static LongPressDelay: number;
  100903. /**
  100904. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100905. */
  100906. static DoubleClickDelay: number;
  100907. /** If you need to check double click without raising a single click at first click, enable this flag */
  100908. static ExclusiveDoubleClickMode: boolean;
  100909. /** @hidden */
  100910. _mirroredCameraPosition: Nullable<Vector3>;
  100911. /**
  100912. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100913. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100914. */
  100915. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100916. /**
  100917. * Observable event triggered each time an keyboard event is received from the hosting window
  100918. */
  100919. onKeyboardObservable: Observable<KeyboardInfo>;
  100920. private _useRightHandedSystem;
  100921. /**
  100922. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100923. */
  100924. useRightHandedSystem: boolean;
  100925. private _timeAccumulator;
  100926. private _currentStepId;
  100927. private _currentInternalStep;
  100928. /**
  100929. * Sets the step Id used by deterministic lock step
  100930. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100931. * @param newStepId defines the step Id
  100932. */
  100933. setStepId(newStepId: number): void;
  100934. /**
  100935. * Gets the step Id used by deterministic lock step
  100936. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100937. * @returns the step Id
  100938. */
  100939. getStepId(): number;
  100940. /**
  100941. * Gets the internal step used by deterministic lock step
  100942. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100943. * @returns the internal step
  100944. */
  100945. getInternalStep(): number;
  100946. private _fogEnabled;
  100947. /**
  100948. * Gets or sets a boolean indicating if fog is enabled on this scene
  100949. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100950. * (Default is true)
  100951. */
  100952. fogEnabled: boolean;
  100953. private _fogMode;
  100954. /**
  100955. * Gets or sets the fog mode to use
  100956. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100957. * | mode | value |
  100958. * | --- | --- |
  100959. * | FOGMODE_NONE | 0 |
  100960. * | FOGMODE_EXP | 1 |
  100961. * | FOGMODE_EXP2 | 2 |
  100962. * | FOGMODE_LINEAR | 3 |
  100963. */
  100964. fogMode: number;
  100965. /**
  100966. * Gets or sets the fog color to use
  100967. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100968. * (Default is Color3(0.2, 0.2, 0.3))
  100969. */
  100970. fogColor: Color3;
  100971. /**
  100972. * Gets or sets the fog density to use
  100973. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100974. * (Default is 0.1)
  100975. */
  100976. fogDensity: number;
  100977. /**
  100978. * Gets or sets the fog start distance to use
  100979. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100980. * (Default is 0)
  100981. */
  100982. fogStart: number;
  100983. /**
  100984. * Gets or sets the fog end distance to use
  100985. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100986. * (Default is 1000)
  100987. */
  100988. fogEnd: number;
  100989. private _shadowsEnabled;
  100990. /**
  100991. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100992. */
  100993. shadowsEnabled: boolean;
  100994. private _lightsEnabled;
  100995. /**
  100996. * Gets or sets a boolean indicating if lights are enabled on this scene
  100997. */
  100998. lightsEnabled: boolean;
  100999. /** All of the active cameras added to this scene. */
  101000. activeCameras: Camera[];
  101001. /** @hidden */
  101002. _activeCamera: Nullable<Camera>;
  101003. /** Gets or sets the current active camera */
  101004. activeCamera: Nullable<Camera>;
  101005. private _defaultMaterial;
  101006. /** The default material used on meshes when no material is affected */
  101007. /** The default material used on meshes when no material is affected */
  101008. defaultMaterial: Material;
  101009. private _texturesEnabled;
  101010. /**
  101011. * Gets or sets a boolean indicating if textures are enabled on this scene
  101012. */
  101013. texturesEnabled: boolean;
  101014. /**
  101015. * Gets or sets a boolean indicating if particles are enabled on this scene
  101016. */
  101017. particlesEnabled: boolean;
  101018. /**
  101019. * Gets or sets a boolean indicating if sprites are enabled on this scene
  101020. */
  101021. spritesEnabled: boolean;
  101022. private _skeletonsEnabled;
  101023. /**
  101024. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  101025. */
  101026. skeletonsEnabled: boolean;
  101027. /**
  101028. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  101029. */
  101030. lensFlaresEnabled: boolean;
  101031. /**
  101032. * Gets or sets a boolean indicating if collisions are enabled on this scene
  101033. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101034. */
  101035. collisionsEnabled: boolean;
  101036. private _collisionCoordinator;
  101037. /** @hidden */
  101038. readonly collisionCoordinator: ICollisionCoordinator;
  101039. /**
  101040. * Defines the gravity applied to this scene (used only for collisions)
  101041. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101042. */
  101043. gravity: Vector3;
  101044. /**
  101045. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  101046. */
  101047. postProcessesEnabled: boolean;
  101048. /**
  101049. * The list of postprocesses added to the scene
  101050. */
  101051. postProcesses: PostProcess[];
  101052. /**
  101053. * Gets the current postprocess manager
  101054. */
  101055. postProcessManager: PostProcessManager;
  101056. /**
  101057. * Gets or sets a boolean indicating if render targets are enabled on this scene
  101058. */
  101059. renderTargetsEnabled: boolean;
  101060. /**
  101061. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  101062. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  101063. */
  101064. dumpNextRenderTargets: boolean;
  101065. /**
  101066. * The list of user defined render targets added to the scene
  101067. */
  101068. customRenderTargets: RenderTargetTexture[];
  101069. /**
  101070. * Defines if texture loading must be delayed
  101071. * If true, textures will only be loaded when they need to be rendered
  101072. */
  101073. useDelayedTextureLoading: boolean;
  101074. /**
  101075. * Gets the list of meshes imported to the scene through SceneLoader
  101076. */
  101077. importedMeshesFiles: String[];
  101078. /**
  101079. * Gets or sets a boolean indicating if probes are enabled on this scene
  101080. */
  101081. probesEnabled: boolean;
  101082. /**
  101083. * Gets or sets the current offline provider to use to store scene data
  101084. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101085. */
  101086. offlineProvider: IOfflineProvider;
  101087. /**
  101088. * Gets or sets the action manager associated with the scene
  101089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101090. */
  101091. actionManager: AbstractActionManager;
  101092. private _meshesForIntersections;
  101093. /**
  101094. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  101095. */
  101096. proceduralTexturesEnabled: boolean;
  101097. private _engine;
  101098. private _totalVertices;
  101099. /** @hidden */
  101100. _activeIndices: PerfCounter;
  101101. /** @hidden */
  101102. _activeParticles: PerfCounter;
  101103. /** @hidden */
  101104. _activeBones: PerfCounter;
  101105. private _animationRatio;
  101106. /** @hidden */
  101107. _animationTimeLast: number;
  101108. /** @hidden */
  101109. _animationTime: number;
  101110. /**
  101111. * Gets or sets a general scale for animation speed
  101112. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101113. */
  101114. animationTimeScale: number;
  101115. /** @hidden */
  101116. _cachedMaterial: Nullable<Material>;
  101117. /** @hidden */
  101118. _cachedEffect: Nullable<Effect>;
  101119. /** @hidden */
  101120. _cachedVisibility: Nullable<number>;
  101121. private _renderId;
  101122. private _frameId;
  101123. private _executeWhenReadyTimeoutId;
  101124. private _intermediateRendering;
  101125. private _viewUpdateFlag;
  101126. private _projectionUpdateFlag;
  101127. /** @hidden */
  101128. _toBeDisposed: Nullable<IDisposable>[];
  101129. private _activeRequests;
  101130. /** @hidden */
  101131. _pendingData: any[];
  101132. private _isDisposed;
  101133. /**
  101134. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101135. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101136. */
  101137. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101138. private _activeMeshes;
  101139. private _processedMaterials;
  101140. private _renderTargets;
  101141. /** @hidden */
  101142. _activeParticleSystems: SmartArray<IParticleSystem>;
  101143. private _activeSkeletons;
  101144. private _softwareSkinnedMeshes;
  101145. private _renderingManager;
  101146. /** @hidden */
  101147. _activeAnimatables: Animatable[];
  101148. private _transformMatrix;
  101149. private _sceneUbo;
  101150. /** @hidden */
  101151. _viewMatrix: Matrix;
  101152. private _projectionMatrix;
  101153. /** @hidden */
  101154. _forcedViewPosition: Nullable<Vector3>;
  101155. /** @hidden */
  101156. _frustumPlanes: Plane[];
  101157. /**
  101158. * Gets the list of frustum planes (built from the active camera)
  101159. */
  101160. readonly frustumPlanes: Plane[];
  101161. /**
  101162. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  101163. * This is useful if there are more lights that the maximum simulteanous authorized
  101164. */
  101165. requireLightSorting: boolean;
  101166. /** @hidden */
  101167. readonly useMaterialMeshMap: boolean;
  101168. /** @hidden */
  101169. readonly useClonedMeshhMap: boolean;
  101170. private _externalData;
  101171. private _uid;
  101172. /**
  101173. * @hidden
  101174. * Backing store of defined scene components.
  101175. */
  101176. _components: ISceneComponent[];
  101177. /**
  101178. * @hidden
  101179. * Backing store of defined scene components.
  101180. */
  101181. _serializableComponents: ISceneSerializableComponent[];
  101182. /**
  101183. * List of components to register on the next registration step.
  101184. */
  101185. private _transientComponents;
  101186. /**
  101187. * Registers the transient components if needed.
  101188. */
  101189. private _registerTransientComponents;
  101190. /**
  101191. * @hidden
  101192. * Add a component to the scene.
  101193. * Note that the ccomponent could be registered on th next frame if this is called after
  101194. * the register component stage.
  101195. * @param component Defines the component to add to the scene
  101196. */
  101197. _addComponent(component: ISceneComponent): void;
  101198. /**
  101199. * @hidden
  101200. * Gets a component from the scene.
  101201. * @param name defines the name of the component to retrieve
  101202. * @returns the component or null if not present
  101203. */
  101204. _getComponent(name: string): Nullable<ISceneComponent>;
  101205. /**
  101206. * @hidden
  101207. * Defines the actions happening before camera updates.
  101208. */
  101209. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  101210. /**
  101211. * @hidden
  101212. * Defines the actions happening before clear the canvas.
  101213. */
  101214. _beforeClearStage: Stage<SimpleStageAction>;
  101215. /**
  101216. * @hidden
  101217. * Defines the actions when collecting render targets for the frame.
  101218. */
  101219. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101220. /**
  101221. * @hidden
  101222. * Defines the actions happening for one camera in the frame.
  101223. */
  101224. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101225. /**
  101226. * @hidden
  101227. * Defines the actions happening during the per mesh ready checks.
  101228. */
  101229. _isReadyForMeshStage: Stage<MeshStageAction>;
  101230. /**
  101231. * @hidden
  101232. * Defines the actions happening before evaluate active mesh checks.
  101233. */
  101234. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  101235. /**
  101236. * @hidden
  101237. * Defines the actions happening during the evaluate sub mesh checks.
  101238. */
  101239. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  101240. /**
  101241. * @hidden
  101242. * Defines the actions happening during the active mesh stage.
  101243. */
  101244. _activeMeshStage: Stage<ActiveMeshStageAction>;
  101245. /**
  101246. * @hidden
  101247. * Defines the actions happening during the per camera render target step.
  101248. */
  101249. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  101250. /**
  101251. * @hidden
  101252. * Defines the actions happening just before the active camera is drawing.
  101253. */
  101254. _beforeCameraDrawStage: Stage<CameraStageAction>;
  101255. /**
  101256. * @hidden
  101257. * Defines the actions happening just before a render target is drawing.
  101258. */
  101259. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101260. /**
  101261. * @hidden
  101262. * Defines the actions happening just before a rendering group is drawing.
  101263. */
  101264. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101265. /**
  101266. * @hidden
  101267. * Defines the actions happening just before a mesh is drawing.
  101268. */
  101269. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101270. /**
  101271. * @hidden
  101272. * Defines the actions happening just after a mesh has been drawn.
  101273. */
  101274. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101275. /**
  101276. * @hidden
  101277. * Defines the actions happening just after a rendering group has been drawn.
  101278. */
  101279. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101280. /**
  101281. * @hidden
  101282. * Defines the actions happening just after the active camera has been drawn.
  101283. */
  101284. _afterCameraDrawStage: Stage<CameraStageAction>;
  101285. /**
  101286. * @hidden
  101287. * Defines the actions happening just after a render target has been drawn.
  101288. */
  101289. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101290. /**
  101291. * @hidden
  101292. * Defines the actions happening just after rendering all cameras and computing intersections.
  101293. */
  101294. _afterRenderStage: Stage<SimpleStageAction>;
  101295. /**
  101296. * @hidden
  101297. * Defines the actions happening when a pointer move event happens.
  101298. */
  101299. _pointerMoveStage: Stage<PointerMoveStageAction>;
  101300. /**
  101301. * @hidden
  101302. * Defines the actions happening when a pointer down event happens.
  101303. */
  101304. _pointerDownStage: Stage<PointerUpDownStageAction>;
  101305. /**
  101306. * @hidden
  101307. * Defines the actions happening when a pointer up event happens.
  101308. */
  101309. _pointerUpStage: Stage<PointerUpDownStageAction>;
  101310. /**
  101311. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  101312. */
  101313. private geometriesByUniqueId;
  101314. /**
  101315. * Creates a new Scene
  101316. * @param engine defines the engine to use to render this scene
  101317. * @param options defines the scene options
  101318. */
  101319. constructor(engine: Engine, options?: SceneOptions);
  101320. /**
  101321. * Gets a string idenfifying the name of the class
  101322. * @returns "Scene" string
  101323. */
  101324. getClassName(): string;
  101325. private _defaultMeshCandidates;
  101326. /**
  101327. * @hidden
  101328. */
  101329. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  101330. private _defaultSubMeshCandidates;
  101331. /**
  101332. * @hidden
  101333. */
  101334. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  101335. /**
  101336. * Sets the default candidate providers for the scene.
  101337. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  101338. * and getCollidingSubMeshCandidates to their default function
  101339. */
  101340. setDefaultCandidateProviders(): void;
  101341. /**
  101342. * Gets the mesh that is currently under the pointer
  101343. */
  101344. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101345. /**
  101346. * Gets or sets the current on-screen X position of the pointer
  101347. */
  101348. pointerX: number;
  101349. /**
  101350. * Gets or sets the current on-screen Y position of the pointer
  101351. */
  101352. pointerY: number;
  101353. /**
  101354. * Gets the cached material (ie. the latest rendered one)
  101355. * @returns the cached material
  101356. */
  101357. getCachedMaterial(): Nullable<Material>;
  101358. /**
  101359. * Gets the cached effect (ie. the latest rendered one)
  101360. * @returns the cached effect
  101361. */
  101362. getCachedEffect(): Nullable<Effect>;
  101363. /**
  101364. * Gets the cached visibility state (ie. the latest rendered one)
  101365. * @returns the cached visibility state
  101366. */
  101367. getCachedVisibility(): Nullable<number>;
  101368. /**
  101369. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  101370. * @param material defines the current material
  101371. * @param effect defines the current effect
  101372. * @param visibility defines the current visibility state
  101373. * @returns true if one parameter is not cached
  101374. */
  101375. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  101376. /**
  101377. * Gets the engine associated with the scene
  101378. * @returns an Engine
  101379. */
  101380. getEngine(): Engine;
  101381. /**
  101382. * Gets the total number of vertices rendered per frame
  101383. * @returns the total number of vertices rendered per frame
  101384. */
  101385. getTotalVertices(): number;
  101386. /**
  101387. * Gets the performance counter for total vertices
  101388. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101389. */
  101390. readonly totalVerticesPerfCounter: PerfCounter;
  101391. /**
  101392. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  101393. * @returns the total number of active indices rendered per frame
  101394. */
  101395. getActiveIndices(): number;
  101396. /**
  101397. * Gets the performance counter for active indices
  101398. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101399. */
  101400. readonly totalActiveIndicesPerfCounter: PerfCounter;
  101401. /**
  101402. * Gets the total number of active particles rendered per frame
  101403. * @returns the total number of active particles rendered per frame
  101404. */
  101405. getActiveParticles(): number;
  101406. /**
  101407. * Gets the performance counter for active particles
  101408. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101409. */
  101410. readonly activeParticlesPerfCounter: PerfCounter;
  101411. /**
  101412. * Gets the total number of active bones rendered per frame
  101413. * @returns the total number of active bones rendered per frame
  101414. */
  101415. getActiveBones(): number;
  101416. /**
  101417. * Gets the performance counter for active bones
  101418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101419. */
  101420. readonly activeBonesPerfCounter: PerfCounter;
  101421. /**
  101422. * Gets the array of active meshes
  101423. * @returns an array of AbstractMesh
  101424. */
  101425. getActiveMeshes(): SmartArray<AbstractMesh>;
  101426. /**
  101427. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  101428. * @returns a number
  101429. */
  101430. getAnimationRatio(): number;
  101431. /**
  101432. * Gets an unique Id for the current render phase
  101433. * @returns a number
  101434. */
  101435. getRenderId(): number;
  101436. /**
  101437. * Gets an unique Id for the current frame
  101438. * @returns a number
  101439. */
  101440. getFrameId(): number;
  101441. /** Call this function if you want to manually increment the render Id*/
  101442. incrementRenderId(): void;
  101443. private _createUbo;
  101444. /**
  101445. * Use this method to simulate a pointer move on a mesh
  101446. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101447. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101448. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101449. * @returns the current scene
  101450. */
  101451. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101452. /**
  101453. * Use this method to simulate a pointer down on a mesh
  101454. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101455. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101456. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101457. * @returns the current scene
  101458. */
  101459. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101460. /**
  101461. * Use this method to simulate a pointer up on a mesh
  101462. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101463. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101464. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101465. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101466. * @returns the current scene
  101467. */
  101468. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  101469. /**
  101470. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101471. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101472. * @returns true if the pointer was captured
  101473. */
  101474. isPointerCaptured(pointerId?: number): boolean;
  101475. /**
  101476. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101477. * @param attachUp defines if you want to attach events to pointerup
  101478. * @param attachDown defines if you want to attach events to pointerdown
  101479. * @param attachMove defines if you want to attach events to pointermove
  101480. */
  101481. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101482. /** Detaches all event handlers*/
  101483. detachControl(): void;
  101484. /**
  101485. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  101486. * Delay loaded resources are not taking in account
  101487. * @return true if all required resources are ready
  101488. */
  101489. isReady(): boolean;
  101490. /** Resets all cached information relative to material (including effect and visibility) */
  101491. resetCachedMaterial(): void;
  101492. /**
  101493. * Registers a function to be called before every frame render
  101494. * @param func defines the function to register
  101495. */
  101496. registerBeforeRender(func: () => void): void;
  101497. /**
  101498. * Unregisters a function called before every frame render
  101499. * @param func defines the function to unregister
  101500. */
  101501. unregisterBeforeRender(func: () => void): void;
  101502. /**
  101503. * Registers a function to be called after every frame render
  101504. * @param func defines the function to register
  101505. */
  101506. registerAfterRender(func: () => void): void;
  101507. /**
  101508. * Unregisters a function called after every frame render
  101509. * @param func defines the function to unregister
  101510. */
  101511. unregisterAfterRender(func: () => void): void;
  101512. private _executeOnceBeforeRender;
  101513. /**
  101514. * The provided function will run before render once and will be disposed afterwards.
  101515. * A timeout delay can be provided so that the function will be executed in N ms.
  101516. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  101517. * @param func The function to be executed.
  101518. * @param timeout optional delay in ms
  101519. */
  101520. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  101521. /** @hidden */
  101522. _addPendingData(data: any): void;
  101523. /** @hidden */
  101524. _removePendingData(data: any): void;
  101525. /**
  101526. * Returns the number of items waiting to be loaded
  101527. * @returns the number of items waiting to be loaded
  101528. */
  101529. getWaitingItemsCount(): number;
  101530. /**
  101531. * Returns a boolean indicating if the scene is still loading data
  101532. */
  101533. readonly isLoading: boolean;
  101534. /**
  101535. * Registers a function to be executed when the scene is ready
  101536. * @param {Function} func - the function to be executed
  101537. */
  101538. executeWhenReady(func: () => void): void;
  101539. /**
  101540. * Returns a promise that resolves when the scene is ready
  101541. * @returns A promise that resolves when the scene is ready
  101542. */
  101543. whenReadyAsync(): Promise<void>;
  101544. /** @hidden */
  101545. _checkIsReady(): void;
  101546. /**
  101547. * Gets all animatable attached to the scene
  101548. */
  101549. readonly animatables: Animatable[];
  101550. /**
  101551. * Resets the last animation time frame.
  101552. * Useful to override when animations start running when loading a scene for the first time.
  101553. */
  101554. resetLastAnimationTimeFrame(): void;
  101555. /**
  101556. * Gets the current view matrix
  101557. * @returns a Matrix
  101558. */
  101559. getViewMatrix(): Matrix;
  101560. /**
  101561. * Gets the current projection matrix
  101562. * @returns a Matrix
  101563. */
  101564. getProjectionMatrix(): Matrix;
  101565. /**
  101566. * Gets the current transform matrix
  101567. * @returns a Matrix made of View * Projection
  101568. */
  101569. getTransformMatrix(): Matrix;
  101570. /**
  101571. * Sets the current transform matrix
  101572. * @param viewL defines the View matrix to use
  101573. * @param projectionL defines the Projection matrix to use
  101574. * @param viewR defines the right View matrix to use (if provided)
  101575. * @param projectionR defines the right Projection matrix to use (if provided)
  101576. */
  101577. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  101578. /**
  101579. * Gets the uniform buffer used to store scene data
  101580. * @returns a UniformBuffer
  101581. */
  101582. getSceneUniformBuffer(): UniformBuffer;
  101583. /**
  101584. * Gets an unique (relatively to the current scene) Id
  101585. * @returns an unique number for the scene
  101586. */
  101587. getUniqueId(): number;
  101588. /**
  101589. * Add a mesh to the list of scene's meshes
  101590. * @param newMesh defines the mesh to add
  101591. * @param recursive if all child meshes should also be added to the scene
  101592. */
  101593. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  101594. /**
  101595. * Remove a mesh for the list of scene's meshes
  101596. * @param toRemove defines the mesh to remove
  101597. * @param recursive if all child meshes should also be removed from the scene
  101598. * @returns the index where the mesh was in the mesh list
  101599. */
  101600. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  101601. /**
  101602. * Add a transform node to the list of scene's transform nodes
  101603. * @param newTransformNode defines the transform node to add
  101604. */
  101605. addTransformNode(newTransformNode: TransformNode): void;
  101606. /**
  101607. * Remove a transform node for the list of scene's transform nodes
  101608. * @param toRemove defines the transform node to remove
  101609. * @returns the index where the transform node was in the transform node list
  101610. */
  101611. removeTransformNode(toRemove: TransformNode): number;
  101612. /**
  101613. * Remove a skeleton for the list of scene's skeletons
  101614. * @param toRemove defines the skeleton to remove
  101615. * @returns the index where the skeleton was in the skeleton list
  101616. */
  101617. removeSkeleton(toRemove: Skeleton): number;
  101618. /**
  101619. * Remove a morph target for the list of scene's morph targets
  101620. * @param toRemove defines the morph target to remove
  101621. * @returns the index where the morph target was in the morph target list
  101622. */
  101623. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  101624. /**
  101625. * Remove a light for the list of scene's lights
  101626. * @param toRemove defines the light to remove
  101627. * @returns the index where the light was in the light list
  101628. */
  101629. removeLight(toRemove: Light): number;
  101630. /**
  101631. * Remove a camera for the list of scene's cameras
  101632. * @param toRemove defines the camera to remove
  101633. * @returns the index where the camera was in the camera list
  101634. */
  101635. removeCamera(toRemove: Camera): number;
  101636. /**
  101637. * Remove a particle system for the list of scene's particle systems
  101638. * @param toRemove defines the particle system to remove
  101639. * @returns the index where the particle system was in the particle system list
  101640. */
  101641. removeParticleSystem(toRemove: IParticleSystem): number;
  101642. /**
  101643. * Remove a animation for the list of scene's animations
  101644. * @param toRemove defines the animation to remove
  101645. * @returns the index where the animation was in the animation list
  101646. */
  101647. removeAnimation(toRemove: Animation): number;
  101648. /**
  101649. * Will stop the animation of the given target
  101650. * @param target - the target
  101651. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  101652. * @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)
  101653. */
  101654. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  101655. /**
  101656. * Removes the given animation group from this scene.
  101657. * @param toRemove The animation group to remove
  101658. * @returns The index of the removed animation group
  101659. */
  101660. removeAnimationGroup(toRemove: AnimationGroup): number;
  101661. /**
  101662. * Removes the given multi-material from this scene.
  101663. * @param toRemove The multi-material to remove
  101664. * @returns The index of the removed multi-material
  101665. */
  101666. removeMultiMaterial(toRemove: MultiMaterial): number;
  101667. /**
  101668. * Removes the given material from this scene.
  101669. * @param toRemove The material to remove
  101670. * @returns The index of the removed material
  101671. */
  101672. removeMaterial(toRemove: Material): number;
  101673. /**
  101674. * Removes the given action manager from this scene.
  101675. * @param toRemove The action manager to remove
  101676. * @returns The index of the removed action manager
  101677. */
  101678. removeActionManager(toRemove: AbstractActionManager): number;
  101679. /**
  101680. * Removes the given texture from this scene.
  101681. * @param toRemove The texture to remove
  101682. * @returns The index of the removed texture
  101683. */
  101684. removeTexture(toRemove: BaseTexture): number;
  101685. /**
  101686. * Adds the given light to this scene
  101687. * @param newLight The light to add
  101688. */
  101689. addLight(newLight: Light): void;
  101690. /**
  101691. * Sorts the list list based on light priorities
  101692. */
  101693. sortLightsByPriority(): void;
  101694. /**
  101695. * Adds the given camera to this scene
  101696. * @param newCamera The camera to add
  101697. */
  101698. addCamera(newCamera: Camera): void;
  101699. /**
  101700. * Adds the given skeleton to this scene
  101701. * @param newSkeleton The skeleton to add
  101702. */
  101703. addSkeleton(newSkeleton: Skeleton): void;
  101704. /**
  101705. * Adds the given particle system to this scene
  101706. * @param newParticleSystem The particle system to add
  101707. */
  101708. addParticleSystem(newParticleSystem: IParticleSystem): void;
  101709. /**
  101710. * Adds the given animation to this scene
  101711. * @param newAnimation The animation to add
  101712. */
  101713. addAnimation(newAnimation: Animation): void;
  101714. /**
  101715. * Adds the given animation group to this scene.
  101716. * @param newAnimationGroup The animation group to add
  101717. */
  101718. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  101719. /**
  101720. * Adds the given multi-material to this scene
  101721. * @param newMultiMaterial The multi-material to add
  101722. */
  101723. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  101724. /**
  101725. * Adds the given material to this scene
  101726. * @param newMaterial The material to add
  101727. */
  101728. addMaterial(newMaterial: Material): void;
  101729. /**
  101730. * Adds the given morph target to this scene
  101731. * @param newMorphTargetManager The morph target to add
  101732. */
  101733. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101734. /**
  101735. * Adds the given geometry to this scene
  101736. * @param newGeometry The geometry to add
  101737. */
  101738. addGeometry(newGeometry: Geometry): void;
  101739. /**
  101740. * Adds the given action manager to this scene
  101741. * @param newActionManager The action manager to add
  101742. */
  101743. addActionManager(newActionManager: AbstractActionManager): void;
  101744. /**
  101745. * Adds the given texture to this scene.
  101746. * @param newTexture The texture to add
  101747. */
  101748. addTexture(newTexture: BaseTexture): void;
  101749. /**
  101750. * Switch active camera
  101751. * @param newCamera defines the new active camera
  101752. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101753. */
  101754. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101755. /**
  101756. * sets the active camera of the scene using its ID
  101757. * @param id defines the camera's ID
  101758. * @return the new active camera or null if none found.
  101759. */
  101760. setActiveCameraByID(id: string): Nullable<Camera>;
  101761. /**
  101762. * sets the active camera of the scene using its name
  101763. * @param name defines the camera's name
  101764. * @returns the new active camera or null if none found.
  101765. */
  101766. setActiveCameraByName(name: string): Nullable<Camera>;
  101767. /**
  101768. * get an animation group using its name
  101769. * @param name defines the material's name
  101770. * @return the animation group or null if none found.
  101771. */
  101772. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101773. /**
  101774. * Get a material using its unique id
  101775. * @param uniqueId defines the material's unique id
  101776. * @return the material or null if none found.
  101777. */
  101778. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101779. /**
  101780. * get a material using its id
  101781. * @param id defines the material's ID
  101782. * @return the material or null if none found.
  101783. */
  101784. getMaterialByID(id: string): Nullable<Material>;
  101785. /**
  101786. * Gets a the last added material using a given id
  101787. * @param id defines the material's ID
  101788. * @return the last material with the given id or null if none found.
  101789. */
  101790. getLastMaterialByID(id: string): Nullable<Material>;
  101791. /**
  101792. * Gets a material using its name
  101793. * @param name defines the material's name
  101794. * @return the material or null if none found.
  101795. */
  101796. getMaterialByName(name: string): Nullable<Material>;
  101797. /**
  101798. * Get a texture using its unique id
  101799. * @param uniqueId defines the texture's unique id
  101800. * @return the texture or null if none found.
  101801. */
  101802. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101803. /**
  101804. * Gets a camera using its id
  101805. * @param id defines the id to look for
  101806. * @returns the camera or null if not found
  101807. */
  101808. getCameraByID(id: string): Nullable<Camera>;
  101809. /**
  101810. * Gets a camera using its unique id
  101811. * @param uniqueId defines the unique id to look for
  101812. * @returns the camera or null if not found
  101813. */
  101814. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101815. /**
  101816. * Gets a camera using its name
  101817. * @param name defines the camera's name
  101818. * @return the camera or null if none found.
  101819. */
  101820. getCameraByName(name: string): Nullable<Camera>;
  101821. /**
  101822. * Gets a bone using its id
  101823. * @param id defines the bone's id
  101824. * @return the bone or null if not found
  101825. */
  101826. getBoneByID(id: string): Nullable<Bone>;
  101827. /**
  101828. * Gets a bone using its id
  101829. * @param name defines the bone's name
  101830. * @return the bone or null if not found
  101831. */
  101832. getBoneByName(name: string): Nullable<Bone>;
  101833. /**
  101834. * Gets a light node using its name
  101835. * @param name defines the the light's name
  101836. * @return the light or null if none found.
  101837. */
  101838. getLightByName(name: string): Nullable<Light>;
  101839. /**
  101840. * Gets a light node using its id
  101841. * @param id defines the light's id
  101842. * @return the light or null if none found.
  101843. */
  101844. getLightByID(id: string): Nullable<Light>;
  101845. /**
  101846. * Gets a light node using its scene-generated unique ID
  101847. * @param uniqueId defines the light's unique id
  101848. * @return the light or null if none found.
  101849. */
  101850. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101851. /**
  101852. * Gets a particle system by id
  101853. * @param id defines the particle system id
  101854. * @return the corresponding system or null if none found
  101855. */
  101856. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101857. /**
  101858. * Gets a geometry using its ID
  101859. * @param id defines the geometry's id
  101860. * @return the geometry or null if none found.
  101861. */
  101862. getGeometryByID(id: string): Nullable<Geometry>;
  101863. private _getGeometryByUniqueID;
  101864. /**
  101865. * Add a new geometry to this scene
  101866. * @param geometry defines the geometry to be added to the scene.
  101867. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101868. * @return a boolean defining if the geometry was added or not
  101869. */
  101870. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101871. /**
  101872. * Removes an existing geometry
  101873. * @param geometry defines the geometry to be removed from the scene
  101874. * @return a boolean defining if the geometry was removed or not
  101875. */
  101876. removeGeometry(geometry: Geometry): boolean;
  101877. /**
  101878. * Gets the list of geometries attached to the scene
  101879. * @returns an array of Geometry
  101880. */
  101881. getGeometries(): Geometry[];
  101882. /**
  101883. * Gets the first added mesh found of a given ID
  101884. * @param id defines the id to search for
  101885. * @return the mesh found or null if not found at all
  101886. */
  101887. getMeshByID(id: string): Nullable<AbstractMesh>;
  101888. /**
  101889. * Gets a list of meshes using their id
  101890. * @param id defines the id to search for
  101891. * @returns a list of meshes
  101892. */
  101893. getMeshesByID(id: string): Array<AbstractMesh>;
  101894. /**
  101895. * Gets the first added transform node found of a given ID
  101896. * @param id defines the id to search for
  101897. * @return the found transform node or null if not found at all.
  101898. */
  101899. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101900. /**
  101901. * Gets a transform node with its auto-generated unique id
  101902. * @param uniqueId efines the unique id to search for
  101903. * @return the found transform node or null if not found at all.
  101904. */
  101905. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101906. /**
  101907. * Gets a list of transform nodes using their id
  101908. * @param id defines the id to search for
  101909. * @returns a list of transform nodes
  101910. */
  101911. getTransformNodesByID(id: string): Array<TransformNode>;
  101912. /**
  101913. * Gets a mesh with its auto-generated unique id
  101914. * @param uniqueId defines the unique id to search for
  101915. * @return the found mesh or null if not found at all.
  101916. */
  101917. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101918. /**
  101919. * Gets a the last added mesh using a given id
  101920. * @param id defines the id to search for
  101921. * @return the found mesh or null if not found at all.
  101922. */
  101923. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101924. /**
  101925. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101926. * @param id defines the id to search for
  101927. * @return the found node or null if not found at all
  101928. */
  101929. getLastEntryByID(id: string): Nullable<Node>;
  101930. /**
  101931. * Gets a node (Mesh, Camera, Light) using a given id
  101932. * @param id defines the id to search for
  101933. * @return the found node or null if not found at all
  101934. */
  101935. getNodeByID(id: string): Nullable<Node>;
  101936. /**
  101937. * Gets a node (Mesh, Camera, Light) using a given name
  101938. * @param name defines the name to search for
  101939. * @return the found node or null if not found at all.
  101940. */
  101941. getNodeByName(name: string): Nullable<Node>;
  101942. /**
  101943. * Gets a mesh using a given name
  101944. * @param name defines the name to search for
  101945. * @return the found mesh or null if not found at all.
  101946. */
  101947. getMeshByName(name: string): Nullable<AbstractMesh>;
  101948. /**
  101949. * Gets a transform node using a given name
  101950. * @param name defines the name to search for
  101951. * @return the found transform node or null if not found at all.
  101952. */
  101953. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101954. /**
  101955. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101956. * @param id defines the id to search for
  101957. * @return the found skeleton or null if not found at all.
  101958. */
  101959. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101960. /**
  101961. * Gets a skeleton using a given auto generated unique id
  101962. * @param uniqueId defines the unique id to search for
  101963. * @return the found skeleton or null if not found at all.
  101964. */
  101965. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101966. /**
  101967. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101968. * @param id defines the id to search for
  101969. * @return the found skeleton or null if not found at all.
  101970. */
  101971. getSkeletonById(id: string): Nullable<Skeleton>;
  101972. /**
  101973. * Gets a skeleton using a given name
  101974. * @param name defines the name to search for
  101975. * @return the found skeleton or null if not found at all.
  101976. */
  101977. getSkeletonByName(name: string): Nullable<Skeleton>;
  101978. /**
  101979. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101980. * @param id defines the id to search for
  101981. * @return the found morph target manager or null if not found at all.
  101982. */
  101983. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101984. /**
  101985. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101986. * @param id defines the id to search for
  101987. * @return the found morph target or null if not found at all.
  101988. */
  101989. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101990. /**
  101991. * Gets a boolean indicating if the given mesh is active
  101992. * @param mesh defines the mesh to look for
  101993. * @returns true if the mesh is in the active list
  101994. */
  101995. isActiveMesh(mesh: AbstractMesh): boolean;
  101996. /**
  101997. * Return a unique id as a string which can serve as an identifier for the scene
  101998. */
  101999. readonly uid: string;
  102000. /**
  102001. * Add an externaly attached data from its key.
  102002. * This method call will fail and return false, if such key already exists.
  102003. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  102004. * @param key the unique key that identifies the data
  102005. * @param data the data object to associate to the key for this Engine instance
  102006. * @return true if no such key were already present and the data was added successfully, false otherwise
  102007. */
  102008. addExternalData<T>(key: string, data: T): boolean;
  102009. /**
  102010. * Get an externaly attached data from its key
  102011. * @param key the unique key that identifies the data
  102012. * @return the associated data, if present (can be null), or undefined if not present
  102013. */
  102014. getExternalData<T>(key: string): Nullable<T>;
  102015. /**
  102016. * Get an externaly attached data from its key, create it using a factory if it's not already present
  102017. * @param key the unique key that identifies the data
  102018. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  102019. * @return the associated data, can be null if the factory returned null.
  102020. */
  102021. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  102022. /**
  102023. * Remove an externaly attached data from the Engine instance
  102024. * @param key the unique key that identifies the data
  102025. * @return true if the data was successfully removed, false if it doesn't exist
  102026. */
  102027. removeExternalData(key: string): boolean;
  102028. private _evaluateSubMesh;
  102029. /**
  102030. * Clear the processed materials smart array preventing retention point in material dispose.
  102031. */
  102032. freeProcessedMaterials(): void;
  102033. private _preventFreeActiveMeshesAndRenderingGroups;
  102034. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  102035. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  102036. * when disposing several meshes in a row or a hierarchy of meshes.
  102037. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  102038. */
  102039. blockfreeActiveMeshesAndRenderingGroups: boolean;
  102040. /**
  102041. * Clear the active meshes smart array preventing retention point in mesh dispose.
  102042. */
  102043. freeActiveMeshes(): void;
  102044. /**
  102045. * Clear the info related to rendering groups preventing retention points during dispose.
  102046. */
  102047. freeRenderingGroups(): void;
  102048. /** @hidden */
  102049. _isInIntermediateRendering(): boolean;
  102050. /**
  102051. * Lambda returning the list of potentially active meshes.
  102052. */
  102053. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  102054. /**
  102055. * Lambda returning the list of potentially active sub meshes.
  102056. */
  102057. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  102058. /**
  102059. * Lambda returning the list of potentially intersecting sub meshes.
  102060. */
  102061. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  102062. /**
  102063. * Lambda returning the list of potentially colliding sub meshes.
  102064. */
  102065. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  102066. private _activeMeshesFrozen;
  102067. /**
  102068. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  102069. * @returns the current scene
  102070. */
  102071. freezeActiveMeshes(): Scene;
  102072. /**
  102073. * Use this function to restart evaluating active meshes on every frame
  102074. * @returns the current scene
  102075. */
  102076. unfreezeActiveMeshes(): Scene;
  102077. private _evaluateActiveMeshes;
  102078. private _activeMesh;
  102079. /**
  102080. * Update the transform matrix to update from the current active camera
  102081. * @param force defines a boolean used to force the update even if cache is up to date
  102082. */
  102083. updateTransformMatrix(force?: boolean): void;
  102084. private _bindFrameBuffer;
  102085. /** @hidden */
  102086. _allowPostProcessClearColor: boolean;
  102087. /** @hidden */
  102088. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  102089. private _processSubCameras;
  102090. private _checkIntersections;
  102091. /** @hidden */
  102092. _advancePhysicsEngineStep(step: number): void;
  102093. /**
  102094. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  102095. */
  102096. getDeterministicFrameTime: () => number;
  102097. /** @hidden */
  102098. _animate(): void;
  102099. /** Execute all animations (for a frame) */
  102100. animate(): void;
  102101. /**
  102102. * Render the scene
  102103. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102104. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102105. */
  102106. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102107. /**
  102108. * Freeze all materials
  102109. * A frozen material will not be updatable but should be faster to render
  102110. */
  102111. freezeMaterials(): void;
  102112. /**
  102113. * Unfreeze all materials
  102114. * A frozen material will not be updatable but should be faster to render
  102115. */
  102116. unfreezeMaterials(): void;
  102117. /**
  102118. * Releases all held ressources
  102119. */
  102120. dispose(): void;
  102121. /**
  102122. * Gets if the scene is already disposed
  102123. */
  102124. readonly isDisposed: boolean;
  102125. /**
  102126. * Call this function to reduce memory footprint of the scene.
  102127. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102128. */
  102129. clearCachedVertexData(): void;
  102130. /**
  102131. * This function will remove the local cached buffer data from texture.
  102132. * It will save memory but will prevent the texture from being rebuilt
  102133. */
  102134. cleanCachedTextureBuffer(): void;
  102135. /**
  102136. * Get the world extend vectors with an optional filter
  102137. *
  102138. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102139. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102140. */
  102141. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  102142. min: Vector3;
  102143. max: Vector3;
  102144. };
  102145. /**
  102146. * Creates a ray that can be used to pick in the scene
  102147. * @param x defines the x coordinate of the origin (on-screen)
  102148. * @param y defines the y coordinate of the origin (on-screen)
  102149. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102150. * @param camera defines the camera to use for the picking
  102151. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102152. * @returns a Ray
  102153. */
  102154. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  102155. /**
  102156. * Creates a ray that can be used to pick in the scene
  102157. * @param x defines the x coordinate of the origin (on-screen)
  102158. * @param y defines the y coordinate of the origin (on-screen)
  102159. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102160. * @param result defines the ray where to store the picking ray
  102161. * @param camera defines the camera to use for the picking
  102162. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102163. * @returns the current scene
  102164. */
  102165. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  102166. /**
  102167. * Creates a ray that can be used to pick in the scene
  102168. * @param x defines the x coordinate of the origin (on-screen)
  102169. * @param y defines the y coordinate of the origin (on-screen)
  102170. * @param camera defines the camera to use for the picking
  102171. * @returns a Ray
  102172. */
  102173. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  102174. /**
  102175. * Creates a ray that can be used to pick in the scene
  102176. * @param x defines the x coordinate of the origin (on-screen)
  102177. * @param y defines the y coordinate of the origin (on-screen)
  102178. * @param result defines the ray where to store the picking ray
  102179. * @param camera defines the camera to use for the picking
  102180. * @returns the current scene
  102181. */
  102182. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  102183. /** Launch a ray to try to pick a mesh in the scene
  102184. * @param x position on screen
  102185. * @param y position on screen
  102186. * @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
  102187. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  102188. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102189. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102190. * @returns a PickingInfo
  102191. */
  102192. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102193. /** Use the given ray to pick a mesh in the scene
  102194. * @param ray The ray to use to pick meshes
  102195. * @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
  102196. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  102197. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102198. * @returns a PickingInfo
  102199. */
  102200. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102201. /**
  102202. * Launch a ray to try to pick a mesh in the scene
  102203. * @param x X position on screen
  102204. * @param y Y position on screen
  102205. * @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
  102206. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102207. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102208. * @returns an array of PickingInfo
  102209. */
  102210. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102211. /**
  102212. * Launch a ray to try to pick a mesh in the scene
  102213. * @param ray Ray to use
  102214. * @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
  102215. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102216. * @returns an array of PickingInfo
  102217. */
  102218. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102219. /**
  102220. * Force the value of meshUnderPointer
  102221. * @param mesh defines the mesh to use
  102222. */
  102223. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  102224. /**
  102225. * Gets the mesh under the pointer
  102226. * @returns a Mesh or null if no mesh is under the pointer
  102227. */
  102228. getPointerOverMesh(): Nullable<AbstractMesh>;
  102229. /** @hidden */
  102230. _rebuildGeometries(): void;
  102231. /** @hidden */
  102232. _rebuildTextures(): void;
  102233. private _getByTags;
  102234. /**
  102235. * Get a list of meshes by tags
  102236. * @param tagsQuery defines the tags query to use
  102237. * @param forEach defines a predicate used to filter results
  102238. * @returns an array of Mesh
  102239. */
  102240. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  102241. /**
  102242. * Get a list of cameras by tags
  102243. * @param tagsQuery defines the tags query to use
  102244. * @param forEach defines a predicate used to filter results
  102245. * @returns an array of Camera
  102246. */
  102247. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  102248. /**
  102249. * Get a list of lights by tags
  102250. * @param tagsQuery defines the tags query to use
  102251. * @param forEach defines a predicate used to filter results
  102252. * @returns an array of Light
  102253. */
  102254. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  102255. /**
  102256. * Get a list of materials by tags
  102257. * @param tagsQuery defines the tags query to use
  102258. * @param forEach defines a predicate used to filter results
  102259. * @returns an array of Material
  102260. */
  102261. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  102262. /**
  102263. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102264. * This allowed control for front to back rendering or reversly depending of the special needs.
  102265. *
  102266. * @param renderingGroupId The rendering group id corresponding to its index
  102267. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102268. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102269. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102270. */
  102271. 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;
  102272. /**
  102273. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102274. *
  102275. * @param renderingGroupId The rendering group id corresponding to its index
  102276. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102277. * @param depth Automatically clears depth between groups if true and autoClear is true.
  102278. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  102279. */
  102280. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  102281. /**
  102282. * Gets the current auto clear configuration for one rendering group of the rendering
  102283. * manager.
  102284. * @param index the rendering group index to get the information for
  102285. * @returns The auto clear setup for the requested rendering group
  102286. */
  102287. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  102288. private _blockMaterialDirtyMechanism;
  102289. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  102290. blockMaterialDirtyMechanism: boolean;
  102291. /**
  102292. * Will flag all materials as dirty to trigger new shader compilation
  102293. * @param flag defines the flag used to specify which material part must be marked as dirty
  102294. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  102295. */
  102296. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102297. /** @hidden */
  102298. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  102299. /** @hidden */
  102300. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102301. /** @hidden */
  102302. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  102303. /** @hidden */
  102304. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  102305. /** @hidden */
  102306. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102307. /** @hidden */
  102308. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102309. }
  102310. }
  102311. declare module BABYLON {
  102312. /**
  102313. * Set of assets to keep when moving a scene into an asset container.
  102314. */
  102315. export class KeepAssets extends AbstractScene {
  102316. }
  102317. /**
  102318. * Container with a set of assets that can be added or removed from a scene.
  102319. */
  102320. export class AssetContainer extends AbstractScene {
  102321. /**
  102322. * The scene the AssetContainer belongs to.
  102323. */
  102324. scene: Scene;
  102325. /**
  102326. * Instantiates an AssetContainer.
  102327. * @param scene The scene the AssetContainer belongs to.
  102328. */
  102329. constructor(scene: Scene);
  102330. /**
  102331. * Adds all the assets from the container to the scene.
  102332. */
  102333. addAllToScene(): void;
  102334. /**
  102335. * Removes all the assets in the container from the scene
  102336. */
  102337. removeAllFromScene(): void;
  102338. /**
  102339. * Disposes all the assets in the container
  102340. */
  102341. dispose(): void;
  102342. private _moveAssets;
  102343. /**
  102344. * Removes all the assets contained in the scene and adds them to the container.
  102345. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  102346. */
  102347. moveAllFromScene(keepAssets?: KeepAssets): void;
  102348. /**
  102349. * 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.
  102350. * @returns the root mesh
  102351. */
  102352. createRootMesh(): Mesh;
  102353. }
  102354. }
  102355. declare module BABYLON {
  102356. /**
  102357. * Defines how the parser contract is defined.
  102358. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  102359. */
  102360. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  102361. /**
  102362. * Defines how the individual parser contract is defined.
  102363. * These parser can parse an individual asset
  102364. */
  102365. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  102366. /**
  102367. * Base class of the scene acting as a container for the different elements composing a scene.
  102368. * This class is dynamically extended by the different components of the scene increasing
  102369. * flexibility and reducing coupling
  102370. */
  102371. export abstract class AbstractScene {
  102372. /**
  102373. * Stores the list of available parsers in the application.
  102374. */
  102375. private static _BabylonFileParsers;
  102376. /**
  102377. * Stores the list of available individual parsers in the application.
  102378. */
  102379. private static _IndividualBabylonFileParsers;
  102380. /**
  102381. * Adds a parser in the list of available ones
  102382. * @param name Defines the name of the parser
  102383. * @param parser Defines the parser to add
  102384. */
  102385. static AddParser(name: string, parser: BabylonFileParser): void;
  102386. /**
  102387. * Gets a general parser from the list of avaialble ones
  102388. * @param name Defines the name of the parser
  102389. * @returns the requested parser or null
  102390. */
  102391. static GetParser(name: string): Nullable<BabylonFileParser>;
  102392. /**
  102393. * Adds n individual parser in the list of available ones
  102394. * @param name Defines the name of the parser
  102395. * @param parser Defines the parser to add
  102396. */
  102397. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  102398. /**
  102399. * Gets an individual parser from the list of avaialble ones
  102400. * @param name Defines the name of the parser
  102401. * @returns the requested parser or null
  102402. */
  102403. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  102404. /**
  102405. * Parser json data and populate both a scene and its associated container object
  102406. * @param jsonData Defines the data to parse
  102407. * @param scene Defines the scene to parse the data for
  102408. * @param container Defines the container attached to the parsing sequence
  102409. * @param rootUrl Defines the root url of the data
  102410. */
  102411. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  102412. /**
  102413. * Gets the list of root nodes (ie. nodes with no parent)
  102414. */
  102415. rootNodes: Node[];
  102416. /** All of the cameras added to this scene
  102417. * @see http://doc.babylonjs.com/babylon101/cameras
  102418. */
  102419. cameras: Camera[];
  102420. /**
  102421. * All of the lights added to this scene
  102422. * @see http://doc.babylonjs.com/babylon101/lights
  102423. */
  102424. lights: Light[];
  102425. /**
  102426. * All of the (abstract) meshes added to this scene
  102427. */
  102428. meshes: AbstractMesh[];
  102429. /**
  102430. * The list of skeletons added to the scene
  102431. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102432. */
  102433. skeletons: Skeleton[];
  102434. /**
  102435. * All of the particle systems added to this scene
  102436. * @see http://doc.babylonjs.com/babylon101/particles
  102437. */
  102438. particleSystems: IParticleSystem[];
  102439. /**
  102440. * Gets a list of Animations associated with the scene
  102441. */
  102442. animations: Animation[];
  102443. /**
  102444. * All of the animation groups added to this scene
  102445. * @see http://doc.babylonjs.com/how_to/group
  102446. */
  102447. animationGroups: AnimationGroup[];
  102448. /**
  102449. * All of the multi-materials added to this scene
  102450. * @see http://doc.babylonjs.com/how_to/multi_materials
  102451. */
  102452. multiMaterials: MultiMaterial[];
  102453. /**
  102454. * All of the materials added to this scene
  102455. * In the context of a Scene, it is not supposed to be modified manually.
  102456. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  102457. * Note also that the order of the Material wihin the array is not significant and might change.
  102458. * @see http://doc.babylonjs.com/babylon101/materials
  102459. */
  102460. materials: Material[];
  102461. /**
  102462. * The list of morph target managers added to the scene
  102463. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  102464. */
  102465. morphTargetManagers: MorphTargetManager[];
  102466. /**
  102467. * The list of geometries used in the scene.
  102468. */
  102469. geometries: Geometry[];
  102470. /**
  102471. * All of the tranform nodes added to this scene
  102472. * In the context of a Scene, it is not supposed to be modified manually.
  102473. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  102474. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  102475. * @see http://doc.babylonjs.com/how_to/transformnode
  102476. */
  102477. transformNodes: TransformNode[];
  102478. /**
  102479. * ActionManagers available on the scene.
  102480. */
  102481. actionManagers: AbstractActionManager[];
  102482. /**
  102483. * Textures to keep.
  102484. */
  102485. textures: BaseTexture[];
  102486. /**
  102487. * Environment texture for the scene
  102488. */
  102489. environmentTexture: Nullable<BaseTexture>;
  102490. }
  102491. }
  102492. declare module BABYLON {
  102493. /**
  102494. * Interface used to define options for Sound class
  102495. */
  102496. export interface ISoundOptions {
  102497. /**
  102498. * Does the sound autoplay once loaded.
  102499. */
  102500. autoplay?: boolean;
  102501. /**
  102502. * Does the sound loop after it finishes playing once.
  102503. */
  102504. loop?: boolean;
  102505. /**
  102506. * Sound's volume
  102507. */
  102508. volume?: number;
  102509. /**
  102510. * Is it a spatial sound?
  102511. */
  102512. spatialSound?: boolean;
  102513. /**
  102514. * Maximum distance to hear that sound
  102515. */
  102516. maxDistance?: number;
  102517. /**
  102518. * Uses user defined attenuation function
  102519. */
  102520. useCustomAttenuation?: boolean;
  102521. /**
  102522. * Define the roll off factor of spatial sounds.
  102523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102524. */
  102525. rolloffFactor?: number;
  102526. /**
  102527. * Define the reference distance the sound should be heard perfectly.
  102528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102529. */
  102530. refDistance?: number;
  102531. /**
  102532. * Define the distance attenuation model the sound will follow.
  102533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102534. */
  102535. distanceModel?: string;
  102536. /**
  102537. * Defines the playback speed (1 by default)
  102538. */
  102539. playbackRate?: number;
  102540. /**
  102541. * Defines if the sound is from a streaming source
  102542. */
  102543. streaming?: boolean;
  102544. /**
  102545. * Defines an optional length (in seconds) inside the sound file
  102546. */
  102547. length?: number;
  102548. /**
  102549. * Defines an optional offset (in seconds) inside the sound file
  102550. */
  102551. offset?: number;
  102552. /**
  102553. * If true, URLs will not be required to state the audio file codec to use.
  102554. */
  102555. skipCodecCheck?: boolean;
  102556. }
  102557. /**
  102558. * Defines a sound that can be played in the application.
  102559. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  102560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102561. */
  102562. export class Sound {
  102563. /**
  102564. * The name of the sound in the scene.
  102565. */
  102566. name: string;
  102567. /**
  102568. * Does the sound autoplay once loaded.
  102569. */
  102570. autoplay: boolean;
  102571. /**
  102572. * Does the sound loop after it finishes playing once.
  102573. */
  102574. loop: boolean;
  102575. /**
  102576. * Does the sound use a custom attenuation curve to simulate the falloff
  102577. * happening when the source gets further away from the camera.
  102578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102579. */
  102580. useCustomAttenuation: boolean;
  102581. /**
  102582. * The sound track id this sound belongs to.
  102583. */
  102584. soundTrackId: number;
  102585. /**
  102586. * Is this sound currently played.
  102587. */
  102588. isPlaying: boolean;
  102589. /**
  102590. * Is this sound currently paused.
  102591. */
  102592. isPaused: boolean;
  102593. /**
  102594. * Does this sound enables spatial sound.
  102595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102596. */
  102597. spatialSound: boolean;
  102598. /**
  102599. * Define the reference distance the sound should be heard perfectly.
  102600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102601. */
  102602. refDistance: number;
  102603. /**
  102604. * Define the roll off factor of spatial sounds.
  102605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102606. */
  102607. rolloffFactor: number;
  102608. /**
  102609. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  102610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102611. */
  102612. maxDistance: number;
  102613. /**
  102614. * Define the distance attenuation model the sound will follow.
  102615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102616. */
  102617. distanceModel: string;
  102618. /**
  102619. * @hidden
  102620. * Back Compat
  102621. **/
  102622. onended: () => any;
  102623. /**
  102624. * Observable event when the current playing sound finishes.
  102625. */
  102626. onEndedObservable: Observable<Sound>;
  102627. private _panningModel;
  102628. private _playbackRate;
  102629. private _streaming;
  102630. private _startTime;
  102631. private _startOffset;
  102632. private _position;
  102633. /** @hidden */
  102634. _positionInEmitterSpace: boolean;
  102635. private _localDirection;
  102636. private _volume;
  102637. private _isReadyToPlay;
  102638. private _isDirectional;
  102639. private _readyToPlayCallback;
  102640. private _audioBuffer;
  102641. private _soundSource;
  102642. private _streamingSource;
  102643. private _soundPanner;
  102644. private _soundGain;
  102645. private _inputAudioNode;
  102646. private _outputAudioNode;
  102647. private _coneInnerAngle;
  102648. private _coneOuterAngle;
  102649. private _coneOuterGain;
  102650. private _scene;
  102651. private _connectedTransformNode;
  102652. private _customAttenuationFunction;
  102653. private _registerFunc;
  102654. private _isOutputConnected;
  102655. private _htmlAudioElement;
  102656. private _urlType;
  102657. private _length?;
  102658. private _offset?;
  102659. /** @hidden */
  102660. static _SceneComponentInitialization: (scene: Scene) => void;
  102661. /**
  102662. * Create a sound and attach it to a scene
  102663. * @param name Name of your sound
  102664. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  102665. * @param scene defines the scene the sound belongs to
  102666. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  102667. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  102668. */
  102669. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  102670. /**
  102671. * Release the sound and its associated resources
  102672. */
  102673. dispose(): void;
  102674. /**
  102675. * Gets if the sounds is ready to be played or not.
  102676. * @returns true if ready, otherwise false
  102677. */
  102678. isReady(): boolean;
  102679. private _soundLoaded;
  102680. /**
  102681. * Sets the data of the sound from an audiobuffer
  102682. * @param audioBuffer The audioBuffer containing the data
  102683. */
  102684. setAudioBuffer(audioBuffer: AudioBuffer): void;
  102685. /**
  102686. * Updates the current sounds options such as maxdistance, loop...
  102687. * @param options A JSON object containing values named as the object properties
  102688. */
  102689. updateOptions(options: ISoundOptions): void;
  102690. private _createSpatialParameters;
  102691. private _updateSpatialParameters;
  102692. /**
  102693. * Switch the panning model to HRTF:
  102694. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102696. */
  102697. switchPanningModelToHRTF(): void;
  102698. /**
  102699. * Switch the panning model to Equal Power:
  102700. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102702. */
  102703. switchPanningModelToEqualPower(): void;
  102704. private _switchPanningModel;
  102705. /**
  102706. * Connect this sound to a sound track audio node like gain...
  102707. * @param soundTrackAudioNode the sound track audio node to connect to
  102708. */
  102709. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  102710. /**
  102711. * Transform this sound into a directional source
  102712. * @param coneInnerAngle Size of the inner cone in degree
  102713. * @param coneOuterAngle Size of the outer cone in degree
  102714. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  102715. */
  102716. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  102717. /**
  102718. * Gets or sets the inner angle for the directional cone.
  102719. */
  102720. /**
  102721. * Gets or sets the inner angle for the directional cone.
  102722. */
  102723. directionalConeInnerAngle: number;
  102724. /**
  102725. * Gets or sets the outer angle for the directional cone.
  102726. */
  102727. /**
  102728. * Gets or sets the outer angle for the directional cone.
  102729. */
  102730. directionalConeOuterAngle: number;
  102731. /**
  102732. * Sets the position of the emitter if spatial sound is enabled
  102733. * @param newPosition Defines the new posisiton
  102734. */
  102735. setPosition(newPosition: Vector3): void;
  102736. /**
  102737. * Sets the local direction of the emitter if spatial sound is enabled
  102738. * @param newLocalDirection Defines the new local direction
  102739. */
  102740. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102741. private _updateDirection;
  102742. /** @hidden */
  102743. updateDistanceFromListener(): void;
  102744. /**
  102745. * Sets a new custom attenuation function for the sound.
  102746. * @param callback Defines the function used for the attenuation
  102747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102748. */
  102749. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102750. /**
  102751. * Play the sound
  102752. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102753. * @param offset (optional) Start the sound at a specific time in seconds
  102754. * @param length (optional) Sound duration (in seconds)
  102755. */
  102756. play(time?: number, offset?: number, length?: number): void;
  102757. private _onended;
  102758. /**
  102759. * Stop the sound
  102760. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102761. */
  102762. stop(time?: number): void;
  102763. /**
  102764. * Put the sound in pause
  102765. */
  102766. pause(): void;
  102767. /**
  102768. * Sets a dedicated volume for this sounds
  102769. * @param newVolume Define the new volume of the sound
  102770. * @param time Define time for gradual change to new volume
  102771. */
  102772. setVolume(newVolume: number, time?: number): void;
  102773. /**
  102774. * Set the sound play back rate
  102775. * @param newPlaybackRate Define the playback rate the sound should be played at
  102776. */
  102777. setPlaybackRate(newPlaybackRate: number): void;
  102778. /**
  102779. * Gets the volume of the sound.
  102780. * @returns the volume of the sound
  102781. */
  102782. getVolume(): number;
  102783. /**
  102784. * Attach the sound to a dedicated mesh
  102785. * @param transformNode The transform node to connect the sound with
  102786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102787. */
  102788. attachToMesh(transformNode: TransformNode): void;
  102789. /**
  102790. * Detach the sound from the previously attached mesh
  102791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102792. */
  102793. detachFromMesh(): void;
  102794. private _onRegisterAfterWorldMatrixUpdate;
  102795. /**
  102796. * Clone the current sound in the scene.
  102797. * @returns the new sound clone
  102798. */
  102799. clone(): Nullable<Sound>;
  102800. /**
  102801. * Gets the current underlying audio buffer containing the data
  102802. * @returns the audio buffer
  102803. */
  102804. getAudioBuffer(): Nullable<AudioBuffer>;
  102805. /**
  102806. * Serializes the Sound in a JSON representation
  102807. * @returns the JSON representation of the sound
  102808. */
  102809. serialize(): any;
  102810. /**
  102811. * Parse a JSON representation of a sound to innstantiate in a given scene
  102812. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102813. * @param scene Define the scene the new parsed sound should be created in
  102814. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102815. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102816. * @returns the newly parsed sound
  102817. */
  102818. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102819. }
  102820. }
  102821. declare module BABYLON {
  102822. /**
  102823. * This defines an action helpful to play a defined sound on a triggered action.
  102824. */
  102825. export class PlaySoundAction extends Action {
  102826. private _sound;
  102827. /**
  102828. * Instantiate the action
  102829. * @param triggerOptions defines the trigger options
  102830. * @param sound defines the sound to play
  102831. * @param condition defines the trigger related conditions
  102832. */
  102833. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102834. /** @hidden */
  102835. _prepare(): void;
  102836. /**
  102837. * Execute the action and play the sound.
  102838. */
  102839. execute(): void;
  102840. /**
  102841. * Serializes the actions and its related information.
  102842. * @param parent defines the object to serialize in
  102843. * @returns the serialized object
  102844. */
  102845. serialize(parent: any): any;
  102846. }
  102847. /**
  102848. * This defines an action helpful to stop a defined sound on a triggered action.
  102849. */
  102850. export class StopSoundAction extends Action {
  102851. private _sound;
  102852. /**
  102853. * Instantiate the action
  102854. * @param triggerOptions defines the trigger options
  102855. * @param sound defines the sound to stop
  102856. * @param condition defines the trigger related conditions
  102857. */
  102858. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102859. /** @hidden */
  102860. _prepare(): void;
  102861. /**
  102862. * Execute the action and stop the sound.
  102863. */
  102864. execute(): void;
  102865. /**
  102866. * Serializes the actions and its related information.
  102867. * @param parent defines the object to serialize in
  102868. * @returns the serialized object
  102869. */
  102870. serialize(parent: any): any;
  102871. }
  102872. }
  102873. declare module BABYLON {
  102874. /**
  102875. * This defines an action responsible to change the value of a property
  102876. * by interpolating between its current value and the newly set one once triggered.
  102877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102878. */
  102879. export class InterpolateValueAction extends Action {
  102880. /**
  102881. * Defines the path of the property where the value should be interpolated
  102882. */
  102883. propertyPath: string;
  102884. /**
  102885. * Defines the target value at the end of the interpolation.
  102886. */
  102887. value: any;
  102888. /**
  102889. * Defines the time it will take for the property to interpolate to the value.
  102890. */
  102891. duration: number;
  102892. /**
  102893. * Defines if the other scene animations should be stopped when the action has been triggered
  102894. */
  102895. stopOtherAnimations?: boolean;
  102896. /**
  102897. * Defines a callback raised once the interpolation animation has been done.
  102898. */
  102899. onInterpolationDone?: () => void;
  102900. /**
  102901. * Observable triggered once the interpolation animation has been done.
  102902. */
  102903. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102904. private _target;
  102905. private _effectiveTarget;
  102906. private _property;
  102907. /**
  102908. * Instantiate the action
  102909. * @param triggerOptions defines the trigger options
  102910. * @param target defines the object containing the value to interpolate
  102911. * @param propertyPath defines the path to the property in the target object
  102912. * @param value defines the target value at the end of the interpolation
  102913. * @param duration deines the time it will take for the property to interpolate to the value.
  102914. * @param condition defines the trigger related conditions
  102915. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102916. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102917. */
  102918. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102919. /** @hidden */
  102920. _prepare(): void;
  102921. /**
  102922. * Execute the action starts the value interpolation.
  102923. */
  102924. execute(): void;
  102925. /**
  102926. * Serializes the actions and its related information.
  102927. * @param parent defines the object to serialize in
  102928. * @returns the serialized object
  102929. */
  102930. serialize(parent: any): any;
  102931. }
  102932. }
  102933. declare module BABYLON {
  102934. /**
  102935. * Options allowed during the creation of a sound track.
  102936. */
  102937. export interface ISoundTrackOptions {
  102938. /**
  102939. * The volume the sound track should take during creation
  102940. */
  102941. volume?: number;
  102942. /**
  102943. * Define if the sound track is the main sound track of the scene
  102944. */
  102945. mainTrack?: boolean;
  102946. }
  102947. /**
  102948. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102949. * It will be also used in a future release to apply effects on a specific track.
  102950. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102951. */
  102952. export class SoundTrack {
  102953. /**
  102954. * The unique identifier of the sound track in the scene.
  102955. */
  102956. id: number;
  102957. /**
  102958. * The list of sounds included in the sound track.
  102959. */
  102960. soundCollection: Array<Sound>;
  102961. private _outputAudioNode;
  102962. private _scene;
  102963. private _isMainTrack;
  102964. private _connectedAnalyser;
  102965. private _options;
  102966. private _isInitialized;
  102967. /**
  102968. * Creates a new sound track.
  102969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102970. * @param scene Define the scene the sound track belongs to
  102971. * @param options
  102972. */
  102973. constructor(scene: Scene, options?: ISoundTrackOptions);
  102974. private _initializeSoundTrackAudioGraph;
  102975. /**
  102976. * Release the sound track and its associated resources
  102977. */
  102978. dispose(): void;
  102979. /**
  102980. * Adds a sound to this sound track
  102981. * @param sound define the cound to add
  102982. * @ignoreNaming
  102983. */
  102984. AddSound(sound: Sound): void;
  102985. /**
  102986. * Removes a sound to this sound track
  102987. * @param sound define the cound to remove
  102988. * @ignoreNaming
  102989. */
  102990. RemoveSound(sound: Sound): void;
  102991. /**
  102992. * Set a global volume for the full sound track.
  102993. * @param newVolume Define the new volume of the sound track
  102994. */
  102995. setVolume(newVolume: number): void;
  102996. /**
  102997. * Switch the panning model to HRTF:
  102998. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103000. */
  103001. switchPanningModelToHRTF(): void;
  103002. /**
  103003. * Switch the panning model to Equal Power:
  103004. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103006. */
  103007. switchPanningModelToEqualPower(): void;
  103008. /**
  103009. * Connect the sound track to an audio analyser allowing some amazing
  103010. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103012. * @param analyser The analyser to connect to the engine
  103013. */
  103014. connectToAnalyser(analyser: Analyser): void;
  103015. }
  103016. }
  103017. declare module BABYLON {
  103018. interface AbstractScene {
  103019. /**
  103020. * The list of sounds used in the scene.
  103021. */
  103022. sounds: Nullable<Array<Sound>>;
  103023. }
  103024. interface Scene {
  103025. /**
  103026. * @hidden
  103027. * Backing field
  103028. */
  103029. _mainSoundTrack: SoundTrack;
  103030. /**
  103031. * The main sound track played by the scene.
  103032. * It cotains your primary collection of sounds.
  103033. */
  103034. mainSoundTrack: SoundTrack;
  103035. /**
  103036. * The list of sound tracks added to the scene
  103037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103038. */
  103039. soundTracks: Nullable<Array<SoundTrack>>;
  103040. /**
  103041. * Gets a sound using a given name
  103042. * @param name defines the name to search for
  103043. * @return the found sound or null if not found at all.
  103044. */
  103045. getSoundByName(name: string): Nullable<Sound>;
  103046. /**
  103047. * Gets or sets if audio support is enabled
  103048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103049. */
  103050. audioEnabled: boolean;
  103051. /**
  103052. * Gets or sets if audio will be output to headphones
  103053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103054. */
  103055. headphone: boolean;
  103056. /**
  103057. * Gets or sets custom audio listener position provider
  103058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103059. */
  103060. audioListenerPositionProvider: Nullable<() => Vector3>;
  103061. }
  103062. /**
  103063. * Defines the sound scene component responsible to manage any sounds
  103064. * in a given scene.
  103065. */
  103066. export class AudioSceneComponent implements ISceneSerializableComponent {
  103067. /**
  103068. * The component name helpfull to identify the component in the list of scene components.
  103069. */
  103070. readonly name: string;
  103071. /**
  103072. * The scene the component belongs to.
  103073. */
  103074. scene: Scene;
  103075. private _audioEnabled;
  103076. /**
  103077. * Gets whether audio is enabled or not.
  103078. * Please use related enable/disable method to switch state.
  103079. */
  103080. readonly audioEnabled: boolean;
  103081. private _headphone;
  103082. /**
  103083. * Gets whether audio is outputing to headphone or not.
  103084. * Please use the according Switch methods to change output.
  103085. */
  103086. readonly headphone: boolean;
  103087. private _audioListenerPositionProvider;
  103088. /**
  103089. * Gets the current audio listener position provider
  103090. */
  103091. /**
  103092. * Sets a custom listener position for all sounds in the scene
  103093. * By default, this is the position of the first active camera
  103094. */
  103095. audioListenerPositionProvider: Nullable<() => Vector3>;
  103096. /**
  103097. * Creates a new instance of the component for the given scene
  103098. * @param scene Defines the scene to register the component in
  103099. */
  103100. constructor(scene: Scene);
  103101. /**
  103102. * Registers the component in a given scene
  103103. */
  103104. register(): void;
  103105. /**
  103106. * Rebuilds the elements related to this component in case of
  103107. * context lost for instance.
  103108. */
  103109. rebuild(): void;
  103110. /**
  103111. * Serializes the component data to the specified json object
  103112. * @param serializationObject The object to serialize to
  103113. */
  103114. serialize(serializationObject: any): void;
  103115. /**
  103116. * Adds all the elements from the container to the scene
  103117. * @param container the container holding the elements
  103118. */
  103119. addFromContainer(container: AbstractScene): void;
  103120. /**
  103121. * Removes all the elements in the container from the scene
  103122. * @param container contains the elements to remove
  103123. * @param dispose if the removed element should be disposed (default: false)
  103124. */
  103125. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  103126. /**
  103127. * Disposes the component and the associated ressources.
  103128. */
  103129. dispose(): void;
  103130. /**
  103131. * Disables audio in the associated scene.
  103132. */
  103133. disableAudio(): void;
  103134. /**
  103135. * Enables audio in the associated scene.
  103136. */
  103137. enableAudio(): void;
  103138. /**
  103139. * Switch audio to headphone output.
  103140. */
  103141. switchAudioModeForHeadphones(): void;
  103142. /**
  103143. * Switch audio to normal speakers.
  103144. */
  103145. switchAudioModeForNormalSpeakers(): void;
  103146. private _afterRender;
  103147. }
  103148. }
  103149. declare module BABYLON {
  103150. /**
  103151. * Wraps one or more Sound objects and selects one with random weight for playback.
  103152. */
  103153. export class WeightedSound {
  103154. /** When true a Sound will be selected and played when the current playing Sound completes. */
  103155. loop: boolean;
  103156. private _coneInnerAngle;
  103157. private _coneOuterAngle;
  103158. private _volume;
  103159. /** A Sound is currently playing. */
  103160. isPlaying: boolean;
  103161. /** A Sound is currently paused. */
  103162. isPaused: boolean;
  103163. private _sounds;
  103164. private _weights;
  103165. private _currentIndex?;
  103166. /**
  103167. * Creates a new WeightedSound from the list of sounds given.
  103168. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  103169. * @param sounds Array of Sounds that will be selected from.
  103170. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  103171. */
  103172. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  103173. /**
  103174. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  103175. */
  103176. /**
  103177. * The size of cone in degress for a directional sound in which there will be no attenuation.
  103178. */
  103179. directionalConeInnerAngle: number;
  103180. /**
  103181. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103182. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103183. */
  103184. /**
  103185. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103186. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103187. */
  103188. directionalConeOuterAngle: number;
  103189. /**
  103190. * Playback volume.
  103191. */
  103192. /**
  103193. * Playback volume.
  103194. */
  103195. volume: number;
  103196. private _onended;
  103197. /**
  103198. * Suspend playback
  103199. */
  103200. pause(): void;
  103201. /**
  103202. * Stop playback
  103203. */
  103204. stop(): void;
  103205. /**
  103206. * Start playback.
  103207. * @param startOffset Position the clip head at a specific time in seconds.
  103208. */
  103209. play(startOffset?: number): void;
  103210. }
  103211. }
  103212. declare module BABYLON {
  103213. /**
  103214. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  103215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103216. */
  103217. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  103218. /**
  103219. * Gets the name of the behavior.
  103220. */
  103221. readonly name: string;
  103222. /**
  103223. * The easing function used by animations
  103224. */
  103225. static EasingFunction: BackEase;
  103226. /**
  103227. * The easing mode used by animations
  103228. */
  103229. static EasingMode: number;
  103230. /**
  103231. * The duration of the animation, in milliseconds
  103232. */
  103233. transitionDuration: number;
  103234. /**
  103235. * Length of the distance animated by the transition when lower radius is reached
  103236. */
  103237. lowerRadiusTransitionRange: number;
  103238. /**
  103239. * Length of the distance animated by the transition when upper radius is reached
  103240. */
  103241. upperRadiusTransitionRange: number;
  103242. private _autoTransitionRange;
  103243. /**
  103244. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103245. */
  103246. /**
  103247. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103248. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  103249. */
  103250. autoTransitionRange: boolean;
  103251. private _attachedCamera;
  103252. private _onAfterCheckInputsObserver;
  103253. private _onMeshTargetChangedObserver;
  103254. /**
  103255. * Initializes the behavior.
  103256. */
  103257. init(): void;
  103258. /**
  103259. * Attaches the behavior to its arc rotate camera.
  103260. * @param camera Defines the camera to attach the behavior to
  103261. */
  103262. attach(camera: ArcRotateCamera): void;
  103263. /**
  103264. * Detaches the behavior from its current arc rotate camera.
  103265. */
  103266. detach(): void;
  103267. private _radiusIsAnimating;
  103268. private _radiusBounceTransition;
  103269. private _animatables;
  103270. private _cachedWheelPrecision;
  103271. /**
  103272. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  103273. * @param radiusLimit The limit to check against.
  103274. * @return Bool to indicate if at limit.
  103275. */
  103276. private _isRadiusAtLimit;
  103277. /**
  103278. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  103279. * @param radiusDelta The delta by which to animate to. Can be negative.
  103280. */
  103281. private _applyBoundRadiusAnimation;
  103282. /**
  103283. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  103284. */
  103285. protected _clearAnimationLocks(): void;
  103286. /**
  103287. * Stops and removes all animations that have been applied to the camera
  103288. */
  103289. stopAllAnimations(): void;
  103290. }
  103291. }
  103292. declare module BABYLON {
  103293. /**
  103294. * 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.
  103295. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103296. */
  103297. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  103298. /**
  103299. * Gets the name of the behavior.
  103300. */
  103301. readonly name: string;
  103302. private _mode;
  103303. private _radiusScale;
  103304. private _positionScale;
  103305. private _defaultElevation;
  103306. private _elevationReturnTime;
  103307. private _elevationReturnWaitTime;
  103308. private _zoomStopsAnimation;
  103309. private _framingTime;
  103310. /**
  103311. * The easing function used by animations
  103312. */
  103313. static EasingFunction: ExponentialEase;
  103314. /**
  103315. * The easing mode used by animations
  103316. */
  103317. static EasingMode: number;
  103318. /**
  103319. * Sets the current mode used by the behavior
  103320. */
  103321. /**
  103322. * Gets current mode used by the behavior.
  103323. */
  103324. mode: number;
  103325. /**
  103326. * Sets the scale applied to the radius (1 by default)
  103327. */
  103328. /**
  103329. * Gets the scale applied to the radius
  103330. */
  103331. radiusScale: number;
  103332. /**
  103333. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103334. */
  103335. /**
  103336. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103337. */
  103338. positionScale: number;
  103339. /**
  103340. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103341. * behaviour is triggered, in radians.
  103342. */
  103343. /**
  103344. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103345. * behaviour is triggered, in radians.
  103346. */
  103347. defaultElevation: number;
  103348. /**
  103349. * Sets the time (in milliseconds) taken to return to the default beta position.
  103350. * Negative value indicates camera should not return to default.
  103351. */
  103352. /**
  103353. * Gets the time (in milliseconds) taken to return to the default beta position.
  103354. * Negative value indicates camera should not return to default.
  103355. */
  103356. elevationReturnTime: number;
  103357. /**
  103358. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103359. */
  103360. /**
  103361. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103362. */
  103363. elevationReturnWaitTime: number;
  103364. /**
  103365. * Sets the flag that indicates if user zooming should stop animation.
  103366. */
  103367. /**
  103368. * Gets the flag that indicates if user zooming should stop animation.
  103369. */
  103370. zoomStopsAnimation: boolean;
  103371. /**
  103372. * Sets the transition time when framing the mesh, in milliseconds
  103373. */
  103374. /**
  103375. * Gets the transition time when framing the mesh, in milliseconds
  103376. */
  103377. framingTime: number;
  103378. /**
  103379. * Define if the behavior should automatically change the configured
  103380. * camera limits and sensibilities.
  103381. */
  103382. autoCorrectCameraLimitsAndSensibility: boolean;
  103383. private _onPrePointerObservableObserver;
  103384. private _onAfterCheckInputsObserver;
  103385. private _onMeshTargetChangedObserver;
  103386. private _attachedCamera;
  103387. private _isPointerDown;
  103388. private _lastInteractionTime;
  103389. /**
  103390. * Initializes the behavior.
  103391. */
  103392. init(): void;
  103393. /**
  103394. * Attaches the behavior to its arc rotate camera.
  103395. * @param camera Defines the camera to attach the behavior to
  103396. */
  103397. attach(camera: ArcRotateCamera): void;
  103398. /**
  103399. * Detaches the behavior from its current arc rotate camera.
  103400. */
  103401. detach(): void;
  103402. private _animatables;
  103403. private _betaIsAnimating;
  103404. private _betaTransition;
  103405. private _radiusTransition;
  103406. private _vectorTransition;
  103407. /**
  103408. * Targets the given mesh and updates zoom level accordingly.
  103409. * @param mesh The mesh to target.
  103410. * @param radius Optional. If a cached radius position already exists, overrides default.
  103411. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103412. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103413. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103414. */
  103415. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103416. /**
  103417. * Targets the given mesh with its children and updates zoom level accordingly.
  103418. * @param mesh The mesh to target.
  103419. * @param radius Optional. If a cached radius position already exists, overrides default.
  103420. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103421. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103422. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103423. */
  103424. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103425. /**
  103426. * Targets the given meshes with their children and updates zoom level accordingly.
  103427. * @param meshes The mesh to target.
  103428. * @param radius Optional. If a cached radius position already exists, overrides default.
  103429. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103430. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103431. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103432. */
  103433. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103434. /**
  103435. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  103436. * @param minimumWorld Determines the smaller position of the bounding box extend
  103437. * @param maximumWorld Determines the bigger position of the bounding box extend
  103438. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103439. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103440. */
  103441. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103442. /**
  103443. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  103444. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  103445. * frustum width.
  103446. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  103447. * to fully enclose the mesh in the viewing frustum.
  103448. */
  103449. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  103450. /**
  103451. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  103452. * is automatically returned to its default position (expected to be above ground plane).
  103453. */
  103454. private _maintainCameraAboveGround;
  103455. /**
  103456. * Returns the frustum slope based on the canvas ratio and camera FOV
  103457. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  103458. */
  103459. private _getFrustumSlope;
  103460. /**
  103461. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  103462. */
  103463. private _clearAnimationLocks;
  103464. /**
  103465. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103466. */
  103467. private _applyUserInteraction;
  103468. /**
  103469. * Stops and removes all animations that have been applied to the camera
  103470. */
  103471. stopAllAnimations(): void;
  103472. /**
  103473. * Gets a value indicating if the user is moving the camera
  103474. */
  103475. readonly isUserIsMoving: boolean;
  103476. /**
  103477. * The camera can move all the way towards the mesh.
  103478. */
  103479. static IgnoreBoundsSizeMode: number;
  103480. /**
  103481. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  103482. */
  103483. static FitFrustumSidesMode: number;
  103484. }
  103485. }
  103486. declare module BABYLON {
  103487. /**
  103488. * Base class for Camera Pointer Inputs.
  103489. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  103490. * for example usage.
  103491. */
  103492. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  103493. /**
  103494. * Defines the camera the input is attached to.
  103495. */
  103496. abstract camera: Camera;
  103497. /**
  103498. * Whether keyboard modifier keys are pressed at time of last mouse event.
  103499. */
  103500. protected _altKey: boolean;
  103501. protected _ctrlKey: boolean;
  103502. protected _metaKey: boolean;
  103503. protected _shiftKey: boolean;
  103504. /**
  103505. * Which mouse buttons were pressed at time of last mouse event.
  103506. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  103507. */
  103508. protected _buttonsPressed: number;
  103509. /**
  103510. * Defines the buttons associated with the input to handle camera move.
  103511. */
  103512. buttons: number[];
  103513. /**
  103514. * Attach the input controls to a specific dom element to get the input from.
  103515. * @param element Defines the element the controls should be listened from
  103516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103517. */
  103518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103519. /**
  103520. * Detach the current controls from the specified dom element.
  103521. * @param element Defines the element to stop listening the inputs from
  103522. */
  103523. detachControl(element: Nullable<HTMLElement>): void;
  103524. /**
  103525. * Gets the class name of the current input.
  103526. * @returns the class name
  103527. */
  103528. getClassName(): string;
  103529. /**
  103530. * Get the friendly name associated with the input class.
  103531. * @returns the input friendly name
  103532. */
  103533. getSimpleName(): string;
  103534. /**
  103535. * Called on pointer POINTERDOUBLETAP event.
  103536. * Override this method to provide functionality on POINTERDOUBLETAP event.
  103537. */
  103538. protected onDoubleTap(type: string): void;
  103539. /**
  103540. * Called on pointer POINTERMOVE event if only a single touch is active.
  103541. * Override this method to provide functionality.
  103542. */
  103543. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103544. /**
  103545. * Called on pointer POINTERMOVE event if multiple touches are active.
  103546. * Override this method to provide functionality.
  103547. */
  103548. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103549. /**
  103550. * Called on JS contextmenu event.
  103551. * Override this method to provide functionality.
  103552. */
  103553. protected onContextMenu(evt: PointerEvent): void;
  103554. /**
  103555. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103556. * press.
  103557. * Override this method to provide functionality.
  103558. */
  103559. protected onButtonDown(evt: PointerEvent): void;
  103560. /**
  103561. * Called each time a new POINTERUP event occurs. Ie, for each button
  103562. * release.
  103563. * Override this method to provide functionality.
  103564. */
  103565. protected onButtonUp(evt: PointerEvent): void;
  103566. /**
  103567. * Called when window becomes inactive.
  103568. * Override this method to provide functionality.
  103569. */
  103570. protected onLostFocus(): void;
  103571. private _pointerInput;
  103572. private _observer;
  103573. private _onLostFocus;
  103574. private pointA;
  103575. private pointB;
  103576. }
  103577. }
  103578. declare module BABYLON {
  103579. /**
  103580. * Manage the pointers inputs to control an arc rotate camera.
  103581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103582. */
  103583. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  103584. /**
  103585. * Defines the camera the input is attached to.
  103586. */
  103587. camera: ArcRotateCamera;
  103588. /**
  103589. * Gets the class name of the current input.
  103590. * @returns the class name
  103591. */
  103592. getClassName(): string;
  103593. /**
  103594. * Defines the buttons associated with the input to handle camera move.
  103595. */
  103596. buttons: number[];
  103597. /**
  103598. * Defines the pointer angular sensibility along the X axis or how fast is
  103599. * the camera rotating.
  103600. */
  103601. angularSensibilityX: number;
  103602. /**
  103603. * Defines the pointer angular sensibility along the Y axis or how fast is
  103604. * the camera rotating.
  103605. */
  103606. angularSensibilityY: number;
  103607. /**
  103608. * Defines the pointer pinch precision or how fast is the camera zooming.
  103609. */
  103610. pinchPrecision: number;
  103611. /**
  103612. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103613. * from 0.
  103614. * It defines the percentage of current camera.radius to use as delta when
  103615. * pinch zoom is used.
  103616. */
  103617. pinchDeltaPercentage: number;
  103618. /**
  103619. * Defines the pointer panning sensibility or how fast is the camera moving.
  103620. */
  103621. panningSensibility: number;
  103622. /**
  103623. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  103624. */
  103625. multiTouchPanning: boolean;
  103626. /**
  103627. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  103628. * zoom (pinch) through multitouch.
  103629. */
  103630. multiTouchPanAndZoom: boolean;
  103631. /**
  103632. * Revers pinch action direction.
  103633. */
  103634. pinchInwards: boolean;
  103635. private _isPanClick;
  103636. private _twoFingerActivityCount;
  103637. private _isPinching;
  103638. /**
  103639. * Called on pointer POINTERMOVE event if only a single touch is active.
  103640. */
  103641. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103642. /**
  103643. * Called on pointer POINTERDOUBLETAP event.
  103644. */
  103645. protected onDoubleTap(type: string): void;
  103646. /**
  103647. * Called on pointer POINTERMOVE event if multiple touches are active.
  103648. */
  103649. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103650. /**
  103651. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103652. * press.
  103653. */
  103654. protected onButtonDown(evt: PointerEvent): void;
  103655. /**
  103656. * Called each time a new POINTERUP event occurs. Ie, for each button
  103657. * release.
  103658. */
  103659. protected onButtonUp(evt: PointerEvent): void;
  103660. /**
  103661. * Called when window becomes inactive.
  103662. */
  103663. protected onLostFocus(): void;
  103664. }
  103665. }
  103666. declare module BABYLON {
  103667. /**
  103668. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  103669. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103670. */
  103671. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  103672. /**
  103673. * Defines the camera the input is attached to.
  103674. */
  103675. camera: ArcRotateCamera;
  103676. /**
  103677. * Defines the list of key codes associated with the up action (increase alpha)
  103678. */
  103679. keysUp: number[];
  103680. /**
  103681. * Defines the list of key codes associated with the down action (decrease alpha)
  103682. */
  103683. keysDown: number[];
  103684. /**
  103685. * Defines the list of key codes associated with the left action (increase beta)
  103686. */
  103687. keysLeft: number[];
  103688. /**
  103689. * Defines the list of key codes associated with the right action (decrease beta)
  103690. */
  103691. keysRight: number[];
  103692. /**
  103693. * Defines the list of key codes associated with the reset action.
  103694. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  103695. */
  103696. keysReset: number[];
  103697. /**
  103698. * Defines the panning sensibility of the inputs.
  103699. * (How fast is the camera paning)
  103700. */
  103701. panningSensibility: number;
  103702. /**
  103703. * Defines the zooming sensibility of the inputs.
  103704. * (How fast is the camera zooming)
  103705. */
  103706. zoomingSensibility: number;
  103707. /**
  103708. * Defines wether maintaining the alt key down switch the movement mode from
  103709. * orientation to zoom.
  103710. */
  103711. useAltToZoom: boolean;
  103712. /**
  103713. * Rotation speed of the camera
  103714. */
  103715. angularSpeed: number;
  103716. private _keys;
  103717. private _ctrlPressed;
  103718. private _altPressed;
  103719. private _onCanvasBlurObserver;
  103720. private _onKeyboardObserver;
  103721. private _engine;
  103722. private _scene;
  103723. /**
  103724. * Attach the input controls to a specific dom element to get the input from.
  103725. * @param element Defines the element the controls should be listened from
  103726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103727. */
  103728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103729. /**
  103730. * Detach the current controls from the specified dom element.
  103731. * @param element Defines the element to stop listening the inputs from
  103732. */
  103733. detachControl(element: Nullable<HTMLElement>): void;
  103734. /**
  103735. * Update the current camera state depending on the inputs that have been used this frame.
  103736. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103737. */
  103738. checkInputs(): void;
  103739. /**
  103740. * Gets the class name of the current intput.
  103741. * @returns the class name
  103742. */
  103743. getClassName(): string;
  103744. /**
  103745. * Get the friendly name associated with the input class.
  103746. * @returns the input friendly name
  103747. */
  103748. getSimpleName(): string;
  103749. }
  103750. }
  103751. declare module BABYLON {
  103752. /**
  103753. * Manage the mouse wheel inputs to control an arc rotate camera.
  103754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103755. */
  103756. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103757. /**
  103758. * Defines the camera the input is attached to.
  103759. */
  103760. camera: ArcRotateCamera;
  103761. /**
  103762. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103763. */
  103764. wheelPrecision: number;
  103765. /**
  103766. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103767. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103768. */
  103769. wheelDeltaPercentage: number;
  103770. private _wheel;
  103771. private _observer;
  103772. private computeDeltaFromMouseWheelLegacyEvent;
  103773. /**
  103774. * Attach the input controls to a specific dom element to get the input from.
  103775. * @param element Defines the element the controls should be listened from
  103776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103777. */
  103778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103779. /**
  103780. * Detach the current controls from the specified dom element.
  103781. * @param element Defines the element to stop listening the inputs from
  103782. */
  103783. detachControl(element: Nullable<HTMLElement>): void;
  103784. /**
  103785. * Gets the class name of the current intput.
  103786. * @returns the class name
  103787. */
  103788. getClassName(): string;
  103789. /**
  103790. * Get the friendly name associated with the input class.
  103791. * @returns the input friendly name
  103792. */
  103793. getSimpleName(): string;
  103794. }
  103795. }
  103796. declare module BABYLON {
  103797. /**
  103798. * Default Inputs manager for the ArcRotateCamera.
  103799. * It groups all the default supported inputs for ease of use.
  103800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103801. */
  103802. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103803. /**
  103804. * Instantiates a new ArcRotateCameraInputsManager.
  103805. * @param camera Defines the camera the inputs belong to
  103806. */
  103807. constructor(camera: ArcRotateCamera);
  103808. /**
  103809. * Add mouse wheel input support to the input manager.
  103810. * @returns the current input manager
  103811. */
  103812. addMouseWheel(): ArcRotateCameraInputsManager;
  103813. /**
  103814. * Add pointers input support to the input manager.
  103815. * @returns the current input manager
  103816. */
  103817. addPointers(): ArcRotateCameraInputsManager;
  103818. /**
  103819. * Add keyboard input support to the input manager.
  103820. * @returns the current input manager
  103821. */
  103822. addKeyboard(): ArcRotateCameraInputsManager;
  103823. }
  103824. }
  103825. declare module BABYLON {
  103826. /**
  103827. * This represents an orbital type of camera.
  103828. *
  103829. * 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.
  103830. * 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.
  103831. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103832. */
  103833. export class ArcRotateCamera extends TargetCamera {
  103834. /**
  103835. * Defines the rotation angle of the camera along the longitudinal axis.
  103836. */
  103837. alpha: number;
  103838. /**
  103839. * Defines the rotation angle of the camera along the latitudinal axis.
  103840. */
  103841. beta: number;
  103842. /**
  103843. * Defines the radius of the camera from it s target point.
  103844. */
  103845. radius: number;
  103846. protected _target: Vector3;
  103847. protected _targetHost: Nullable<AbstractMesh>;
  103848. /**
  103849. * Defines the target point of the camera.
  103850. * The camera looks towards it form the radius distance.
  103851. */
  103852. target: Vector3;
  103853. /**
  103854. * Define the current local position of the camera in the scene
  103855. */
  103856. position: Vector3;
  103857. protected _upVector: Vector3;
  103858. protected _upToYMatrix: Matrix;
  103859. protected _YToUpMatrix: Matrix;
  103860. /**
  103861. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103862. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103863. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103864. */
  103865. upVector: Vector3;
  103866. /**
  103867. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103868. */
  103869. setMatUp(): void;
  103870. /**
  103871. * Current inertia value on the longitudinal axis.
  103872. * The bigger this number the longer it will take for the camera to stop.
  103873. */
  103874. inertialAlphaOffset: number;
  103875. /**
  103876. * Current inertia value on the latitudinal axis.
  103877. * The bigger this number the longer it will take for the camera to stop.
  103878. */
  103879. inertialBetaOffset: number;
  103880. /**
  103881. * Current inertia value on the radius axis.
  103882. * The bigger this number the longer it will take for the camera to stop.
  103883. */
  103884. inertialRadiusOffset: number;
  103885. /**
  103886. * Minimum allowed angle on the longitudinal axis.
  103887. * This can help limiting how the Camera is able to move in the scene.
  103888. */
  103889. lowerAlphaLimit: Nullable<number>;
  103890. /**
  103891. * Maximum allowed angle on the longitudinal axis.
  103892. * This can help limiting how the Camera is able to move in the scene.
  103893. */
  103894. upperAlphaLimit: Nullable<number>;
  103895. /**
  103896. * Minimum allowed angle on the latitudinal axis.
  103897. * This can help limiting how the Camera is able to move in the scene.
  103898. */
  103899. lowerBetaLimit: number;
  103900. /**
  103901. * Maximum allowed angle on the latitudinal axis.
  103902. * This can help limiting how the Camera is able to move in the scene.
  103903. */
  103904. upperBetaLimit: number;
  103905. /**
  103906. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103907. * This can help limiting how the Camera is able to move in the scene.
  103908. */
  103909. lowerRadiusLimit: Nullable<number>;
  103910. /**
  103911. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103912. * This can help limiting how the Camera is able to move in the scene.
  103913. */
  103914. upperRadiusLimit: Nullable<number>;
  103915. /**
  103916. * Defines the current inertia value used during panning of the camera along the X axis.
  103917. */
  103918. inertialPanningX: number;
  103919. /**
  103920. * Defines the current inertia value used during panning of the camera along the Y axis.
  103921. */
  103922. inertialPanningY: number;
  103923. /**
  103924. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103925. * Basically if your fingers moves away from more than this distance you will be considered
  103926. * in pinch mode.
  103927. */
  103928. pinchToPanMaxDistance: number;
  103929. /**
  103930. * Defines the maximum distance the camera can pan.
  103931. * This could help keeping the cammera always in your scene.
  103932. */
  103933. panningDistanceLimit: Nullable<number>;
  103934. /**
  103935. * Defines the target of the camera before paning.
  103936. */
  103937. panningOriginTarget: Vector3;
  103938. /**
  103939. * Defines the value of the inertia used during panning.
  103940. * 0 would mean stop inertia and one would mean no decelleration at all.
  103941. */
  103942. panningInertia: number;
  103943. /**
  103944. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103945. */
  103946. angularSensibilityX: number;
  103947. /**
  103948. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103949. */
  103950. angularSensibilityY: number;
  103951. /**
  103952. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103953. */
  103954. pinchPrecision: number;
  103955. /**
  103956. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103957. * It will be used instead of pinchDeltaPrecision if different from 0.
  103958. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103959. */
  103960. pinchDeltaPercentage: number;
  103961. /**
  103962. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103963. */
  103964. panningSensibility: number;
  103965. /**
  103966. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103967. */
  103968. keysUp: number[];
  103969. /**
  103970. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103971. */
  103972. keysDown: number[];
  103973. /**
  103974. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103975. */
  103976. keysLeft: number[];
  103977. /**
  103978. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103979. */
  103980. keysRight: number[];
  103981. /**
  103982. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103983. */
  103984. wheelPrecision: number;
  103985. /**
  103986. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103987. * It will be used instead of pinchDeltaPrecision if different from 0.
  103988. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103989. */
  103990. wheelDeltaPercentage: number;
  103991. /**
  103992. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103993. */
  103994. zoomOnFactor: number;
  103995. /**
  103996. * Defines a screen offset for the camera position.
  103997. */
  103998. targetScreenOffset: Vector2;
  103999. /**
  104000. * Allows the camera to be completely reversed.
  104001. * If false the camera can not arrive upside down.
  104002. */
  104003. allowUpsideDown: boolean;
  104004. /**
  104005. * Define if double tap/click is used to restore the previously saved state of the camera.
  104006. */
  104007. useInputToRestoreState: boolean;
  104008. /** @hidden */
  104009. _viewMatrix: Matrix;
  104010. /** @hidden */
  104011. _useCtrlForPanning: boolean;
  104012. /** @hidden */
  104013. _panningMouseButton: number;
  104014. /**
  104015. * Defines the input associated to the camera.
  104016. */
  104017. inputs: ArcRotateCameraInputsManager;
  104018. /** @hidden */
  104019. _reset: () => void;
  104020. /**
  104021. * Defines the allowed panning axis.
  104022. */
  104023. panningAxis: Vector3;
  104024. protected _localDirection: Vector3;
  104025. protected _transformedDirection: Vector3;
  104026. private _bouncingBehavior;
  104027. /**
  104028. * Gets the bouncing behavior of the camera if it has been enabled.
  104029. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104030. */
  104031. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  104032. /**
  104033. * Defines if the bouncing behavior of the camera is enabled on the camera.
  104034. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104035. */
  104036. useBouncingBehavior: boolean;
  104037. private _framingBehavior;
  104038. /**
  104039. * Gets the framing behavior of the camera if it has been enabled.
  104040. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104041. */
  104042. readonly framingBehavior: Nullable<FramingBehavior>;
  104043. /**
  104044. * Defines if the framing behavior of the camera is enabled on the camera.
  104045. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104046. */
  104047. useFramingBehavior: boolean;
  104048. private _autoRotationBehavior;
  104049. /**
  104050. * Gets the auto rotation behavior of the camera if it has been enabled.
  104051. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104052. */
  104053. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  104054. /**
  104055. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  104056. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104057. */
  104058. useAutoRotationBehavior: boolean;
  104059. /**
  104060. * Observable triggered when the mesh target has been changed on the camera.
  104061. */
  104062. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  104063. /**
  104064. * Event raised when the camera is colliding with a mesh.
  104065. */
  104066. onCollide: (collidedMesh: AbstractMesh) => void;
  104067. /**
  104068. * Defines whether the camera should check collision with the objects oh the scene.
  104069. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  104070. */
  104071. checkCollisions: boolean;
  104072. /**
  104073. * Defines the collision radius of the camera.
  104074. * This simulates a sphere around the camera.
  104075. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104076. */
  104077. collisionRadius: Vector3;
  104078. protected _collider: Collider;
  104079. protected _previousPosition: Vector3;
  104080. protected _collisionVelocity: Vector3;
  104081. protected _newPosition: Vector3;
  104082. protected _previousAlpha: number;
  104083. protected _previousBeta: number;
  104084. protected _previousRadius: number;
  104085. protected _collisionTriggered: boolean;
  104086. protected _targetBoundingCenter: Nullable<Vector3>;
  104087. private _computationVector;
  104088. /**
  104089. * Instantiates a new ArcRotateCamera in a given scene
  104090. * @param name Defines the name of the camera
  104091. * @param alpha Defines the camera rotation along the logitudinal axis
  104092. * @param beta Defines the camera rotation along the latitudinal axis
  104093. * @param radius Defines the camera distance from its target
  104094. * @param target Defines the camera target
  104095. * @param scene Defines the scene the camera belongs to
  104096. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  104097. */
  104098. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104099. /** @hidden */
  104100. _initCache(): void;
  104101. /** @hidden */
  104102. _updateCache(ignoreParentClass?: boolean): void;
  104103. protected _getTargetPosition(): Vector3;
  104104. private _storedAlpha;
  104105. private _storedBeta;
  104106. private _storedRadius;
  104107. private _storedTarget;
  104108. private _storedTargetScreenOffset;
  104109. /**
  104110. * Stores the current state of the camera (alpha, beta, radius and target)
  104111. * @returns the camera itself
  104112. */
  104113. storeState(): Camera;
  104114. /**
  104115. * @hidden
  104116. * Restored camera state. You must call storeState() first
  104117. */
  104118. _restoreStateValues(): boolean;
  104119. /** @hidden */
  104120. _isSynchronizedViewMatrix(): boolean;
  104121. /**
  104122. * Attached controls to the current camera.
  104123. * @param element Defines the element the controls should be listened from
  104124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104125. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  104126. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  104127. */
  104128. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  104129. /**
  104130. * Detach the current controls from the camera.
  104131. * The camera will stop reacting to inputs.
  104132. * @param element Defines the element to stop listening the inputs from
  104133. */
  104134. detachControl(element: HTMLElement): void;
  104135. /** @hidden */
  104136. _checkInputs(): void;
  104137. protected _checkLimits(): void;
  104138. /**
  104139. * Rebuilds angles (alpha, beta) and radius from the give position and target
  104140. */
  104141. rebuildAnglesAndRadius(): void;
  104142. /**
  104143. * Use a position to define the current camera related information like alpha, beta and radius
  104144. * @param position Defines the position to set the camera at
  104145. */
  104146. setPosition(position: Vector3): void;
  104147. /**
  104148. * Defines the target the camera should look at.
  104149. * This will automatically adapt alpha beta and radius to fit within the new target.
  104150. * @param target Defines the new target as a Vector or a mesh
  104151. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  104152. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  104153. */
  104154. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  104155. /** @hidden */
  104156. _getViewMatrix(): Matrix;
  104157. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  104158. /**
  104159. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  104160. * @param meshes Defines the mesh to zoom on
  104161. * @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)
  104162. */
  104163. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  104164. /**
  104165. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  104166. * The target will be changed but the radius
  104167. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  104168. * @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)
  104169. */
  104170. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  104171. min: Vector3;
  104172. max: Vector3;
  104173. distance: number;
  104174. }, doNotUpdateMaxZ?: boolean): void;
  104175. /**
  104176. * @override
  104177. * Override Camera.createRigCamera
  104178. */
  104179. createRigCamera(name: string, cameraIndex: number): Camera;
  104180. /**
  104181. * @hidden
  104182. * @override
  104183. * Override Camera._updateRigCameras
  104184. */
  104185. _updateRigCameras(): void;
  104186. /**
  104187. * Destroy the camera and release the current resources hold by it.
  104188. */
  104189. dispose(): void;
  104190. /**
  104191. * Gets the current object class name.
  104192. * @return the class name
  104193. */
  104194. getClassName(): string;
  104195. }
  104196. }
  104197. declare module BABYLON {
  104198. /**
  104199. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  104200. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104201. */
  104202. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  104203. /**
  104204. * Gets the name of the behavior.
  104205. */
  104206. readonly name: string;
  104207. private _zoomStopsAnimation;
  104208. private _idleRotationSpeed;
  104209. private _idleRotationWaitTime;
  104210. private _idleRotationSpinupTime;
  104211. /**
  104212. * Sets the flag that indicates if user zooming should stop animation.
  104213. */
  104214. /**
  104215. * Gets the flag that indicates if user zooming should stop animation.
  104216. */
  104217. zoomStopsAnimation: boolean;
  104218. /**
  104219. * Sets the default speed at which the camera rotates around the model.
  104220. */
  104221. /**
  104222. * Gets the default speed at which the camera rotates around the model.
  104223. */
  104224. idleRotationSpeed: number;
  104225. /**
  104226. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  104227. */
  104228. /**
  104229. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  104230. */
  104231. idleRotationWaitTime: number;
  104232. /**
  104233. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104234. */
  104235. /**
  104236. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104237. */
  104238. idleRotationSpinupTime: number;
  104239. /**
  104240. * Gets a value indicating if the camera is currently rotating because of this behavior
  104241. */
  104242. readonly rotationInProgress: boolean;
  104243. private _onPrePointerObservableObserver;
  104244. private _onAfterCheckInputsObserver;
  104245. private _attachedCamera;
  104246. private _isPointerDown;
  104247. private _lastFrameTime;
  104248. private _lastInteractionTime;
  104249. private _cameraRotationSpeed;
  104250. /**
  104251. * Initializes the behavior.
  104252. */
  104253. init(): void;
  104254. /**
  104255. * Attaches the behavior to its arc rotate camera.
  104256. * @param camera Defines the camera to attach the behavior to
  104257. */
  104258. attach(camera: ArcRotateCamera): void;
  104259. /**
  104260. * Detaches the behavior from its current arc rotate camera.
  104261. */
  104262. detach(): void;
  104263. /**
  104264. * Returns true if user is scrolling.
  104265. * @return true if user is scrolling.
  104266. */
  104267. private _userIsZooming;
  104268. private _lastFrameRadius;
  104269. private _shouldAnimationStopForInteraction;
  104270. /**
  104271. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104272. */
  104273. private _applyUserInteraction;
  104274. private _userIsMoving;
  104275. }
  104276. }
  104277. declare module BABYLON {
  104278. /**
  104279. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  104280. */
  104281. export class AttachToBoxBehavior implements Behavior<Mesh> {
  104282. private ui;
  104283. /**
  104284. * The name of the behavior
  104285. */
  104286. name: string;
  104287. /**
  104288. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  104289. */
  104290. distanceAwayFromFace: number;
  104291. /**
  104292. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  104293. */
  104294. distanceAwayFromBottomOfFace: number;
  104295. private _faceVectors;
  104296. private _target;
  104297. private _scene;
  104298. private _onRenderObserver;
  104299. private _tmpMatrix;
  104300. private _tmpVector;
  104301. /**
  104302. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  104303. * @param ui The transform node that should be attched to the mesh
  104304. */
  104305. constructor(ui: TransformNode);
  104306. /**
  104307. * Initializes the behavior
  104308. */
  104309. init(): void;
  104310. private _closestFace;
  104311. private _zeroVector;
  104312. private _lookAtTmpMatrix;
  104313. private _lookAtToRef;
  104314. /**
  104315. * Attaches the AttachToBoxBehavior to the passed in mesh
  104316. * @param target The mesh that the specified node will be attached to
  104317. */
  104318. attach(target: Mesh): void;
  104319. /**
  104320. * Detaches the behavior from the mesh
  104321. */
  104322. detach(): void;
  104323. }
  104324. }
  104325. declare module BABYLON {
  104326. /**
  104327. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  104328. */
  104329. export class FadeInOutBehavior implements Behavior<Mesh> {
  104330. /**
  104331. * Time in milliseconds to delay before fading in (Default: 0)
  104332. */
  104333. delay: number;
  104334. /**
  104335. * Time in milliseconds for the mesh to fade in (Default: 300)
  104336. */
  104337. fadeInTime: number;
  104338. private _millisecondsPerFrame;
  104339. private _hovered;
  104340. private _hoverValue;
  104341. private _ownerNode;
  104342. /**
  104343. * Instatiates the FadeInOutBehavior
  104344. */
  104345. constructor();
  104346. /**
  104347. * The name of the behavior
  104348. */
  104349. readonly name: string;
  104350. /**
  104351. * Initializes the behavior
  104352. */
  104353. init(): void;
  104354. /**
  104355. * Attaches the fade behavior on the passed in mesh
  104356. * @param ownerNode The mesh that will be faded in/out once attached
  104357. */
  104358. attach(ownerNode: Mesh): void;
  104359. /**
  104360. * Detaches the behavior from the mesh
  104361. */
  104362. detach(): void;
  104363. /**
  104364. * Triggers the mesh to begin fading in or out
  104365. * @param value if the object should fade in or out (true to fade in)
  104366. */
  104367. fadeIn(value: boolean): void;
  104368. private _update;
  104369. private _setAllVisibility;
  104370. }
  104371. }
  104372. declare module BABYLON {
  104373. /**
  104374. * Class containing a set of static utilities functions for managing Pivots
  104375. * @hidden
  104376. */
  104377. export class PivotTools {
  104378. private static _PivotCached;
  104379. private static _OldPivotPoint;
  104380. private static _PivotTranslation;
  104381. private static _PivotTmpVector;
  104382. /** @hidden */
  104383. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  104384. /** @hidden */
  104385. static _RestorePivotPoint(mesh: AbstractMesh): void;
  104386. }
  104387. }
  104388. declare module BABYLON {
  104389. /**
  104390. * Class containing static functions to help procedurally build meshes
  104391. */
  104392. export class PlaneBuilder {
  104393. /**
  104394. * Creates a plane mesh
  104395. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104396. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104397. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104401. * @param name defines the name of the mesh
  104402. * @param options defines the options used to create the mesh
  104403. * @param scene defines the hosting scene
  104404. * @returns the plane mesh
  104405. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104406. */
  104407. static CreatePlane(name: string, options: {
  104408. size?: number;
  104409. width?: number;
  104410. height?: number;
  104411. sideOrientation?: number;
  104412. frontUVs?: Vector4;
  104413. backUVs?: Vector4;
  104414. updatable?: boolean;
  104415. sourcePlane?: Plane;
  104416. }, scene?: Nullable<Scene>): Mesh;
  104417. }
  104418. }
  104419. declare module BABYLON {
  104420. /**
  104421. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  104422. */
  104423. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  104424. private static _AnyMouseID;
  104425. /**
  104426. * Abstract mesh the behavior is set on
  104427. */
  104428. attachedNode: AbstractMesh;
  104429. private _dragPlane;
  104430. private _scene;
  104431. private _pointerObserver;
  104432. private _beforeRenderObserver;
  104433. private static _planeScene;
  104434. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  104435. /**
  104436. * 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)
  104437. */
  104438. maxDragAngle: number;
  104439. /**
  104440. * @hidden
  104441. */
  104442. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  104443. /**
  104444. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104445. */
  104446. currentDraggingPointerID: number;
  104447. /**
  104448. * The last position where the pointer hit the drag plane in world space
  104449. */
  104450. lastDragPosition: Vector3;
  104451. /**
  104452. * If the behavior is currently in a dragging state
  104453. */
  104454. dragging: boolean;
  104455. /**
  104456. * 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)
  104457. */
  104458. dragDeltaRatio: number;
  104459. /**
  104460. * If the drag plane orientation should be updated during the dragging (Default: true)
  104461. */
  104462. updateDragPlane: boolean;
  104463. private _debugMode;
  104464. private _moving;
  104465. /**
  104466. * Fires each time the attached mesh is dragged with the pointer
  104467. * * delta between last drag position and current drag position in world space
  104468. * * dragDistance along the drag axis
  104469. * * dragPlaneNormal normal of the current drag plane used during the drag
  104470. * * dragPlanePoint in world space where the drag intersects the drag plane
  104471. */
  104472. onDragObservable: Observable<{
  104473. delta: Vector3;
  104474. dragPlanePoint: Vector3;
  104475. dragPlaneNormal: Vector3;
  104476. dragDistance: number;
  104477. pointerId: number;
  104478. }>;
  104479. /**
  104480. * Fires each time a drag begins (eg. mouse down on mesh)
  104481. */
  104482. onDragStartObservable: Observable<{
  104483. dragPlanePoint: Vector3;
  104484. pointerId: number;
  104485. }>;
  104486. /**
  104487. * Fires each time a drag ends (eg. mouse release after drag)
  104488. */
  104489. onDragEndObservable: Observable<{
  104490. dragPlanePoint: Vector3;
  104491. pointerId: number;
  104492. }>;
  104493. /**
  104494. * If the attached mesh should be moved when dragged
  104495. */
  104496. moveAttached: boolean;
  104497. /**
  104498. * If the drag behavior will react to drag events (Default: true)
  104499. */
  104500. enabled: boolean;
  104501. /**
  104502. * If pointer events should start and release the drag (Default: true)
  104503. */
  104504. startAndReleaseDragOnPointerEvents: boolean;
  104505. /**
  104506. * If camera controls should be detached during the drag
  104507. */
  104508. detachCameraControls: boolean;
  104509. /**
  104510. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  104511. */
  104512. useObjectOrienationForDragging: boolean;
  104513. private _options;
  104514. /**
  104515. * Creates a pointer drag behavior that can be attached to a mesh
  104516. * @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)
  104517. */
  104518. constructor(options?: {
  104519. dragAxis?: Vector3;
  104520. dragPlaneNormal?: Vector3;
  104521. });
  104522. /**
  104523. * Predicate to determine if it is valid to move the object to a new position when it is moved
  104524. */
  104525. validateDrag: (targetPosition: Vector3) => boolean;
  104526. /**
  104527. * The name of the behavior
  104528. */
  104529. readonly name: string;
  104530. /**
  104531. * Initializes the behavior
  104532. */
  104533. init(): void;
  104534. private _tmpVector;
  104535. private _alternatePickedPoint;
  104536. private _worldDragAxis;
  104537. private _targetPosition;
  104538. private _attachedElement;
  104539. /**
  104540. * Attaches the drag behavior the passed in mesh
  104541. * @param ownerNode The mesh that will be dragged around once attached
  104542. * @param predicate Predicate to use for pick filtering
  104543. */
  104544. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  104545. /**
  104546. * Force relase the drag action by code.
  104547. */
  104548. releaseDrag(): void;
  104549. private _startDragRay;
  104550. private _lastPointerRay;
  104551. /**
  104552. * Simulates the start of a pointer drag event on the behavior
  104553. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  104554. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  104555. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  104556. */
  104557. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  104558. private _startDrag;
  104559. private _dragDelta;
  104560. private _moveDrag;
  104561. private _pickWithRayOnDragPlane;
  104562. private _pointA;
  104563. private _pointB;
  104564. private _pointC;
  104565. private _lineA;
  104566. private _lineB;
  104567. private _localAxis;
  104568. private _lookAt;
  104569. private _updateDragPlanePosition;
  104570. /**
  104571. * Detaches the behavior from the mesh
  104572. */
  104573. detach(): void;
  104574. }
  104575. }
  104576. declare module BABYLON {
  104577. /**
  104578. * A behavior that when attached to a mesh will allow the mesh to be scaled
  104579. */
  104580. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  104581. private _dragBehaviorA;
  104582. private _dragBehaviorB;
  104583. private _startDistance;
  104584. private _initialScale;
  104585. private _targetScale;
  104586. private _ownerNode;
  104587. private _sceneRenderObserver;
  104588. /**
  104589. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  104590. */
  104591. constructor();
  104592. /**
  104593. * The name of the behavior
  104594. */
  104595. readonly name: string;
  104596. /**
  104597. * Initializes the behavior
  104598. */
  104599. init(): void;
  104600. private _getCurrentDistance;
  104601. /**
  104602. * Attaches the scale behavior the passed in mesh
  104603. * @param ownerNode The mesh that will be scaled around once attached
  104604. */
  104605. attach(ownerNode: Mesh): void;
  104606. /**
  104607. * Detaches the behavior from the mesh
  104608. */
  104609. detach(): void;
  104610. }
  104611. }
  104612. declare module BABYLON {
  104613. /**
  104614. * 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
  104615. */
  104616. export class SixDofDragBehavior implements Behavior<Mesh> {
  104617. private static _virtualScene;
  104618. private _ownerNode;
  104619. private _sceneRenderObserver;
  104620. private _scene;
  104621. private _targetPosition;
  104622. private _virtualOriginMesh;
  104623. private _virtualDragMesh;
  104624. private _pointerObserver;
  104625. private _moving;
  104626. private _startingOrientation;
  104627. /**
  104628. * 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)
  104629. */
  104630. private zDragFactor;
  104631. /**
  104632. * If the object should rotate to face the drag origin
  104633. */
  104634. rotateDraggedObject: boolean;
  104635. /**
  104636. * If the behavior is currently in a dragging state
  104637. */
  104638. dragging: boolean;
  104639. /**
  104640. * 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)
  104641. */
  104642. dragDeltaRatio: number;
  104643. /**
  104644. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104645. */
  104646. currentDraggingPointerID: number;
  104647. /**
  104648. * If camera controls should be detached during the drag
  104649. */
  104650. detachCameraControls: boolean;
  104651. /**
  104652. * Fires each time a drag starts
  104653. */
  104654. onDragStartObservable: Observable<{}>;
  104655. /**
  104656. * Fires each time a drag ends (eg. mouse release after drag)
  104657. */
  104658. onDragEndObservable: Observable<{}>;
  104659. /**
  104660. * 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
  104661. */
  104662. constructor();
  104663. /**
  104664. * The name of the behavior
  104665. */
  104666. readonly name: string;
  104667. /**
  104668. * Initializes the behavior
  104669. */
  104670. init(): void;
  104671. /**
  104672. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  104673. */
  104674. private readonly _pointerCamera;
  104675. /**
  104676. * Attaches the scale behavior the passed in mesh
  104677. * @param ownerNode The mesh that will be scaled around once attached
  104678. */
  104679. attach(ownerNode: Mesh): void;
  104680. /**
  104681. * Detaches the behavior from the mesh
  104682. */
  104683. detach(): void;
  104684. }
  104685. }
  104686. declare module BABYLON {
  104687. /**
  104688. * Class used to apply inverse kinematics to bones
  104689. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  104690. */
  104691. export class BoneIKController {
  104692. private static _tmpVecs;
  104693. private static _tmpQuat;
  104694. private static _tmpMats;
  104695. /**
  104696. * Gets or sets the target mesh
  104697. */
  104698. targetMesh: AbstractMesh;
  104699. /** Gets or sets the mesh used as pole */
  104700. poleTargetMesh: AbstractMesh;
  104701. /**
  104702. * Gets or sets the bone used as pole
  104703. */
  104704. poleTargetBone: Nullable<Bone>;
  104705. /**
  104706. * Gets or sets the target position
  104707. */
  104708. targetPosition: Vector3;
  104709. /**
  104710. * Gets or sets the pole target position
  104711. */
  104712. poleTargetPosition: Vector3;
  104713. /**
  104714. * Gets or sets the pole target local offset
  104715. */
  104716. poleTargetLocalOffset: Vector3;
  104717. /**
  104718. * Gets or sets the pole angle
  104719. */
  104720. poleAngle: number;
  104721. /**
  104722. * Gets or sets the mesh associated with the controller
  104723. */
  104724. mesh: AbstractMesh;
  104725. /**
  104726. * 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)
  104727. */
  104728. slerpAmount: number;
  104729. private _bone1Quat;
  104730. private _bone1Mat;
  104731. private _bone2Ang;
  104732. private _bone1;
  104733. private _bone2;
  104734. private _bone1Length;
  104735. private _bone2Length;
  104736. private _maxAngle;
  104737. private _maxReach;
  104738. private _rightHandedSystem;
  104739. private _bendAxis;
  104740. private _slerping;
  104741. private _adjustRoll;
  104742. /**
  104743. * Gets or sets maximum allowed angle
  104744. */
  104745. maxAngle: number;
  104746. /**
  104747. * Creates a new BoneIKController
  104748. * @param mesh defines the mesh to control
  104749. * @param bone defines the bone to control
  104750. * @param options defines options to set up the controller
  104751. */
  104752. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104753. targetMesh?: AbstractMesh;
  104754. poleTargetMesh?: AbstractMesh;
  104755. poleTargetBone?: Bone;
  104756. poleTargetLocalOffset?: Vector3;
  104757. poleAngle?: number;
  104758. bendAxis?: Vector3;
  104759. maxAngle?: number;
  104760. slerpAmount?: number;
  104761. });
  104762. private _setMaxAngle;
  104763. /**
  104764. * Force the controller to update the bones
  104765. */
  104766. update(): void;
  104767. }
  104768. }
  104769. declare module BABYLON {
  104770. /**
  104771. * Class used to make a bone look toward a point in space
  104772. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104773. */
  104774. export class BoneLookController {
  104775. private static _tmpVecs;
  104776. private static _tmpQuat;
  104777. private static _tmpMats;
  104778. /**
  104779. * The target Vector3 that the bone will look at
  104780. */
  104781. target: Vector3;
  104782. /**
  104783. * The mesh that the bone is attached to
  104784. */
  104785. mesh: AbstractMesh;
  104786. /**
  104787. * The bone that will be looking to the target
  104788. */
  104789. bone: Bone;
  104790. /**
  104791. * The up axis of the coordinate system that is used when the bone is rotated
  104792. */
  104793. upAxis: Vector3;
  104794. /**
  104795. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104796. */
  104797. upAxisSpace: Space;
  104798. /**
  104799. * Used to make an adjustment to the yaw of the bone
  104800. */
  104801. adjustYaw: number;
  104802. /**
  104803. * Used to make an adjustment to the pitch of the bone
  104804. */
  104805. adjustPitch: number;
  104806. /**
  104807. * Used to make an adjustment to the roll of the bone
  104808. */
  104809. adjustRoll: number;
  104810. /**
  104811. * 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)
  104812. */
  104813. slerpAmount: number;
  104814. private _minYaw;
  104815. private _maxYaw;
  104816. private _minPitch;
  104817. private _maxPitch;
  104818. private _minYawSin;
  104819. private _minYawCos;
  104820. private _maxYawSin;
  104821. private _maxYawCos;
  104822. private _midYawConstraint;
  104823. private _minPitchTan;
  104824. private _maxPitchTan;
  104825. private _boneQuat;
  104826. private _slerping;
  104827. private _transformYawPitch;
  104828. private _transformYawPitchInv;
  104829. private _firstFrameSkipped;
  104830. private _yawRange;
  104831. private _fowardAxis;
  104832. /**
  104833. * Gets or sets the minimum yaw angle that the bone can look to
  104834. */
  104835. minYaw: number;
  104836. /**
  104837. * Gets or sets the maximum yaw angle that the bone can look to
  104838. */
  104839. maxYaw: number;
  104840. /**
  104841. * Gets or sets the minimum pitch angle that the bone can look to
  104842. */
  104843. minPitch: number;
  104844. /**
  104845. * Gets or sets the maximum pitch angle that the bone can look to
  104846. */
  104847. maxPitch: number;
  104848. /**
  104849. * Create a BoneLookController
  104850. * @param mesh the mesh that the bone belongs to
  104851. * @param bone the bone that will be looking to the target
  104852. * @param target the target Vector3 to look at
  104853. * @param options optional settings:
  104854. * * maxYaw: the maximum angle the bone will yaw to
  104855. * * minYaw: the minimum angle the bone will yaw to
  104856. * * maxPitch: the maximum angle the bone will pitch to
  104857. * * minPitch: the minimum angle the bone will yaw to
  104858. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104859. * * upAxis: the up axis of the coordinate system
  104860. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104861. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104862. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104863. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104864. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104865. * * adjustRoll: used to make an adjustment to the roll of the bone
  104866. **/
  104867. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104868. maxYaw?: number;
  104869. minYaw?: number;
  104870. maxPitch?: number;
  104871. minPitch?: number;
  104872. slerpAmount?: number;
  104873. upAxis?: Vector3;
  104874. upAxisSpace?: Space;
  104875. yawAxis?: Vector3;
  104876. pitchAxis?: Vector3;
  104877. adjustYaw?: number;
  104878. adjustPitch?: number;
  104879. adjustRoll?: number;
  104880. });
  104881. /**
  104882. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104883. */
  104884. update(): void;
  104885. private _getAngleDiff;
  104886. private _getAngleBetween;
  104887. private _isAngleBetween;
  104888. }
  104889. }
  104890. declare module BABYLON {
  104891. /**
  104892. * Manage the gamepad inputs to control an arc rotate camera.
  104893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104894. */
  104895. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104896. /**
  104897. * Defines the camera the input is attached to.
  104898. */
  104899. camera: ArcRotateCamera;
  104900. /**
  104901. * Defines the gamepad the input is gathering event from.
  104902. */
  104903. gamepad: Nullable<Gamepad>;
  104904. /**
  104905. * Defines the gamepad rotation sensiblity.
  104906. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104907. */
  104908. gamepadRotationSensibility: number;
  104909. /**
  104910. * Defines the gamepad move sensiblity.
  104911. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104912. */
  104913. gamepadMoveSensibility: number;
  104914. private _yAxisScale;
  104915. /**
  104916. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104917. */
  104918. invertYAxis: boolean;
  104919. private _onGamepadConnectedObserver;
  104920. private _onGamepadDisconnectedObserver;
  104921. /**
  104922. * Attach the input controls to a specific dom element to get the input from.
  104923. * @param element Defines the element the controls should be listened from
  104924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104925. */
  104926. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104927. /**
  104928. * Detach the current controls from the specified dom element.
  104929. * @param element Defines the element to stop listening the inputs from
  104930. */
  104931. detachControl(element: Nullable<HTMLElement>): void;
  104932. /**
  104933. * Update the current camera state depending on the inputs that have been used this frame.
  104934. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104935. */
  104936. checkInputs(): void;
  104937. /**
  104938. * Gets the class name of the current intput.
  104939. * @returns the class name
  104940. */
  104941. getClassName(): string;
  104942. /**
  104943. * Get the friendly name associated with the input class.
  104944. * @returns the input friendly name
  104945. */
  104946. getSimpleName(): string;
  104947. }
  104948. }
  104949. declare module BABYLON {
  104950. interface ArcRotateCameraInputsManager {
  104951. /**
  104952. * Add orientation input support to the input manager.
  104953. * @returns the current input manager
  104954. */
  104955. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104956. }
  104957. /**
  104958. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104960. */
  104961. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104962. /**
  104963. * Defines the camera the input is attached to.
  104964. */
  104965. camera: ArcRotateCamera;
  104966. /**
  104967. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104968. */
  104969. alphaCorrection: number;
  104970. /**
  104971. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104972. */
  104973. gammaCorrection: number;
  104974. private _alpha;
  104975. private _gamma;
  104976. private _dirty;
  104977. private _deviceOrientationHandler;
  104978. /**
  104979. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104980. */
  104981. constructor();
  104982. /**
  104983. * Attach the input controls to a specific dom element to get the input from.
  104984. * @param element Defines the element the controls should be listened from
  104985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104986. */
  104987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104988. /** @hidden */
  104989. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104990. /**
  104991. * Update the current camera state depending on the inputs that have been used this frame.
  104992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104993. */
  104994. checkInputs(): void;
  104995. /**
  104996. * Detach the current controls from the specified dom element.
  104997. * @param element Defines the element to stop listening the inputs from
  104998. */
  104999. detachControl(element: Nullable<HTMLElement>): void;
  105000. /**
  105001. * Gets the class name of the current intput.
  105002. * @returns the class name
  105003. */
  105004. getClassName(): string;
  105005. /**
  105006. * Get the friendly name associated with the input class.
  105007. * @returns the input friendly name
  105008. */
  105009. getSimpleName(): string;
  105010. }
  105011. }
  105012. declare module BABYLON {
  105013. /**
  105014. * Listen to mouse events to control the camera.
  105015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105016. */
  105017. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  105018. /**
  105019. * Defines the camera the input is attached to.
  105020. */
  105021. camera: FlyCamera;
  105022. /**
  105023. * Defines if touch is enabled. (Default is true.)
  105024. */
  105025. touchEnabled: boolean;
  105026. /**
  105027. * Defines the buttons associated with the input to handle camera rotation.
  105028. */
  105029. buttons: number[];
  105030. /**
  105031. * Assign buttons for Yaw control.
  105032. */
  105033. buttonsYaw: number[];
  105034. /**
  105035. * Assign buttons for Pitch control.
  105036. */
  105037. buttonsPitch: number[];
  105038. /**
  105039. * Assign buttons for Roll control.
  105040. */
  105041. buttonsRoll: number[];
  105042. /**
  105043. * Detect if any button is being pressed while mouse is moved.
  105044. * -1 = Mouse locked.
  105045. * 0 = Left button.
  105046. * 1 = Middle Button.
  105047. * 2 = Right Button.
  105048. */
  105049. activeButton: number;
  105050. /**
  105051. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  105052. * Higher values reduce its sensitivity.
  105053. */
  105054. angularSensibility: number;
  105055. private _mousemoveCallback;
  105056. private _observer;
  105057. private _rollObserver;
  105058. private previousPosition;
  105059. private noPreventDefault;
  105060. private element;
  105061. /**
  105062. * Listen to mouse events to control the camera.
  105063. * @param touchEnabled Define if touch is enabled. (Default is true.)
  105064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105065. */
  105066. constructor(touchEnabled?: boolean);
  105067. /**
  105068. * Attach the mouse control to the HTML DOM element.
  105069. * @param element Defines the element that listens to the input events.
  105070. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  105071. */
  105072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105073. /**
  105074. * Detach the current controls from the specified dom element.
  105075. * @param element Defines the element to stop listening the inputs from
  105076. */
  105077. detachControl(element: Nullable<HTMLElement>): void;
  105078. /**
  105079. * Gets the class name of the current input.
  105080. * @returns the class name.
  105081. */
  105082. getClassName(): string;
  105083. /**
  105084. * Get the friendly name associated with the input class.
  105085. * @returns the input's friendly name.
  105086. */
  105087. getSimpleName(): string;
  105088. private _pointerInput;
  105089. private _onMouseMove;
  105090. /**
  105091. * Rotate camera by mouse offset.
  105092. */
  105093. private rotateCamera;
  105094. }
  105095. }
  105096. declare module BABYLON {
  105097. /**
  105098. * Default Inputs manager for the FlyCamera.
  105099. * It groups all the default supported inputs for ease of use.
  105100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105101. */
  105102. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  105103. /**
  105104. * Instantiates a new FlyCameraInputsManager.
  105105. * @param camera Defines the camera the inputs belong to.
  105106. */
  105107. constructor(camera: FlyCamera);
  105108. /**
  105109. * Add keyboard input support to the input manager.
  105110. * @returns the new FlyCameraKeyboardMoveInput().
  105111. */
  105112. addKeyboard(): FlyCameraInputsManager;
  105113. /**
  105114. * Add mouse input support to the input manager.
  105115. * @param touchEnabled Enable touch screen support.
  105116. * @returns the new FlyCameraMouseInput().
  105117. */
  105118. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  105119. }
  105120. }
  105121. declare module BABYLON {
  105122. /**
  105123. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105124. * such as in a 3D Space Shooter or a Flight Simulator.
  105125. */
  105126. export class FlyCamera extends TargetCamera {
  105127. /**
  105128. * Define the collision ellipsoid of the camera.
  105129. * This is helpful for simulating a camera body, like a player's body.
  105130. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105131. */
  105132. ellipsoid: Vector3;
  105133. /**
  105134. * Define an offset for the position of the ellipsoid around the camera.
  105135. * This can be helpful if the camera is attached away from the player's body center,
  105136. * such as at its head.
  105137. */
  105138. ellipsoidOffset: Vector3;
  105139. /**
  105140. * Enable or disable collisions of the camera with the rest of the scene objects.
  105141. */
  105142. checkCollisions: boolean;
  105143. /**
  105144. * Enable or disable gravity on the camera.
  105145. */
  105146. applyGravity: boolean;
  105147. /**
  105148. * Define the current direction the camera is moving to.
  105149. */
  105150. cameraDirection: Vector3;
  105151. /**
  105152. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  105153. * This overrides and empties cameraRotation.
  105154. */
  105155. rotationQuaternion: Quaternion;
  105156. /**
  105157. * Track Roll to maintain the wanted Rolling when looking around.
  105158. */
  105159. _trackRoll: number;
  105160. /**
  105161. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  105162. */
  105163. rollCorrect: number;
  105164. /**
  105165. * Mimic a banked turn, Rolling the camera when Yawing.
  105166. * It's recommended to use rollCorrect = 10 for faster banking correction.
  105167. */
  105168. bankedTurn: boolean;
  105169. /**
  105170. * Limit in radians for how much Roll banking will add. (Default: 90°)
  105171. */
  105172. bankedTurnLimit: number;
  105173. /**
  105174. * Value of 0 disables the banked Roll.
  105175. * Value of 1 is equal to the Yaw angle in radians.
  105176. */
  105177. bankedTurnMultiplier: number;
  105178. /**
  105179. * The inputs manager loads all the input sources, such as keyboard and mouse.
  105180. */
  105181. inputs: FlyCameraInputsManager;
  105182. /**
  105183. * Gets the input sensibility for mouse input.
  105184. * Higher values reduce sensitivity.
  105185. */
  105186. /**
  105187. * Sets the input sensibility for a mouse input.
  105188. * Higher values reduce sensitivity.
  105189. */
  105190. angularSensibility: number;
  105191. /**
  105192. * Get the keys for camera movement forward.
  105193. */
  105194. /**
  105195. * Set the keys for camera movement forward.
  105196. */
  105197. keysForward: number[];
  105198. /**
  105199. * Get the keys for camera movement backward.
  105200. */
  105201. keysBackward: number[];
  105202. /**
  105203. * Get the keys for camera movement up.
  105204. */
  105205. /**
  105206. * Set the keys for camera movement up.
  105207. */
  105208. keysUp: number[];
  105209. /**
  105210. * Get the keys for camera movement down.
  105211. */
  105212. /**
  105213. * Set the keys for camera movement down.
  105214. */
  105215. keysDown: number[];
  105216. /**
  105217. * Get the keys for camera movement left.
  105218. */
  105219. /**
  105220. * Set the keys for camera movement left.
  105221. */
  105222. keysLeft: number[];
  105223. /**
  105224. * Set the keys for camera movement right.
  105225. */
  105226. /**
  105227. * Set the keys for camera movement right.
  105228. */
  105229. keysRight: number[];
  105230. /**
  105231. * Event raised when the camera collides with a mesh in the scene.
  105232. */
  105233. onCollide: (collidedMesh: AbstractMesh) => void;
  105234. private _collider;
  105235. private _needMoveForGravity;
  105236. private _oldPosition;
  105237. private _diffPosition;
  105238. private _newPosition;
  105239. /** @hidden */
  105240. _localDirection: Vector3;
  105241. /** @hidden */
  105242. _transformedDirection: Vector3;
  105243. /**
  105244. * Instantiates a FlyCamera.
  105245. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105246. * such as in a 3D Space Shooter or a Flight Simulator.
  105247. * @param name Define the name of the camera in the scene.
  105248. * @param position Define the starting position of the camera in the scene.
  105249. * @param scene Define the scene the camera belongs to.
  105250. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  105251. */
  105252. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105253. /**
  105254. * Attach a control to the HTML DOM element.
  105255. * @param element Defines the element that listens to the input events.
  105256. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  105257. */
  105258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105259. /**
  105260. * Detach a control from the HTML DOM element.
  105261. * The camera will stop reacting to that input.
  105262. * @param element Defines the element that listens to the input events.
  105263. */
  105264. detachControl(element: HTMLElement): void;
  105265. private _collisionMask;
  105266. /**
  105267. * Get the mask that the camera ignores in collision events.
  105268. */
  105269. /**
  105270. * Set the mask that the camera ignores in collision events.
  105271. */
  105272. collisionMask: number;
  105273. /** @hidden */
  105274. _collideWithWorld(displacement: Vector3): void;
  105275. /** @hidden */
  105276. private _onCollisionPositionChange;
  105277. /** @hidden */
  105278. _checkInputs(): void;
  105279. /** @hidden */
  105280. _decideIfNeedsToMove(): boolean;
  105281. /** @hidden */
  105282. _updatePosition(): void;
  105283. /**
  105284. * Restore the Roll to its target value at the rate specified.
  105285. * @param rate - Higher means slower restoring.
  105286. * @hidden
  105287. */
  105288. restoreRoll(rate: number): void;
  105289. /**
  105290. * Destroy the camera and release the current resources held by it.
  105291. */
  105292. dispose(): void;
  105293. /**
  105294. * Get the current object class name.
  105295. * @returns the class name.
  105296. */
  105297. getClassName(): string;
  105298. }
  105299. }
  105300. declare module BABYLON {
  105301. /**
  105302. * Listen to keyboard events to control the camera.
  105303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105304. */
  105305. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  105306. /**
  105307. * Defines the camera the input is attached to.
  105308. */
  105309. camera: FlyCamera;
  105310. /**
  105311. * The list of keyboard keys used to control the forward move of the camera.
  105312. */
  105313. keysForward: number[];
  105314. /**
  105315. * The list of keyboard keys used to control the backward move of the camera.
  105316. */
  105317. keysBackward: number[];
  105318. /**
  105319. * The list of keyboard keys used to control the forward move of the camera.
  105320. */
  105321. keysUp: number[];
  105322. /**
  105323. * The list of keyboard keys used to control the backward move of the camera.
  105324. */
  105325. keysDown: number[];
  105326. /**
  105327. * The list of keyboard keys used to control the right strafe move of the camera.
  105328. */
  105329. keysRight: number[];
  105330. /**
  105331. * The list of keyboard keys used to control the left strafe move of the camera.
  105332. */
  105333. keysLeft: number[];
  105334. private _keys;
  105335. private _onCanvasBlurObserver;
  105336. private _onKeyboardObserver;
  105337. private _engine;
  105338. private _scene;
  105339. /**
  105340. * Attach the input controls to a specific dom element to get the input from.
  105341. * @param element Defines the element the controls should be listened from
  105342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105343. */
  105344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105345. /**
  105346. * Detach the current controls from the specified dom element.
  105347. * @param element Defines the element to stop listening the inputs from
  105348. */
  105349. detachControl(element: Nullable<HTMLElement>): void;
  105350. /**
  105351. * Gets the class name of the current intput.
  105352. * @returns the class name
  105353. */
  105354. getClassName(): string;
  105355. /** @hidden */
  105356. _onLostFocus(e: FocusEvent): void;
  105357. /**
  105358. * Get the friendly name associated with the input class.
  105359. * @returns the input friendly name
  105360. */
  105361. getSimpleName(): string;
  105362. /**
  105363. * Update the current camera state depending on the inputs that have been used this frame.
  105364. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105365. */
  105366. checkInputs(): void;
  105367. }
  105368. }
  105369. declare module BABYLON {
  105370. /**
  105371. * Manage the mouse wheel inputs to control a follow camera.
  105372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105373. */
  105374. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  105375. /**
  105376. * Defines the camera the input is attached to.
  105377. */
  105378. camera: FollowCamera;
  105379. /**
  105380. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  105381. */
  105382. axisControlRadius: boolean;
  105383. /**
  105384. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  105385. */
  105386. axisControlHeight: boolean;
  105387. /**
  105388. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  105389. */
  105390. axisControlRotation: boolean;
  105391. /**
  105392. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  105393. * relation to mouseWheel events.
  105394. */
  105395. wheelPrecision: number;
  105396. /**
  105397. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105398. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105399. */
  105400. wheelDeltaPercentage: number;
  105401. private _wheel;
  105402. private _observer;
  105403. /**
  105404. * Attach the input controls to a specific dom element to get the input from.
  105405. * @param element Defines the element the controls should be listened from
  105406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105407. */
  105408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105409. /**
  105410. * Detach the current controls from the specified dom element.
  105411. * @param element Defines the element to stop listening the inputs from
  105412. */
  105413. detachControl(element: Nullable<HTMLElement>): void;
  105414. /**
  105415. * Gets the class name of the current intput.
  105416. * @returns the class name
  105417. */
  105418. getClassName(): string;
  105419. /**
  105420. * Get the friendly name associated with the input class.
  105421. * @returns the input friendly name
  105422. */
  105423. getSimpleName(): string;
  105424. }
  105425. }
  105426. declare module BABYLON {
  105427. /**
  105428. * Manage the pointers inputs to control an follow camera.
  105429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105430. */
  105431. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  105432. /**
  105433. * Defines the camera the input is attached to.
  105434. */
  105435. camera: FollowCamera;
  105436. /**
  105437. * Gets the class name of the current input.
  105438. * @returns the class name
  105439. */
  105440. getClassName(): string;
  105441. /**
  105442. * Defines the pointer angular sensibility along the X axis or how fast is
  105443. * the camera rotating.
  105444. * A negative number will reverse the axis direction.
  105445. */
  105446. angularSensibilityX: number;
  105447. /**
  105448. * Defines the pointer angular sensibility along the Y axis or how fast is
  105449. * the camera rotating.
  105450. * A negative number will reverse the axis direction.
  105451. */
  105452. angularSensibilityY: number;
  105453. /**
  105454. * Defines the pointer pinch precision or how fast is the camera zooming.
  105455. * A negative number will reverse the axis direction.
  105456. */
  105457. pinchPrecision: number;
  105458. /**
  105459. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  105460. * from 0.
  105461. * It defines the percentage of current camera.radius to use as delta when
  105462. * pinch zoom is used.
  105463. */
  105464. pinchDeltaPercentage: number;
  105465. /**
  105466. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  105467. */
  105468. axisXControlRadius: boolean;
  105469. /**
  105470. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  105471. */
  105472. axisXControlHeight: boolean;
  105473. /**
  105474. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  105475. */
  105476. axisXControlRotation: boolean;
  105477. /**
  105478. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  105479. */
  105480. axisYControlRadius: boolean;
  105481. /**
  105482. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  105483. */
  105484. axisYControlHeight: boolean;
  105485. /**
  105486. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  105487. */
  105488. axisYControlRotation: boolean;
  105489. /**
  105490. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  105491. */
  105492. axisPinchControlRadius: boolean;
  105493. /**
  105494. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  105495. */
  105496. axisPinchControlHeight: boolean;
  105497. /**
  105498. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  105499. */
  105500. axisPinchControlRotation: boolean;
  105501. /**
  105502. * Log error messages if basic misconfiguration has occurred.
  105503. */
  105504. warningEnable: boolean;
  105505. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105506. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105507. private _warningCounter;
  105508. private _warning;
  105509. }
  105510. }
  105511. declare module BABYLON {
  105512. /**
  105513. * Default Inputs manager for the FollowCamera.
  105514. * It groups all the default supported inputs for ease of use.
  105515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105516. */
  105517. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  105518. /**
  105519. * Instantiates a new FollowCameraInputsManager.
  105520. * @param camera Defines the camera the inputs belong to
  105521. */
  105522. constructor(camera: FollowCamera);
  105523. /**
  105524. * Add keyboard input support to the input manager.
  105525. * @returns the current input manager
  105526. */
  105527. addKeyboard(): FollowCameraInputsManager;
  105528. /**
  105529. * Add mouse wheel input support to the input manager.
  105530. * @returns the current input manager
  105531. */
  105532. addMouseWheel(): FollowCameraInputsManager;
  105533. /**
  105534. * Add pointers input support to the input manager.
  105535. * @returns the current input manager
  105536. */
  105537. addPointers(): FollowCameraInputsManager;
  105538. /**
  105539. * Add orientation input support to the input manager.
  105540. * @returns the current input manager
  105541. */
  105542. addVRDeviceOrientation(): FollowCameraInputsManager;
  105543. }
  105544. }
  105545. declare module BABYLON {
  105546. /**
  105547. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  105548. * an arc rotate version arcFollowCamera are available.
  105549. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105550. */
  105551. export class FollowCamera extends TargetCamera {
  105552. /**
  105553. * Distance the follow camera should follow an object at
  105554. */
  105555. radius: number;
  105556. /**
  105557. * Minimum allowed distance of the camera to the axis of rotation
  105558. * (The camera can not get closer).
  105559. * This can help limiting how the Camera is able to move in the scene.
  105560. */
  105561. lowerRadiusLimit: Nullable<number>;
  105562. /**
  105563. * Maximum allowed distance of the camera to the axis of rotation
  105564. * (The camera can not get further).
  105565. * This can help limiting how the Camera is able to move in the scene.
  105566. */
  105567. upperRadiusLimit: Nullable<number>;
  105568. /**
  105569. * Define a rotation offset between the camera and the object it follows
  105570. */
  105571. rotationOffset: number;
  105572. /**
  105573. * Minimum allowed angle to camera position relative to target object.
  105574. * This can help limiting how the Camera is able to move in the scene.
  105575. */
  105576. lowerRotationOffsetLimit: Nullable<number>;
  105577. /**
  105578. * Maximum allowed angle to camera position relative to target object.
  105579. * This can help limiting how the Camera is able to move in the scene.
  105580. */
  105581. upperRotationOffsetLimit: Nullable<number>;
  105582. /**
  105583. * Define a height offset between the camera and the object it follows.
  105584. * It can help following an object from the top (like a car chaing a plane)
  105585. */
  105586. heightOffset: number;
  105587. /**
  105588. * Minimum allowed height of camera position relative to target object.
  105589. * This can help limiting how the Camera is able to move in the scene.
  105590. */
  105591. lowerHeightOffsetLimit: Nullable<number>;
  105592. /**
  105593. * Maximum allowed height of camera position relative to target object.
  105594. * This can help limiting how the Camera is able to move in the scene.
  105595. */
  105596. upperHeightOffsetLimit: Nullable<number>;
  105597. /**
  105598. * Define how fast the camera can accelerate to follow it s target.
  105599. */
  105600. cameraAcceleration: number;
  105601. /**
  105602. * Define the speed limit of the camera following an object.
  105603. */
  105604. maxCameraSpeed: number;
  105605. /**
  105606. * Define the target of the camera.
  105607. */
  105608. lockedTarget: Nullable<AbstractMesh>;
  105609. /**
  105610. * Defines the input associated with the camera.
  105611. */
  105612. inputs: FollowCameraInputsManager;
  105613. /**
  105614. * Instantiates the follow camera.
  105615. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105616. * @param name Define the name of the camera in the scene
  105617. * @param position Define the position of the camera
  105618. * @param scene Define the scene the camera belong to
  105619. * @param lockedTarget Define the target of the camera
  105620. */
  105621. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  105622. private _follow;
  105623. /**
  105624. * Attached controls to the current camera.
  105625. * @param element Defines the element the controls should be listened from
  105626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105627. */
  105628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105629. /**
  105630. * Detach the current controls from the camera.
  105631. * The camera will stop reacting to inputs.
  105632. * @param element Defines the element to stop listening the inputs from
  105633. */
  105634. detachControl(element: HTMLElement): void;
  105635. /** @hidden */
  105636. _checkInputs(): void;
  105637. private _checkLimits;
  105638. /**
  105639. * Gets the camera class name.
  105640. * @returns the class name
  105641. */
  105642. getClassName(): string;
  105643. }
  105644. /**
  105645. * Arc Rotate version of the follow camera.
  105646. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  105647. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105648. */
  105649. export class ArcFollowCamera extends TargetCamera {
  105650. /** The longitudinal angle of the camera */
  105651. alpha: number;
  105652. /** The latitudinal angle of the camera */
  105653. beta: number;
  105654. /** The radius of the camera from its target */
  105655. radius: number;
  105656. /** Define the camera target (the messh it should follow) */
  105657. target: Nullable<AbstractMesh>;
  105658. private _cartesianCoordinates;
  105659. /**
  105660. * Instantiates a new ArcFollowCamera
  105661. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105662. * @param name Define the name of the camera
  105663. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  105664. * @param beta Define the rotation angle of the camera around the elevation axis
  105665. * @param radius Define the radius of the camera from its target point
  105666. * @param target Define the target of the camera
  105667. * @param scene Define the scene the camera belongs to
  105668. */
  105669. constructor(name: string,
  105670. /** The longitudinal angle of the camera */
  105671. alpha: number,
  105672. /** The latitudinal angle of the camera */
  105673. beta: number,
  105674. /** The radius of the camera from its target */
  105675. radius: number,
  105676. /** Define the camera target (the messh it should follow) */
  105677. target: Nullable<AbstractMesh>, scene: Scene);
  105678. private _follow;
  105679. /** @hidden */
  105680. _checkInputs(): void;
  105681. /**
  105682. * Returns the class name of the object.
  105683. * It is mostly used internally for serialization purposes.
  105684. */
  105685. getClassName(): string;
  105686. }
  105687. }
  105688. declare module BABYLON {
  105689. /**
  105690. * Manage the keyboard inputs to control the movement of a follow camera.
  105691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105692. */
  105693. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  105694. /**
  105695. * Defines the camera the input is attached to.
  105696. */
  105697. camera: FollowCamera;
  105698. /**
  105699. * Defines the list of key codes associated with the up action (increase heightOffset)
  105700. */
  105701. keysHeightOffsetIncr: number[];
  105702. /**
  105703. * Defines the list of key codes associated with the down action (decrease heightOffset)
  105704. */
  105705. keysHeightOffsetDecr: number[];
  105706. /**
  105707. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  105708. */
  105709. keysHeightOffsetModifierAlt: boolean;
  105710. /**
  105711. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  105712. */
  105713. keysHeightOffsetModifierCtrl: boolean;
  105714. /**
  105715. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  105716. */
  105717. keysHeightOffsetModifierShift: boolean;
  105718. /**
  105719. * Defines the list of key codes associated with the left action (increase rotationOffset)
  105720. */
  105721. keysRotationOffsetIncr: number[];
  105722. /**
  105723. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  105724. */
  105725. keysRotationOffsetDecr: number[];
  105726. /**
  105727. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  105728. */
  105729. keysRotationOffsetModifierAlt: boolean;
  105730. /**
  105731. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  105732. */
  105733. keysRotationOffsetModifierCtrl: boolean;
  105734. /**
  105735. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  105736. */
  105737. keysRotationOffsetModifierShift: boolean;
  105738. /**
  105739. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105740. */
  105741. keysRadiusIncr: number[];
  105742. /**
  105743. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105744. */
  105745. keysRadiusDecr: number[];
  105746. /**
  105747. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105748. */
  105749. keysRadiusModifierAlt: boolean;
  105750. /**
  105751. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105752. */
  105753. keysRadiusModifierCtrl: boolean;
  105754. /**
  105755. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105756. */
  105757. keysRadiusModifierShift: boolean;
  105758. /**
  105759. * Defines the rate of change of heightOffset.
  105760. */
  105761. heightSensibility: number;
  105762. /**
  105763. * Defines the rate of change of rotationOffset.
  105764. */
  105765. rotationSensibility: number;
  105766. /**
  105767. * Defines the rate of change of radius.
  105768. */
  105769. radiusSensibility: number;
  105770. private _keys;
  105771. private _ctrlPressed;
  105772. private _altPressed;
  105773. private _shiftPressed;
  105774. private _onCanvasBlurObserver;
  105775. private _onKeyboardObserver;
  105776. private _engine;
  105777. private _scene;
  105778. /**
  105779. * Attach the input controls to a specific dom element to get the input from.
  105780. * @param element Defines the element the controls should be listened from
  105781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105782. */
  105783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105784. /**
  105785. * Detach the current controls from the specified dom element.
  105786. * @param element Defines the element to stop listening the inputs from
  105787. */
  105788. detachControl(element: Nullable<HTMLElement>): void;
  105789. /**
  105790. * Update the current camera state depending on the inputs that have been used this frame.
  105791. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105792. */
  105793. checkInputs(): void;
  105794. /**
  105795. * Gets the class name of the current input.
  105796. * @returns the class name
  105797. */
  105798. getClassName(): string;
  105799. /**
  105800. * Get the friendly name associated with the input class.
  105801. * @returns the input friendly name
  105802. */
  105803. getSimpleName(): string;
  105804. /**
  105805. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105806. * allow modification of the heightOffset value.
  105807. */
  105808. private _modifierHeightOffset;
  105809. /**
  105810. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105811. * allow modification of the rotationOffset value.
  105812. */
  105813. private _modifierRotationOffset;
  105814. /**
  105815. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105816. * allow modification of the radius value.
  105817. */
  105818. private _modifierRadius;
  105819. }
  105820. }
  105821. declare module BABYLON {
  105822. interface FreeCameraInputsManager {
  105823. /**
  105824. * @hidden
  105825. */
  105826. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105827. /**
  105828. * Add orientation input support to the input manager.
  105829. * @returns the current input manager
  105830. */
  105831. addDeviceOrientation(): FreeCameraInputsManager;
  105832. }
  105833. /**
  105834. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105835. * Screen rotation is taken into account.
  105836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105837. */
  105838. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105839. private _camera;
  105840. private _screenOrientationAngle;
  105841. private _constantTranform;
  105842. private _screenQuaternion;
  105843. private _alpha;
  105844. private _beta;
  105845. private _gamma;
  105846. /**
  105847. * Can be used to detect if a device orientation sensor is availible on a device
  105848. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105849. * @returns a promise that will resolve on orientation change
  105850. */
  105851. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105852. /**
  105853. * @hidden
  105854. */
  105855. _onDeviceOrientationChangedObservable: Observable<void>;
  105856. /**
  105857. * Instantiates a new input
  105858. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105859. */
  105860. constructor();
  105861. /**
  105862. * Define the camera controlled by the input.
  105863. */
  105864. camera: FreeCamera;
  105865. /**
  105866. * Attach the input controls to a specific dom element to get the input from.
  105867. * @param element Defines the element the controls should be listened from
  105868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105869. */
  105870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105871. private _orientationChanged;
  105872. private _deviceOrientation;
  105873. /**
  105874. * Detach the current controls from the specified dom element.
  105875. * @param element Defines the element to stop listening the inputs from
  105876. */
  105877. detachControl(element: Nullable<HTMLElement>): void;
  105878. /**
  105879. * Update the current camera state depending on the inputs that have been used this frame.
  105880. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105881. */
  105882. checkInputs(): void;
  105883. /**
  105884. * Gets the class name of the current intput.
  105885. * @returns the class name
  105886. */
  105887. getClassName(): string;
  105888. /**
  105889. * Get the friendly name associated with the input class.
  105890. * @returns the input friendly name
  105891. */
  105892. getSimpleName(): string;
  105893. }
  105894. }
  105895. declare module BABYLON {
  105896. /**
  105897. * Manage the gamepad inputs to control a free camera.
  105898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105899. */
  105900. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105901. /**
  105902. * Define the camera the input is attached to.
  105903. */
  105904. camera: FreeCamera;
  105905. /**
  105906. * Define the Gamepad controlling the input
  105907. */
  105908. gamepad: Nullable<Gamepad>;
  105909. /**
  105910. * Defines the gamepad rotation sensiblity.
  105911. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105912. */
  105913. gamepadAngularSensibility: number;
  105914. /**
  105915. * Defines the gamepad move sensiblity.
  105916. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105917. */
  105918. gamepadMoveSensibility: number;
  105919. private _yAxisScale;
  105920. /**
  105921. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105922. */
  105923. invertYAxis: boolean;
  105924. private _onGamepadConnectedObserver;
  105925. private _onGamepadDisconnectedObserver;
  105926. private _cameraTransform;
  105927. private _deltaTransform;
  105928. private _vector3;
  105929. private _vector2;
  105930. /**
  105931. * Attach the input controls to a specific dom element to get the input from.
  105932. * @param element Defines the element the controls should be listened from
  105933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105934. */
  105935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105936. /**
  105937. * Detach the current controls from the specified dom element.
  105938. * @param element Defines the element to stop listening the inputs from
  105939. */
  105940. detachControl(element: Nullable<HTMLElement>): void;
  105941. /**
  105942. * Update the current camera state depending on the inputs that have been used this frame.
  105943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105944. */
  105945. checkInputs(): void;
  105946. /**
  105947. * Gets the class name of the current intput.
  105948. * @returns the class name
  105949. */
  105950. getClassName(): string;
  105951. /**
  105952. * Get the friendly name associated with the input class.
  105953. * @returns the input friendly name
  105954. */
  105955. getSimpleName(): string;
  105956. }
  105957. }
  105958. declare module BABYLON {
  105959. /**
  105960. * Defines the potential axis of a Joystick
  105961. */
  105962. export enum JoystickAxis {
  105963. /** X axis */
  105964. X = 0,
  105965. /** Y axis */
  105966. Y = 1,
  105967. /** Z axis */
  105968. Z = 2
  105969. }
  105970. /**
  105971. * Class used to define virtual joystick (used in touch mode)
  105972. */
  105973. export class VirtualJoystick {
  105974. /**
  105975. * Gets or sets a boolean indicating that left and right values must be inverted
  105976. */
  105977. reverseLeftRight: boolean;
  105978. /**
  105979. * Gets or sets a boolean indicating that up and down values must be inverted
  105980. */
  105981. reverseUpDown: boolean;
  105982. /**
  105983. * Gets the offset value for the position (ie. the change of the position value)
  105984. */
  105985. deltaPosition: Vector3;
  105986. /**
  105987. * Gets a boolean indicating if the virtual joystick was pressed
  105988. */
  105989. pressed: boolean;
  105990. /**
  105991. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105992. */
  105993. static Canvas: Nullable<HTMLCanvasElement>;
  105994. private static _globalJoystickIndex;
  105995. private static vjCanvasContext;
  105996. private static vjCanvasWidth;
  105997. private static vjCanvasHeight;
  105998. private static halfWidth;
  105999. private _action;
  106000. private _axisTargetedByLeftAndRight;
  106001. private _axisTargetedByUpAndDown;
  106002. private _joystickSensibility;
  106003. private _inversedSensibility;
  106004. private _joystickPointerID;
  106005. private _joystickColor;
  106006. private _joystickPointerPos;
  106007. private _joystickPreviousPointerPos;
  106008. private _joystickPointerStartPos;
  106009. private _deltaJoystickVector;
  106010. private _leftJoystick;
  106011. private _touches;
  106012. private _onPointerDownHandlerRef;
  106013. private _onPointerMoveHandlerRef;
  106014. private _onPointerUpHandlerRef;
  106015. private _onResize;
  106016. /**
  106017. * Creates a new virtual joystick
  106018. * @param leftJoystick defines that the joystick is for left hand (false by default)
  106019. */
  106020. constructor(leftJoystick?: boolean);
  106021. /**
  106022. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  106023. * @param newJoystickSensibility defines the new sensibility
  106024. */
  106025. setJoystickSensibility(newJoystickSensibility: number): void;
  106026. private _onPointerDown;
  106027. private _onPointerMove;
  106028. private _onPointerUp;
  106029. /**
  106030. * Change the color of the virtual joystick
  106031. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  106032. */
  106033. setJoystickColor(newColor: string): void;
  106034. /**
  106035. * Defines a callback to call when the joystick is touched
  106036. * @param action defines the callback
  106037. */
  106038. setActionOnTouch(action: () => any): void;
  106039. /**
  106040. * Defines which axis you'd like to control for left & right
  106041. * @param axis defines the axis to use
  106042. */
  106043. setAxisForLeftRight(axis: JoystickAxis): void;
  106044. /**
  106045. * Defines which axis you'd like to control for up & down
  106046. * @param axis defines the axis to use
  106047. */
  106048. setAxisForUpDown(axis: JoystickAxis): void;
  106049. private _drawVirtualJoystick;
  106050. /**
  106051. * Release internal HTML canvas
  106052. */
  106053. releaseCanvas(): void;
  106054. }
  106055. }
  106056. declare module BABYLON {
  106057. interface FreeCameraInputsManager {
  106058. /**
  106059. * Add virtual joystick input support to the input manager.
  106060. * @returns the current input manager
  106061. */
  106062. addVirtualJoystick(): FreeCameraInputsManager;
  106063. }
  106064. /**
  106065. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  106066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106067. */
  106068. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  106069. /**
  106070. * Defines the camera the input is attached to.
  106071. */
  106072. camera: FreeCamera;
  106073. private _leftjoystick;
  106074. private _rightjoystick;
  106075. /**
  106076. * Gets the left stick of the virtual joystick.
  106077. * @returns The virtual Joystick
  106078. */
  106079. getLeftJoystick(): VirtualJoystick;
  106080. /**
  106081. * Gets the right stick of the virtual joystick.
  106082. * @returns The virtual Joystick
  106083. */
  106084. getRightJoystick(): VirtualJoystick;
  106085. /**
  106086. * Update the current camera state depending on the inputs that have been used this frame.
  106087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106088. */
  106089. checkInputs(): void;
  106090. /**
  106091. * Attach the input controls to a specific dom element to get the input from.
  106092. * @param element Defines the element the controls should be listened from
  106093. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106094. */
  106095. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106096. /**
  106097. * Detach the current controls from the specified dom element.
  106098. * @param element Defines the element to stop listening the inputs from
  106099. */
  106100. detachControl(element: Nullable<HTMLElement>): void;
  106101. /**
  106102. * Gets the class name of the current intput.
  106103. * @returns the class name
  106104. */
  106105. getClassName(): string;
  106106. /**
  106107. * Get the friendly name associated with the input class.
  106108. * @returns the input friendly name
  106109. */
  106110. getSimpleName(): string;
  106111. }
  106112. }
  106113. declare module BABYLON {
  106114. /**
  106115. * This represents a FPS type of camera controlled by touch.
  106116. * This is like a universal camera minus the Gamepad controls.
  106117. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106118. */
  106119. export class TouchCamera extends FreeCamera {
  106120. /**
  106121. * Defines the touch sensibility for rotation.
  106122. * The higher the faster.
  106123. */
  106124. touchAngularSensibility: number;
  106125. /**
  106126. * Defines the touch sensibility for move.
  106127. * The higher the faster.
  106128. */
  106129. touchMoveSensibility: number;
  106130. /**
  106131. * Instantiates a new touch camera.
  106132. * This represents a FPS type of camera controlled by touch.
  106133. * This is like a universal camera minus the Gamepad controls.
  106134. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106135. * @param name Define the name of the camera in the scene
  106136. * @param position Define the start position of the camera in the scene
  106137. * @param scene Define the scene the camera belongs to
  106138. */
  106139. constructor(name: string, position: Vector3, scene: Scene);
  106140. /**
  106141. * Gets the current object class name.
  106142. * @return the class name
  106143. */
  106144. getClassName(): string;
  106145. /** @hidden */
  106146. _setupInputs(): void;
  106147. }
  106148. }
  106149. declare module BABYLON {
  106150. /**
  106151. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  106152. * being tilted forward or back and left or right.
  106153. */
  106154. export class DeviceOrientationCamera extends FreeCamera {
  106155. private _initialQuaternion;
  106156. private _quaternionCache;
  106157. private _tmpDragQuaternion;
  106158. private _disablePointerInputWhenUsingDeviceOrientation;
  106159. /**
  106160. * Creates a new device orientation camera
  106161. * @param name The name of the camera
  106162. * @param position The start position camera
  106163. * @param scene The scene the camera belongs to
  106164. */
  106165. constructor(name: string, position: Vector3, scene: Scene);
  106166. /**
  106167. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  106168. */
  106169. disablePointerInputWhenUsingDeviceOrientation: boolean;
  106170. private _dragFactor;
  106171. /**
  106172. * Enabled turning on the y axis when the orientation sensor is active
  106173. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  106174. */
  106175. enableHorizontalDragging(dragFactor?: number): void;
  106176. /**
  106177. * Gets the current instance class name ("DeviceOrientationCamera").
  106178. * This helps avoiding instanceof at run time.
  106179. * @returns the class name
  106180. */
  106181. getClassName(): string;
  106182. /**
  106183. * @hidden
  106184. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  106185. */
  106186. _checkInputs(): void;
  106187. /**
  106188. * Reset the camera to its default orientation on the specified axis only.
  106189. * @param axis The axis to reset
  106190. */
  106191. resetToCurrentRotation(axis?: Axis): void;
  106192. }
  106193. }
  106194. declare module BABYLON {
  106195. /**
  106196. * Defines supported buttons for XBox360 compatible gamepads
  106197. */
  106198. export enum Xbox360Button {
  106199. /** A */
  106200. A = 0,
  106201. /** B */
  106202. B = 1,
  106203. /** X */
  106204. X = 2,
  106205. /** Y */
  106206. Y = 3,
  106207. /** Start */
  106208. Start = 4,
  106209. /** Back */
  106210. Back = 5,
  106211. /** Left button */
  106212. LB = 6,
  106213. /** Right button */
  106214. RB = 7,
  106215. /** Left stick */
  106216. LeftStick = 8,
  106217. /** Right stick */
  106218. RightStick = 9
  106219. }
  106220. /** Defines values for XBox360 DPad */
  106221. export enum Xbox360Dpad {
  106222. /** Up */
  106223. Up = 0,
  106224. /** Down */
  106225. Down = 1,
  106226. /** Left */
  106227. Left = 2,
  106228. /** Right */
  106229. Right = 3
  106230. }
  106231. /**
  106232. * Defines a XBox360 gamepad
  106233. */
  106234. export class Xbox360Pad extends Gamepad {
  106235. private _leftTrigger;
  106236. private _rightTrigger;
  106237. private _onlefttriggerchanged;
  106238. private _onrighttriggerchanged;
  106239. private _onbuttondown;
  106240. private _onbuttonup;
  106241. private _ondpaddown;
  106242. private _ondpadup;
  106243. /** Observable raised when a button is pressed */
  106244. onButtonDownObservable: Observable<Xbox360Button>;
  106245. /** Observable raised when a button is released */
  106246. onButtonUpObservable: Observable<Xbox360Button>;
  106247. /** Observable raised when a pad is pressed */
  106248. onPadDownObservable: Observable<Xbox360Dpad>;
  106249. /** Observable raised when a pad is released */
  106250. onPadUpObservable: Observable<Xbox360Dpad>;
  106251. private _buttonA;
  106252. private _buttonB;
  106253. private _buttonX;
  106254. private _buttonY;
  106255. private _buttonBack;
  106256. private _buttonStart;
  106257. private _buttonLB;
  106258. private _buttonRB;
  106259. private _buttonLeftStick;
  106260. private _buttonRightStick;
  106261. private _dPadUp;
  106262. private _dPadDown;
  106263. private _dPadLeft;
  106264. private _dPadRight;
  106265. private _isXboxOnePad;
  106266. /**
  106267. * Creates a new XBox360 gamepad object
  106268. * @param id defines the id of this gamepad
  106269. * @param index defines its index
  106270. * @param gamepad defines the internal HTML gamepad object
  106271. * @param xboxOne defines if it is a XBox One gamepad
  106272. */
  106273. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  106274. /**
  106275. * Defines the callback to call when left trigger is pressed
  106276. * @param callback defines the callback to use
  106277. */
  106278. onlefttriggerchanged(callback: (value: number) => void): void;
  106279. /**
  106280. * Defines the callback to call when right trigger is pressed
  106281. * @param callback defines the callback to use
  106282. */
  106283. onrighttriggerchanged(callback: (value: number) => void): void;
  106284. /**
  106285. * Gets the left trigger value
  106286. */
  106287. /**
  106288. * Sets the left trigger value
  106289. */
  106290. leftTrigger: number;
  106291. /**
  106292. * Gets the right trigger value
  106293. */
  106294. /**
  106295. * Sets the right trigger value
  106296. */
  106297. rightTrigger: number;
  106298. /**
  106299. * Defines the callback to call when a button is pressed
  106300. * @param callback defines the callback to use
  106301. */
  106302. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  106303. /**
  106304. * Defines the callback to call when a button is released
  106305. * @param callback defines the callback to use
  106306. */
  106307. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  106308. /**
  106309. * Defines the callback to call when a pad is pressed
  106310. * @param callback defines the callback to use
  106311. */
  106312. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  106313. /**
  106314. * Defines the callback to call when a pad is released
  106315. * @param callback defines the callback to use
  106316. */
  106317. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  106318. private _setButtonValue;
  106319. private _setDPadValue;
  106320. /**
  106321. * Gets the value of the `A` button
  106322. */
  106323. /**
  106324. * Sets the value of the `A` button
  106325. */
  106326. buttonA: number;
  106327. /**
  106328. * Gets the value of the `B` button
  106329. */
  106330. /**
  106331. * Sets the value of the `B` button
  106332. */
  106333. buttonB: number;
  106334. /**
  106335. * Gets the value of the `X` button
  106336. */
  106337. /**
  106338. * Sets the value of the `X` button
  106339. */
  106340. buttonX: number;
  106341. /**
  106342. * Gets the value of the `Y` button
  106343. */
  106344. /**
  106345. * Sets the value of the `Y` button
  106346. */
  106347. buttonY: number;
  106348. /**
  106349. * Gets the value of the `Start` button
  106350. */
  106351. /**
  106352. * Sets the value of the `Start` button
  106353. */
  106354. buttonStart: number;
  106355. /**
  106356. * Gets the value of the `Back` button
  106357. */
  106358. /**
  106359. * Sets the value of the `Back` button
  106360. */
  106361. buttonBack: number;
  106362. /**
  106363. * Gets the value of the `Left` button
  106364. */
  106365. /**
  106366. * Sets the value of the `Left` button
  106367. */
  106368. buttonLB: number;
  106369. /**
  106370. * Gets the value of the `Right` button
  106371. */
  106372. /**
  106373. * Sets the value of the `Right` button
  106374. */
  106375. buttonRB: number;
  106376. /**
  106377. * Gets the value of the Left joystick
  106378. */
  106379. /**
  106380. * Sets the value of the Left joystick
  106381. */
  106382. buttonLeftStick: number;
  106383. /**
  106384. * Gets the value of the Right joystick
  106385. */
  106386. /**
  106387. * Sets the value of the Right joystick
  106388. */
  106389. buttonRightStick: number;
  106390. /**
  106391. * Gets the value of D-pad up
  106392. */
  106393. /**
  106394. * Sets the value of D-pad up
  106395. */
  106396. dPadUp: number;
  106397. /**
  106398. * Gets the value of D-pad down
  106399. */
  106400. /**
  106401. * Sets the value of D-pad down
  106402. */
  106403. dPadDown: number;
  106404. /**
  106405. * Gets the value of D-pad left
  106406. */
  106407. /**
  106408. * Sets the value of D-pad left
  106409. */
  106410. dPadLeft: number;
  106411. /**
  106412. * Gets the value of D-pad right
  106413. */
  106414. /**
  106415. * Sets the value of D-pad right
  106416. */
  106417. dPadRight: number;
  106418. /**
  106419. * Force the gamepad to synchronize with device values
  106420. */
  106421. update(): void;
  106422. /**
  106423. * Disposes the gamepad
  106424. */
  106425. dispose(): void;
  106426. }
  106427. }
  106428. declare module BABYLON {
  106429. /**
  106430. * Defines supported buttons for DualShock compatible gamepads
  106431. */
  106432. export enum DualShockButton {
  106433. /** Cross */
  106434. Cross = 0,
  106435. /** Circle */
  106436. Circle = 1,
  106437. /** Square */
  106438. Square = 2,
  106439. /** Triangle */
  106440. Triangle = 3,
  106441. /** Options */
  106442. Options = 4,
  106443. /** Share */
  106444. Share = 5,
  106445. /** L1 */
  106446. L1 = 6,
  106447. /** R1 */
  106448. R1 = 7,
  106449. /** Left stick */
  106450. LeftStick = 8,
  106451. /** Right stick */
  106452. RightStick = 9
  106453. }
  106454. /** Defines values for DualShock DPad */
  106455. export enum DualShockDpad {
  106456. /** Up */
  106457. Up = 0,
  106458. /** Down */
  106459. Down = 1,
  106460. /** Left */
  106461. Left = 2,
  106462. /** Right */
  106463. Right = 3
  106464. }
  106465. /**
  106466. * Defines a DualShock gamepad
  106467. */
  106468. export class DualShockPad extends Gamepad {
  106469. private _leftTrigger;
  106470. private _rightTrigger;
  106471. private _onlefttriggerchanged;
  106472. private _onrighttriggerchanged;
  106473. private _onbuttondown;
  106474. private _onbuttonup;
  106475. private _ondpaddown;
  106476. private _ondpadup;
  106477. /** Observable raised when a button is pressed */
  106478. onButtonDownObservable: Observable<DualShockButton>;
  106479. /** Observable raised when a button is released */
  106480. onButtonUpObservable: Observable<DualShockButton>;
  106481. /** Observable raised when a pad is pressed */
  106482. onPadDownObservable: Observable<DualShockDpad>;
  106483. /** Observable raised when a pad is released */
  106484. onPadUpObservable: Observable<DualShockDpad>;
  106485. private _buttonCross;
  106486. private _buttonCircle;
  106487. private _buttonSquare;
  106488. private _buttonTriangle;
  106489. private _buttonShare;
  106490. private _buttonOptions;
  106491. private _buttonL1;
  106492. private _buttonR1;
  106493. private _buttonLeftStick;
  106494. private _buttonRightStick;
  106495. private _dPadUp;
  106496. private _dPadDown;
  106497. private _dPadLeft;
  106498. private _dPadRight;
  106499. /**
  106500. * Creates a new DualShock gamepad object
  106501. * @param id defines the id of this gamepad
  106502. * @param index defines its index
  106503. * @param gamepad defines the internal HTML gamepad object
  106504. */
  106505. constructor(id: string, index: number, gamepad: any);
  106506. /**
  106507. * Defines the callback to call when left trigger is pressed
  106508. * @param callback defines the callback to use
  106509. */
  106510. onlefttriggerchanged(callback: (value: number) => void): void;
  106511. /**
  106512. * Defines the callback to call when right trigger is pressed
  106513. * @param callback defines the callback to use
  106514. */
  106515. onrighttriggerchanged(callback: (value: number) => void): void;
  106516. /**
  106517. * Gets the left trigger value
  106518. */
  106519. /**
  106520. * Sets the left trigger value
  106521. */
  106522. leftTrigger: number;
  106523. /**
  106524. * Gets the right trigger value
  106525. */
  106526. /**
  106527. * Sets the right trigger value
  106528. */
  106529. rightTrigger: number;
  106530. /**
  106531. * Defines the callback to call when a button is pressed
  106532. * @param callback defines the callback to use
  106533. */
  106534. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  106535. /**
  106536. * Defines the callback to call when a button is released
  106537. * @param callback defines the callback to use
  106538. */
  106539. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  106540. /**
  106541. * Defines the callback to call when a pad is pressed
  106542. * @param callback defines the callback to use
  106543. */
  106544. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  106545. /**
  106546. * Defines the callback to call when a pad is released
  106547. * @param callback defines the callback to use
  106548. */
  106549. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  106550. private _setButtonValue;
  106551. private _setDPadValue;
  106552. /**
  106553. * Gets the value of the `Cross` button
  106554. */
  106555. /**
  106556. * Sets the value of the `Cross` button
  106557. */
  106558. buttonCross: number;
  106559. /**
  106560. * Gets the value of the `Circle` button
  106561. */
  106562. /**
  106563. * Sets the value of the `Circle` button
  106564. */
  106565. buttonCircle: number;
  106566. /**
  106567. * Gets the value of the `Square` button
  106568. */
  106569. /**
  106570. * Sets the value of the `Square` button
  106571. */
  106572. buttonSquare: number;
  106573. /**
  106574. * Gets the value of the `Triangle` button
  106575. */
  106576. /**
  106577. * Sets the value of the `Triangle` button
  106578. */
  106579. buttonTriangle: number;
  106580. /**
  106581. * Gets the value of the `Options` button
  106582. */
  106583. /**
  106584. * Sets the value of the `Options` button
  106585. */
  106586. buttonOptions: number;
  106587. /**
  106588. * Gets the value of the `Share` button
  106589. */
  106590. /**
  106591. * Sets the value of the `Share` button
  106592. */
  106593. buttonShare: number;
  106594. /**
  106595. * Gets the value of the `L1` button
  106596. */
  106597. /**
  106598. * Sets the value of the `L1` button
  106599. */
  106600. buttonL1: number;
  106601. /**
  106602. * Gets the value of the `R1` button
  106603. */
  106604. /**
  106605. * Sets the value of the `R1` button
  106606. */
  106607. buttonR1: number;
  106608. /**
  106609. * Gets the value of the Left joystick
  106610. */
  106611. /**
  106612. * Sets the value of the Left joystick
  106613. */
  106614. buttonLeftStick: number;
  106615. /**
  106616. * Gets the value of the Right joystick
  106617. */
  106618. /**
  106619. * Sets the value of the Right joystick
  106620. */
  106621. buttonRightStick: number;
  106622. /**
  106623. * Gets the value of D-pad up
  106624. */
  106625. /**
  106626. * Sets the value of D-pad up
  106627. */
  106628. dPadUp: number;
  106629. /**
  106630. * Gets the value of D-pad down
  106631. */
  106632. /**
  106633. * Sets the value of D-pad down
  106634. */
  106635. dPadDown: number;
  106636. /**
  106637. * Gets the value of D-pad left
  106638. */
  106639. /**
  106640. * Sets the value of D-pad left
  106641. */
  106642. dPadLeft: number;
  106643. /**
  106644. * Gets the value of D-pad right
  106645. */
  106646. /**
  106647. * Sets the value of D-pad right
  106648. */
  106649. dPadRight: number;
  106650. /**
  106651. * Force the gamepad to synchronize with device values
  106652. */
  106653. update(): void;
  106654. /**
  106655. * Disposes the gamepad
  106656. */
  106657. dispose(): void;
  106658. }
  106659. }
  106660. declare module BABYLON {
  106661. /**
  106662. * Manager for handling gamepads
  106663. */
  106664. export class GamepadManager {
  106665. private _scene?;
  106666. private _babylonGamepads;
  106667. private _oneGamepadConnected;
  106668. /** @hidden */
  106669. _isMonitoring: boolean;
  106670. private _gamepadEventSupported;
  106671. private _gamepadSupport;
  106672. /**
  106673. * observable to be triggered when the gamepad controller has been connected
  106674. */
  106675. onGamepadConnectedObservable: Observable<Gamepad>;
  106676. /**
  106677. * observable to be triggered when the gamepad controller has been disconnected
  106678. */
  106679. onGamepadDisconnectedObservable: Observable<Gamepad>;
  106680. private _onGamepadConnectedEvent;
  106681. private _onGamepadDisconnectedEvent;
  106682. /**
  106683. * Initializes the gamepad manager
  106684. * @param _scene BabylonJS scene
  106685. */
  106686. constructor(_scene?: Scene | undefined);
  106687. /**
  106688. * The gamepads in the game pad manager
  106689. */
  106690. readonly gamepads: Gamepad[];
  106691. /**
  106692. * Get the gamepad controllers based on type
  106693. * @param type The type of gamepad controller
  106694. * @returns Nullable gamepad
  106695. */
  106696. getGamepadByType(type?: number): Nullable<Gamepad>;
  106697. /**
  106698. * Disposes the gamepad manager
  106699. */
  106700. dispose(): void;
  106701. private _addNewGamepad;
  106702. private _startMonitoringGamepads;
  106703. private _stopMonitoringGamepads;
  106704. /** @hidden */
  106705. _checkGamepadsStatus(): void;
  106706. private _updateGamepadObjects;
  106707. }
  106708. }
  106709. declare module BABYLON {
  106710. interface Scene {
  106711. /** @hidden */
  106712. _gamepadManager: Nullable<GamepadManager>;
  106713. /**
  106714. * Gets the gamepad manager associated with the scene
  106715. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  106716. */
  106717. gamepadManager: GamepadManager;
  106718. }
  106719. /**
  106720. * Interface representing a free camera inputs manager
  106721. */
  106722. interface FreeCameraInputsManager {
  106723. /**
  106724. * Adds gamepad input support to the FreeCameraInputsManager.
  106725. * @returns the FreeCameraInputsManager
  106726. */
  106727. addGamepad(): FreeCameraInputsManager;
  106728. }
  106729. /**
  106730. * Interface representing an arc rotate camera inputs manager
  106731. */
  106732. interface ArcRotateCameraInputsManager {
  106733. /**
  106734. * Adds gamepad input support to the ArcRotateCamera InputManager.
  106735. * @returns the camera inputs manager
  106736. */
  106737. addGamepad(): ArcRotateCameraInputsManager;
  106738. }
  106739. /**
  106740. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106741. */
  106742. export class GamepadSystemSceneComponent implements ISceneComponent {
  106743. /**
  106744. * The component name helpfull to identify the component in the list of scene components.
  106745. */
  106746. readonly name: string;
  106747. /**
  106748. * The scene the component belongs to.
  106749. */
  106750. scene: Scene;
  106751. /**
  106752. * Creates a new instance of the component for the given scene
  106753. * @param scene Defines the scene to register the component in
  106754. */
  106755. constructor(scene: Scene);
  106756. /**
  106757. * Registers the component in a given scene
  106758. */
  106759. register(): void;
  106760. /**
  106761. * Rebuilds the elements related to this component in case of
  106762. * context lost for instance.
  106763. */
  106764. rebuild(): void;
  106765. /**
  106766. * Disposes the component and the associated ressources
  106767. */
  106768. dispose(): void;
  106769. private _beforeCameraUpdate;
  106770. }
  106771. }
  106772. declare module BABYLON {
  106773. /**
  106774. * 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,
  106775. * which still works and will still be found in many Playgrounds.
  106776. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106777. */
  106778. export class UniversalCamera extends TouchCamera {
  106779. /**
  106780. * Defines the gamepad rotation sensiblity.
  106781. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106782. */
  106783. gamepadAngularSensibility: number;
  106784. /**
  106785. * Defines the gamepad move sensiblity.
  106786. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106787. */
  106788. gamepadMoveSensibility: number;
  106789. /**
  106790. * 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,
  106791. * which still works and will still be found in many Playgrounds.
  106792. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106793. * @param name Define the name of the camera in the scene
  106794. * @param position Define the start position of the camera in the scene
  106795. * @param scene Define the scene the camera belongs to
  106796. */
  106797. constructor(name: string, position: Vector3, scene: Scene);
  106798. /**
  106799. * Gets the current object class name.
  106800. * @return the class name
  106801. */
  106802. getClassName(): string;
  106803. }
  106804. }
  106805. declare module BABYLON {
  106806. /**
  106807. * This represents a FPS type of camera. This is only here for back compat purpose.
  106808. * Please use the UniversalCamera instead as both are identical.
  106809. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106810. */
  106811. export class GamepadCamera extends UniversalCamera {
  106812. /**
  106813. * Instantiates a new Gamepad Camera
  106814. * This represents a FPS type of camera. This is only here for back compat purpose.
  106815. * Please use the UniversalCamera instead as both are identical.
  106816. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106817. * @param name Define the name of the camera in the scene
  106818. * @param position Define the start position of the camera in the scene
  106819. * @param scene Define the scene the camera belongs to
  106820. */
  106821. constructor(name: string, position: Vector3, scene: Scene);
  106822. /**
  106823. * Gets the current object class name.
  106824. * @return the class name
  106825. */
  106826. getClassName(): string;
  106827. }
  106828. }
  106829. declare module BABYLON {
  106830. /** @hidden */
  106831. export var passPixelShader: {
  106832. name: string;
  106833. shader: string;
  106834. };
  106835. }
  106836. declare module BABYLON {
  106837. /** @hidden */
  106838. export var passCubePixelShader: {
  106839. name: string;
  106840. shader: string;
  106841. };
  106842. }
  106843. declare module BABYLON {
  106844. /**
  106845. * PassPostProcess which produces an output the same as it's input
  106846. */
  106847. export class PassPostProcess extends PostProcess {
  106848. /**
  106849. * Creates the PassPostProcess
  106850. * @param name The name of the effect.
  106851. * @param options The required width/height ratio to downsize to before computing the render pass.
  106852. * @param camera The camera to apply the render pass to.
  106853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106854. * @param engine The engine which the post process will be applied. (default: current engine)
  106855. * @param reusable If the post process can be reused on the same frame. (default: false)
  106856. * @param textureType The type of texture to be used when performing the post processing.
  106857. * @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)
  106858. */
  106859. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106860. }
  106861. /**
  106862. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106863. */
  106864. export class PassCubePostProcess extends PostProcess {
  106865. private _face;
  106866. /**
  106867. * Gets or sets the cube face to display.
  106868. * * 0 is +X
  106869. * * 1 is -X
  106870. * * 2 is +Y
  106871. * * 3 is -Y
  106872. * * 4 is +Z
  106873. * * 5 is -Z
  106874. */
  106875. face: number;
  106876. /**
  106877. * Creates the PassCubePostProcess
  106878. * @param name The name of the effect.
  106879. * @param options The required width/height ratio to downsize to before computing the render pass.
  106880. * @param camera The camera to apply the render pass to.
  106881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106882. * @param engine The engine which the post process will be applied. (default: current engine)
  106883. * @param reusable If the post process can be reused on the same frame. (default: false)
  106884. * @param textureType The type of texture to be used when performing the post processing.
  106885. * @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)
  106886. */
  106887. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106888. }
  106889. }
  106890. declare module BABYLON {
  106891. /** @hidden */
  106892. export var anaglyphPixelShader: {
  106893. name: string;
  106894. shader: string;
  106895. };
  106896. }
  106897. declare module BABYLON {
  106898. /**
  106899. * Postprocess used to generate anaglyphic rendering
  106900. */
  106901. export class AnaglyphPostProcess extends PostProcess {
  106902. private _passedProcess;
  106903. /**
  106904. * Creates a new AnaglyphPostProcess
  106905. * @param name defines postprocess name
  106906. * @param options defines creation options or target ratio scale
  106907. * @param rigCameras defines cameras using this postprocess
  106908. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106909. * @param engine defines hosting engine
  106910. * @param reusable defines if the postprocess will be reused multiple times per frame
  106911. */
  106912. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106913. }
  106914. }
  106915. declare module BABYLON {
  106916. /**
  106917. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106918. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106919. */
  106920. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106921. /**
  106922. * Creates a new AnaglyphArcRotateCamera
  106923. * @param name defines camera name
  106924. * @param alpha defines alpha angle (in radians)
  106925. * @param beta defines beta angle (in radians)
  106926. * @param radius defines radius
  106927. * @param target defines camera target
  106928. * @param interaxialDistance defines distance between each color axis
  106929. * @param scene defines the hosting scene
  106930. */
  106931. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106932. /**
  106933. * Gets camera class name
  106934. * @returns AnaglyphArcRotateCamera
  106935. */
  106936. getClassName(): string;
  106937. }
  106938. }
  106939. declare module BABYLON {
  106940. /**
  106941. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106942. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106943. */
  106944. export class AnaglyphFreeCamera extends FreeCamera {
  106945. /**
  106946. * Creates a new AnaglyphFreeCamera
  106947. * @param name defines camera name
  106948. * @param position defines initial position
  106949. * @param interaxialDistance defines distance between each color axis
  106950. * @param scene defines the hosting scene
  106951. */
  106952. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106953. /**
  106954. * Gets camera class name
  106955. * @returns AnaglyphFreeCamera
  106956. */
  106957. getClassName(): string;
  106958. }
  106959. }
  106960. declare module BABYLON {
  106961. /**
  106962. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106963. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106964. */
  106965. export class AnaglyphGamepadCamera extends GamepadCamera {
  106966. /**
  106967. * Creates a new AnaglyphGamepadCamera
  106968. * @param name defines camera name
  106969. * @param position defines initial position
  106970. * @param interaxialDistance defines distance between each color axis
  106971. * @param scene defines the hosting scene
  106972. */
  106973. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106974. /**
  106975. * Gets camera class name
  106976. * @returns AnaglyphGamepadCamera
  106977. */
  106978. getClassName(): string;
  106979. }
  106980. }
  106981. declare module BABYLON {
  106982. /**
  106983. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106984. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106985. */
  106986. export class AnaglyphUniversalCamera extends UniversalCamera {
  106987. /**
  106988. * Creates a new AnaglyphUniversalCamera
  106989. * @param name defines camera name
  106990. * @param position defines initial position
  106991. * @param interaxialDistance defines distance between each color axis
  106992. * @param scene defines the hosting scene
  106993. */
  106994. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106995. /**
  106996. * Gets camera class name
  106997. * @returns AnaglyphUniversalCamera
  106998. */
  106999. getClassName(): string;
  107000. }
  107001. }
  107002. declare module BABYLON {
  107003. /** @hidden */
  107004. export var stereoscopicInterlacePixelShader: {
  107005. name: string;
  107006. shader: string;
  107007. };
  107008. }
  107009. declare module BABYLON {
  107010. /**
  107011. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  107012. */
  107013. export class StereoscopicInterlacePostProcess extends PostProcess {
  107014. private _stepSize;
  107015. private _passedProcess;
  107016. /**
  107017. * Initializes a StereoscopicInterlacePostProcess
  107018. * @param name The name of the effect.
  107019. * @param rigCameras The rig cameras to be appled to the post process
  107020. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  107021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107022. * @param engine The engine which the post process will be applied. (default: current engine)
  107023. * @param reusable If the post process can be reused on the same frame. (default: false)
  107024. */
  107025. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107026. }
  107027. }
  107028. declare module BABYLON {
  107029. /**
  107030. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  107031. * @see http://doc.babylonjs.com/features/cameras
  107032. */
  107033. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  107034. /**
  107035. * Creates a new StereoscopicArcRotateCamera
  107036. * @param name defines camera name
  107037. * @param alpha defines alpha angle (in radians)
  107038. * @param beta defines beta angle (in radians)
  107039. * @param radius defines radius
  107040. * @param target defines camera target
  107041. * @param interaxialDistance defines distance between each color axis
  107042. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107043. * @param scene defines the hosting scene
  107044. */
  107045. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107046. /**
  107047. * Gets camera class name
  107048. * @returns StereoscopicArcRotateCamera
  107049. */
  107050. getClassName(): string;
  107051. }
  107052. }
  107053. declare module BABYLON {
  107054. /**
  107055. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  107056. * @see http://doc.babylonjs.com/features/cameras
  107057. */
  107058. export class StereoscopicFreeCamera extends FreeCamera {
  107059. /**
  107060. * Creates a new StereoscopicFreeCamera
  107061. * @param name defines camera name
  107062. * @param position defines initial position
  107063. * @param interaxialDistance defines distance between each color axis
  107064. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107065. * @param scene defines the hosting scene
  107066. */
  107067. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107068. /**
  107069. * Gets camera class name
  107070. * @returns StereoscopicFreeCamera
  107071. */
  107072. getClassName(): string;
  107073. }
  107074. }
  107075. declare module BABYLON {
  107076. /**
  107077. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  107078. * @see http://doc.babylonjs.com/features/cameras
  107079. */
  107080. export class StereoscopicGamepadCamera extends GamepadCamera {
  107081. /**
  107082. * Creates a new StereoscopicGamepadCamera
  107083. * @param name defines camera name
  107084. * @param position defines initial position
  107085. * @param interaxialDistance defines distance between each color axis
  107086. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107087. * @param scene defines the hosting scene
  107088. */
  107089. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107090. /**
  107091. * Gets camera class name
  107092. * @returns StereoscopicGamepadCamera
  107093. */
  107094. getClassName(): string;
  107095. }
  107096. }
  107097. declare module BABYLON {
  107098. /**
  107099. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  107100. * @see http://doc.babylonjs.com/features/cameras
  107101. */
  107102. export class StereoscopicUniversalCamera extends UniversalCamera {
  107103. /**
  107104. * Creates a new StereoscopicUniversalCamera
  107105. * @param name defines camera name
  107106. * @param position defines initial position
  107107. * @param interaxialDistance defines distance between each color axis
  107108. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107109. * @param scene defines the hosting scene
  107110. */
  107111. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107112. /**
  107113. * Gets camera class name
  107114. * @returns StereoscopicUniversalCamera
  107115. */
  107116. getClassName(): string;
  107117. }
  107118. }
  107119. declare module BABYLON {
  107120. /**
  107121. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  107122. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107123. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107124. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107125. */
  107126. export class VirtualJoysticksCamera extends FreeCamera {
  107127. /**
  107128. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  107129. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107130. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107131. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107132. * @param name Define the name of the camera in the scene
  107133. * @param position Define the start position of the camera in the scene
  107134. * @param scene Define the scene the camera belongs to
  107135. */
  107136. constructor(name: string, position: Vector3, scene: Scene);
  107137. /**
  107138. * Gets the current object class name.
  107139. * @return the class name
  107140. */
  107141. getClassName(): string;
  107142. }
  107143. }
  107144. declare module BABYLON {
  107145. /**
  107146. * This represents all the required metrics to create a VR camera.
  107147. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  107148. */
  107149. export class VRCameraMetrics {
  107150. /**
  107151. * Define the horizontal resolution off the screen.
  107152. */
  107153. hResolution: number;
  107154. /**
  107155. * Define the vertical resolution off the screen.
  107156. */
  107157. vResolution: number;
  107158. /**
  107159. * Define the horizontal screen size.
  107160. */
  107161. hScreenSize: number;
  107162. /**
  107163. * Define the vertical screen size.
  107164. */
  107165. vScreenSize: number;
  107166. /**
  107167. * Define the vertical screen center position.
  107168. */
  107169. vScreenCenter: number;
  107170. /**
  107171. * Define the distance of the eyes to the screen.
  107172. */
  107173. eyeToScreenDistance: number;
  107174. /**
  107175. * Define the distance between both lenses
  107176. */
  107177. lensSeparationDistance: number;
  107178. /**
  107179. * Define the distance between both viewer's eyes.
  107180. */
  107181. interpupillaryDistance: number;
  107182. /**
  107183. * Define the distortion factor of the VR postprocess.
  107184. * Please, touch with care.
  107185. */
  107186. distortionK: number[];
  107187. /**
  107188. * Define the chromatic aberration correction factors for the VR post process.
  107189. */
  107190. chromaAbCorrection: number[];
  107191. /**
  107192. * Define the scale factor of the post process.
  107193. * The smaller the better but the slower.
  107194. */
  107195. postProcessScaleFactor: number;
  107196. /**
  107197. * Define an offset for the lens center.
  107198. */
  107199. lensCenterOffset: number;
  107200. /**
  107201. * Define if the current vr camera should compensate the distortion of the lense or not.
  107202. */
  107203. compensateDistortion: boolean;
  107204. /**
  107205. * Defines if multiview should be enabled when rendering (Default: false)
  107206. */
  107207. multiviewEnabled: boolean;
  107208. /**
  107209. * Gets the rendering aspect ratio based on the provided resolutions.
  107210. */
  107211. readonly aspectRatio: number;
  107212. /**
  107213. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  107214. */
  107215. readonly aspectRatioFov: number;
  107216. /**
  107217. * @hidden
  107218. */
  107219. readonly leftHMatrix: Matrix;
  107220. /**
  107221. * @hidden
  107222. */
  107223. readonly rightHMatrix: Matrix;
  107224. /**
  107225. * @hidden
  107226. */
  107227. readonly leftPreViewMatrix: Matrix;
  107228. /**
  107229. * @hidden
  107230. */
  107231. readonly rightPreViewMatrix: Matrix;
  107232. /**
  107233. * Get the default VRMetrics based on the most generic setup.
  107234. * @returns the default vr metrics
  107235. */
  107236. static GetDefault(): VRCameraMetrics;
  107237. }
  107238. }
  107239. declare module BABYLON {
  107240. /** @hidden */
  107241. export var vrDistortionCorrectionPixelShader: {
  107242. name: string;
  107243. shader: string;
  107244. };
  107245. }
  107246. declare module BABYLON {
  107247. /**
  107248. * VRDistortionCorrectionPostProcess used for mobile VR
  107249. */
  107250. export class VRDistortionCorrectionPostProcess extends PostProcess {
  107251. private _isRightEye;
  107252. private _distortionFactors;
  107253. private _postProcessScaleFactor;
  107254. private _lensCenterOffset;
  107255. private _scaleIn;
  107256. private _scaleFactor;
  107257. private _lensCenter;
  107258. /**
  107259. * Initializes the VRDistortionCorrectionPostProcess
  107260. * @param name The name of the effect.
  107261. * @param camera The camera to apply the render pass to.
  107262. * @param isRightEye If this is for the right eye distortion
  107263. * @param vrMetrics All the required metrics for the VR camera
  107264. */
  107265. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  107266. }
  107267. }
  107268. declare module BABYLON {
  107269. /**
  107270. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  107271. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107272. */
  107273. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  107274. /**
  107275. * Creates a new VRDeviceOrientationArcRotateCamera
  107276. * @param name defines camera name
  107277. * @param alpha defines the camera rotation along the logitudinal axis
  107278. * @param beta defines the camera rotation along the latitudinal axis
  107279. * @param radius defines the camera distance from its target
  107280. * @param target defines the camera target
  107281. * @param scene defines the scene the camera belongs to
  107282. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107283. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107284. */
  107285. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107286. /**
  107287. * Gets camera class name
  107288. * @returns VRDeviceOrientationArcRotateCamera
  107289. */
  107290. getClassName(): string;
  107291. }
  107292. }
  107293. declare module BABYLON {
  107294. /**
  107295. * Camera used to simulate VR rendering (based on FreeCamera)
  107296. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107297. */
  107298. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  107299. /**
  107300. * Creates a new VRDeviceOrientationFreeCamera
  107301. * @param name defines camera name
  107302. * @param position defines the start position of the camera
  107303. * @param scene defines the scene the camera belongs to
  107304. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107305. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107306. */
  107307. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107308. /**
  107309. * Gets camera class name
  107310. * @returns VRDeviceOrientationFreeCamera
  107311. */
  107312. getClassName(): string;
  107313. }
  107314. }
  107315. declare module BABYLON {
  107316. /**
  107317. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  107318. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107319. */
  107320. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  107321. /**
  107322. * Creates a new VRDeviceOrientationGamepadCamera
  107323. * @param name defines camera name
  107324. * @param position defines the start position of the camera
  107325. * @param scene defines the scene the camera belongs to
  107326. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107327. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107328. */
  107329. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107330. /**
  107331. * Gets camera class name
  107332. * @returns VRDeviceOrientationGamepadCamera
  107333. */
  107334. getClassName(): string;
  107335. }
  107336. }
  107337. declare module BABYLON {
  107338. /**
  107339. * Base class of materials working in push mode in babylon JS
  107340. * @hidden
  107341. */
  107342. export class PushMaterial extends Material {
  107343. protected _activeEffect: Effect;
  107344. protected _normalMatrix: Matrix;
  107345. /**
  107346. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  107347. * This means that the material can keep using a previous shader while a new one is being compiled.
  107348. * This is mostly used when shader parallel compilation is supported (true by default)
  107349. */
  107350. allowShaderHotSwapping: boolean;
  107351. constructor(name: string, scene: Scene);
  107352. getEffect(): Effect;
  107353. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  107354. /**
  107355. * Binds the given world matrix to the active effect
  107356. *
  107357. * @param world the matrix to bind
  107358. */
  107359. bindOnlyWorldMatrix(world: Matrix): void;
  107360. /**
  107361. * Binds the given normal matrix to the active effect
  107362. *
  107363. * @param normalMatrix the matrix to bind
  107364. */
  107365. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  107366. bind(world: Matrix, mesh?: Mesh): void;
  107367. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  107368. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  107369. }
  107370. }
  107371. declare module BABYLON {
  107372. /**
  107373. * This groups all the flags used to control the materials channel.
  107374. */
  107375. export class MaterialFlags {
  107376. private static _DiffuseTextureEnabled;
  107377. /**
  107378. * Are diffuse textures enabled in the application.
  107379. */
  107380. static DiffuseTextureEnabled: boolean;
  107381. private static _AmbientTextureEnabled;
  107382. /**
  107383. * Are ambient textures enabled in the application.
  107384. */
  107385. static AmbientTextureEnabled: boolean;
  107386. private static _OpacityTextureEnabled;
  107387. /**
  107388. * Are opacity textures enabled in the application.
  107389. */
  107390. static OpacityTextureEnabled: boolean;
  107391. private static _ReflectionTextureEnabled;
  107392. /**
  107393. * Are reflection textures enabled in the application.
  107394. */
  107395. static ReflectionTextureEnabled: boolean;
  107396. private static _EmissiveTextureEnabled;
  107397. /**
  107398. * Are emissive textures enabled in the application.
  107399. */
  107400. static EmissiveTextureEnabled: boolean;
  107401. private static _SpecularTextureEnabled;
  107402. /**
  107403. * Are specular textures enabled in the application.
  107404. */
  107405. static SpecularTextureEnabled: boolean;
  107406. private static _BumpTextureEnabled;
  107407. /**
  107408. * Are bump textures enabled in the application.
  107409. */
  107410. static BumpTextureEnabled: boolean;
  107411. private static _LightmapTextureEnabled;
  107412. /**
  107413. * Are lightmap textures enabled in the application.
  107414. */
  107415. static LightmapTextureEnabled: boolean;
  107416. private static _RefractionTextureEnabled;
  107417. /**
  107418. * Are refraction textures enabled in the application.
  107419. */
  107420. static RefractionTextureEnabled: boolean;
  107421. private static _ColorGradingTextureEnabled;
  107422. /**
  107423. * Are color grading textures enabled in the application.
  107424. */
  107425. static ColorGradingTextureEnabled: boolean;
  107426. private static _FresnelEnabled;
  107427. /**
  107428. * Are fresnels enabled in the application.
  107429. */
  107430. static FresnelEnabled: boolean;
  107431. private static _ClearCoatTextureEnabled;
  107432. /**
  107433. * Are clear coat textures enabled in the application.
  107434. */
  107435. static ClearCoatTextureEnabled: boolean;
  107436. private static _ClearCoatBumpTextureEnabled;
  107437. /**
  107438. * Are clear coat bump textures enabled in the application.
  107439. */
  107440. static ClearCoatBumpTextureEnabled: boolean;
  107441. private static _ClearCoatTintTextureEnabled;
  107442. /**
  107443. * Are clear coat tint textures enabled in the application.
  107444. */
  107445. static ClearCoatTintTextureEnabled: boolean;
  107446. private static _SheenTextureEnabled;
  107447. /**
  107448. * Are sheen textures enabled in the application.
  107449. */
  107450. static SheenTextureEnabled: boolean;
  107451. private static _AnisotropicTextureEnabled;
  107452. /**
  107453. * Are anisotropic textures enabled in the application.
  107454. */
  107455. static AnisotropicTextureEnabled: boolean;
  107456. private static _ThicknessTextureEnabled;
  107457. /**
  107458. * Are thickness textures enabled in the application.
  107459. */
  107460. static ThicknessTextureEnabled: boolean;
  107461. }
  107462. }
  107463. declare module BABYLON {
  107464. /** @hidden */
  107465. export var defaultFragmentDeclaration: {
  107466. name: string;
  107467. shader: string;
  107468. };
  107469. }
  107470. declare module BABYLON {
  107471. /** @hidden */
  107472. export var defaultUboDeclaration: {
  107473. name: string;
  107474. shader: string;
  107475. };
  107476. }
  107477. declare module BABYLON {
  107478. /** @hidden */
  107479. export var lightFragmentDeclaration: {
  107480. name: string;
  107481. shader: string;
  107482. };
  107483. }
  107484. declare module BABYLON {
  107485. /** @hidden */
  107486. export var lightUboDeclaration: {
  107487. name: string;
  107488. shader: string;
  107489. };
  107490. }
  107491. declare module BABYLON {
  107492. /** @hidden */
  107493. export var lightsFragmentFunctions: {
  107494. name: string;
  107495. shader: string;
  107496. };
  107497. }
  107498. declare module BABYLON {
  107499. /** @hidden */
  107500. export var shadowsFragmentFunctions: {
  107501. name: string;
  107502. shader: string;
  107503. };
  107504. }
  107505. declare module BABYLON {
  107506. /** @hidden */
  107507. export var fresnelFunction: {
  107508. name: string;
  107509. shader: string;
  107510. };
  107511. }
  107512. declare module BABYLON {
  107513. /** @hidden */
  107514. export var reflectionFunction: {
  107515. name: string;
  107516. shader: string;
  107517. };
  107518. }
  107519. declare module BABYLON {
  107520. /** @hidden */
  107521. export var bumpFragmentFunctions: {
  107522. name: string;
  107523. shader: string;
  107524. };
  107525. }
  107526. declare module BABYLON {
  107527. /** @hidden */
  107528. export var logDepthDeclaration: {
  107529. name: string;
  107530. shader: string;
  107531. };
  107532. }
  107533. declare module BABYLON {
  107534. /** @hidden */
  107535. export var bumpFragment: {
  107536. name: string;
  107537. shader: string;
  107538. };
  107539. }
  107540. declare module BABYLON {
  107541. /** @hidden */
  107542. export var depthPrePass: {
  107543. name: string;
  107544. shader: string;
  107545. };
  107546. }
  107547. declare module BABYLON {
  107548. /** @hidden */
  107549. export var lightFragment: {
  107550. name: string;
  107551. shader: string;
  107552. };
  107553. }
  107554. declare module BABYLON {
  107555. /** @hidden */
  107556. export var logDepthFragment: {
  107557. name: string;
  107558. shader: string;
  107559. };
  107560. }
  107561. declare module BABYLON {
  107562. /** @hidden */
  107563. export var defaultPixelShader: {
  107564. name: string;
  107565. shader: string;
  107566. };
  107567. }
  107568. declare module BABYLON {
  107569. /** @hidden */
  107570. export var defaultVertexDeclaration: {
  107571. name: string;
  107572. shader: string;
  107573. };
  107574. }
  107575. declare module BABYLON {
  107576. /** @hidden */
  107577. export var bumpVertexDeclaration: {
  107578. name: string;
  107579. shader: string;
  107580. };
  107581. }
  107582. declare module BABYLON {
  107583. /** @hidden */
  107584. export var bumpVertex: {
  107585. name: string;
  107586. shader: string;
  107587. };
  107588. }
  107589. declare module BABYLON {
  107590. /** @hidden */
  107591. export var fogVertex: {
  107592. name: string;
  107593. shader: string;
  107594. };
  107595. }
  107596. declare module BABYLON {
  107597. /** @hidden */
  107598. export var shadowsVertex: {
  107599. name: string;
  107600. shader: string;
  107601. };
  107602. }
  107603. declare module BABYLON {
  107604. /** @hidden */
  107605. export var pointCloudVertex: {
  107606. name: string;
  107607. shader: string;
  107608. };
  107609. }
  107610. declare module BABYLON {
  107611. /** @hidden */
  107612. export var logDepthVertex: {
  107613. name: string;
  107614. shader: string;
  107615. };
  107616. }
  107617. declare module BABYLON {
  107618. /** @hidden */
  107619. export var defaultVertexShader: {
  107620. name: string;
  107621. shader: string;
  107622. };
  107623. }
  107624. declare module BABYLON {
  107625. /** @hidden */
  107626. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  107627. MAINUV1: boolean;
  107628. MAINUV2: boolean;
  107629. DIFFUSE: boolean;
  107630. DIFFUSEDIRECTUV: number;
  107631. AMBIENT: boolean;
  107632. AMBIENTDIRECTUV: number;
  107633. OPACITY: boolean;
  107634. OPACITYDIRECTUV: number;
  107635. OPACITYRGB: boolean;
  107636. REFLECTION: boolean;
  107637. EMISSIVE: boolean;
  107638. EMISSIVEDIRECTUV: number;
  107639. SPECULAR: boolean;
  107640. SPECULARDIRECTUV: number;
  107641. BUMP: boolean;
  107642. BUMPDIRECTUV: number;
  107643. PARALLAX: boolean;
  107644. PARALLAXOCCLUSION: boolean;
  107645. SPECULAROVERALPHA: boolean;
  107646. CLIPPLANE: boolean;
  107647. CLIPPLANE2: boolean;
  107648. CLIPPLANE3: boolean;
  107649. CLIPPLANE4: boolean;
  107650. ALPHATEST: boolean;
  107651. DEPTHPREPASS: boolean;
  107652. ALPHAFROMDIFFUSE: boolean;
  107653. POINTSIZE: boolean;
  107654. FOG: boolean;
  107655. SPECULARTERM: boolean;
  107656. DIFFUSEFRESNEL: boolean;
  107657. OPACITYFRESNEL: boolean;
  107658. REFLECTIONFRESNEL: boolean;
  107659. REFRACTIONFRESNEL: boolean;
  107660. EMISSIVEFRESNEL: boolean;
  107661. FRESNEL: boolean;
  107662. NORMAL: boolean;
  107663. UV1: boolean;
  107664. UV2: boolean;
  107665. VERTEXCOLOR: boolean;
  107666. VERTEXALPHA: boolean;
  107667. NUM_BONE_INFLUENCERS: number;
  107668. BonesPerMesh: number;
  107669. BONETEXTURE: boolean;
  107670. INSTANCES: boolean;
  107671. GLOSSINESS: boolean;
  107672. ROUGHNESS: boolean;
  107673. EMISSIVEASILLUMINATION: boolean;
  107674. LINKEMISSIVEWITHDIFFUSE: boolean;
  107675. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107676. LIGHTMAP: boolean;
  107677. LIGHTMAPDIRECTUV: number;
  107678. OBJECTSPACE_NORMALMAP: boolean;
  107679. USELIGHTMAPASSHADOWMAP: boolean;
  107680. REFLECTIONMAP_3D: boolean;
  107681. REFLECTIONMAP_SPHERICAL: boolean;
  107682. REFLECTIONMAP_PLANAR: boolean;
  107683. REFLECTIONMAP_CUBIC: boolean;
  107684. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107685. REFLECTIONMAP_PROJECTION: boolean;
  107686. REFLECTIONMAP_SKYBOX: boolean;
  107687. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107688. REFLECTIONMAP_EXPLICIT: boolean;
  107689. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107690. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107691. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107692. INVERTCUBICMAP: boolean;
  107693. LOGARITHMICDEPTH: boolean;
  107694. REFRACTION: boolean;
  107695. REFRACTIONMAP_3D: boolean;
  107696. REFLECTIONOVERALPHA: boolean;
  107697. TWOSIDEDLIGHTING: boolean;
  107698. SHADOWFLOAT: boolean;
  107699. MORPHTARGETS: boolean;
  107700. MORPHTARGETS_NORMAL: boolean;
  107701. MORPHTARGETS_TANGENT: boolean;
  107702. MORPHTARGETS_UV: boolean;
  107703. NUM_MORPH_INFLUENCERS: number;
  107704. NONUNIFORMSCALING: boolean;
  107705. PREMULTIPLYALPHA: boolean;
  107706. IMAGEPROCESSING: boolean;
  107707. VIGNETTE: boolean;
  107708. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107709. VIGNETTEBLENDMODEOPAQUE: boolean;
  107710. TONEMAPPING: boolean;
  107711. TONEMAPPING_ACES: boolean;
  107712. CONTRAST: boolean;
  107713. COLORCURVES: boolean;
  107714. COLORGRADING: boolean;
  107715. COLORGRADING3D: boolean;
  107716. SAMPLER3DGREENDEPTH: boolean;
  107717. SAMPLER3DBGRMAP: boolean;
  107718. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107719. MULTIVIEW: boolean;
  107720. /**
  107721. * If the reflection texture on this material is in linear color space
  107722. * @hidden
  107723. */
  107724. IS_REFLECTION_LINEAR: boolean;
  107725. /**
  107726. * If the refraction texture on this material is in linear color space
  107727. * @hidden
  107728. */
  107729. IS_REFRACTION_LINEAR: boolean;
  107730. EXPOSURE: boolean;
  107731. constructor();
  107732. setReflectionMode(modeToEnable: string): void;
  107733. }
  107734. /**
  107735. * This is the default material used in Babylon. It is the best trade off between quality
  107736. * and performances.
  107737. * @see http://doc.babylonjs.com/babylon101/materials
  107738. */
  107739. export class StandardMaterial extends PushMaterial {
  107740. private _diffuseTexture;
  107741. /**
  107742. * The basic texture of the material as viewed under a light.
  107743. */
  107744. diffuseTexture: Nullable<BaseTexture>;
  107745. private _ambientTexture;
  107746. /**
  107747. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107748. */
  107749. ambientTexture: Nullable<BaseTexture>;
  107750. private _opacityTexture;
  107751. /**
  107752. * Define the transparency of the material from a texture.
  107753. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107754. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107755. */
  107756. opacityTexture: Nullable<BaseTexture>;
  107757. private _reflectionTexture;
  107758. /**
  107759. * Define the texture used to display the reflection.
  107760. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107761. */
  107762. reflectionTexture: Nullable<BaseTexture>;
  107763. private _emissiveTexture;
  107764. /**
  107765. * Define texture of the material as if self lit.
  107766. * This will be mixed in the final result even in the absence of light.
  107767. */
  107768. emissiveTexture: Nullable<BaseTexture>;
  107769. private _specularTexture;
  107770. /**
  107771. * Define how the color and intensity of the highlight given by the light in the material.
  107772. */
  107773. specularTexture: Nullable<BaseTexture>;
  107774. private _bumpTexture;
  107775. /**
  107776. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107777. * 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.
  107778. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107779. */
  107780. bumpTexture: Nullable<BaseTexture>;
  107781. private _lightmapTexture;
  107782. /**
  107783. * Complex lighting can be computationally expensive to compute at runtime.
  107784. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107785. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107786. */
  107787. lightmapTexture: Nullable<BaseTexture>;
  107788. private _refractionTexture;
  107789. /**
  107790. * Define the texture used to display the refraction.
  107791. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107792. */
  107793. refractionTexture: Nullable<BaseTexture>;
  107794. /**
  107795. * The color of the material lit by the environmental background lighting.
  107796. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107797. */
  107798. ambientColor: Color3;
  107799. /**
  107800. * The basic color of the material as viewed under a light.
  107801. */
  107802. diffuseColor: Color3;
  107803. /**
  107804. * Define how the color and intensity of the highlight given by the light in the material.
  107805. */
  107806. specularColor: Color3;
  107807. /**
  107808. * Define the color of the material as if self lit.
  107809. * This will be mixed in the final result even in the absence of light.
  107810. */
  107811. emissiveColor: Color3;
  107812. /**
  107813. * Defines how sharp are the highlights in the material.
  107814. * The bigger the value the sharper giving a more glossy feeling to the result.
  107815. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107816. */
  107817. specularPower: number;
  107818. private _useAlphaFromDiffuseTexture;
  107819. /**
  107820. * Does the transparency come from the diffuse texture alpha channel.
  107821. */
  107822. useAlphaFromDiffuseTexture: boolean;
  107823. private _useEmissiveAsIllumination;
  107824. /**
  107825. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107826. */
  107827. useEmissiveAsIllumination: boolean;
  107828. private _linkEmissiveWithDiffuse;
  107829. /**
  107830. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107831. * the emissive level when the final color is close to one.
  107832. */
  107833. linkEmissiveWithDiffuse: boolean;
  107834. private _useSpecularOverAlpha;
  107835. /**
  107836. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107837. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107838. */
  107839. useSpecularOverAlpha: boolean;
  107840. private _useReflectionOverAlpha;
  107841. /**
  107842. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107843. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107844. */
  107845. useReflectionOverAlpha: boolean;
  107846. private _disableLighting;
  107847. /**
  107848. * Does lights from the scene impacts this material.
  107849. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107850. */
  107851. disableLighting: boolean;
  107852. private _useObjectSpaceNormalMap;
  107853. /**
  107854. * Allows using an object space normal map (instead of tangent space).
  107855. */
  107856. useObjectSpaceNormalMap: boolean;
  107857. private _useParallax;
  107858. /**
  107859. * Is parallax enabled or not.
  107860. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107861. */
  107862. useParallax: boolean;
  107863. private _useParallaxOcclusion;
  107864. /**
  107865. * Is parallax occlusion enabled or not.
  107866. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107867. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107868. */
  107869. useParallaxOcclusion: boolean;
  107870. /**
  107871. * 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.
  107872. */
  107873. parallaxScaleBias: number;
  107874. private _roughness;
  107875. /**
  107876. * Helps to define how blurry the reflections should appears in the material.
  107877. */
  107878. roughness: number;
  107879. /**
  107880. * In case of refraction, define the value of the index of refraction.
  107881. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107882. */
  107883. indexOfRefraction: number;
  107884. /**
  107885. * Invert the refraction texture alongside the y axis.
  107886. * It can be useful with procedural textures or probe for instance.
  107887. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107888. */
  107889. invertRefractionY: boolean;
  107890. /**
  107891. * Defines the alpha limits in alpha test mode.
  107892. */
  107893. alphaCutOff: number;
  107894. private _useLightmapAsShadowmap;
  107895. /**
  107896. * In case of light mapping, define whether the map contains light or shadow informations.
  107897. */
  107898. useLightmapAsShadowmap: boolean;
  107899. private _diffuseFresnelParameters;
  107900. /**
  107901. * Define the diffuse fresnel parameters of the material.
  107902. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107903. */
  107904. diffuseFresnelParameters: FresnelParameters;
  107905. private _opacityFresnelParameters;
  107906. /**
  107907. * Define the opacity fresnel parameters of the material.
  107908. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107909. */
  107910. opacityFresnelParameters: FresnelParameters;
  107911. private _reflectionFresnelParameters;
  107912. /**
  107913. * Define the reflection fresnel parameters of the material.
  107914. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107915. */
  107916. reflectionFresnelParameters: FresnelParameters;
  107917. private _refractionFresnelParameters;
  107918. /**
  107919. * Define the refraction fresnel parameters of the material.
  107920. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107921. */
  107922. refractionFresnelParameters: FresnelParameters;
  107923. private _emissiveFresnelParameters;
  107924. /**
  107925. * Define the emissive fresnel parameters of the material.
  107926. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107927. */
  107928. emissiveFresnelParameters: FresnelParameters;
  107929. private _useReflectionFresnelFromSpecular;
  107930. /**
  107931. * If true automatically deducts the fresnels values from the material specularity.
  107932. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107933. */
  107934. useReflectionFresnelFromSpecular: boolean;
  107935. private _useGlossinessFromSpecularMapAlpha;
  107936. /**
  107937. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107938. */
  107939. useGlossinessFromSpecularMapAlpha: boolean;
  107940. private _maxSimultaneousLights;
  107941. /**
  107942. * Defines the maximum number of lights that can be used in the material
  107943. */
  107944. maxSimultaneousLights: number;
  107945. private _invertNormalMapX;
  107946. /**
  107947. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107948. */
  107949. invertNormalMapX: boolean;
  107950. private _invertNormalMapY;
  107951. /**
  107952. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107953. */
  107954. invertNormalMapY: boolean;
  107955. private _twoSidedLighting;
  107956. /**
  107957. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107958. */
  107959. twoSidedLighting: boolean;
  107960. /**
  107961. * Default configuration related to image processing available in the standard Material.
  107962. */
  107963. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107964. /**
  107965. * Gets the image processing configuration used either in this material.
  107966. */
  107967. /**
  107968. * Sets the Default image processing configuration used either in the this material.
  107969. *
  107970. * If sets to null, the scene one is in use.
  107971. */
  107972. imageProcessingConfiguration: ImageProcessingConfiguration;
  107973. /**
  107974. * Keep track of the image processing observer to allow dispose and replace.
  107975. */
  107976. private _imageProcessingObserver;
  107977. /**
  107978. * Attaches a new image processing configuration to the Standard Material.
  107979. * @param configuration
  107980. */
  107981. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107982. /**
  107983. * Gets wether the color curves effect is enabled.
  107984. */
  107985. /**
  107986. * Sets wether the color curves effect is enabled.
  107987. */
  107988. cameraColorCurvesEnabled: boolean;
  107989. /**
  107990. * Gets wether the color grading effect is enabled.
  107991. */
  107992. /**
  107993. * Gets wether the color grading effect is enabled.
  107994. */
  107995. cameraColorGradingEnabled: boolean;
  107996. /**
  107997. * Gets wether tonemapping is enabled or not.
  107998. */
  107999. /**
  108000. * Sets wether tonemapping is enabled or not
  108001. */
  108002. cameraToneMappingEnabled: boolean;
  108003. /**
  108004. * The camera exposure used on this material.
  108005. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108006. * This corresponds to a photographic exposure.
  108007. */
  108008. /**
  108009. * The camera exposure used on this material.
  108010. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108011. * This corresponds to a photographic exposure.
  108012. */
  108013. cameraExposure: number;
  108014. /**
  108015. * Gets The camera contrast used on this material.
  108016. */
  108017. /**
  108018. * Sets The camera contrast used on this material.
  108019. */
  108020. cameraContrast: number;
  108021. /**
  108022. * Gets the Color Grading 2D Lookup Texture.
  108023. */
  108024. /**
  108025. * Sets the Color Grading 2D Lookup Texture.
  108026. */
  108027. cameraColorGradingTexture: Nullable<BaseTexture>;
  108028. /**
  108029. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108030. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108031. * 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;
  108032. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108033. */
  108034. /**
  108035. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108036. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108037. * 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;
  108038. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108039. */
  108040. cameraColorCurves: Nullable<ColorCurves>;
  108041. /**
  108042. * Custom callback helping to override the default shader used in the material.
  108043. */
  108044. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  108045. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108046. protected _worldViewProjectionMatrix: Matrix;
  108047. protected _globalAmbientColor: Color3;
  108048. protected _useLogarithmicDepth: boolean;
  108049. protected _rebuildInParallel: boolean;
  108050. /**
  108051. * Instantiates a new standard material.
  108052. * This is the default material used in Babylon. It is the best trade off between quality
  108053. * and performances.
  108054. * @see http://doc.babylonjs.com/babylon101/materials
  108055. * @param name Define the name of the material in the scene
  108056. * @param scene Define the scene the material belong to
  108057. */
  108058. constructor(name: string, scene: Scene);
  108059. /**
  108060. * Gets a boolean indicating that current material needs to register RTT
  108061. */
  108062. readonly hasRenderTargetTextures: boolean;
  108063. /**
  108064. * Gets the current class name of the material e.g. "StandardMaterial"
  108065. * Mainly use in serialization.
  108066. * @returns the class name
  108067. */
  108068. getClassName(): string;
  108069. /**
  108070. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108071. * You can try switching to logarithmic depth.
  108072. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108073. */
  108074. useLogarithmicDepth: boolean;
  108075. /**
  108076. * Specifies if the material will require alpha blending
  108077. * @returns a boolean specifying if alpha blending is needed
  108078. */
  108079. needAlphaBlending(): boolean;
  108080. /**
  108081. * Specifies if this material should be rendered in alpha test mode
  108082. * @returns a boolean specifying if an alpha test is needed.
  108083. */
  108084. needAlphaTesting(): boolean;
  108085. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108086. /**
  108087. * Get the texture used for alpha test purpose.
  108088. * @returns the diffuse texture in case of the standard material.
  108089. */
  108090. getAlphaTestTexture(): Nullable<BaseTexture>;
  108091. /**
  108092. * Get if the submesh is ready to be used and all its information available.
  108093. * Child classes can use it to update shaders
  108094. * @param mesh defines the mesh to check
  108095. * @param subMesh defines which submesh to check
  108096. * @param useInstances specifies that instances should be used
  108097. * @returns a boolean indicating that the submesh is ready or not
  108098. */
  108099. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108100. /**
  108101. * Builds the material UBO layouts.
  108102. * Used internally during the effect preparation.
  108103. */
  108104. buildUniformLayout(): void;
  108105. /**
  108106. * Unbinds the material from the mesh
  108107. */
  108108. unbind(): void;
  108109. /**
  108110. * Binds the submesh to this material by preparing the effect and shader to draw
  108111. * @param world defines the world transformation matrix
  108112. * @param mesh defines the mesh containing the submesh
  108113. * @param subMesh defines the submesh to bind the material to
  108114. */
  108115. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108116. /**
  108117. * Get the list of animatables in the material.
  108118. * @returns the list of animatables object used in the material
  108119. */
  108120. getAnimatables(): IAnimatable[];
  108121. /**
  108122. * Gets the active textures from the material
  108123. * @returns an array of textures
  108124. */
  108125. getActiveTextures(): BaseTexture[];
  108126. /**
  108127. * Specifies if the material uses a texture
  108128. * @param texture defines the texture to check against the material
  108129. * @returns a boolean specifying if the material uses the texture
  108130. */
  108131. hasTexture(texture: BaseTexture): boolean;
  108132. /**
  108133. * Disposes the material
  108134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108136. */
  108137. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108138. /**
  108139. * Makes a duplicate of the material, and gives it a new name
  108140. * @param name defines the new name for the duplicated material
  108141. * @returns the cloned material
  108142. */
  108143. clone(name: string): StandardMaterial;
  108144. /**
  108145. * Serializes this material in a JSON representation
  108146. * @returns the serialized material object
  108147. */
  108148. serialize(): any;
  108149. /**
  108150. * Creates a standard material from parsed material data
  108151. * @param source defines the JSON representation of the material
  108152. * @param scene defines the hosting scene
  108153. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108154. * @returns a new standard material
  108155. */
  108156. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108157. /**
  108158. * Are diffuse textures enabled in the application.
  108159. */
  108160. static DiffuseTextureEnabled: boolean;
  108161. /**
  108162. * Are ambient textures enabled in the application.
  108163. */
  108164. static AmbientTextureEnabled: boolean;
  108165. /**
  108166. * Are opacity textures enabled in the application.
  108167. */
  108168. static OpacityTextureEnabled: boolean;
  108169. /**
  108170. * Are reflection textures enabled in the application.
  108171. */
  108172. static ReflectionTextureEnabled: boolean;
  108173. /**
  108174. * Are emissive textures enabled in the application.
  108175. */
  108176. static EmissiveTextureEnabled: boolean;
  108177. /**
  108178. * Are specular textures enabled in the application.
  108179. */
  108180. static SpecularTextureEnabled: boolean;
  108181. /**
  108182. * Are bump textures enabled in the application.
  108183. */
  108184. static BumpTextureEnabled: boolean;
  108185. /**
  108186. * Are lightmap textures enabled in the application.
  108187. */
  108188. static LightmapTextureEnabled: boolean;
  108189. /**
  108190. * Are refraction textures enabled in the application.
  108191. */
  108192. static RefractionTextureEnabled: boolean;
  108193. /**
  108194. * Are color grading textures enabled in the application.
  108195. */
  108196. static ColorGradingTextureEnabled: boolean;
  108197. /**
  108198. * Are fresnels enabled in the application.
  108199. */
  108200. static FresnelEnabled: boolean;
  108201. }
  108202. }
  108203. declare module BABYLON {
  108204. /** @hidden */
  108205. export var imageProcessingPixelShader: {
  108206. name: string;
  108207. shader: string;
  108208. };
  108209. }
  108210. declare module BABYLON {
  108211. /**
  108212. * ImageProcessingPostProcess
  108213. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  108214. */
  108215. export class ImageProcessingPostProcess extends PostProcess {
  108216. /**
  108217. * Default configuration related to image processing available in the PBR Material.
  108218. */
  108219. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108220. /**
  108221. * Gets the image processing configuration used either in this material.
  108222. */
  108223. /**
  108224. * Sets the Default image processing configuration used either in the this material.
  108225. *
  108226. * If sets to null, the scene one is in use.
  108227. */
  108228. imageProcessingConfiguration: ImageProcessingConfiguration;
  108229. /**
  108230. * Keep track of the image processing observer to allow dispose and replace.
  108231. */
  108232. private _imageProcessingObserver;
  108233. /**
  108234. * Attaches a new image processing configuration to the PBR Material.
  108235. * @param configuration
  108236. */
  108237. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  108238. /**
  108239. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108240. */
  108241. /**
  108242. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108243. */
  108244. colorCurves: Nullable<ColorCurves>;
  108245. /**
  108246. * Gets wether the color curves effect is enabled.
  108247. */
  108248. /**
  108249. * Sets wether the color curves effect is enabled.
  108250. */
  108251. colorCurvesEnabled: boolean;
  108252. /**
  108253. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108254. */
  108255. /**
  108256. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108257. */
  108258. colorGradingTexture: Nullable<BaseTexture>;
  108259. /**
  108260. * Gets wether the color grading effect is enabled.
  108261. */
  108262. /**
  108263. * Gets wether the color grading effect is enabled.
  108264. */
  108265. colorGradingEnabled: boolean;
  108266. /**
  108267. * Gets exposure used in the effect.
  108268. */
  108269. /**
  108270. * Sets exposure used in the effect.
  108271. */
  108272. exposure: number;
  108273. /**
  108274. * Gets wether tonemapping is enabled or not.
  108275. */
  108276. /**
  108277. * Sets wether tonemapping is enabled or not
  108278. */
  108279. toneMappingEnabled: boolean;
  108280. /**
  108281. * Gets the type of tone mapping effect.
  108282. */
  108283. /**
  108284. * Sets the type of tone mapping effect.
  108285. */
  108286. toneMappingType: number;
  108287. /**
  108288. * Gets contrast used in the effect.
  108289. */
  108290. /**
  108291. * Sets contrast used in the effect.
  108292. */
  108293. contrast: number;
  108294. /**
  108295. * Gets Vignette stretch size.
  108296. */
  108297. /**
  108298. * Sets Vignette stretch size.
  108299. */
  108300. vignetteStretch: number;
  108301. /**
  108302. * Gets Vignette centre X Offset.
  108303. */
  108304. /**
  108305. * Sets Vignette centre X Offset.
  108306. */
  108307. vignetteCentreX: number;
  108308. /**
  108309. * Gets Vignette centre Y Offset.
  108310. */
  108311. /**
  108312. * Sets Vignette centre Y Offset.
  108313. */
  108314. vignetteCentreY: number;
  108315. /**
  108316. * Gets Vignette weight or intensity of the vignette effect.
  108317. */
  108318. /**
  108319. * Sets Vignette weight or intensity of the vignette effect.
  108320. */
  108321. vignetteWeight: number;
  108322. /**
  108323. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108324. * if vignetteEnabled is set to true.
  108325. */
  108326. /**
  108327. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108328. * if vignetteEnabled is set to true.
  108329. */
  108330. vignetteColor: Color4;
  108331. /**
  108332. * Gets Camera field of view used by the Vignette effect.
  108333. */
  108334. /**
  108335. * Sets Camera field of view used by the Vignette effect.
  108336. */
  108337. vignetteCameraFov: number;
  108338. /**
  108339. * Gets the vignette blend mode allowing different kind of effect.
  108340. */
  108341. /**
  108342. * Sets the vignette blend mode allowing different kind of effect.
  108343. */
  108344. vignetteBlendMode: number;
  108345. /**
  108346. * Gets wether the vignette effect is enabled.
  108347. */
  108348. /**
  108349. * Sets wether the vignette effect is enabled.
  108350. */
  108351. vignetteEnabled: boolean;
  108352. private _fromLinearSpace;
  108353. /**
  108354. * Gets wether the input of the processing is in Gamma or Linear Space.
  108355. */
  108356. /**
  108357. * Sets wether the input of the processing is in Gamma or Linear Space.
  108358. */
  108359. fromLinearSpace: boolean;
  108360. /**
  108361. * Defines cache preventing GC.
  108362. */
  108363. private _defines;
  108364. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  108365. /**
  108366. * "ImageProcessingPostProcess"
  108367. * @returns "ImageProcessingPostProcess"
  108368. */
  108369. getClassName(): string;
  108370. protected _updateParameters(): void;
  108371. dispose(camera?: Camera): void;
  108372. }
  108373. }
  108374. declare module BABYLON {
  108375. /**
  108376. * Class containing static functions to help procedurally build meshes
  108377. */
  108378. export class GroundBuilder {
  108379. /**
  108380. * Creates a ground mesh
  108381. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  108382. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  108383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108384. * @param name defines the name of the mesh
  108385. * @param options defines the options used to create the mesh
  108386. * @param scene defines the hosting scene
  108387. * @returns the ground mesh
  108388. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  108389. */
  108390. static CreateGround(name: string, options: {
  108391. width?: number;
  108392. height?: number;
  108393. subdivisions?: number;
  108394. subdivisionsX?: number;
  108395. subdivisionsY?: number;
  108396. updatable?: boolean;
  108397. }, scene: any): Mesh;
  108398. /**
  108399. * Creates a tiled ground mesh
  108400. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  108401. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  108402. * * 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
  108403. * * 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
  108404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108405. * @param name defines the name of the mesh
  108406. * @param options defines the options used to create the mesh
  108407. * @param scene defines the hosting scene
  108408. * @returns the tiled ground mesh
  108409. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  108410. */
  108411. static CreateTiledGround(name: string, options: {
  108412. xmin: number;
  108413. zmin: number;
  108414. xmax: number;
  108415. zmax: number;
  108416. subdivisions?: {
  108417. w: number;
  108418. h: number;
  108419. };
  108420. precision?: {
  108421. w: number;
  108422. h: number;
  108423. };
  108424. updatable?: boolean;
  108425. }, scene?: Nullable<Scene>): Mesh;
  108426. /**
  108427. * Creates a ground mesh from a height map
  108428. * * The parameter `url` sets the URL of the height map image resource.
  108429. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  108430. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  108431. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  108432. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  108433. * * 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.
  108434. * * 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).
  108435. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108437. * @param name defines the name of the mesh
  108438. * @param url defines the url to the height map
  108439. * @param options defines the options used to create the mesh
  108440. * @param scene defines the hosting scene
  108441. * @returns the ground mesh
  108442. * @see https://doc.babylonjs.com/babylon101/height_map
  108443. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  108444. */
  108445. static CreateGroundFromHeightMap(name: string, url: string, options: {
  108446. width?: number;
  108447. height?: number;
  108448. subdivisions?: number;
  108449. minHeight?: number;
  108450. maxHeight?: number;
  108451. colorFilter?: Color3;
  108452. alphaFilter?: number;
  108453. updatable?: boolean;
  108454. onReady?: (mesh: GroundMesh) => void;
  108455. }, scene?: Nullable<Scene>): GroundMesh;
  108456. }
  108457. }
  108458. declare module BABYLON {
  108459. /**
  108460. * Class containing static functions to help procedurally build meshes
  108461. */
  108462. export class TorusBuilder {
  108463. /**
  108464. * Creates a torus mesh
  108465. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108466. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108467. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108471. * @param name defines the name of the mesh
  108472. * @param options defines the options used to create the mesh
  108473. * @param scene defines the hosting scene
  108474. * @returns the torus mesh
  108475. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108476. */
  108477. static CreateTorus(name: string, options: {
  108478. diameter?: number;
  108479. thickness?: number;
  108480. tessellation?: number;
  108481. updatable?: boolean;
  108482. sideOrientation?: number;
  108483. frontUVs?: Vector4;
  108484. backUVs?: Vector4;
  108485. }, scene: any): Mesh;
  108486. }
  108487. }
  108488. declare module BABYLON {
  108489. /**
  108490. * Class containing static functions to help procedurally build meshes
  108491. */
  108492. export class CylinderBuilder {
  108493. /**
  108494. * Creates a cylinder or a cone mesh
  108495. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108496. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108497. * * 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.
  108498. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108499. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108500. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108501. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108502. * * 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).
  108503. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108504. * * 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).
  108505. * * 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
  108506. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108507. * * 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
  108508. * * 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.
  108509. * * If `enclose` is false, a ring surface is one element.
  108510. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108511. * * 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
  108512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108515. * @param name defines the name of the mesh
  108516. * @param options defines the options used to create the mesh
  108517. * @param scene defines the hosting scene
  108518. * @returns the cylinder mesh
  108519. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108520. */
  108521. static CreateCylinder(name: string, options: {
  108522. height?: number;
  108523. diameterTop?: number;
  108524. diameterBottom?: number;
  108525. diameter?: number;
  108526. tessellation?: number;
  108527. subdivisions?: number;
  108528. arc?: number;
  108529. faceColors?: Color4[];
  108530. faceUV?: Vector4[];
  108531. updatable?: boolean;
  108532. hasRings?: boolean;
  108533. enclose?: boolean;
  108534. cap?: number;
  108535. sideOrientation?: number;
  108536. frontUVs?: Vector4;
  108537. backUVs?: Vector4;
  108538. }, scene: any): Mesh;
  108539. }
  108540. }
  108541. declare module BABYLON {
  108542. /**
  108543. * Options to modify the vr teleportation behavior.
  108544. */
  108545. export interface VRTeleportationOptions {
  108546. /**
  108547. * The name of the mesh which should be used as the teleportation floor. (default: null)
  108548. */
  108549. floorMeshName?: string;
  108550. /**
  108551. * A list of meshes to be used as the teleportation floor. (default: empty)
  108552. */
  108553. floorMeshes?: Mesh[];
  108554. }
  108555. /**
  108556. * Options to modify the vr experience helper's behavior.
  108557. */
  108558. export interface VRExperienceHelperOptions extends WebVROptions {
  108559. /**
  108560. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  108561. */
  108562. createDeviceOrientationCamera?: boolean;
  108563. /**
  108564. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  108565. */
  108566. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  108567. /**
  108568. * Uses the main button on the controller to toggle the laser casted. (default: true)
  108569. */
  108570. laserToggle?: boolean;
  108571. /**
  108572. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  108573. */
  108574. floorMeshes?: Mesh[];
  108575. /**
  108576. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  108577. */
  108578. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  108579. }
  108580. /**
  108581. * Event containing information after VR has been entered
  108582. */
  108583. export class OnAfterEnteringVRObservableEvent {
  108584. /**
  108585. * If entering vr was successful
  108586. */
  108587. success: boolean;
  108588. }
  108589. /**
  108590. * Helps to quickly add VR support to an existing scene.
  108591. * See http://doc.babylonjs.com/how_to/webvr_helper
  108592. */
  108593. export class VRExperienceHelper {
  108594. /** Options to modify the vr experience helper's behavior. */
  108595. webVROptions: VRExperienceHelperOptions;
  108596. private _scene;
  108597. private _position;
  108598. private _btnVR;
  108599. private _btnVRDisplayed;
  108600. private _webVRsupported;
  108601. private _webVRready;
  108602. private _webVRrequesting;
  108603. private _webVRpresenting;
  108604. private _hasEnteredVR;
  108605. private _fullscreenVRpresenting;
  108606. private _canvas;
  108607. private _webVRCamera;
  108608. private _vrDeviceOrientationCamera;
  108609. private _deviceOrientationCamera;
  108610. private _existingCamera;
  108611. private _onKeyDown;
  108612. private _onVrDisplayPresentChange;
  108613. private _onVRDisplayChanged;
  108614. private _onVRRequestPresentStart;
  108615. private _onVRRequestPresentComplete;
  108616. /**
  108617. * 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)
  108618. */
  108619. enableGazeEvenWhenNoPointerLock: boolean;
  108620. /**
  108621. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  108622. */
  108623. exitVROnDoubleTap: boolean;
  108624. /**
  108625. * Observable raised right before entering VR.
  108626. */
  108627. onEnteringVRObservable: Observable<VRExperienceHelper>;
  108628. /**
  108629. * Observable raised when entering VR has completed.
  108630. */
  108631. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  108632. /**
  108633. * Observable raised when exiting VR.
  108634. */
  108635. onExitingVRObservable: Observable<VRExperienceHelper>;
  108636. /**
  108637. * Observable raised when controller mesh is loaded.
  108638. */
  108639. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108640. /** Return this.onEnteringVRObservable
  108641. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  108642. */
  108643. readonly onEnteringVR: Observable<VRExperienceHelper>;
  108644. /** Return this.onExitingVRObservable
  108645. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  108646. */
  108647. readonly onExitingVR: Observable<VRExperienceHelper>;
  108648. /** Return this.onControllerMeshLoadedObservable
  108649. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  108650. */
  108651. readonly onControllerMeshLoaded: Observable<WebVRController>;
  108652. private _rayLength;
  108653. private _useCustomVRButton;
  108654. private _teleportationRequested;
  108655. private _teleportActive;
  108656. private _floorMeshName;
  108657. private _floorMeshesCollection;
  108658. private _rotationAllowed;
  108659. private _teleportBackwardsVector;
  108660. private _teleportationTarget;
  108661. private _isDefaultTeleportationTarget;
  108662. private _postProcessMove;
  108663. private _teleportationFillColor;
  108664. private _teleportationBorderColor;
  108665. private _rotationAngle;
  108666. private _haloCenter;
  108667. private _cameraGazer;
  108668. private _padSensibilityUp;
  108669. private _padSensibilityDown;
  108670. private _leftController;
  108671. private _rightController;
  108672. /**
  108673. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  108674. */
  108675. onNewMeshSelected: Observable<AbstractMesh>;
  108676. /**
  108677. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  108678. * This observable will provide the mesh and the controller used to select the mesh
  108679. */
  108680. onMeshSelectedWithController: Observable<{
  108681. mesh: AbstractMesh;
  108682. controller: WebVRController;
  108683. }>;
  108684. /**
  108685. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  108686. */
  108687. onNewMeshPicked: Observable<PickingInfo>;
  108688. private _circleEase;
  108689. /**
  108690. * Observable raised before camera teleportation
  108691. */
  108692. onBeforeCameraTeleport: Observable<Vector3>;
  108693. /**
  108694. * Observable raised after camera teleportation
  108695. */
  108696. onAfterCameraTeleport: Observable<Vector3>;
  108697. /**
  108698. * Observable raised when current selected mesh gets unselected
  108699. */
  108700. onSelectedMeshUnselected: Observable<AbstractMesh>;
  108701. private _raySelectionPredicate;
  108702. /**
  108703. * To be optionaly changed by user to define custom ray selection
  108704. */
  108705. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  108706. /**
  108707. * To be optionaly changed by user to define custom selection logic (after ray selection)
  108708. */
  108709. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  108710. /**
  108711. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  108712. */
  108713. teleportationEnabled: boolean;
  108714. private _defaultHeight;
  108715. private _teleportationInitialized;
  108716. private _interactionsEnabled;
  108717. private _interactionsRequested;
  108718. private _displayGaze;
  108719. private _displayLaserPointer;
  108720. /**
  108721. * The mesh used to display where the user is going to teleport.
  108722. */
  108723. /**
  108724. * Sets the mesh to be used to display where the user is going to teleport.
  108725. */
  108726. teleportationTarget: Mesh;
  108727. /**
  108728. * 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
  108729. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  108730. * See http://doc.babylonjs.com/resources/baking_transformations
  108731. */
  108732. gazeTrackerMesh: Mesh;
  108733. /**
  108734. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  108735. */
  108736. updateGazeTrackerScale: boolean;
  108737. /**
  108738. * If the gaze trackers color should be updated when selecting meshes
  108739. */
  108740. updateGazeTrackerColor: boolean;
  108741. /**
  108742. * If the controller laser color should be updated when selecting meshes
  108743. */
  108744. updateControllerLaserColor: boolean;
  108745. /**
  108746. * The gaze tracking mesh corresponding to the left controller
  108747. */
  108748. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108749. /**
  108750. * The gaze tracking mesh corresponding to the right controller
  108751. */
  108752. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108753. /**
  108754. * If the ray of the gaze should be displayed.
  108755. */
  108756. /**
  108757. * Sets if the ray of the gaze should be displayed.
  108758. */
  108759. displayGaze: boolean;
  108760. /**
  108761. * If the ray of the LaserPointer should be displayed.
  108762. */
  108763. /**
  108764. * Sets if the ray of the LaserPointer should be displayed.
  108765. */
  108766. displayLaserPointer: boolean;
  108767. /**
  108768. * The deviceOrientationCamera used as the camera when not in VR.
  108769. */
  108770. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108771. /**
  108772. * Based on the current WebVR support, returns the current VR camera used.
  108773. */
  108774. readonly currentVRCamera: Nullable<Camera>;
  108775. /**
  108776. * The webVRCamera which is used when in VR.
  108777. */
  108778. readonly webVRCamera: WebVRFreeCamera;
  108779. /**
  108780. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108781. */
  108782. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108783. /**
  108784. * The html button that is used to trigger entering into VR.
  108785. */
  108786. readonly vrButton: Nullable<HTMLButtonElement>;
  108787. private readonly _teleportationRequestInitiated;
  108788. /**
  108789. * Defines wether or not Pointer lock should be requested when switching to
  108790. * full screen.
  108791. */
  108792. requestPointerLockOnFullScreen: boolean;
  108793. /**
  108794. * Instantiates a VRExperienceHelper.
  108795. * Helps to quickly add VR support to an existing scene.
  108796. * @param scene The scene the VRExperienceHelper belongs to.
  108797. * @param webVROptions Options to modify the vr experience helper's behavior.
  108798. */
  108799. constructor(scene: Scene,
  108800. /** Options to modify the vr experience helper's behavior. */
  108801. webVROptions?: VRExperienceHelperOptions);
  108802. private _onDefaultMeshLoaded;
  108803. private _onResize;
  108804. private _onFullscreenChange;
  108805. /**
  108806. * Gets a value indicating if we are currently in VR mode.
  108807. */
  108808. readonly isInVRMode: boolean;
  108809. private onVrDisplayPresentChange;
  108810. private onVRDisplayChanged;
  108811. private moveButtonToBottomRight;
  108812. private displayVRButton;
  108813. private updateButtonVisibility;
  108814. private _cachedAngularSensibility;
  108815. /**
  108816. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108817. * Otherwise, will use the fullscreen API.
  108818. */
  108819. enterVR(): void;
  108820. /**
  108821. * Attempt to exit VR, or fullscreen.
  108822. */
  108823. exitVR(): void;
  108824. /**
  108825. * The position of the vr experience helper.
  108826. */
  108827. /**
  108828. * Sets the position of the vr experience helper.
  108829. */
  108830. position: Vector3;
  108831. /**
  108832. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108833. */
  108834. enableInteractions(): void;
  108835. private readonly _noControllerIsActive;
  108836. private beforeRender;
  108837. private _isTeleportationFloor;
  108838. /**
  108839. * Adds a floor mesh to be used for teleportation.
  108840. * @param floorMesh the mesh to be used for teleportation.
  108841. */
  108842. addFloorMesh(floorMesh: Mesh): void;
  108843. /**
  108844. * Removes a floor mesh from being used for teleportation.
  108845. * @param floorMesh the mesh to be removed.
  108846. */
  108847. removeFloorMesh(floorMesh: Mesh): void;
  108848. /**
  108849. * Enables interactions and teleportation using the VR controllers and gaze.
  108850. * @param vrTeleportationOptions options to modify teleportation behavior.
  108851. */
  108852. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108853. private _onNewGamepadConnected;
  108854. private _tryEnableInteractionOnController;
  108855. private _onNewGamepadDisconnected;
  108856. private _enableInteractionOnController;
  108857. private _checkTeleportWithRay;
  108858. private _checkRotate;
  108859. private _checkTeleportBackwards;
  108860. private _enableTeleportationOnController;
  108861. private _createTeleportationCircles;
  108862. private _displayTeleportationTarget;
  108863. private _hideTeleportationTarget;
  108864. private _rotateCamera;
  108865. private _moveTeleportationSelectorTo;
  108866. private _workingVector;
  108867. private _workingQuaternion;
  108868. private _workingMatrix;
  108869. /**
  108870. * Teleports the users feet to the desired location
  108871. * @param location The location where the user's feet should be placed
  108872. */
  108873. teleportCamera(location: Vector3): void;
  108874. private _convertNormalToDirectionOfRay;
  108875. private _castRayAndSelectObject;
  108876. private _notifySelectedMeshUnselected;
  108877. /**
  108878. * Sets the color of the laser ray from the vr controllers.
  108879. * @param color new color for the ray.
  108880. */
  108881. changeLaserColor(color: Color3): void;
  108882. /**
  108883. * Sets the color of the ray from the vr headsets gaze.
  108884. * @param color new color for the ray.
  108885. */
  108886. changeGazeColor(color: Color3): void;
  108887. /**
  108888. * Exits VR and disposes of the vr experience helper
  108889. */
  108890. dispose(): void;
  108891. /**
  108892. * Gets the name of the VRExperienceHelper class
  108893. * @returns "VRExperienceHelper"
  108894. */
  108895. getClassName(): string;
  108896. }
  108897. }
  108898. declare module BABYLON {
  108899. /**
  108900. * Manages an XRSession to work with Babylon's engine
  108901. * @see https://doc.babylonjs.com/how_to/webxr
  108902. */
  108903. export class WebXRSessionManager implements IDisposable {
  108904. private scene;
  108905. /**
  108906. * Fires every time a new xrFrame arrives which can be used to update the camera
  108907. */
  108908. onXRFrameObservable: Observable<any>;
  108909. /**
  108910. * Fires when the xr session is ended either by the device or manually done
  108911. */
  108912. onXRSessionEnded: Observable<any>;
  108913. /**
  108914. * Underlying xr session
  108915. */
  108916. session: XRSession;
  108917. /**
  108918. * Type of reference space used when creating the session
  108919. */
  108920. referenceSpace: XRReferenceSpace;
  108921. /** @hidden */
  108922. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108923. /**
  108924. * Current XR frame
  108925. */
  108926. currentFrame: Nullable<XRFrame>;
  108927. private _xrNavigator;
  108928. private baseLayer;
  108929. /**
  108930. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108931. * @param scene The scene which the session should be created for
  108932. */
  108933. constructor(scene: Scene);
  108934. /**
  108935. * Initializes the manager
  108936. * After initialization enterXR can be called to start an XR session
  108937. * @returns Promise which resolves after it is initialized
  108938. */
  108939. initializeAsync(): Promise<void>;
  108940. /**
  108941. * Initializes an xr session
  108942. * @param xrSessionMode mode to initialize
  108943. * @returns a promise which will resolve once the session has been initialized
  108944. */
  108945. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108946. /**
  108947. * Sets the reference space on the xr session
  108948. * @param referenceSpace space to set
  108949. * @returns a promise that will resolve once the reference space has been set
  108950. */
  108951. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108952. /**
  108953. * Updates the render state of the session
  108954. * @param state state to set
  108955. * @returns a promise that resolves once the render state has been updated
  108956. */
  108957. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108958. /**
  108959. * Starts rendering to the xr layer
  108960. * @returns a promise that will resolve once rendering has started
  108961. */
  108962. startRenderingToXRAsync(): Promise<void>;
  108963. /**
  108964. * Stops the xrSession and restores the renderloop
  108965. * @returns Promise which resolves after it exits XR
  108966. */
  108967. exitXRAsync(): Promise<unknown>;
  108968. /**
  108969. * Checks if a session would be supported for the creation options specified
  108970. * @param sessionMode session mode to check if supported eg. immersive-vr
  108971. * @returns true if supported
  108972. */
  108973. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108974. /**
  108975. * @hidden
  108976. * Converts the render layer of xrSession to a render target
  108977. * @param session session to create render target for
  108978. * @param scene scene the new render target should be created for
  108979. */
  108980. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108981. /**
  108982. * Disposes of the session manager
  108983. */
  108984. dispose(): void;
  108985. }
  108986. }
  108987. declare module BABYLON {
  108988. /**
  108989. * WebXR Camera which holds the views for the xrSession
  108990. * @see https://doc.babylonjs.com/how_to/webxr
  108991. */
  108992. export class WebXRCamera extends FreeCamera {
  108993. private static _TmpMatrix;
  108994. /**
  108995. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108996. * @param name the name of the camera
  108997. * @param scene the scene to add the camera to
  108998. */
  108999. constructor(name: string, scene: Scene);
  109000. private _updateNumberOfRigCameras;
  109001. /** @hidden */
  109002. _updateForDualEyeDebugging(pupilDistance?: number): void;
  109003. /**
  109004. * Updates the cameras position from the current pose information of the XR session
  109005. * @param xrSessionManager the session containing pose information
  109006. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  109007. */
  109008. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  109009. }
  109010. }
  109011. declare module BABYLON {
  109012. /**
  109013. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  109014. */
  109015. export class WebXRManagedOutputCanvas implements IDisposable {
  109016. private helper;
  109017. private _canvas;
  109018. /**
  109019. * xrpresent context of the canvas which can be used to display/mirror xr content
  109020. */
  109021. canvasContext: WebGLRenderingContext;
  109022. /**
  109023. * xr layer for the canvas
  109024. */
  109025. xrLayer: Nullable<XRWebGLLayer>;
  109026. /**
  109027. * Initializes the xr layer for the session
  109028. * @param xrSession xr session
  109029. * @returns a promise that will resolve once the XR Layer has been created
  109030. */
  109031. initializeXRLayerAsync(xrSession: any): any;
  109032. /**
  109033. * Initializes the canvas to be added/removed upon entering/exiting xr
  109034. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  109035. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  109036. */
  109037. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  109038. /**
  109039. * Disposes of the object
  109040. */
  109041. dispose(): void;
  109042. private _setManagedOutputCanvas;
  109043. private _addCanvas;
  109044. private _removeCanvas;
  109045. }
  109046. }
  109047. declare module BABYLON {
  109048. /**
  109049. * States of the webXR experience
  109050. */
  109051. export enum WebXRState {
  109052. /**
  109053. * Transitioning to being in XR mode
  109054. */
  109055. ENTERING_XR = 0,
  109056. /**
  109057. * Transitioning to non XR mode
  109058. */
  109059. EXITING_XR = 1,
  109060. /**
  109061. * In XR mode and presenting
  109062. */
  109063. IN_XR = 2,
  109064. /**
  109065. * Not entered XR mode
  109066. */
  109067. NOT_IN_XR = 3
  109068. }
  109069. /**
  109070. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  109071. * @see https://doc.babylonjs.com/how_to/webxr
  109072. */
  109073. export class WebXRExperienceHelper implements IDisposable {
  109074. private scene;
  109075. /**
  109076. * 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
  109077. */
  109078. container: AbstractMesh;
  109079. /**
  109080. * Camera used to render xr content
  109081. */
  109082. camera: WebXRCamera;
  109083. /**
  109084. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  109085. */
  109086. state: WebXRState;
  109087. private _setState;
  109088. private static _TmpVector;
  109089. /**
  109090. * Fires when the state of the experience helper has changed
  109091. */
  109092. onStateChangedObservable: Observable<WebXRState>;
  109093. /** Session manager used to keep track of xr session */
  109094. sessionManager: WebXRSessionManager;
  109095. private _nonVRCamera;
  109096. private _originalSceneAutoClear;
  109097. private _supported;
  109098. /**
  109099. * Creates the experience helper
  109100. * @param scene the scene to attach the experience helper to
  109101. * @returns a promise for the experience helper
  109102. */
  109103. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  109104. /**
  109105. * Creates a WebXRExperienceHelper
  109106. * @param scene The scene the helper should be created in
  109107. */
  109108. private constructor();
  109109. /**
  109110. * Exits XR mode and returns the scene to its original state
  109111. * @returns promise that resolves after xr mode has exited
  109112. */
  109113. exitXRAsync(): Promise<unknown>;
  109114. /**
  109115. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  109116. * @param sessionCreationOptions options for the XR session
  109117. * @param referenceSpaceType frame of reference of the XR session
  109118. * @param outputCanvas the output canvas that will be used to enter XR mode
  109119. * @returns promise that resolves after xr mode has entered
  109120. */
  109121. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  109122. /**
  109123. * Updates the global position of the camera by moving the camera's container
  109124. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  109125. * @param position The desired global position of the camera
  109126. */
  109127. setPositionOfCameraUsingContainer(position: Vector3): void;
  109128. /**
  109129. * Rotates the xr camera by rotating the camera's container around the camera's position
  109130. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  109131. * @param rotation the desired quaternion rotation to apply to the camera
  109132. */
  109133. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  109134. /**
  109135. * Disposes of the experience helper
  109136. */
  109137. dispose(): void;
  109138. }
  109139. }
  109140. declare module BABYLON {
  109141. /**
  109142. * Button which can be used to enter a different mode of XR
  109143. */
  109144. export class WebXREnterExitUIButton {
  109145. /** button element */
  109146. element: HTMLElement;
  109147. /** XR initialization options for the button */
  109148. sessionMode: XRSessionMode;
  109149. /** Reference space type */
  109150. referenceSpaceType: XRReferenceSpaceType;
  109151. /**
  109152. * Creates a WebXREnterExitUIButton
  109153. * @param element button element
  109154. * @param sessionMode XR initialization session mode
  109155. * @param referenceSpaceType the type of reference space to be used
  109156. */
  109157. constructor(
  109158. /** button element */
  109159. element: HTMLElement,
  109160. /** XR initialization options for the button */
  109161. sessionMode: XRSessionMode,
  109162. /** Reference space type */
  109163. referenceSpaceType: XRReferenceSpaceType);
  109164. /**
  109165. * Overwritable function which can be used to update the button's visuals when the state changes
  109166. * @param activeButton the current active button in the UI
  109167. */
  109168. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  109169. }
  109170. /**
  109171. * Options to create the webXR UI
  109172. */
  109173. export class WebXREnterExitUIOptions {
  109174. /**
  109175. * Context to enter xr with
  109176. */
  109177. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  109178. /**
  109179. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  109180. */
  109181. customButtons?: Array<WebXREnterExitUIButton>;
  109182. }
  109183. /**
  109184. * UI to allow the user to enter/exit XR mode
  109185. */
  109186. export class WebXREnterExitUI implements IDisposable {
  109187. private scene;
  109188. private _overlay;
  109189. private _buttons;
  109190. private _activeButton;
  109191. /**
  109192. * Fired every time the active button is changed.
  109193. *
  109194. * When xr is entered via a button that launches xr that button will be the callback parameter
  109195. *
  109196. * When exiting xr the callback parameter will be null)
  109197. */
  109198. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  109199. /**
  109200. * Creates UI to allow the user to enter/exit XR mode
  109201. * @param scene the scene to add the ui to
  109202. * @param helper the xr experience helper to enter/exit xr with
  109203. * @param options options to configure the UI
  109204. * @returns the created ui
  109205. */
  109206. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  109207. private constructor();
  109208. private _updateButtons;
  109209. /**
  109210. * Disposes of the object
  109211. */
  109212. dispose(): void;
  109213. }
  109214. }
  109215. declare module BABYLON {
  109216. /**
  109217. * Represents an XR input
  109218. */
  109219. export class WebXRController {
  109220. private scene;
  109221. /** The underlying input source for the controller */
  109222. inputSource: XRInputSource;
  109223. private parentContainer;
  109224. /**
  109225. * 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
  109226. */
  109227. grip?: AbstractMesh;
  109228. /**
  109229. * Pointer which can be used to select objects or attach a visible laser to
  109230. */
  109231. pointer: AbstractMesh;
  109232. /**
  109233. * Event that fires when the controller is removed/disposed
  109234. */
  109235. onDisposeObservable: Observable<{}>;
  109236. private _tmpMatrix;
  109237. private _tmpQuaternion;
  109238. private _tmpVector;
  109239. /**
  109240. * Creates the controller
  109241. * @see https://doc.babylonjs.com/how_to/webxr
  109242. * @param scene the scene which the controller should be associated to
  109243. * @param inputSource the underlying input source for the controller
  109244. * @param parentContainer parent that the controller meshes should be children of
  109245. */
  109246. constructor(scene: Scene,
  109247. /** The underlying input source for the controller */
  109248. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  109249. /**
  109250. * Updates the controller pose based on the given XRFrame
  109251. * @param xrFrame xr frame to update the pose with
  109252. * @param referenceSpace reference space to use
  109253. */
  109254. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  109255. /**
  109256. * Gets a world space ray coming from the controller
  109257. * @param result the resulting ray
  109258. */
  109259. getWorldPointerRayToRef(result: Ray): void;
  109260. /**
  109261. * Disposes of the object
  109262. */
  109263. dispose(): void;
  109264. }
  109265. }
  109266. declare module BABYLON {
  109267. /**
  109268. * XR input used to track XR inputs such as controllers/rays
  109269. */
  109270. export class WebXRInput implements IDisposable {
  109271. /**
  109272. * Base experience the input listens to
  109273. */
  109274. baseExperience: WebXRExperienceHelper;
  109275. /**
  109276. * XR controllers being tracked
  109277. */
  109278. controllers: Array<WebXRController>;
  109279. private _frameObserver;
  109280. private _stateObserver;
  109281. /**
  109282. * Event when a controller has been connected/added
  109283. */
  109284. onControllerAddedObservable: Observable<WebXRController>;
  109285. /**
  109286. * Event when a controller has been removed/disconnected
  109287. */
  109288. onControllerRemovedObservable: Observable<WebXRController>;
  109289. /**
  109290. * Initializes the WebXRInput
  109291. * @param baseExperience experience helper which the input should be created for
  109292. */
  109293. constructor(
  109294. /**
  109295. * Base experience the input listens to
  109296. */
  109297. baseExperience: WebXRExperienceHelper);
  109298. private _onInputSourcesChange;
  109299. private _addAndRemoveControllers;
  109300. /**
  109301. * Disposes of the object
  109302. */
  109303. dispose(): void;
  109304. }
  109305. }
  109306. declare module BABYLON {
  109307. /**
  109308. * Enables teleportation
  109309. */
  109310. export class WebXRControllerTeleportation {
  109311. private _teleportationFillColor;
  109312. private _teleportationBorderColor;
  109313. private _tmpRay;
  109314. private _tmpVector;
  109315. /**
  109316. * Creates a WebXRControllerTeleportation
  109317. * @param input input manager to add teleportation to
  109318. * @param floorMeshes floormeshes which can be teleported to
  109319. */
  109320. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  109321. }
  109322. }
  109323. declare module BABYLON {
  109324. /**
  109325. * Handles pointer input automatically for the pointer of XR controllers
  109326. */
  109327. export class WebXRControllerPointerSelection {
  109328. private static _idCounter;
  109329. private _tmpRay;
  109330. /**
  109331. * Creates a WebXRControllerPointerSelection
  109332. * @param input input manager to setup pointer selection
  109333. */
  109334. constructor(input: WebXRInput);
  109335. private _convertNormalToDirectionOfRay;
  109336. private _updatePointerDistance;
  109337. }
  109338. }
  109339. declare module BABYLON {
  109340. /**
  109341. * Class used to represent data loading progression
  109342. */
  109343. export class SceneLoaderProgressEvent {
  109344. /** defines if data length to load can be evaluated */
  109345. readonly lengthComputable: boolean;
  109346. /** defines the loaded data length */
  109347. readonly loaded: number;
  109348. /** defines the data length to load */
  109349. readonly total: number;
  109350. /**
  109351. * Create a new progress event
  109352. * @param lengthComputable defines if data length to load can be evaluated
  109353. * @param loaded defines the loaded data length
  109354. * @param total defines the data length to load
  109355. */
  109356. constructor(
  109357. /** defines if data length to load can be evaluated */
  109358. lengthComputable: boolean,
  109359. /** defines the loaded data length */
  109360. loaded: number,
  109361. /** defines the data length to load */
  109362. total: number);
  109363. /**
  109364. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  109365. * @param event defines the source event
  109366. * @returns a new SceneLoaderProgressEvent
  109367. */
  109368. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  109369. }
  109370. /**
  109371. * Interface used by SceneLoader plugins to define supported file extensions
  109372. */
  109373. export interface ISceneLoaderPluginExtensions {
  109374. /**
  109375. * Defines the list of supported extensions
  109376. */
  109377. [extension: string]: {
  109378. isBinary: boolean;
  109379. };
  109380. }
  109381. /**
  109382. * Interface used by SceneLoader plugin factory
  109383. */
  109384. export interface ISceneLoaderPluginFactory {
  109385. /**
  109386. * Defines the name of the factory
  109387. */
  109388. name: string;
  109389. /**
  109390. * Function called to create a new plugin
  109391. * @return the new plugin
  109392. */
  109393. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  109394. /**
  109395. * The callback that returns true if the data can be directly loaded.
  109396. * @param data string containing the file data
  109397. * @returns if the data can be loaded directly
  109398. */
  109399. canDirectLoad?(data: string): boolean;
  109400. }
  109401. /**
  109402. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  109403. */
  109404. export interface ISceneLoaderPluginBase {
  109405. /**
  109406. * The friendly name of this plugin.
  109407. */
  109408. name: string;
  109409. /**
  109410. * The file extensions supported by this plugin.
  109411. */
  109412. extensions: string | ISceneLoaderPluginExtensions;
  109413. /**
  109414. * The callback called when loading from a url.
  109415. * @param scene scene loading this url
  109416. * @param url url to load
  109417. * @param onSuccess callback called when the file successfully loads
  109418. * @param onProgress callback called while file is loading (if the server supports this mode)
  109419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  109420. * @param onError callback called when the file fails to load
  109421. * @returns a file request object
  109422. */
  109423. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109424. /**
  109425. * The callback called when loading from a file object.
  109426. * @param scene scene loading this file
  109427. * @param file defines the file to load
  109428. * @param onSuccess defines the callback to call when data is loaded
  109429. * @param onProgress defines the callback to call during loading process
  109430. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  109431. * @param onError defines the callback to call when an error occurs
  109432. * @returns a file request object
  109433. */
  109434. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109435. /**
  109436. * The callback that returns true if the data can be directly loaded.
  109437. * @param data string containing the file data
  109438. * @returns if the data can be loaded directly
  109439. */
  109440. canDirectLoad?(data: string): boolean;
  109441. /**
  109442. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  109443. * @param scene scene loading this data
  109444. * @param data string containing the data
  109445. * @returns data to pass to the plugin
  109446. */
  109447. directLoad?(scene: Scene, data: string): any;
  109448. /**
  109449. * The callback that allows custom handling of the root url based on the response url.
  109450. * @param rootUrl the original root url
  109451. * @param responseURL the response url if available
  109452. * @returns the new root url
  109453. */
  109454. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  109455. }
  109456. /**
  109457. * Interface used to define a SceneLoader plugin
  109458. */
  109459. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  109460. /**
  109461. * Import meshes into a scene.
  109462. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109463. * @param scene The scene to import into
  109464. * @param data The data to import
  109465. * @param rootUrl The root url for scene and resources
  109466. * @param meshes The meshes array to import into
  109467. * @param particleSystems The particle systems array to import into
  109468. * @param skeletons The skeletons array to import into
  109469. * @param onError The callback when import fails
  109470. * @returns True if successful or false otherwise
  109471. */
  109472. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  109473. /**
  109474. * Load into a scene.
  109475. * @param scene The scene to load into
  109476. * @param data The data to import
  109477. * @param rootUrl The root url for scene and resources
  109478. * @param onError The callback when import fails
  109479. * @returns True if successful or false otherwise
  109480. */
  109481. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  109482. /**
  109483. * Load into an asset container.
  109484. * @param scene The scene to load into
  109485. * @param data The data to import
  109486. * @param rootUrl The root url for scene and resources
  109487. * @param onError The callback when import fails
  109488. * @returns The loaded asset container
  109489. */
  109490. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  109491. }
  109492. /**
  109493. * Interface used to define an async SceneLoader plugin
  109494. */
  109495. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  109496. /**
  109497. * Import meshes into a scene.
  109498. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109499. * @param scene The scene to import into
  109500. * @param data The data to import
  109501. * @param rootUrl The root url for scene and resources
  109502. * @param onProgress The callback when the load progresses
  109503. * @param fileName Defines the name of the file to load
  109504. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  109505. */
  109506. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  109507. meshes: AbstractMesh[];
  109508. particleSystems: IParticleSystem[];
  109509. skeletons: Skeleton[];
  109510. animationGroups: AnimationGroup[];
  109511. }>;
  109512. /**
  109513. * Load into a scene.
  109514. * @param scene The scene to load into
  109515. * @param data The data to import
  109516. * @param rootUrl The root url for scene and resources
  109517. * @param onProgress The callback when the load progresses
  109518. * @param fileName Defines the name of the file to load
  109519. * @returns Nothing
  109520. */
  109521. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  109522. /**
  109523. * Load into an asset container.
  109524. * @param scene The scene to load into
  109525. * @param data The data to import
  109526. * @param rootUrl The root url for scene and resources
  109527. * @param onProgress The callback when the load progresses
  109528. * @param fileName Defines the name of the file to load
  109529. * @returns The loaded asset container
  109530. */
  109531. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  109532. }
  109533. /**
  109534. * Class used to load scene from various file formats using registered plugins
  109535. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  109536. */
  109537. export class SceneLoader {
  109538. /**
  109539. * No logging while loading
  109540. */
  109541. static readonly NO_LOGGING: number;
  109542. /**
  109543. * Minimal logging while loading
  109544. */
  109545. static readonly MINIMAL_LOGGING: number;
  109546. /**
  109547. * Summary logging while loading
  109548. */
  109549. static readonly SUMMARY_LOGGING: number;
  109550. /**
  109551. * Detailled logging while loading
  109552. */
  109553. static readonly DETAILED_LOGGING: number;
  109554. /**
  109555. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  109556. */
  109557. static ForceFullSceneLoadingForIncremental: boolean;
  109558. /**
  109559. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  109560. */
  109561. static ShowLoadingScreen: boolean;
  109562. /**
  109563. * Defines the current logging level (while loading the scene)
  109564. * @ignorenaming
  109565. */
  109566. static loggingLevel: number;
  109567. /**
  109568. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  109569. */
  109570. static CleanBoneMatrixWeights: boolean;
  109571. /**
  109572. * Event raised when a plugin is used to load a scene
  109573. */
  109574. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  109575. private static _registeredPlugins;
  109576. private static _getDefaultPlugin;
  109577. private static _getPluginForExtension;
  109578. private static _getPluginForDirectLoad;
  109579. private static _getPluginForFilename;
  109580. private static _getDirectLoad;
  109581. private static _loadData;
  109582. private static _getFileInfo;
  109583. /**
  109584. * Gets a plugin that can load the given extension
  109585. * @param extension defines the extension to load
  109586. * @returns a plugin or null if none works
  109587. */
  109588. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  109589. /**
  109590. * Gets a boolean indicating that the given extension can be loaded
  109591. * @param extension defines the extension to load
  109592. * @returns true if the extension is supported
  109593. */
  109594. static IsPluginForExtensionAvailable(extension: string): boolean;
  109595. /**
  109596. * Adds a new plugin to the list of registered plugins
  109597. * @param plugin defines the plugin to add
  109598. */
  109599. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  109600. /**
  109601. * Import meshes into a scene
  109602. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109603. * @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)
  109604. * @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)
  109605. * @param scene the instance of BABYLON.Scene to append to
  109606. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  109607. * @param onProgress a callback with a progress event for each file being loaded
  109608. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109609. * @param pluginExtension the extension used to determine the plugin
  109610. * @returns The loaded plugin
  109611. */
  109612. 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>;
  109613. /**
  109614. * Import meshes into a scene
  109615. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109616. * @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)
  109617. * @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)
  109618. * @param scene the instance of BABYLON.Scene to append to
  109619. * @param onProgress a callback with a progress event for each file being loaded
  109620. * @param pluginExtension the extension used to determine the plugin
  109621. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  109622. */
  109623. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  109624. meshes: AbstractMesh[];
  109625. particleSystems: IParticleSystem[];
  109626. skeletons: Skeleton[];
  109627. animationGroups: AnimationGroup[];
  109628. }>;
  109629. /**
  109630. * Load a scene
  109631. * @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)
  109632. * @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)
  109633. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109634. * @param onSuccess a callback with the scene when import succeeds
  109635. * @param onProgress a callback with a progress event for each file being loaded
  109636. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109637. * @param pluginExtension the extension used to determine the plugin
  109638. * @returns The loaded plugin
  109639. */
  109640. 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>;
  109641. /**
  109642. * Load a scene
  109643. * @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)
  109644. * @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)
  109645. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109646. * @param onProgress a callback with a progress event for each file being loaded
  109647. * @param pluginExtension the extension used to determine the plugin
  109648. * @returns The loaded scene
  109649. */
  109650. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109651. /**
  109652. * Append a scene
  109653. * @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)
  109654. * @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)
  109655. * @param scene is the instance of BABYLON.Scene to append to
  109656. * @param onSuccess a callback with the scene when import succeeds
  109657. * @param onProgress a callback with a progress event for each file being loaded
  109658. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109659. * @param pluginExtension the extension used to determine the plugin
  109660. * @returns The loaded plugin
  109661. */
  109662. 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>;
  109663. /**
  109664. * Append a scene
  109665. * @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)
  109666. * @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)
  109667. * @param scene is the instance of BABYLON.Scene to append to
  109668. * @param onProgress a callback with a progress event for each file being loaded
  109669. * @param pluginExtension the extension used to determine the plugin
  109670. * @returns The given scene
  109671. */
  109672. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109673. /**
  109674. * Load a scene into an asset container
  109675. * @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)
  109676. * @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)
  109677. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109678. * @param onSuccess a callback with the scene when import succeeds
  109679. * @param onProgress a callback with a progress event for each file being loaded
  109680. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109681. * @param pluginExtension the extension used to determine the plugin
  109682. * @returns The loaded plugin
  109683. */
  109684. 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>;
  109685. /**
  109686. * Load a scene into an asset container
  109687. * @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)
  109688. * @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)
  109689. * @param scene is the instance of Scene to append to
  109690. * @param onProgress a callback with a progress event for each file being loaded
  109691. * @param pluginExtension the extension used to determine the plugin
  109692. * @returns The loaded asset container
  109693. */
  109694. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  109695. }
  109696. }
  109697. declare module BABYLON {
  109698. /**
  109699. * Generic Controller
  109700. */
  109701. export class GenericController extends WebVRController {
  109702. /**
  109703. * Base Url for the controller model.
  109704. */
  109705. static readonly MODEL_BASE_URL: string;
  109706. /**
  109707. * File name for the controller model.
  109708. */
  109709. static readonly MODEL_FILENAME: string;
  109710. /**
  109711. * Creates a new GenericController from a gamepad
  109712. * @param vrGamepad the gamepad that the controller should be created from
  109713. */
  109714. constructor(vrGamepad: any);
  109715. /**
  109716. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109717. * @param scene scene in which to add meshes
  109718. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109719. */
  109720. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109721. /**
  109722. * Called once for each button that changed state since the last frame
  109723. * @param buttonIdx Which button index changed
  109724. * @param state New state of the button
  109725. * @param changes Which properties on the state changed since last frame
  109726. */
  109727. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109728. }
  109729. }
  109730. declare module BABYLON {
  109731. /**
  109732. * Defines the WindowsMotionController object that the state of the windows motion controller
  109733. */
  109734. export class WindowsMotionController extends WebVRController {
  109735. /**
  109736. * The base url used to load the left and right controller models
  109737. */
  109738. static MODEL_BASE_URL: string;
  109739. /**
  109740. * The name of the left controller model file
  109741. */
  109742. static MODEL_LEFT_FILENAME: string;
  109743. /**
  109744. * The name of the right controller model file
  109745. */
  109746. static MODEL_RIGHT_FILENAME: string;
  109747. /**
  109748. * The controller name prefix for this controller type
  109749. */
  109750. static readonly GAMEPAD_ID_PREFIX: string;
  109751. /**
  109752. * The controller id pattern for this controller type
  109753. */
  109754. private static readonly GAMEPAD_ID_PATTERN;
  109755. private _loadedMeshInfo;
  109756. private readonly _mapping;
  109757. /**
  109758. * Fired when the trackpad on this controller is clicked
  109759. */
  109760. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  109761. /**
  109762. * Fired when the trackpad on this controller is modified
  109763. */
  109764. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109765. /**
  109766. * The current x and y values of this controller's trackpad
  109767. */
  109768. trackpad: StickValues;
  109769. /**
  109770. * Creates a new WindowsMotionController from a gamepad
  109771. * @param vrGamepad the gamepad that the controller should be created from
  109772. */
  109773. constructor(vrGamepad: any);
  109774. /**
  109775. * Fired when the trigger on this controller is modified
  109776. */
  109777. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109778. /**
  109779. * Fired when the menu button on this controller is modified
  109780. */
  109781. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109782. /**
  109783. * Fired when the grip button on this controller is modified
  109784. */
  109785. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109786. /**
  109787. * Fired when the thumbstick button on this controller is modified
  109788. */
  109789. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109790. /**
  109791. * Fired when the touchpad button on this controller is modified
  109792. */
  109793. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109794. /**
  109795. * Fired when the touchpad values on this controller are modified
  109796. */
  109797. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109798. private _updateTrackpad;
  109799. /**
  109800. * Called once per frame by the engine.
  109801. */
  109802. update(): void;
  109803. /**
  109804. * Called once for each button that changed state since the last frame
  109805. * @param buttonIdx Which button index changed
  109806. * @param state New state of the button
  109807. * @param changes Which properties on the state changed since last frame
  109808. */
  109809. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109810. /**
  109811. * Moves the buttons on the controller mesh based on their current state
  109812. * @param buttonName the name of the button to move
  109813. * @param buttonValue the value of the button which determines the buttons new position
  109814. */
  109815. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109816. /**
  109817. * Moves the axis on the controller mesh based on its current state
  109818. * @param axis the index of the axis
  109819. * @param axisValue the value of the axis which determines the meshes new position
  109820. * @hidden
  109821. */
  109822. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109823. /**
  109824. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109825. * @param scene scene in which to add meshes
  109826. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109827. */
  109828. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109829. /**
  109830. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109831. * can be transformed by button presses and axes values, based on this._mapping.
  109832. *
  109833. * @param scene scene in which the meshes exist
  109834. * @param meshes list of meshes that make up the controller model to process
  109835. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109836. */
  109837. private processModel;
  109838. private createMeshInfo;
  109839. /**
  109840. * Gets the ray of the controller in the direction the controller is pointing
  109841. * @param length the length the resulting ray should be
  109842. * @returns a ray in the direction the controller is pointing
  109843. */
  109844. getForwardRay(length?: number): Ray;
  109845. /**
  109846. * Disposes of the controller
  109847. */
  109848. dispose(): void;
  109849. }
  109850. }
  109851. declare module BABYLON {
  109852. /**
  109853. * Oculus Touch Controller
  109854. */
  109855. export class OculusTouchController extends WebVRController {
  109856. /**
  109857. * Base Url for the controller model.
  109858. */
  109859. static MODEL_BASE_URL: string;
  109860. /**
  109861. * File name for the left controller model.
  109862. */
  109863. static MODEL_LEFT_FILENAME: string;
  109864. /**
  109865. * File name for the right controller model.
  109866. */
  109867. static MODEL_RIGHT_FILENAME: string;
  109868. /**
  109869. * Base Url for the Quest controller model.
  109870. */
  109871. static QUEST_MODEL_BASE_URL: string;
  109872. /**
  109873. * @hidden
  109874. * If the controllers are running on a device that needs the updated Quest controller models
  109875. */
  109876. static _IsQuest: boolean;
  109877. /**
  109878. * Fired when the secondary trigger on this controller is modified
  109879. */
  109880. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109881. /**
  109882. * Fired when the thumb rest on this controller is modified
  109883. */
  109884. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109885. /**
  109886. * Creates a new OculusTouchController from a gamepad
  109887. * @param vrGamepad the gamepad that the controller should be created from
  109888. */
  109889. constructor(vrGamepad: any);
  109890. /**
  109891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109892. * @param scene scene in which to add meshes
  109893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109894. */
  109895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109896. /**
  109897. * Fired when the A button on this controller is modified
  109898. */
  109899. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109900. /**
  109901. * Fired when the B button on this controller is modified
  109902. */
  109903. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109904. /**
  109905. * Fired when the X button on this controller is modified
  109906. */
  109907. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109908. /**
  109909. * Fired when the Y button on this controller is modified
  109910. */
  109911. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109912. /**
  109913. * Called once for each button that changed state since the last frame
  109914. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109915. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109916. * 2) secondary trigger (same)
  109917. * 3) A (right) X (left), touch, pressed = value
  109918. * 4) B / Y
  109919. * 5) thumb rest
  109920. * @param buttonIdx Which button index changed
  109921. * @param state New state of the button
  109922. * @param changes Which properties on the state changed since last frame
  109923. */
  109924. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109925. }
  109926. }
  109927. declare module BABYLON {
  109928. /**
  109929. * Vive Controller
  109930. */
  109931. export class ViveController extends WebVRController {
  109932. /**
  109933. * Base Url for the controller model.
  109934. */
  109935. static MODEL_BASE_URL: string;
  109936. /**
  109937. * File name for the controller model.
  109938. */
  109939. static MODEL_FILENAME: string;
  109940. /**
  109941. * Creates a new ViveController from a gamepad
  109942. * @param vrGamepad the gamepad that the controller should be created from
  109943. */
  109944. constructor(vrGamepad: any);
  109945. /**
  109946. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109947. * @param scene scene in which to add meshes
  109948. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109949. */
  109950. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109951. /**
  109952. * Fired when the left button on this controller is modified
  109953. */
  109954. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109955. /**
  109956. * Fired when the right button on this controller is modified
  109957. */
  109958. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109959. /**
  109960. * Fired when the menu button on this controller is modified
  109961. */
  109962. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109963. /**
  109964. * Called once for each button that changed state since the last frame
  109965. * Vive mapping:
  109966. * 0: touchpad
  109967. * 1: trigger
  109968. * 2: left AND right buttons
  109969. * 3: menu button
  109970. * @param buttonIdx Which button index changed
  109971. * @param state New state of the button
  109972. * @param changes Which properties on the state changed since last frame
  109973. */
  109974. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109975. }
  109976. }
  109977. declare module BABYLON {
  109978. /**
  109979. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109980. */
  109981. export class WebXRControllerModelLoader {
  109982. /**
  109983. * Creates the WebXRControllerModelLoader
  109984. * @param input xr input that creates the controllers
  109985. */
  109986. constructor(input: WebXRInput);
  109987. }
  109988. }
  109989. declare module BABYLON {
  109990. /**
  109991. * Contains an array of blocks representing the octree
  109992. */
  109993. export interface IOctreeContainer<T> {
  109994. /**
  109995. * Blocks within the octree
  109996. */
  109997. blocks: Array<OctreeBlock<T>>;
  109998. }
  109999. /**
  110000. * Class used to store a cell in an octree
  110001. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110002. */
  110003. export class OctreeBlock<T> {
  110004. /**
  110005. * Gets the content of the current block
  110006. */
  110007. entries: T[];
  110008. /**
  110009. * Gets the list of block children
  110010. */
  110011. blocks: Array<OctreeBlock<T>>;
  110012. private _depth;
  110013. private _maxDepth;
  110014. private _capacity;
  110015. private _minPoint;
  110016. private _maxPoint;
  110017. private _boundingVectors;
  110018. private _creationFunc;
  110019. /**
  110020. * Creates a new block
  110021. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  110022. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  110023. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110024. * @param depth defines the current depth of this block in the octree
  110025. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  110026. * @param creationFunc defines a callback to call when an element is added to the block
  110027. */
  110028. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  110029. /**
  110030. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110031. */
  110032. readonly capacity: number;
  110033. /**
  110034. * Gets the minimum vector (in world space) of the block's bounding box
  110035. */
  110036. readonly minPoint: Vector3;
  110037. /**
  110038. * Gets the maximum vector (in world space) of the block's bounding box
  110039. */
  110040. readonly maxPoint: Vector3;
  110041. /**
  110042. * Add a new element to this block
  110043. * @param entry defines the element to add
  110044. */
  110045. addEntry(entry: T): void;
  110046. /**
  110047. * Remove an element from this block
  110048. * @param entry defines the element to remove
  110049. */
  110050. removeEntry(entry: T): void;
  110051. /**
  110052. * Add an array of elements to this block
  110053. * @param entries defines the array of elements to add
  110054. */
  110055. addEntries(entries: T[]): void;
  110056. /**
  110057. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  110058. * @param frustumPlanes defines the frustum planes to test
  110059. * @param selection defines the array to store current content if selection is positive
  110060. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110061. */
  110062. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110063. /**
  110064. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  110065. * @param sphereCenter defines the bounding sphere center
  110066. * @param sphereRadius defines the bounding sphere radius
  110067. * @param selection defines the array to store current content if selection is positive
  110068. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110069. */
  110070. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110071. /**
  110072. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  110073. * @param ray defines the ray to test with
  110074. * @param selection defines the array to store current content if selection is positive
  110075. */
  110076. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  110077. /**
  110078. * Subdivide the content into child blocks (this block will then be empty)
  110079. */
  110080. createInnerBlocks(): void;
  110081. /**
  110082. * @hidden
  110083. */
  110084. 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;
  110085. }
  110086. }
  110087. declare module BABYLON {
  110088. /**
  110089. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  110090. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110091. */
  110092. export class Octree<T> {
  110093. /** 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.) */
  110094. maxDepth: number;
  110095. /**
  110096. * Blocks within the octree containing objects
  110097. */
  110098. blocks: Array<OctreeBlock<T>>;
  110099. /**
  110100. * Content stored in the octree
  110101. */
  110102. dynamicContent: T[];
  110103. private _maxBlockCapacity;
  110104. private _selectionContent;
  110105. private _creationFunc;
  110106. /**
  110107. * Creates a octree
  110108. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110109. * @param creationFunc function to be used to instatiate the octree
  110110. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  110111. * @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.)
  110112. */
  110113. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  110114. /** 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.) */
  110115. maxDepth?: number);
  110116. /**
  110117. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  110118. * @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);
  110119. * @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);
  110120. * @param entries meshes to be added to the octree blocks
  110121. */
  110122. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  110123. /**
  110124. * Adds a mesh to the octree
  110125. * @param entry Mesh to add to the octree
  110126. */
  110127. addMesh(entry: T): void;
  110128. /**
  110129. * Remove an element from the octree
  110130. * @param entry defines the element to remove
  110131. */
  110132. removeMesh(entry: T): void;
  110133. /**
  110134. * Selects an array of meshes within the frustum
  110135. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  110136. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  110137. * @returns array of meshes within the frustum
  110138. */
  110139. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  110140. /**
  110141. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  110142. * @param sphereCenter defines the bounding sphere center
  110143. * @param sphereRadius defines the bounding sphere radius
  110144. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110145. * @returns an array of objects that intersect the sphere
  110146. */
  110147. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  110148. /**
  110149. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  110150. * @param ray defines the ray to test with
  110151. * @returns array of intersected objects
  110152. */
  110153. intersectsRay(ray: Ray): SmartArray<T>;
  110154. /**
  110155. * Adds a mesh into the octree block if it intersects the block
  110156. */
  110157. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  110158. /**
  110159. * Adds a submesh into the octree block if it intersects the block
  110160. */
  110161. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  110162. }
  110163. }
  110164. declare module BABYLON {
  110165. interface Scene {
  110166. /**
  110167. * @hidden
  110168. * Backing Filed
  110169. */
  110170. _selectionOctree: Octree<AbstractMesh>;
  110171. /**
  110172. * Gets the octree used to boost mesh selection (picking)
  110173. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110174. */
  110175. selectionOctree: Octree<AbstractMesh>;
  110176. /**
  110177. * Creates or updates the octree used to boost selection (picking)
  110178. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110179. * @param maxCapacity defines the maximum capacity per leaf
  110180. * @param maxDepth defines the maximum depth of the octree
  110181. * @returns an octree of AbstractMesh
  110182. */
  110183. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  110184. }
  110185. interface AbstractMesh {
  110186. /**
  110187. * @hidden
  110188. * Backing Field
  110189. */
  110190. _submeshesOctree: Octree<SubMesh>;
  110191. /**
  110192. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  110193. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  110194. * @param maxCapacity defines the maximum size of each block (64 by default)
  110195. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  110196. * @returns the new octree
  110197. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  110198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110199. */
  110200. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  110201. }
  110202. /**
  110203. * Defines the octree scene component responsible to manage any octrees
  110204. * in a given scene.
  110205. */
  110206. export class OctreeSceneComponent {
  110207. /**
  110208. * The component name help to identify the component in the list of scene components.
  110209. */
  110210. readonly name: string;
  110211. /**
  110212. * The scene the component belongs to.
  110213. */
  110214. scene: Scene;
  110215. /**
  110216. * Indicates if the meshes have been checked to make sure they are isEnabled()
  110217. */
  110218. readonly checksIsEnabled: boolean;
  110219. /**
  110220. * Creates a new instance of the component for the given scene
  110221. * @param scene Defines the scene to register the component in
  110222. */
  110223. constructor(scene: Scene);
  110224. /**
  110225. * Registers the component in a given scene
  110226. */
  110227. register(): void;
  110228. /**
  110229. * Return the list of active meshes
  110230. * @returns the list of active meshes
  110231. */
  110232. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110233. /**
  110234. * Return the list of active sub meshes
  110235. * @param mesh The mesh to get the candidates sub meshes from
  110236. * @returns the list of active sub meshes
  110237. */
  110238. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110239. private _tempRay;
  110240. /**
  110241. * Return the list of sub meshes intersecting with a given local ray
  110242. * @param mesh defines the mesh to find the submesh for
  110243. * @param localRay defines the ray in local space
  110244. * @returns the list of intersecting sub meshes
  110245. */
  110246. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  110247. /**
  110248. * Return the list of sub meshes colliding with a collider
  110249. * @param mesh defines the mesh to find the submesh for
  110250. * @param collider defines the collider to evaluate the collision against
  110251. * @returns the list of colliding sub meshes
  110252. */
  110253. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  110254. /**
  110255. * Rebuilds the elements related to this component in case of
  110256. * context lost for instance.
  110257. */
  110258. rebuild(): void;
  110259. /**
  110260. * Disposes the component and the associated ressources.
  110261. */
  110262. dispose(): void;
  110263. }
  110264. }
  110265. declare module BABYLON {
  110266. /**
  110267. * Renders a layer on top of an existing scene
  110268. */
  110269. export class UtilityLayerRenderer implements IDisposable {
  110270. /** the original scene that will be rendered on top of */
  110271. originalScene: Scene;
  110272. private _pointerCaptures;
  110273. private _lastPointerEvents;
  110274. private static _DefaultUtilityLayer;
  110275. private static _DefaultKeepDepthUtilityLayer;
  110276. private _sharedGizmoLight;
  110277. private _renderCamera;
  110278. /**
  110279. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  110280. * @returns the camera that is used when rendering the utility layer
  110281. */
  110282. getRenderCamera(): Nullable<Camera>;
  110283. /**
  110284. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  110285. * @param cam the camera that should be used when rendering the utility layer
  110286. */
  110287. setRenderCamera(cam: Nullable<Camera>): void;
  110288. /**
  110289. * @hidden
  110290. * Light which used by gizmos to get light shading
  110291. */
  110292. _getSharedGizmoLight(): HemisphericLight;
  110293. /**
  110294. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  110295. */
  110296. pickUtilitySceneFirst: boolean;
  110297. /**
  110298. * 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)
  110299. */
  110300. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  110301. /**
  110302. * 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)
  110303. */
  110304. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  110305. /**
  110306. * The scene that is rendered on top of the original scene
  110307. */
  110308. utilityLayerScene: Scene;
  110309. /**
  110310. * If the utility layer should automatically be rendered on top of existing scene
  110311. */
  110312. shouldRender: boolean;
  110313. /**
  110314. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  110315. */
  110316. onlyCheckPointerDownEvents: boolean;
  110317. /**
  110318. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  110319. */
  110320. processAllEvents: boolean;
  110321. /**
  110322. * Observable raised when the pointer move from the utility layer scene to the main scene
  110323. */
  110324. onPointerOutObservable: Observable<number>;
  110325. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  110326. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  110327. private _afterRenderObserver;
  110328. private _sceneDisposeObserver;
  110329. private _originalPointerObserver;
  110330. /**
  110331. * Instantiates a UtilityLayerRenderer
  110332. * @param originalScene the original scene that will be rendered on top of
  110333. * @param handleEvents boolean indicating if the utility layer should handle events
  110334. */
  110335. constructor(
  110336. /** the original scene that will be rendered on top of */
  110337. originalScene: Scene, handleEvents?: boolean);
  110338. private _notifyObservers;
  110339. /**
  110340. * Renders the utility layers scene on top of the original scene
  110341. */
  110342. render(): void;
  110343. /**
  110344. * Disposes of the renderer
  110345. */
  110346. dispose(): void;
  110347. private _updateCamera;
  110348. }
  110349. }
  110350. declare module BABYLON {
  110351. /**
  110352. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  110353. */
  110354. export class Gizmo implements IDisposable {
  110355. /** The utility layer the gizmo will be added to */
  110356. gizmoLayer: UtilityLayerRenderer;
  110357. /**
  110358. * The root mesh of the gizmo
  110359. */
  110360. _rootMesh: Mesh;
  110361. private _attachedMesh;
  110362. /**
  110363. * Ratio for the scale of the gizmo (Default: 1)
  110364. */
  110365. scaleRatio: number;
  110366. /**
  110367. * If a custom mesh has been set (Default: false)
  110368. */
  110369. protected _customMeshSet: boolean;
  110370. /**
  110371. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  110372. * * When set, interactions will be enabled
  110373. */
  110374. attachedMesh: Nullable<AbstractMesh>;
  110375. /**
  110376. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110377. * @param mesh The mesh to replace the default mesh of the gizmo
  110378. */
  110379. setCustomMesh(mesh: Mesh): void;
  110380. /**
  110381. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  110382. */
  110383. updateGizmoRotationToMatchAttachedMesh: boolean;
  110384. /**
  110385. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  110386. */
  110387. updateGizmoPositionToMatchAttachedMesh: boolean;
  110388. /**
  110389. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  110390. */
  110391. updateScale: boolean;
  110392. protected _interactionsEnabled: boolean;
  110393. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110394. private _beforeRenderObserver;
  110395. private _tempVector;
  110396. /**
  110397. * Creates a gizmo
  110398. * @param gizmoLayer The utility layer the gizmo will be added to
  110399. */
  110400. constructor(
  110401. /** The utility layer the gizmo will be added to */
  110402. gizmoLayer?: UtilityLayerRenderer);
  110403. /**
  110404. * Updates the gizmo to match the attached mesh's position/rotation
  110405. */
  110406. protected _update(): void;
  110407. /**
  110408. * Disposes of the gizmo
  110409. */
  110410. dispose(): void;
  110411. }
  110412. }
  110413. declare module BABYLON {
  110414. /**
  110415. * Single plane drag gizmo
  110416. */
  110417. export class PlaneDragGizmo extends Gizmo {
  110418. /**
  110419. * Drag behavior responsible for the gizmos dragging interactions
  110420. */
  110421. dragBehavior: PointerDragBehavior;
  110422. private _pointerObserver;
  110423. /**
  110424. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110425. */
  110426. snapDistance: number;
  110427. /**
  110428. * Event that fires each time the gizmo snaps to a new location.
  110429. * * snapDistance is the the change in distance
  110430. */
  110431. onSnapObservable: Observable<{
  110432. snapDistance: number;
  110433. }>;
  110434. private _plane;
  110435. private _coloredMaterial;
  110436. private _hoverMaterial;
  110437. private _isEnabled;
  110438. private _parent;
  110439. /** @hidden */
  110440. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  110441. /** @hidden */
  110442. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110443. /**
  110444. * Creates a PlaneDragGizmo
  110445. * @param gizmoLayer The utility layer the gizmo will be added to
  110446. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  110447. * @param color The color of the gizmo
  110448. */
  110449. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110450. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110451. /**
  110452. * If the gizmo is enabled
  110453. */
  110454. isEnabled: boolean;
  110455. /**
  110456. * Disposes of the gizmo
  110457. */
  110458. dispose(): void;
  110459. }
  110460. }
  110461. declare module BABYLON {
  110462. /**
  110463. * Gizmo that enables dragging a mesh along 3 axis
  110464. */
  110465. export class PositionGizmo extends Gizmo {
  110466. /**
  110467. * Internal gizmo used for interactions on the x axis
  110468. */
  110469. xGizmo: AxisDragGizmo;
  110470. /**
  110471. * Internal gizmo used for interactions on the y axis
  110472. */
  110473. yGizmo: AxisDragGizmo;
  110474. /**
  110475. * Internal gizmo used for interactions on the z axis
  110476. */
  110477. zGizmo: AxisDragGizmo;
  110478. /**
  110479. * Internal gizmo used for interactions on the yz plane
  110480. */
  110481. xPlaneGizmo: PlaneDragGizmo;
  110482. /**
  110483. * Internal gizmo used for interactions on the xz plane
  110484. */
  110485. yPlaneGizmo: PlaneDragGizmo;
  110486. /**
  110487. * Internal gizmo used for interactions on the xy plane
  110488. */
  110489. zPlaneGizmo: PlaneDragGizmo;
  110490. /**
  110491. * private variables
  110492. */
  110493. private _meshAttached;
  110494. private _updateGizmoRotationToMatchAttachedMesh;
  110495. private _snapDistance;
  110496. private _scaleRatio;
  110497. /** Fires an event when any of it's sub gizmos are dragged */
  110498. onDragStartObservable: Observable<unknown>;
  110499. /** Fires an event when any of it's sub gizmos are released from dragging */
  110500. onDragEndObservable: Observable<unknown>;
  110501. /**
  110502. * If set to true, planar drag is enabled
  110503. */
  110504. private _planarGizmoEnabled;
  110505. attachedMesh: Nullable<AbstractMesh>;
  110506. /**
  110507. * Creates a PositionGizmo
  110508. * @param gizmoLayer The utility layer the gizmo will be added to
  110509. */
  110510. constructor(gizmoLayer?: UtilityLayerRenderer);
  110511. /**
  110512. * If the planar drag gizmo is enabled
  110513. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  110514. */
  110515. planarGizmoEnabled: boolean;
  110516. updateGizmoRotationToMatchAttachedMesh: boolean;
  110517. /**
  110518. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110519. */
  110520. snapDistance: number;
  110521. /**
  110522. * Ratio for the scale of the gizmo (Default: 1)
  110523. */
  110524. scaleRatio: number;
  110525. /**
  110526. * Disposes of the gizmo
  110527. */
  110528. dispose(): void;
  110529. /**
  110530. * CustomMeshes are not supported by this gizmo
  110531. * @param mesh The mesh to replace the default mesh of the gizmo
  110532. */
  110533. setCustomMesh(mesh: Mesh): void;
  110534. }
  110535. }
  110536. declare module BABYLON {
  110537. /**
  110538. * Single axis drag gizmo
  110539. */
  110540. export class AxisDragGizmo extends Gizmo {
  110541. /**
  110542. * Drag behavior responsible for the gizmos dragging interactions
  110543. */
  110544. dragBehavior: PointerDragBehavior;
  110545. private _pointerObserver;
  110546. /**
  110547. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110548. */
  110549. snapDistance: number;
  110550. /**
  110551. * Event that fires each time the gizmo snaps to a new location.
  110552. * * snapDistance is the the change in distance
  110553. */
  110554. onSnapObservable: Observable<{
  110555. snapDistance: number;
  110556. }>;
  110557. private _isEnabled;
  110558. private _parent;
  110559. private _arrow;
  110560. private _coloredMaterial;
  110561. private _hoverMaterial;
  110562. /** @hidden */
  110563. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  110564. /** @hidden */
  110565. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110566. /**
  110567. * Creates an AxisDragGizmo
  110568. * @param gizmoLayer The utility layer the gizmo will be added to
  110569. * @param dragAxis The axis which the gizmo will be able to drag on
  110570. * @param color The color of the gizmo
  110571. */
  110572. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110573. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110574. /**
  110575. * If the gizmo is enabled
  110576. */
  110577. isEnabled: boolean;
  110578. /**
  110579. * Disposes of the gizmo
  110580. */
  110581. dispose(): void;
  110582. }
  110583. }
  110584. declare module BABYLON.Debug {
  110585. /**
  110586. * The Axes viewer will show 3 axes in a specific point in space
  110587. */
  110588. export class AxesViewer {
  110589. private _xAxis;
  110590. private _yAxis;
  110591. private _zAxis;
  110592. private _scaleLinesFactor;
  110593. private _instanced;
  110594. /**
  110595. * Gets the hosting scene
  110596. */
  110597. scene: Scene;
  110598. /**
  110599. * Gets or sets a number used to scale line length
  110600. */
  110601. scaleLines: number;
  110602. /** Gets the node hierarchy used to render x-axis */
  110603. readonly xAxis: TransformNode;
  110604. /** Gets the node hierarchy used to render y-axis */
  110605. readonly yAxis: TransformNode;
  110606. /** Gets the node hierarchy used to render z-axis */
  110607. readonly zAxis: TransformNode;
  110608. /**
  110609. * Creates a new AxesViewer
  110610. * @param scene defines the hosting scene
  110611. * @param scaleLines defines a number used to scale line length (1 by default)
  110612. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  110613. * @param xAxis defines the node hierarchy used to render the x-axis
  110614. * @param yAxis defines the node hierarchy used to render the y-axis
  110615. * @param zAxis defines the node hierarchy used to render the z-axis
  110616. */
  110617. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  110618. /**
  110619. * Force the viewer to update
  110620. * @param position defines the position of the viewer
  110621. * @param xaxis defines the x axis of the viewer
  110622. * @param yaxis defines the y axis of the viewer
  110623. * @param zaxis defines the z axis of the viewer
  110624. */
  110625. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  110626. /**
  110627. * Creates an instance of this axes viewer.
  110628. * @returns a new axes viewer with instanced meshes
  110629. */
  110630. createInstance(): AxesViewer;
  110631. /** Releases resources */
  110632. dispose(): void;
  110633. private static _SetRenderingGroupId;
  110634. }
  110635. }
  110636. declare module BABYLON.Debug {
  110637. /**
  110638. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  110639. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  110640. */
  110641. export class BoneAxesViewer extends AxesViewer {
  110642. /**
  110643. * Gets or sets the target mesh where to display the axes viewer
  110644. */
  110645. mesh: Nullable<Mesh>;
  110646. /**
  110647. * Gets or sets the target bone where to display the axes viewer
  110648. */
  110649. bone: Nullable<Bone>;
  110650. /** Gets current position */
  110651. pos: Vector3;
  110652. /** Gets direction of X axis */
  110653. xaxis: Vector3;
  110654. /** Gets direction of Y axis */
  110655. yaxis: Vector3;
  110656. /** Gets direction of Z axis */
  110657. zaxis: Vector3;
  110658. /**
  110659. * Creates a new BoneAxesViewer
  110660. * @param scene defines the hosting scene
  110661. * @param bone defines the target bone
  110662. * @param mesh defines the target mesh
  110663. * @param scaleLines defines a scaling factor for line length (1 by default)
  110664. */
  110665. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  110666. /**
  110667. * Force the viewer to update
  110668. */
  110669. update(): void;
  110670. /** Releases resources */
  110671. dispose(): void;
  110672. }
  110673. }
  110674. declare module BABYLON {
  110675. /**
  110676. * Interface used to define scene explorer extensibility option
  110677. */
  110678. export interface IExplorerExtensibilityOption {
  110679. /**
  110680. * Define the option label
  110681. */
  110682. label: string;
  110683. /**
  110684. * Defines the action to execute on click
  110685. */
  110686. action: (entity: any) => void;
  110687. }
  110688. /**
  110689. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  110690. */
  110691. export interface IExplorerExtensibilityGroup {
  110692. /**
  110693. * Defines a predicate to test if a given type mut be extended
  110694. */
  110695. predicate: (entity: any) => boolean;
  110696. /**
  110697. * Gets the list of options added to a type
  110698. */
  110699. entries: IExplorerExtensibilityOption[];
  110700. }
  110701. /**
  110702. * Interface used to define the options to use to create the Inspector
  110703. */
  110704. export interface IInspectorOptions {
  110705. /**
  110706. * Display in overlay mode (default: false)
  110707. */
  110708. overlay?: boolean;
  110709. /**
  110710. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  110711. */
  110712. globalRoot?: HTMLElement;
  110713. /**
  110714. * Display the Scene explorer
  110715. */
  110716. showExplorer?: boolean;
  110717. /**
  110718. * Display the property inspector
  110719. */
  110720. showInspector?: boolean;
  110721. /**
  110722. * Display in embed mode (both panes on the right)
  110723. */
  110724. embedMode?: boolean;
  110725. /**
  110726. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  110727. */
  110728. handleResize?: boolean;
  110729. /**
  110730. * Allow the panes to popup (default: true)
  110731. */
  110732. enablePopup?: boolean;
  110733. /**
  110734. * Allow the panes to be closed by users (default: true)
  110735. */
  110736. enableClose?: boolean;
  110737. /**
  110738. * Optional list of extensibility entries
  110739. */
  110740. explorerExtensibility?: IExplorerExtensibilityGroup[];
  110741. /**
  110742. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  110743. */
  110744. inspectorURL?: string;
  110745. }
  110746. interface Scene {
  110747. /**
  110748. * @hidden
  110749. * Backing field
  110750. */
  110751. _debugLayer: DebugLayer;
  110752. /**
  110753. * Gets the debug layer (aka Inspector) associated with the scene
  110754. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110755. */
  110756. debugLayer: DebugLayer;
  110757. }
  110758. /**
  110759. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110760. * what is happening in your scene
  110761. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110762. */
  110763. export class DebugLayer {
  110764. /**
  110765. * Define the url to get the inspector script from.
  110766. * By default it uses the babylonjs CDN.
  110767. * @ignoreNaming
  110768. */
  110769. static InspectorURL: string;
  110770. private _scene;
  110771. private BJSINSPECTOR;
  110772. private _onPropertyChangedObservable?;
  110773. /**
  110774. * Observable triggered when a property is changed through the inspector.
  110775. */
  110776. readonly onPropertyChangedObservable: any;
  110777. /**
  110778. * Instantiates a new debug layer.
  110779. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110780. * what is happening in your scene
  110781. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110782. * @param scene Defines the scene to inspect
  110783. */
  110784. constructor(scene: Scene);
  110785. /** Creates the inspector window. */
  110786. private _createInspector;
  110787. /**
  110788. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110789. * @param entity defines the entity to select
  110790. * @param lineContainerTitle defines the specific block to highlight
  110791. */
  110792. select(entity: any, lineContainerTitle?: string): void;
  110793. /** Get the inspector from bundle or global */
  110794. private _getGlobalInspector;
  110795. /**
  110796. * Get if the inspector is visible or not.
  110797. * @returns true if visible otherwise, false
  110798. */
  110799. isVisible(): boolean;
  110800. /**
  110801. * Hide the inspector and close its window.
  110802. */
  110803. hide(): void;
  110804. /**
  110805. * Launch the debugLayer.
  110806. * @param config Define the configuration of the inspector
  110807. * @return a promise fulfilled when the debug layer is visible
  110808. */
  110809. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110810. }
  110811. }
  110812. declare module BABYLON {
  110813. /**
  110814. * Class containing static functions to help procedurally build meshes
  110815. */
  110816. export class BoxBuilder {
  110817. /**
  110818. * Creates a box mesh
  110819. * * The parameter `size` sets the size (float) of each box side (default 1)
  110820. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110821. * * 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)
  110822. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110826. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110827. * @param name defines the name of the mesh
  110828. * @param options defines the options used to create the mesh
  110829. * @param scene defines the hosting scene
  110830. * @returns the box mesh
  110831. */
  110832. static CreateBox(name: string, options: {
  110833. size?: number;
  110834. width?: number;
  110835. height?: number;
  110836. depth?: number;
  110837. faceUV?: Vector4[];
  110838. faceColors?: Color4[];
  110839. sideOrientation?: number;
  110840. frontUVs?: Vector4;
  110841. backUVs?: Vector4;
  110842. wrap?: boolean;
  110843. topBaseAt?: number;
  110844. bottomBaseAt?: number;
  110845. updatable?: boolean;
  110846. }, scene?: Nullable<Scene>): Mesh;
  110847. }
  110848. }
  110849. declare module BABYLON {
  110850. /**
  110851. * Class containing static functions to help procedurally build meshes
  110852. */
  110853. export class SphereBuilder {
  110854. /**
  110855. * Creates a sphere mesh
  110856. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110857. * * 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`)
  110858. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110859. * * 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
  110860. * * 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)
  110861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110864. * @param name defines the name of the mesh
  110865. * @param options defines the options used to create the mesh
  110866. * @param scene defines the hosting scene
  110867. * @returns the sphere mesh
  110868. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110869. */
  110870. static CreateSphere(name: string, options: {
  110871. segments?: number;
  110872. diameter?: number;
  110873. diameterX?: number;
  110874. diameterY?: number;
  110875. diameterZ?: number;
  110876. arc?: number;
  110877. slice?: number;
  110878. sideOrientation?: number;
  110879. frontUVs?: Vector4;
  110880. backUVs?: Vector4;
  110881. updatable?: boolean;
  110882. }, scene?: Nullable<Scene>): Mesh;
  110883. }
  110884. }
  110885. declare module BABYLON.Debug {
  110886. /**
  110887. * Used to show the physics impostor around the specific mesh
  110888. */
  110889. export class PhysicsViewer {
  110890. /** @hidden */
  110891. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110892. /** @hidden */
  110893. protected _meshes: Array<Nullable<AbstractMesh>>;
  110894. /** @hidden */
  110895. protected _scene: Nullable<Scene>;
  110896. /** @hidden */
  110897. protected _numMeshes: number;
  110898. /** @hidden */
  110899. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110900. private _renderFunction;
  110901. private _utilityLayer;
  110902. private _debugBoxMesh;
  110903. private _debugSphereMesh;
  110904. private _debugCylinderMesh;
  110905. private _debugMaterial;
  110906. private _debugMeshMeshes;
  110907. /**
  110908. * Creates a new PhysicsViewer
  110909. * @param scene defines the hosting scene
  110910. */
  110911. constructor(scene: Scene);
  110912. /** @hidden */
  110913. protected _updateDebugMeshes(): void;
  110914. /**
  110915. * Renders a specified physic impostor
  110916. * @param impostor defines the impostor to render
  110917. * @param targetMesh defines the mesh represented by the impostor
  110918. * @returns the new debug mesh used to render the impostor
  110919. */
  110920. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110921. /**
  110922. * Hides a specified physic impostor
  110923. * @param impostor defines the impostor to hide
  110924. */
  110925. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110926. private _getDebugMaterial;
  110927. private _getDebugBoxMesh;
  110928. private _getDebugSphereMesh;
  110929. private _getDebugCylinderMesh;
  110930. private _getDebugMeshMesh;
  110931. private _getDebugMesh;
  110932. /** Releases all resources */
  110933. dispose(): void;
  110934. }
  110935. }
  110936. declare module BABYLON {
  110937. /**
  110938. * Class containing static functions to help procedurally build meshes
  110939. */
  110940. export class LinesBuilder {
  110941. /**
  110942. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110943. * * 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
  110944. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110945. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110946. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110947. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110948. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110949. * * 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
  110950. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110953. * @param name defines the name of the new line system
  110954. * @param options defines the options used to create the line system
  110955. * @param scene defines the hosting scene
  110956. * @returns a new line system mesh
  110957. */
  110958. static CreateLineSystem(name: string, options: {
  110959. lines: Vector3[][];
  110960. updatable?: boolean;
  110961. instance?: Nullable<LinesMesh>;
  110962. colors?: Nullable<Color4[][]>;
  110963. useVertexAlpha?: boolean;
  110964. }, scene: Nullable<Scene>): LinesMesh;
  110965. /**
  110966. * Creates a line mesh
  110967. * 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
  110968. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110969. * * The parameter `points` is an array successive Vector3
  110970. * * 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
  110971. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110972. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110973. * * When updating an instance, remember that only point positions can change, not the number of points
  110974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110975. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110976. * @param name defines the name of the new line system
  110977. * @param options defines the options used to create the line system
  110978. * @param scene defines the hosting scene
  110979. * @returns a new line mesh
  110980. */
  110981. static CreateLines(name: string, options: {
  110982. points: Vector3[];
  110983. updatable?: boolean;
  110984. instance?: Nullable<LinesMesh>;
  110985. colors?: Color4[];
  110986. useVertexAlpha?: boolean;
  110987. }, scene?: Nullable<Scene>): LinesMesh;
  110988. /**
  110989. * Creates a dashed line mesh
  110990. * * 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
  110991. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110992. * * The parameter `points` is an array successive Vector3
  110993. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110994. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110995. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110996. * * 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
  110997. * * When updating an instance, remember that only point positions can change, not the number of points
  110998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110999. * @param name defines the name of the mesh
  111000. * @param options defines the options used to create the mesh
  111001. * @param scene defines the hosting scene
  111002. * @returns the dashed line mesh
  111003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  111004. */
  111005. static CreateDashedLines(name: string, options: {
  111006. points: Vector3[];
  111007. dashSize?: number;
  111008. gapSize?: number;
  111009. dashNb?: number;
  111010. updatable?: boolean;
  111011. instance?: LinesMesh;
  111012. }, scene?: Nullable<Scene>): LinesMesh;
  111013. }
  111014. }
  111015. declare module BABYLON {
  111016. /**
  111017. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111018. * in order to better appreciate the issue one might have.
  111019. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111020. */
  111021. export class RayHelper {
  111022. /**
  111023. * Defines the ray we are currently tryin to visualize.
  111024. */
  111025. ray: Nullable<Ray>;
  111026. private _renderPoints;
  111027. private _renderLine;
  111028. private _renderFunction;
  111029. private _scene;
  111030. private _updateToMeshFunction;
  111031. private _attachedToMesh;
  111032. private _meshSpaceDirection;
  111033. private _meshSpaceOrigin;
  111034. /**
  111035. * Helper function to create a colored helper in a scene in one line.
  111036. * @param ray Defines the ray we are currently tryin to visualize
  111037. * @param scene Defines the scene the ray is used in
  111038. * @param color Defines the color we want to see the ray in
  111039. * @returns The newly created ray helper.
  111040. */
  111041. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  111042. /**
  111043. * Instantiate a new ray helper.
  111044. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111045. * in order to better appreciate the issue one might have.
  111046. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111047. * @param ray Defines the ray we are currently tryin to visualize
  111048. */
  111049. constructor(ray: Ray);
  111050. /**
  111051. * Shows the ray we are willing to debug.
  111052. * @param scene Defines the scene the ray needs to be rendered in
  111053. * @param color Defines the color the ray needs to be rendered in
  111054. */
  111055. show(scene: Scene, color?: Color3): void;
  111056. /**
  111057. * Hides the ray we are debugging.
  111058. */
  111059. hide(): void;
  111060. private _render;
  111061. /**
  111062. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  111063. * @param mesh Defines the mesh we want the helper attached to
  111064. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  111065. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  111066. * @param length Defines the length of the ray
  111067. */
  111068. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  111069. /**
  111070. * Detach the ray helper from the mesh it has previously been attached to.
  111071. */
  111072. detachFromMesh(): void;
  111073. private _updateToMesh;
  111074. /**
  111075. * Dispose the helper and release its associated resources.
  111076. */
  111077. dispose(): void;
  111078. }
  111079. }
  111080. declare module BABYLON.Debug {
  111081. /**
  111082. * Class used to render a debug view of a given skeleton
  111083. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  111084. */
  111085. export class SkeletonViewer {
  111086. /** defines the skeleton to render */
  111087. skeleton: Skeleton;
  111088. /** defines the mesh attached to the skeleton */
  111089. mesh: AbstractMesh;
  111090. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111091. autoUpdateBonesMatrices: boolean;
  111092. /** defines the rendering group id to use with the viewer */
  111093. renderingGroupId: number;
  111094. /** Gets or sets the color used to render the skeleton */
  111095. color: Color3;
  111096. private _scene;
  111097. private _debugLines;
  111098. private _debugMesh;
  111099. private _isEnabled;
  111100. private _renderFunction;
  111101. private _utilityLayer;
  111102. /**
  111103. * Returns the mesh used to render the bones
  111104. */
  111105. readonly debugMesh: Nullable<LinesMesh>;
  111106. /**
  111107. * Creates a new SkeletonViewer
  111108. * @param skeleton defines the skeleton to render
  111109. * @param mesh defines the mesh attached to the skeleton
  111110. * @param scene defines the hosting scene
  111111. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  111112. * @param renderingGroupId defines the rendering group id to use with the viewer
  111113. */
  111114. constructor(
  111115. /** defines the skeleton to render */
  111116. skeleton: Skeleton,
  111117. /** defines the mesh attached to the skeleton */
  111118. mesh: AbstractMesh, scene: Scene,
  111119. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111120. autoUpdateBonesMatrices?: boolean,
  111121. /** defines the rendering group id to use with the viewer */
  111122. renderingGroupId?: number);
  111123. /** Gets or sets a boolean indicating if the viewer is enabled */
  111124. isEnabled: boolean;
  111125. private _getBonePosition;
  111126. private _getLinesForBonesWithLength;
  111127. private _getLinesForBonesNoLength;
  111128. /** Update the viewer to sync with current skeleton state */
  111129. update(): void;
  111130. /** Release associated resources */
  111131. dispose(): void;
  111132. }
  111133. }
  111134. declare module BABYLON {
  111135. /**
  111136. * Options to create the null engine
  111137. */
  111138. export class NullEngineOptions {
  111139. /**
  111140. * Render width (Default: 512)
  111141. */
  111142. renderWidth: number;
  111143. /**
  111144. * Render height (Default: 256)
  111145. */
  111146. renderHeight: number;
  111147. /**
  111148. * Texture size (Default: 512)
  111149. */
  111150. textureSize: number;
  111151. /**
  111152. * If delta time between frames should be constant
  111153. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111154. */
  111155. deterministicLockstep: boolean;
  111156. /**
  111157. * Maximum about of steps between frames (Default: 4)
  111158. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111159. */
  111160. lockstepMaxSteps: number;
  111161. }
  111162. /**
  111163. * The null engine class provides support for headless version of babylon.js.
  111164. * This can be used in server side scenario or for testing purposes
  111165. */
  111166. export class NullEngine extends Engine {
  111167. private _options;
  111168. /**
  111169. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  111170. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111171. * @returns true if engine is in deterministic lock step mode
  111172. */
  111173. isDeterministicLockStep(): boolean;
  111174. /**
  111175. * Gets the max steps when engine is running in deterministic lock step
  111176. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111177. * @returns the max steps
  111178. */
  111179. getLockstepMaxSteps(): number;
  111180. /**
  111181. * Gets the current hardware scaling level.
  111182. * By default the hardware scaling level is computed from the window device ratio.
  111183. * 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.
  111184. * @returns a number indicating the current hardware scaling level
  111185. */
  111186. getHardwareScalingLevel(): number;
  111187. constructor(options?: NullEngineOptions);
  111188. /**
  111189. * Creates a vertex buffer
  111190. * @param vertices the data for the vertex buffer
  111191. * @returns the new WebGL static buffer
  111192. */
  111193. createVertexBuffer(vertices: FloatArray): DataBuffer;
  111194. /**
  111195. * Creates a new index buffer
  111196. * @param indices defines the content of the index buffer
  111197. * @param updatable defines if the index buffer must be updatable
  111198. * @returns a new webGL buffer
  111199. */
  111200. createIndexBuffer(indices: IndicesArray): DataBuffer;
  111201. /**
  111202. * Clear the current render buffer or the current render target (if any is set up)
  111203. * @param color defines the color to use
  111204. * @param backBuffer defines if the back buffer must be cleared
  111205. * @param depth defines if the depth buffer must be cleared
  111206. * @param stencil defines if the stencil buffer must be cleared
  111207. */
  111208. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111209. /**
  111210. * Gets the current render width
  111211. * @param useScreen defines if screen size must be used (or the current render target if any)
  111212. * @returns a number defining the current render width
  111213. */
  111214. getRenderWidth(useScreen?: boolean): number;
  111215. /**
  111216. * Gets the current render height
  111217. * @param useScreen defines if screen size must be used (or the current render target if any)
  111218. * @returns a number defining the current render height
  111219. */
  111220. getRenderHeight(useScreen?: boolean): number;
  111221. /**
  111222. * Set the WebGL's viewport
  111223. * @param viewport defines the viewport element to be used
  111224. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111225. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111226. */
  111227. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111228. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  111229. /**
  111230. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111231. * @param pipelineContext defines the pipeline context to use
  111232. * @param uniformsNames defines the list of uniform names
  111233. * @returns an array of webGL uniform locations
  111234. */
  111235. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111236. /**
  111237. * Gets the lsit of active attributes for a given webGL program
  111238. * @param pipelineContext defines the pipeline context to use
  111239. * @param attributesNames defines the list of attribute names to get
  111240. * @returns an array of indices indicating the offset of each attribute
  111241. */
  111242. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111243. /**
  111244. * Binds an effect to the webGL context
  111245. * @param effect defines the effect to bind
  111246. */
  111247. bindSamplers(effect: Effect): void;
  111248. /**
  111249. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111250. * @param effect defines the effect to activate
  111251. */
  111252. enableEffect(effect: Effect): void;
  111253. /**
  111254. * Set various states to the webGL context
  111255. * @param culling defines backface culling state
  111256. * @param zOffset defines the value to apply to zOffset (0 by default)
  111257. * @param force defines if states must be applied even if cache is up to date
  111258. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  111259. */
  111260. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111261. /**
  111262. * Set the value of an uniform to an array of int32
  111263. * @param uniform defines the webGL uniform location where to store the value
  111264. * @param array defines the array of int32 to store
  111265. */
  111266. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111267. /**
  111268. * Set the value of an uniform to an array of int32 (stored as vec2)
  111269. * @param uniform defines the webGL uniform location where to store the value
  111270. * @param array defines the array of int32 to store
  111271. */
  111272. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111273. /**
  111274. * Set the value of an uniform to an array of int32 (stored as vec3)
  111275. * @param uniform defines the webGL uniform location where to store the value
  111276. * @param array defines the array of int32 to store
  111277. */
  111278. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111279. /**
  111280. * Set the value of an uniform to an array of int32 (stored as vec4)
  111281. * @param uniform defines the webGL uniform location where to store the value
  111282. * @param array defines the array of int32 to store
  111283. */
  111284. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111285. /**
  111286. * Set the value of an uniform to an array of float32
  111287. * @param uniform defines the webGL uniform location where to store the value
  111288. * @param array defines the array of float32 to store
  111289. */
  111290. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111291. /**
  111292. * Set the value of an uniform to an array of float32 (stored as vec2)
  111293. * @param uniform defines the webGL uniform location where to store the value
  111294. * @param array defines the array of float32 to store
  111295. */
  111296. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111297. /**
  111298. * Set the value of an uniform to an array of float32 (stored as vec3)
  111299. * @param uniform defines the webGL uniform location where to store the value
  111300. * @param array defines the array of float32 to store
  111301. */
  111302. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111303. /**
  111304. * Set the value of an uniform to an array of float32 (stored as vec4)
  111305. * @param uniform defines the webGL uniform location where to store the value
  111306. * @param array defines the array of float32 to store
  111307. */
  111308. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111309. /**
  111310. * Set the value of an uniform to an array of number
  111311. * @param uniform defines the webGL uniform location where to store the value
  111312. * @param array defines the array of number to store
  111313. */
  111314. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111315. /**
  111316. * Set the value of an uniform to an array of number (stored as vec2)
  111317. * @param uniform defines the webGL uniform location where to store the value
  111318. * @param array defines the array of number to store
  111319. */
  111320. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111321. /**
  111322. * Set the value of an uniform to an array of number (stored as vec3)
  111323. * @param uniform defines the webGL uniform location where to store the value
  111324. * @param array defines the array of number to store
  111325. */
  111326. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111327. /**
  111328. * Set the value of an uniform to an array of number (stored as vec4)
  111329. * @param uniform defines the webGL uniform location where to store the value
  111330. * @param array defines the array of number to store
  111331. */
  111332. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111333. /**
  111334. * Set the value of an uniform to an array of float32 (stored as matrices)
  111335. * @param uniform defines the webGL uniform location where to store the value
  111336. * @param matrices defines the array of float32 to store
  111337. */
  111338. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111339. /**
  111340. * Set the value of an uniform to a matrix (3x3)
  111341. * @param uniform defines the webGL uniform location where to store the value
  111342. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111343. */
  111344. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111345. /**
  111346. * Set the value of an uniform to a matrix (2x2)
  111347. * @param uniform defines the webGL uniform location where to store the value
  111348. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111349. */
  111350. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111351. /**
  111352. * Set the value of an uniform to a number (float)
  111353. * @param uniform defines the webGL uniform location where to store the value
  111354. * @param value defines the float number to store
  111355. */
  111356. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111357. /**
  111358. * Set the value of an uniform to a vec2
  111359. * @param uniform defines the webGL uniform location where to store the value
  111360. * @param x defines the 1st component of the value
  111361. * @param y defines the 2nd component of the value
  111362. */
  111363. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111364. /**
  111365. * Set the value of an uniform to a vec3
  111366. * @param uniform defines the webGL uniform location where to store the value
  111367. * @param x defines the 1st component of the value
  111368. * @param y defines the 2nd component of the value
  111369. * @param z defines the 3rd component of the value
  111370. */
  111371. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111372. /**
  111373. * Set the value of an uniform to a boolean
  111374. * @param uniform defines the webGL uniform location where to store the value
  111375. * @param bool defines the boolean to store
  111376. */
  111377. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111378. /**
  111379. * Set the value of an uniform to a vec4
  111380. * @param uniform defines the webGL uniform location where to store the value
  111381. * @param x defines the 1st component of the value
  111382. * @param y defines the 2nd component of the value
  111383. * @param z defines the 3rd component of the value
  111384. * @param w defines the 4th component of the value
  111385. */
  111386. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111387. /**
  111388. * Sets the current alpha mode
  111389. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  111390. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111391. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111392. */
  111393. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111394. /**
  111395. * Bind webGl buffers directly to the webGL context
  111396. * @param vertexBuffers defines the vertex buffer to bind
  111397. * @param indexBuffer defines the index buffer to bind
  111398. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111399. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111400. * @param effect defines the effect associated with the vertex buffer
  111401. */
  111402. bindBuffers(vertexBuffers: {
  111403. [key: string]: VertexBuffer;
  111404. }, indexBuffer: DataBuffer, effect: Effect): void;
  111405. /**
  111406. * Force the entire cache to be cleared
  111407. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111408. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111409. */
  111410. wipeCaches(bruteForce?: boolean): void;
  111411. /**
  111412. * Send a draw order
  111413. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111414. * @param indexStart defines the starting index
  111415. * @param indexCount defines the number of index to draw
  111416. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111417. */
  111418. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111419. /**
  111420. * Draw a list of indexed primitives
  111421. * @param fillMode defines the primitive to use
  111422. * @param indexStart defines the starting index
  111423. * @param indexCount defines the number of index to draw
  111424. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111425. */
  111426. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111427. /**
  111428. * Draw a list of unindexed primitives
  111429. * @param fillMode defines the primitive to use
  111430. * @param verticesStart defines the index of first vertex to draw
  111431. * @param verticesCount defines the count of vertices to draw
  111432. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111433. */
  111434. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111435. /** @hidden */
  111436. _createTexture(): WebGLTexture;
  111437. /** @hidden */
  111438. _releaseTexture(texture: InternalTexture): void;
  111439. /**
  111440. * Usually called from Texture.ts.
  111441. * Passed information to create a WebGLTexture
  111442. * @param urlArg defines a value which contains one of the following:
  111443. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111444. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111445. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111446. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111447. * @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)
  111448. * @param scene needed for loading to the correct scene
  111449. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  111450. * @param onLoad optional callback to be called upon successful completion
  111451. * @param onError optional callback to be called upon failure
  111452. * @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
  111453. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111454. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111455. * @param forcedExtension defines the extension to use to pick the right loader
  111456. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  111457. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111458. */
  111459. 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;
  111460. /**
  111461. * Creates a new render target texture
  111462. * @param size defines the size of the texture
  111463. * @param options defines the options used to create the texture
  111464. * @returns a new render target texture stored in an InternalTexture
  111465. */
  111466. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111467. /**
  111468. * Update the sampling mode of a given texture
  111469. * @param samplingMode defines the required sampling mode
  111470. * @param texture defines the texture to update
  111471. */
  111472. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111473. /**
  111474. * Binds the frame buffer to the specified texture.
  111475. * @param texture The texture to render to or null for the default canvas
  111476. * @param faceIndex The face of the texture to render to in case of cube texture
  111477. * @param requiredWidth The width of the target to render to
  111478. * @param requiredHeight The height of the target to render to
  111479. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111480. * @param depthStencilTexture The depth stencil texture to use to render
  111481. * @param lodLevel defines le lod level to bind to the frame buffer
  111482. */
  111483. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111484. /**
  111485. * Unbind the current render target texture from the webGL context
  111486. * @param texture defines the render target texture to unbind
  111487. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111488. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111489. */
  111490. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111491. /**
  111492. * Creates a dynamic vertex buffer
  111493. * @param vertices the data for the dynamic vertex buffer
  111494. * @returns the new WebGL dynamic buffer
  111495. */
  111496. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  111497. /**
  111498. * Update the content of a dynamic texture
  111499. * @param texture defines the texture to update
  111500. * @param canvas defines the canvas containing the source
  111501. * @param invertY defines if data must be stored with Y axis inverted
  111502. * @param premulAlpha defines if alpha is stored as premultiplied
  111503. * @param format defines the format of the data
  111504. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  111505. */
  111506. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  111507. /**
  111508. * Gets a boolean indicating if all created effects are ready
  111509. * @returns true if all effects are ready
  111510. */
  111511. areAllEffectsReady(): boolean;
  111512. /**
  111513. * @hidden
  111514. * Get the current error code of the webGL context
  111515. * @returns the error code
  111516. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  111517. */
  111518. getError(): number;
  111519. /** @hidden */
  111520. _getUnpackAlignement(): number;
  111521. /** @hidden */
  111522. _unpackFlipY(value: boolean): void;
  111523. /**
  111524. * Update a dynamic index buffer
  111525. * @param indexBuffer defines the target index buffer
  111526. * @param indices defines the data to update
  111527. * @param offset defines the offset in the target index buffer where update should start
  111528. */
  111529. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  111530. /**
  111531. * Updates a dynamic vertex buffer.
  111532. * @param vertexBuffer the vertex buffer to update
  111533. * @param vertices the data used to update the vertex buffer
  111534. * @param byteOffset the byte offset of the data (optional)
  111535. * @param byteLength the byte length of the data (optional)
  111536. */
  111537. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  111538. /** @hidden */
  111539. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  111540. /** @hidden */
  111541. _bindTexture(channel: number, texture: InternalTexture): void;
  111542. protected _deleteBuffer(buffer: WebGLBuffer): void;
  111543. /**
  111544. * 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
  111545. */
  111546. releaseEffects(): void;
  111547. displayLoadingUI(): void;
  111548. hideLoadingUI(): void;
  111549. /** @hidden */
  111550. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111551. /** @hidden */
  111552. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111553. /** @hidden */
  111554. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111555. /** @hidden */
  111556. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111557. }
  111558. }
  111559. declare module BABYLON {
  111560. /** @hidden */
  111561. export class _OcclusionDataStorage {
  111562. /** @hidden */
  111563. occlusionInternalRetryCounter: number;
  111564. /** @hidden */
  111565. isOcclusionQueryInProgress: boolean;
  111566. /** @hidden */
  111567. isOccluded: boolean;
  111568. /** @hidden */
  111569. occlusionRetryCount: number;
  111570. /** @hidden */
  111571. occlusionType: number;
  111572. /** @hidden */
  111573. occlusionQueryAlgorithmType: number;
  111574. }
  111575. interface Engine {
  111576. /**
  111577. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  111578. * @return the new query
  111579. */
  111580. createQuery(): WebGLQuery;
  111581. /**
  111582. * Delete and release a webGL query
  111583. * @param query defines the query to delete
  111584. * @return the current engine
  111585. */
  111586. deleteQuery(query: WebGLQuery): Engine;
  111587. /**
  111588. * Check if a given query has resolved and got its value
  111589. * @param query defines the query to check
  111590. * @returns true if the query got its value
  111591. */
  111592. isQueryResultAvailable(query: WebGLQuery): boolean;
  111593. /**
  111594. * Gets the value of a given query
  111595. * @param query defines the query to check
  111596. * @returns the value of the query
  111597. */
  111598. getQueryResult(query: WebGLQuery): number;
  111599. /**
  111600. * Initiates an occlusion query
  111601. * @param algorithmType defines the algorithm to use
  111602. * @param query defines the query to use
  111603. * @returns the current engine
  111604. * @see http://doc.babylonjs.com/features/occlusionquery
  111605. */
  111606. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  111607. /**
  111608. * Ends an occlusion query
  111609. * @see http://doc.babylonjs.com/features/occlusionquery
  111610. * @param algorithmType defines the algorithm to use
  111611. * @returns the current engine
  111612. */
  111613. endOcclusionQuery(algorithmType: number): Engine;
  111614. /**
  111615. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  111616. * Please note that only one query can be issued at a time
  111617. * @returns a time token used to track the time span
  111618. */
  111619. startTimeQuery(): Nullable<_TimeToken>;
  111620. /**
  111621. * Ends a time query
  111622. * @param token defines the token used to measure the time span
  111623. * @returns the time spent (in ns)
  111624. */
  111625. endTimeQuery(token: _TimeToken): int;
  111626. /** @hidden */
  111627. _currentNonTimestampToken: Nullable<_TimeToken>;
  111628. /** @hidden */
  111629. _createTimeQuery(): WebGLQuery;
  111630. /** @hidden */
  111631. _deleteTimeQuery(query: WebGLQuery): void;
  111632. /** @hidden */
  111633. _getGlAlgorithmType(algorithmType: number): number;
  111634. /** @hidden */
  111635. _getTimeQueryResult(query: WebGLQuery): any;
  111636. /** @hidden */
  111637. _getTimeQueryAvailability(query: WebGLQuery): any;
  111638. }
  111639. interface AbstractMesh {
  111640. /**
  111641. * Backing filed
  111642. * @hidden
  111643. */
  111644. __occlusionDataStorage: _OcclusionDataStorage;
  111645. /**
  111646. * Access property
  111647. * @hidden
  111648. */
  111649. _occlusionDataStorage: _OcclusionDataStorage;
  111650. /**
  111651. * 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.
  111652. * The default value is -1 which means don't break the query and wait till the result
  111653. * @see http://doc.babylonjs.com/features/occlusionquery
  111654. */
  111655. occlusionRetryCount: number;
  111656. /**
  111657. * 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:
  111658. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  111659. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  111660. * * 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.
  111661. * @see http://doc.babylonjs.com/features/occlusionquery
  111662. */
  111663. occlusionType: number;
  111664. /**
  111665. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  111666. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  111667. * * 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.
  111668. * @see http://doc.babylonjs.com/features/occlusionquery
  111669. */
  111670. occlusionQueryAlgorithmType: number;
  111671. /**
  111672. * 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
  111673. * @see http://doc.babylonjs.com/features/occlusionquery
  111674. */
  111675. isOccluded: boolean;
  111676. /**
  111677. * Flag to check the progress status of the query
  111678. * @see http://doc.babylonjs.com/features/occlusionquery
  111679. */
  111680. isOcclusionQueryInProgress: boolean;
  111681. }
  111682. }
  111683. declare module BABYLON {
  111684. /** @hidden */
  111685. export var _forceTransformFeedbackToBundle: boolean;
  111686. interface Engine {
  111687. /**
  111688. * Creates a webGL transform feedback object
  111689. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  111690. * @returns the webGL transform feedback object
  111691. */
  111692. createTransformFeedback(): WebGLTransformFeedback;
  111693. /**
  111694. * Delete a webGL transform feedback object
  111695. * @param value defines the webGL transform feedback object to delete
  111696. */
  111697. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  111698. /**
  111699. * Bind a webGL transform feedback object to the webgl context
  111700. * @param value defines the webGL transform feedback object to bind
  111701. */
  111702. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  111703. /**
  111704. * Begins a transform feedback operation
  111705. * @param usePoints defines if points or triangles must be used
  111706. */
  111707. beginTransformFeedback(usePoints: boolean): void;
  111708. /**
  111709. * Ends a transform feedback operation
  111710. */
  111711. endTransformFeedback(): void;
  111712. /**
  111713. * Specify the varyings to use with transform feedback
  111714. * @param program defines the associated webGL program
  111715. * @param value defines the list of strings representing the varying names
  111716. */
  111717. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  111718. /**
  111719. * Bind a webGL buffer for a transform feedback operation
  111720. * @param value defines the webGL buffer to bind
  111721. */
  111722. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  111723. }
  111724. }
  111725. declare module BABYLON {
  111726. /**
  111727. * Creation options of the multi render target texture.
  111728. */
  111729. export interface IMultiRenderTargetOptions {
  111730. /**
  111731. * Define if the texture needs to create mip maps after render.
  111732. */
  111733. generateMipMaps?: boolean;
  111734. /**
  111735. * Define the types of all the draw buffers we want to create
  111736. */
  111737. types?: number[];
  111738. /**
  111739. * Define the sampling modes of all the draw buffers we want to create
  111740. */
  111741. samplingModes?: number[];
  111742. /**
  111743. * Define if a depth buffer is required
  111744. */
  111745. generateDepthBuffer?: boolean;
  111746. /**
  111747. * Define if a stencil buffer is required
  111748. */
  111749. generateStencilBuffer?: boolean;
  111750. /**
  111751. * Define if a depth texture is required instead of a depth buffer
  111752. */
  111753. generateDepthTexture?: boolean;
  111754. /**
  111755. * Define the number of desired draw buffers
  111756. */
  111757. textureCount?: number;
  111758. /**
  111759. * Define if aspect ratio should be adapted to the texture or stay the scene one
  111760. */
  111761. doNotChangeAspectRatio?: boolean;
  111762. /**
  111763. * Define the default type of the buffers we are creating
  111764. */
  111765. defaultType?: number;
  111766. }
  111767. /**
  111768. * A multi render target, like a render target provides the ability to render to a texture.
  111769. * Unlike the render target, it can render to several draw buffers in one draw.
  111770. * This is specially interesting in deferred rendering or for any effects requiring more than
  111771. * just one color from a single pass.
  111772. */
  111773. export class MultiRenderTarget extends RenderTargetTexture {
  111774. private _internalTextures;
  111775. private _textures;
  111776. private _multiRenderTargetOptions;
  111777. /**
  111778. * Get if draw buffers are currently supported by the used hardware and browser.
  111779. */
  111780. readonly isSupported: boolean;
  111781. /**
  111782. * Get the list of textures generated by the multi render target.
  111783. */
  111784. readonly textures: Texture[];
  111785. /**
  111786. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111787. */
  111788. readonly depthTexture: Texture;
  111789. /**
  111790. * Set the wrapping mode on U of all the textures we are rendering to.
  111791. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111792. */
  111793. wrapU: number;
  111794. /**
  111795. * Set the wrapping mode on V of all the textures we are rendering to.
  111796. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111797. */
  111798. wrapV: number;
  111799. /**
  111800. * Instantiate a new multi render target texture.
  111801. * A multi render target, like a render target provides the ability to render to a texture.
  111802. * Unlike the render target, it can render to several draw buffers in one draw.
  111803. * This is specially interesting in deferred rendering or for any effects requiring more than
  111804. * just one color from a single pass.
  111805. * @param name Define the name of the texture
  111806. * @param size Define the size of the buffers to render to
  111807. * @param count Define the number of target we are rendering into
  111808. * @param scene Define the scene the texture belongs to
  111809. * @param options Define the options used to create the multi render target
  111810. */
  111811. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111812. /** @hidden */
  111813. _rebuild(): void;
  111814. private _createInternalTextures;
  111815. private _createTextures;
  111816. /**
  111817. * Define the number of samples used if MSAA is enabled.
  111818. */
  111819. samples: number;
  111820. /**
  111821. * Resize all the textures in the multi render target.
  111822. * Be carrefull as it will recreate all the data in the new texture.
  111823. * @param size Define the new size
  111824. */
  111825. resize(size: any): void;
  111826. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111827. /**
  111828. * Dispose the render targets and their associated resources
  111829. */
  111830. dispose(): void;
  111831. /**
  111832. * Release all the underlying texture used as draw buffers.
  111833. */
  111834. releaseInternalTextures(): void;
  111835. }
  111836. }
  111837. declare module BABYLON {
  111838. interface ThinEngine {
  111839. /**
  111840. * Unbind a list of render target textures from the webGL context
  111841. * This is used only when drawBuffer extension or webGL2 are active
  111842. * @param textures defines the render target textures to unbind
  111843. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111844. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111845. */
  111846. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111847. /**
  111848. * Create a multi render target texture
  111849. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111850. * @param size defines the size of the texture
  111851. * @param options defines the creation options
  111852. * @returns the cube texture as an InternalTexture
  111853. */
  111854. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111855. /**
  111856. * Update the sample count for a given multiple render target texture
  111857. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111858. * @param textures defines the textures to update
  111859. * @param samples defines the sample count to set
  111860. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111861. */
  111862. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111863. }
  111864. }
  111865. declare module BABYLON {
  111866. /**
  111867. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111868. */
  111869. export interface CubeMapInfo {
  111870. /**
  111871. * The pixel array for the front face.
  111872. * This is stored in format, left to right, up to down format.
  111873. */
  111874. front: Nullable<ArrayBufferView>;
  111875. /**
  111876. * The pixel array for the back face.
  111877. * This is stored in format, left to right, up to down format.
  111878. */
  111879. back: Nullable<ArrayBufferView>;
  111880. /**
  111881. * The pixel array for the left face.
  111882. * This is stored in format, left to right, up to down format.
  111883. */
  111884. left: Nullable<ArrayBufferView>;
  111885. /**
  111886. * The pixel array for the right face.
  111887. * This is stored in format, left to right, up to down format.
  111888. */
  111889. right: Nullable<ArrayBufferView>;
  111890. /**
  111891. * The pixel array for the up face.
  111892. * This is stored in format, left to right, up to down format.
  111893. */
  111894. up: Nullable<ArrayBufferView>;
  111895. /**
  111896. * The pixel array for the down face.
  111897. * This is stored in format, left to right, up to down format.
  111898. */
  111899. down: Nullable<ArrayBufferView>;
  111900. /**
  111901. * The size of the cubemap stored.
  111902. *
  111903. * Each faces will be size * size pixels.
  111904. */
  111905. size: number;
  111906. /**
  111907. * The format of the texture.
  111908. *
  111909. * RGBA, RGB.
  111910. */
  111911. format: number;
  111912. /**
  111913. * The type of the texture data.
  111914. *
  111915. * UNSIGNED_INT, FLOAT.
  111916. */
  111917. type: number;
  111918. /**
  111919. * Specifies whether the texture is in gamma space.
  111920. */
  111921. gammaSpace: boolean;
  111922. }
  111923. /**
  111924. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111925. */
  111926. export class PanoramaToCubeMapTools {
  111927. private static FACE_FRONT;
  111928. private static FACE_BACK;
  111929. private static FACE_RIGHT;
  111930. private static FACE_LEFT;
  111931. private static FACE_DOWN;
  111932. private static FACE_UP;
  111933. /**
  111934. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111935. *
  111936. * @param float32Array The source data.
  111937. * @param inputWidth The width of the input panorama.
  111938. * @param inputHeight The height of the input panorama.
  111939. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111940. * @return The cubemap data
  111941. */
  111942. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111943. private static CreateCubemapTexture;
  111944. private static CalcProjectionSpherical;
  111945. }
  111946. }
  111947. declare module BABYLON {
  111948. /**
  111949. * Helper class dealing with the extraction of spherical polynomial dataArray
  111950. * from a cube map.
  111951. */
  111952. export class CubeMapToSphericalPolynomialTools {
  111953. private static FileFaces;
  111954. /**
  111955. * Converts a texture to the according Spherical Polynomial data.
  111956. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111957. *
  111958. * @param texture The texture to extract the information from.
  111959. * @return The Spherical Polynomial data.
  111960. */
  111961. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111962. /**
  111963. * Converts a cubemap to the according Spherical Polynomial data.
  111964. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111965. *
  111966. * @param cubeInfo The Cube map to extract the information from.
  111967. * @return The Spherical Polynomial data.
  111968. */
  111969. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111970. }
  111971. }
  111972. declare module BABYLON {
  111973. interface BaseTexture {
  111974. /**
  111975. * Get the polynomial representation of the texture data.
  111976. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  111977. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  111978. */
  111979. sphericalPolynomial: Nullable<SphericalPolynomial>;
  111980. }
  111981. }
  111982. declare module BABYLON {
  111983. /** @hidden */
  111984. export var rgbdEncodePixelShader: {
  111985. name: string;
  111986. shader: string;
  111987. };
  111988. }
  111989. declare module BABYLON {
  111990. /** @hidden */
  111991. export var rgbdDecodePixelShader: {
  111992. name: string;
  111993. shader: string;
  111994. };
  111995. }
  111996. declare module BABYLON {
  111997. /**
  111998. * Raw texture data and descriptor sufficient for WebGL texture upload
  111999. */
  112000. export interface EnvironmentTextureInfo {
  112001. /**
  112002. * Version of the environment map
  112003. */
  112004. version: number;
  112005. /**
  112006. * Width of image
  112007. */
  112008. width: number;
  112009. /**
  112010. * Irradiance information stored in the file.
  112011. */
  112012. irradiance: any;
  112013. /**
  112014. * Specular information stored in the file.
  112015. */
  112016. specular: any;
  112017. }
  112018. /**
  112019. * Defines One Image in the file. It requires only the position in the file
  112020. * as well as the length.
  112021. */
  112022. interface BufferImageData {
  112023. /**
  112024. * Length of the image data.
  112025. */
  112026. length: number;
  112027. /**
  112028. * Position of the data from the null terminator delimiting the end of the JSON.
  112029. */
  112030. position: number;
  112031. }
  112032. /**
  112033. * Defines the specular data enclosed in the file.
  112034. * This corresponds to the version 1 of the data.
  112035. */
  112036. export interface EnvironmentTextureSpecularInfoV1 {
  112037. /**
  112038. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  112039. */
  112040. specularDataPosition?: number;
  112041. /**
  112042. * This contains all the images data needed to reconstruct the cubemap.
  112043. */
  112044. mipmaps: Array<BufferImageData>;
  112045. /**
  112046. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  112047. */
  112048. lodGenerationScale: number;
  112049. }
  112050. /**
  112051. * Sets of helpers addressing the serialization and deserialization of environment texture
  112052. * stored in a BabylonJS env file.
  112053. * Those files are usually stored as .env files.
  112054. */
  112055. export class EnvironmentTextureTools {
  112056. /**
  112057. * Magic number identifying the env file.
  112058. */
  112059. private static _MagicBytes;
  112060. /**
  112061. * Gets the environment info from an env file.
  112062. * @param data The array buffer containing the .env bytes.
  112063. * @returns the environment file info (the json header) if successfully parsed.
  112064. */
  112065. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112066. /**
  112067. * Creates an environment texture from a loaded cube texture.
  112068. * @param texture defines the cube texture to convert in env file
  112069. * @return a promise containing the environment data if succesfull.
  112070. */
  112071. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112072. /**
  112073. * Creates a JSON representation of the spherical data.
  112074. * @param texture defines the texture containing the polynomials
  112075. * @return the JSON representation of the spherical info
  112076. */
  112077. private static _CreateEnvTextureIrradiance;
  112078. /**
  112079. * Creates the ArrayBufferViews used for initializing environment texture image data.
  112080. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  112081. * @param info parameters that determine what views will be created for accessing the underlying buffer
  112082. * @return the views described by info providing access to the underlying buffer
  112083. */
  112084. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  112085. /**
  112086. * Uploads the texture info contained in the env file to the GPU.
  112087. * @param texture defines the internal texture to upload to
  112088. * @param arrayBuffer defines the buffer cotaining the data to load
  112089. * @param info defines the texture info retrieved through the GetEnvInfo method
  112090. * @returns a promise
  112091. */
  112092. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112093. private static _OnImageReadyAsync;
  112094. /**
  112095. * Uploads the levels of image data to the GPU.
  112096. * @param texture defines the internal texture to upload to
  112097. * @param imageData defines the array buffer views of image data [mipmap][face]
  112098. * @returns a promise
  112099. */
  112100. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112101. /**
  112102. * Uploads spherical polynomials information to the texture.
  112103. * @param texture defines the texture we are trying to upload the information to
  112104. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112105. */
  112106. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112107. /** @hidden */
  112108. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112109. }
  112110. }
  112111. declare module BABYLON {
  112112. /**
  112113. * Contains position and normal vectors for a vertex
  112114. */
  112115. export class PositionNormalVertex {
  112116. /** the position of the vertex (defaut: 0,0,0) */
  112117. position: Vector3;
  112118. /** the normal of the vertex (defaut: 0,1,0) */
  112119. normal: Vector3;
  112120. /**
  112121. * Creates a PositionNormalVertex
  112122. * @param position the position of the vertex (defaut: 0,0,0)
  112123. * @param normal the normal of the vertex (defaut: 0,1,0)
  112124. */
  112125. constructor(
  112126. /** the position of the vertex (defaut: 0,0,0) */
  112127. position?: Vector3,
  112128. /** the normal of the vertex (defaut: 0,1,0) */
  112129. normal?: Vector3);
  112130. /**
  112131. * Clones the PositionNormalVertex
  112132. * @returns the cloned PositionNormalVertex
  112133. */
  112134. clone(): PositionNormalVertex;
  112135. }
  112136. /**
  112137. * Contains position, normal and uv vectors for a vertex
  112138. */
  112139. export class PositionNormalTextureVertex {
  112140. /** the position of the vertex (defaut: 0,0,0) */
  112141. position: Vector3;
  112142. /** the normal of the vertex (defaut: 0,1,0) */
  112143. normal: Vector3;
  112144. /** the uv of the vertex (default: 0,0) */
  112145. uv: Vector2;
  112146. /**
  112147. * Creates a PositionNormalTextureVertex
  112148. * @param position the position of the vertex (defaut: 0,0,0)
  112149. * @param normal the normal of the vertex (defaut: 0,1,0)
  112150. * @param uv the uv of the vertex (default: 0,0)
  112151. */
  112152. constructor(
  112153. /** the position of the vertex (defaut: 0,0,0) */
  112154. position?: Vector3,
  112155. /** the normal of the vertex (defaut: 0,1,0) */
  112156. normal?: Vector3,
  112157. /** the uv of the vertex (default: 0,0) */
  112158. uv?: Vector2);
  112159. /**
  112160. * Clones the PositionNormalTextureVertex
  112161. * @returns the cloned PositionNormalTextureVertex
  112162. */
  112163. clone(): PositionNormalTextureVertex;
  112164. }
  112165. }
  112166. declare module BABYLON {
  112167. /** @hidden */
  112168. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  112169. private _genericAttributeLocation;
  112170. private _varyingLocationCount;
  112171. private _varyingLocationMap;
  112172. private _replacements;
  112173. private _textureCount;
  112174. private _uniforms;
  112175. lineProcessor(line: string): string;
  112176. attributeProcessor(attribute: string): string;
  112177. varyingProcessor(varying: string, isFragment: boolean): string;
  112178. uniformProcessor(uniform: string): string;
  112179. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  112180. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112181. }
  112182. }
  112183. declare module BABYLON {
  112184. /**
  112185. * Container for accessors for natively-stored mesh data buffers.
  112186. */
  112187. class NativeDataBuffer extends DataBuffer {
  112188. /**
  112189. * Accessor value used to identify/retrieve a natively-stored index buffer.
  112190. */
  112191. nativeIndexBuffer?: any;
  112192. /**
  112193. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  112194. */
  112195. nativeVertexBuffer?: any;
  112196. }
  112197. /** @hidden */
  112198. export class NativeEngine extends Engine {
  112199. private readonly _native;
  112200. getHardwareScalingLevel(): number;
  112201. constructor();
  112202. /**
  112203. * Can be used to override the current requestAnimationFrame requester.
  112204. * @hidden
  112205. */
  112206. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  112207. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112208. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  112209. createVertexBuffer(data: DataArray): NativeDataBuffer;
  112210. recordVertexArrayObject(vertexBuffers: {
  112211. [key: string]: VertexBuffer;
  112212. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112213. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112214. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112215. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112216. /**
  112217. * Draw a list of indexed primitives
  112218. * @param fillMode defines the primitive to use
  112219. * @param indexStart defines the starting index
  112220. * @param indexCount defines the number of index to draw
  112221. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112222. */
  112223. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112224. /**
  112225. * Draw a list of unindexed primitives
  112226. * @param fillMode defines the primitive to use
  112227. * @param verticesStart defines the index of first vertex to draw
  112228. * @param verticesCount defines the count of vertices to draw
  112229. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112230. */
  112231. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112232. createPipelineContext(): IPipelineContext;
  112233. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112234. /** @hidden */
  112235. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112236. /** @hidden */
  112237. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112238. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112239. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112240. protected _setProgram(program: WebGLProgram): void;
  112241. _releaseEffect(effect: Effect): void;
  112242. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112243. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  112244. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  112245. bindSamplers(effect: Effect): void;
  112246. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  112247. getRenderWidth(useScreen?: boolean): number;
  112248. getRenderHeight(useScreen?: boolean): number;
  112249. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  112250. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112251. /**
  112252. * Set the z offset to apply to current rendering
  112253. * @param value defines the offset to apply
  112254. */
  112255. setZOffset(value: number): void;
  112256. /**
  112257. * Gets the current value of the zOffset
  112258. * @returns the current zOffset state
  112259. */
  112260. getZOffset(): number;
  112261. /**
  112262. * Enable or disable depth buffering
  112263. * @param enable defines the state to set
  112264. */
  112265. setDepthBuffer(enable: boolean): void;
  112266. /**
  112267. * Gets a boolean indicating if depth writing is enabled
  112268. * @returns the current depth writing state
  112269. */
  112270. getDepthWrite(): boolean;
  112271. /**
  112272. * Enable or disable depth writing
  112273. * @param enable defines the state to set
  112274. */
  112275. setDepthWrite(enable: boolean): void;
  112276. /**
  112277. * Enable or disable color writing
  112278. * @param enable defines the state to set
  112279. */
  112280. setColorWrite(enable: boolean): void;
  112281. /**
  112282. * Gets a boolean indicating if color writing is enabled
  112283. * @returns the current color writing state
  112284. */
  112285. getColorWrite(): boolean;
  112286. /**
  112287. * Sets alpha constants used by some alpha blending modes
  112288. * @param r defines the red component
  112289. * @param g defines the green component
  112290. * @param b defines the blue component
  112291. * @param a defines the alpha component
  112292. */
  112293. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  112294. /**
  112295. * Sets the current alpha mode
  112296. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  112297. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112298. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112299. */
  112300. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112301. /**
  112302. * Gets the current alpha mode
  112303. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112304. * @returns the current alpha mode
  112305. */
  112306. getAlphaMode(): number;
  112307. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112308. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112309. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112310. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112311. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112312. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112313. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112314. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112315. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112316. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112317. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112318. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112319. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112320. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112321. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112322. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112323. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112324. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112325. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112326. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112327. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  112328. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  112329. wipeCaches(bruteForce?: boolean): void;
  112330. _createTexture(): WebGLTexture;
  112331. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112332. /**
  112333. * Usually called from BABYLON.Texture.ts.
  112334. * Passed information to create a WebGLTexture
  112335. * @param urlArg defines a value which contains one of the following:
  112336. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112337. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112338. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112339. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112340. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  112341. * @param scene needed for loading to the correct scene
  112342. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  112343. * @param onLoad optional callback to be called upon successful completion
  112344. * @param onError optional callback to be called upon failure
  112345. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  112346. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112347. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112348. * @param forcedExtension defines the extension to use to pick the right loader
  112349. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112350. */
  112351. 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;
  112352. /**
  112353. * Creates a cube texture
  112354. * @param rootUrl defines the url where the files to load is located
  112355. * @param scene defines the current scene
  112356. * @param files defines the list of files to load (1 per face)
  112357. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  112358. * @param onLoad defines an optional callback raised when the texture is loaded
  112359. * @param onError defines an optional callback raised if there is an issue to load the texture
  112360. * @param format defines the format of the data
  112361. * @param forcedExtension defines the extension to use to pick the right loader
  112362. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  112363. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112364. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112365. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  112366. * @returns the cube texture as an InternalTexture
  112367. */
  112368. 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;
  112369. private _getSamplingFilter;
  112370. private static _GetNativeTextureFormat;
  112371. createRenderTargetTexture(size: number | {
  112372. width: number;
  112373. height: number;
  112374. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112375. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112376. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112377. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112378. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112379. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  112380. /**
  112381. * Updates a dynamic vertex buffer.
  112382. * @param vertexBuffer the vertex buffer to update
  112383. * @param data the data used to update the vertex buffer
  112384. * @param byteOffset the byte offset of the data (optional)
  112385. * @param byteLength the byte length of the data (optional)
  112386. */
  112387. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  112388. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112389. private _updateAnisotropicLevel;
  112390. private _getAddressMode;
  112391. /** @hidden */
  112392. _bindTexture(channel: number, texture: InternalTexture): void;
  112393. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  112394. releaseEffects(): void;
  112395. /** @hidden */
  112396. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112397. /** @hidden */
  112398. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112399. /** @hidden */
  112400. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112401. /** @hidden */
  112402. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112403. }
  112404. }
  112405. declare module BABYLON {
  112406. /**
  112407. * Gather the list of clipboard event types as constants.
  112408. */
  112409. export class ClipboardEventTypes {
  112410. /**
  112411. * The clipboard event is fired when a copy command is active (pressed).
  112412. */
  112413. static readonly COPY: number;
  112414. /**
  112415. * The clipboard event is fired when a cut command is active (pressed).
  112416. */
  112417. static readonly CUT: number;
  112418. /**
  112419. * The clipboard event is fired when a paste command is active (pressed).
  112420. */
  112421. static readonly PASTE: number;
  112422. }
  112423. /**
  112424. * This class is used to store clipboard related info for the onClipboardObservable event.
  112425. */
  112426. export class ClipboardInfo {
  112427. /**
  112428. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112429. */
  112430. type: number;
  112431. /**
  112432. * Defines the related dom event
  112433. */
  112434. event: ClipboardEvent;
  112435. /**
  112436. *Creates an instance of ClipboardInfo.
  112437. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  112438. * @param event Defines the related dom event
  112439. */
  112440. constructor(
  112441. /**
  112442. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112443. */
  112444. type: number,
  112445. /**
  112446. * Defines the related dom event
  112447. */
  112448. event: ClipboardEvent);
  112449. /**
  112450. * Get the clipboard event's type from the keycode.
  112451. * @param keyCode Defines the keyCode for the current keyboard event.
  112452. * @return {number}
  112453. */
  112454. static GetTypeFromCharacter(keyCode: number): number;
  112455. }
  112456. }
  112457. declare module BABYLON {
  112458. /**
  112459. * Google Daydream controller
  112460. */
  112461. export class DaydreamController extends WebVRController {
  112462. /**
  112463. * Base Url for the controller model.
  112464. */
  112465. static MODEL_BASE_URL: string;
  112466. /**
  112467. * File name for the controller model.
  112468. */
  112469. static MODEL_FILENAME: string;
  112470. /**
  112471. * Gamepad Id prefix used to identify Daydream Controller.
  112472. */
  112473. static readonly GAMEPAD_ID_PREFIX: string;
  112474. /**
  112475. * Creates a new DaydreamController from a gamepad
  112476. * @param vrGamepad the gamepad that the controller should be created from
  112477. */
  112478. constructor(vrGamepad: any);
  112479. /**
  112480. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112481. * @param scene scene in which to add meshes
  112482. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112483. */
  112484. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112485. /**
  112486. * Called once for each button that changed state since the last frame
  112487. * @param buttonIdx Which button index changed
  112488. * @param state New state of the button
  112489. * @param changes Which properties on the state changed since last frame
  112490. */
  112491. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112492. }
  112493. }
  112494. declare module BABYLON {
  112495. /**
  112496. * Gear VR Controller
  112497. */
  112498. export class GearVRController extends WebVRController {
  112499. /**
  112500. * Base Url for the controller model.
  112501. */
  112502. static MODEL_BASE_URL: string;
  112503. /**
  112504. * File name for the controller model.
  112505. */
  112506. static MODEL_FILENAME: string;
  112507. /**
  112508. * Gamepad Id prefix used to identify this controller.
  112509. */
  112510. static readonly GAMEPAD_ID_PREFIX: string;
  112511. private readonly _buttonIndexToObservableNameMap;
  112512. /**
  112513. * Creates a new GearVRController from a gamepad
  112514. * @param vrGamepad the gamepad that the controller should be created from
  112515. */
  112516. constructor(vrGamepad: any);
  112517. /**
  112518. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112519. * @param scene scene in which to add meshes
  112520. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112521. */
  112522. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112523. /**
  112524. * Called once for each button that changed state since the last frame
  112525. * @param buttonIdx Which button index changed
  112526. * @param state New state of the button
  112527. * @param changes Which properties on the state changed since last frame
  112528. */
  112529. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112530. }
  112531. }
  112532. declare module BABYLON {
  112533. /**
  112534. * Class containing static functions to help procedurally build meshes
  112535. */
  112536. export class PolyhedronBuilder {
  112537. /**
  112538. * Creates a polyhedron mesh
  112539. * * 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
  112540. * * The parameter `size` (positive float, default 1) sets the polygon size
  112541. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  112542. * * 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`
  112543. * * 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
  112544. * * 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)`)
  112545. * * 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
  112546. * * 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
  112547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112550. * @param name defines the name of the mesh
  112551. * @param options defines the options used to create the mesh
  112552. * @param scene defines the hosting scene
  112553. * @returns the polyhedron mesh
  112554. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  112555. */
  112556. static CreatePolyhedron(name: string, options: {
  112557. type?: number;
  112558. size?: number;
  112559. sizeX?: number;
  112560. sizeY?: number;
  112561. sizeZ?: number;
  112562. custom?: any;
  112563. faceUV?: Vector4[];
  112564. faceColors?: Color4[];
  112565. flat?: boolean;
  112566. updatable?: boolean;
  112567. sideOrientation?: number;
  112568. frontUVs?: Vector4;
  112569. backUVs?: Vector4;
  112570. }, scene?: Nullable<Scene>): Mesh;
  112571. }
  112572. }
  112573. declare module BABYLON {
  112574. /**
  112575. * Gizmo that enables scaling a mesh along 3 axis
  112576. */
  112577. export class ScaleGizmo extends Gizmo {
  112578. /**
  112579. * Internal gizmo used for interactions on the x axis
  112580. */
  112581. xGizmo: AxisScaleGizmo;
  112582. /**
  112583. * Internal gizmo used for interactions on the y axis
  112584. */
  112585. yGizmo: AxisScaleGizmo;
  112586. /**
  112587. * Internal gizmo used for interactions on the z axis
  112588. */
  112589. zGizmo: AxisScaleGizmo;
  112590. /**
  112591. * Internal gizmo used to scale all axis equally
  112592. */
  112593. uniformScaleGizmo: AxisScaleGizmo;
  112594. private _meshAttached;
  112595. private _updateGizmoRotationToMatchAttachedMesh;
  112596. private _snapDistance;
  112597. private _scaleRatio;
  112598. private _uniformScalingMesh;
  112599. private _octahedron;
  112600. /** Fires an event when any of it's sub gizmos are dragged */
  112601. onDragStartObservable: Observable<unknown>;
  112602. /** Fires an event when any of it's sub gizmos are released from dragging */
  112603. onDragEndObservable: Observable<unknown>;
  112604. attachedMesh: Nullable<AbstractMesh>;
  112605. /**
  112606. * Creates a ScaleGizmo
  112607. * @param gizmoLayer The utility layer the gizmo will be added to
  112608. */
  112609. constructor(gizmoLayer?: UtilityLayerRenderer);
  112610. updateGizmoRotationToMatchAttachedMesh: boolean;
  112611. /**
  112612. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112613. */
  112614. snapDistance: number;
  112615. /**
  112616. * Ratio for the scale of the gizmo (Default: 1)
  112617. */
  112618. scaleRatio: number;
  112619. /**
  112620. * Disposes of the gizmo
  112621. */
  112622. dispose(): void;
  112623. }
  112624. }
  112625. declare module BABYLON {
  112626. /**
  112627. * Single axis scale gizmo
  112628. */
  112629. export class AxisScaleGizmo extends Gizmo {
  112630. /**
  112631. * Drag behavior responsible for the gizmos dragging interactions
  112632. */
  112633. dragBehavior: PointerDragBehavior;
  112634. private _pointerObserver;
  112635. /**
  112636. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112637. */
  112638. snapDistance: number;
  112639. /**
  112640. * Event that fires each time the gizmo snaps to a new location.
  112641. * * snapDistance is the the change in distance
  112642. */
  112643. onSnapObservable: Observable<{
  112644. snapDistance: number;
  112645. }>;
  112646. /**
  112647. * If the scaling operation should be done on all axis (default: false)
  112648. */
  112649. uniformScaling: boolean;
  112650. private _isEnabled;
  112651. private _parent;
  112652. private _arrow;
  112653. private _coloredMaterial;
  112654. private _hoverMaterial;
  112655. /**
  112656. * Creates an AxisScaleGizmo
  112657. * @param gizmoLayer The utility layer the gizmo will be added to
  112658. * @param dragAxis The axis which the gizmo will be able to scale on
  112659. * @param color The color of the gizmo
  112660. */
  112661. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  112662. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112663. /**
  112664. * If the gizmo is enabled
  112665. */
  112666. isEnabled: boolean;
  112667. /**
  112668. * Disposes of the gizmo
  112669. */
  112670. dispose(): void;
  112671. /**
  112672. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112673. * @param mesh The mesh to replace the default mesh of the gizmo
  112674. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  112675. */
  112676. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  112677. }
  112678. }
  112679. declare module BABYLON {
  112680. /**
  112681. * Bounding box gizmo
  112682. */
  112683. export class BoundingBoxGizmo extends Gizmo {
  112684. private _lineBoundingBox;
  112685. private _rotateSpheresParent;
  112686. private _scaleBoxesParent;
  112687. private _boundingDimensions;
  112688. private _renderObserver;
  112689. private _pointerObserver;
  112690. private _scaleDragSpeed;
  112691. private _tmpQuaternion;
  112692. private _tmpVector;
  112693. private _tmpRotationMatrix;
  112694. /**
  112695. * 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)
  112696. */
  112697. ignoreChildren: boolean;
  112698. /**
  112699. * 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)
  112700. */
  112701. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  112702. /**
  112703. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  112704. */
  112705. rotationSphereSize: number;
  112706. /**
  112707. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  112708. */
  112709. scaleBoxSize: number;
  112710. /**
  112711. * 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)
  112712. */
  112713. fixedDragMeshScreenSize: boolean;
  112714. /**
  112715. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  112716. */
  112717. fixedDragMeshScreenSizeDistanceFactor: number;
  112718. /**
  112719. * Fired when a rotation sphere or scale box is dragged
  112720. */
  112721. onDragStartObservable: Observable<{}>;
  112722. /**
  112723. * Fired when a scale box is dragged
  112724. */
  112725. onScaleBoxDragObservable: Observable<{}>;
  112726. /**
  112727. * Fired when a scale box drag is ended
  112728. */
  112729. onScaleBoxDragEndObservable: Observable<{}>;
  112730. /**
  112731. * Fired when a rotation sphere is dragged
  112732. */
  112733. onRotationSphereDragObservable: Observable<{}>;
  112734. /**
  112735. * Fired when a rotation sphere drag is ended
  112736. */
  112737. onRotationSphereDragEndObservable: Observable<{}>;
  112738. /**
  112739. * 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)
  112740. */
  112741. scalePivot: Nullable<Vector3>;
  112742. /**
  112743. * Mesh used as a pivot to rotate the attached mesh
  112744. */
  112745. private _anchorMesh;
  112746. private _existingMeshScale;
  112747. private _dragMesh;
  112748. private pointerDragBehavior;
  112749. private coloredMaterial;
  112750. private hoverColoredMaterial;
  112751. /**
  112752. * Sets the color of the bounding box gizmo
  112753. * @param color the color to set
  112754. */
  112755. setColor(color: Color3): void;
  112756. /**
  112757. * Creates an BoundingBoxGizmo
  112758. * @param gizmoLayer The utility layer the gizmo will be added to
  112759. * @param color The color of the gizmo
  112760. */
  112761. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  112762. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112763. private _selectNode;
  112764. /**
  112765. * Updates the bounding box information for the Gizmo
  112766. */
  112767. updateBoundingBox(): void;
  112768. private _updateRotationSpheres;
  112769. private _updateScaleBoxes;
  112770. /**
  112771. * Enables rotation on the specified axis and disables rotation on the others
  112772. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112773. */
  112774. setEnabledRotationAxis(axis: string): void;
  112775. /**
  112776. * Enables/disables scaling
  112777. * @param enable if scaling should be enabled
  112778. */
  112779. setEnabledScaling(enable: boolean): void;
  112780. private _updateDummy;
  112781. /**
  112782. * Enables a pointer drag behavior on the bounding box of the gizmo
  112783. */
  112784. enableDragBehavior(): void;
  112785. /**
  112786. * Disposes of the gizmo
  112787. */
  112788. dispose(): void;
  112789. /**
  112790. * 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)
  112791. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112792. * @returns the bounding box mesh with the passed in mesh as a child
  112793. */
  112794. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112795. /**
  112796. * CustomMeshes are not supported by this gizmo
  112797. * @param mesh The mesh to replace the default mesh of the gizmo
  112798. */
  112799. setCustomMesh(mesh: Mesh): void;
  112800. }
  112801. }
  112802. declare module BABYLON {
  112803. /**
  112804. * Single plane rotation gizmo
  112805. */
  112806. export class PlaneRotationGizmo extends Gizmo {
  112807. /**
  112808. * Drag behavior responsible for the gizmos dragging interactions
  112809. */
  112810. dragBehavior: PointerDragBehavior;
  112811. private _pointerObserver;
  112812. /**
  112813. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112814. */
  112815. snapDistance: number;
  112816. /**
  112817. * Event that fires each time the gizmo snaps to a new location.
  112818. * * snapDistance is the the change in distance
  112819. */
  112820. onSnapObservable: Observable<{
  112821. snapDistance: number;
  112822. }>;
  112823. private _isEnabled;
  112824. private _parent;
  112825. /**
  112826. * Creates a PlaneRotationGizmo
  112827. * @param gizmoLayer The utility layer the gizmo will be added to
  112828. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112829. * @param color The color of the gizmo
  112830. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112831. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112832. */
  112833. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112834. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112835. /**
  112836. * If the gizmo is enabled
  112837. */
  112838. isEnabled: boolean;
  112839. /**
  112840. * Disposes of the gizmo
  112841. */
  112842. dispose(): void;
  112843. }
  112844. }
  112845. declare module BABYLON {
  112846. /**
  112847. * Gizmo that enables rotating a mesh along 3 axis
  112848. */
  112849. export class RotationGizmo extends Gizmo {
  112850. /**
  112851. * Internal gizmo used for interactions on the x axis
  112852. */
  112853. xGizmo: PlaneRotationGizmo;
  112854. /**
  112855. * Internal gizmo used for interactions on the y axis
  112856. */
  112857. yGizmo: PlaneRotationGizmo;
  112858. /**
  112859. * Internal gizmo used for interactions on the z axis
  112860. */
  112861. zGizmo: PlaneRotationGizmo;
  112862. /** Fires an event when any of it's sub gizmos are dragged */
  112863. onDragStartObservable: Observable<unknown>;
  112864. /** Fires an event when any of it's sub gizmos are released from dragging */
  112865. onDragEndObservable: Observable<unknown>;
  112866. private _meshAttached;
  112867. attachedMesh: Nullable<AbstractMesh>;
  112868. /**
  112869. * Creates a RotationGizmo
  112870. * @param gizmoLayer The utility layer the gizmo will be added to
  112871. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112872. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112873. */
  112874. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112875. updateGizmoRotationToMatchAttachedMesh: boolean;
  112876. /**
  112877. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112878. */
  112879. snapDistance: number;
  112880. /**
  112881. * Ratio for the scale of the gizmo (Default: 1)
  112882. */
  112883. scaleRatio: number;
  112884. /**
  112885. * Disposes of the gizmo
  112886. */
  112887. dispose(): void;
  112888. /**
  112889. * CustomMeshes are not supported by this gizmo
  112890. * @param mesh The mesh to replace the default mesh of the gizmo
  112891. */
  112892. setCustomMesh(mesh: Mesh): void;
  112893. }
  112894. }
  112895. declare module BABYLON {
  112896. /**
  112897. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112898. */
  112899. export class GizmoManager implements IDisposable {
  112900. private scene;
  112901. /**
  112902. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112903. */
  112904. gizmos: {
  112905. positionGizmo: Nullable<PositionGizmo>;
  112906. rotationGizmo: Nullable<RotationGizmo>;
  112907. scaleGizmo: Nullable<ScaleGizmo>;
  112908. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112909. };
  112910. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112911. clearGizmoOnEmptyPointerEvent: boolean;
  112912. /** Fires an event when the manager is attached to a mesh */
  112913. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112914. private _gizmosEnabled;
  112915. private _pointerObserver;
  112916. private _attachedMesh;
  112917. private _boundingBoxColor;
  112918. private _defaultUtilityLayer;
  112919. private _defaultKeepDepthUtilityLayer;
  112920. /**
  112921. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112922. */
  112923. boundingBoxDragBehavior: SixDofDragBehavior;
  112924. /**
  112925. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112926. */
  112927. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112928. /**
  112929. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112930. */
  112931. usePointerToAttachGizmos: boolean;
  112932. /**
  112933. * Utility layer that the bounding box gizmo belongs to
  112934. */
  112935. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112936. /**
  112937. * Utility layer that all gizmos besides bounding box belong to
  112938. */
  112939. readonly utilityLayer: UtilityLayerRenderer;
  112940. /**
  112941. * Instatiates a gizmo manager
  112942. * @param scene the scene to overlay the gizmos on top of
  112943. */
  112944. constructor(scene: Scene);
  112945. /**
  112946. * Attaches a set of gizmos to the specified mesh
  112947. * @param mesh The mesh the gizmo's should be attached to
  112948. */
  112949. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112950. /**
  112951. * If the position gizmo is enabled
  112952. */
  112953. positionGizmoEnabled: boolean;
  112954. /**
  112955. * If the rotation gizmo is enabled
  112956. */
  112957. rotationGizmoEnabled: boolean;
  112958. /**
  112959. * If the scale gizmo is enabled
  112960. */
  112961. scaleGizmoEnabled: boolean;
  112962. /**
  112963. * If the boundingBox gizmo is enabled
  112964. */
  112965. boundingBoxGizmoEnabled: boolean;
  112966. /**
  112967. * Disposes of the gizmo manager
  112968. */
  112969. dispose(): void;
  112970. }
  112971. }
  112972. declare module BABYLON {
  112973. /**
  112974. * A directional light is defined by a direction (what a surprise!).
  112975. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112976. * 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.
  112977. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112978. */
  112979. export class DirectionalLight extends ShadowLight {
  112980. private _shadowFrustumSize;
  112981. /**
  112982. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112983. */
  112984. /**
  112985. * Specifies a fix frustum size for the shadow generation.
  112986. */
  112987. shadowFrustumSize: number;
  112988. private _shadowOrthoScale;
  112989. /**
  112990. * Gets the shadow projection scale against the optimal computed one.
  112991. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112992. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112993. */
  112994. /**
  112995. * Sets the shadow projection scale against the optimal computed one.
  112996. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112997. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112998. */
  112999. shadowOrthoScale: number;
  113000. /**
  113001. * Automatically compute the projection matrix to best fit (including all the casters)
  113002. * on each frame.
  113003. */
  113004. autoUpdateExtends: boolean;
  113005. private _orthoLeft;
  113006. private _orthoRight;
  113007. private _orthoTop;
  113008. private _orthoBottom;
  113009. /**
  113010. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  113011. * The directional light is emitted from everywhere in the given direction.
  113012. * It can cast shadows.
  113013. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113014. * @param name The friendly name of the light
  113015. * @param direction The direction of the light
  113016. * @param scene The scene the light belongs to
  113017. */
  113018. constructor(name: string, direction: Vector3, scene: Scene);
  113019. /**
  113020. * Returns the string "DirectionalLight".
  113021. * @return The class name
  113022. */
  113023. getClassName(): string;
  113024. /**
  113025. * Returns the integer 1.
  113026. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113027. */
  113028. getTypeID(): number;
  113029. /**
  113030. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  113031. * Returns the DirectionalLight Shadow projection matrix.
  113032. */
  113033. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113034. /**
  113035. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  113036. * Returns the DirectionalLight Shadow projection matrix.
  113037. */
  113038. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  113039. /**
  113040. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  113041. * Returns the DirectionalLight Shadow projection matrix.
  113042. */
  113043. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113044. protected _buildUniformLayout(): void;
  113045. /**
  113046. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  113047. * @param effect The effect to update
  113048. * @param lightIndex The index of the light in the effect to update
  113049. * @returns The directional light
  113050. */
  113051. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  113052. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  113053. /**
  113054. * Gets the minZ used for shadow according to both the scene and the light.
  113055. *
  113056. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113057. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113058. * @param activeCamera The camera we are returning the min for
  113059. * @returns the depth min z
  113060. */
  113061. getDepthMinZ(activeCamera: Camera): number;
  113062. /**
  113063. * Gets the maxZ used for shadow according to both the scene and the light.
  113064. *
  113065. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113066. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113067. * @param activeCamera The camera we are returning the max for
  113068. * @returns the depth max z
  113069. */
  113070. getDepthMaxZ(activeCamera: Camera): number;
  113071. /**
  113072. * Prepares the list of defines specific to the light type.
  113073. * @param defines the list of defines
  113074. * @param lightIndex defines the index of the light for the effect
  113075. */
  113076. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113077. }
  113078. }
  113079. declare module BABYLON {
  113080. /**
  113081. * Class containing static functions to help procedurally build meshes
  113082. */
  113083. export class HemisphereBuilder {
  113084. /**
  113085. * Creates a hemisphere mesh
  113086. * @param name defines the name of the mesh
  113087. * @param options defines the options used to create the mesh
  113088. * @param scene defines the hosting scene
  113089. * @returns the hemisphere mesh
  113090. */
  113091. static CreateHemisphere(name: string, options: {
  113092. segments?: number;
  113093. diameter?: number;
  113094. sideOrientation?: number;
  113095. }, scene: any): Mesh;
  113096. }
  113097. }
  113098. declare module BABYLON {
  113099. /**
  113100. * A spot light is defined by a position, a direction, an angle, and an exponent.
  113101. * These values define a cone of light starting from the position, emitting toward the direction.
  113102. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  113103. * and the exponent defines the speed of the decay of the light with distance (reach).
  113104. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113105. */
  113106. export class SpotLight extends ShadowLight {
  113107. private _angle;
  113108. private _innerAngle;
  113109. private _cosHalfAngle;
  113110. private _lightAngleScale;
  113111. private _lightAngleOffset;
  113112. /**
  113113. * Gets the cone angle of the spot light in Radians.
  113114. */
  113115. /**
  113116. * Sets the cone angle of the spot light in Radians.
  113117. */
  113118. angle: number;
  113119. /**
  113120. * Only used in gltf falloff mode, this defines the angle where
  113121. * the directional falloff will start before cutting at angle which could be seen
  113122. * as outer angle.
  113123. */
  113124. /**
  113125. * Only used in gltf falloff mode, this defines the angle where
  113126. * the directional falloff will start before cutting at angle which could be seen
  113127. * as outer angle.
  113128. */
  113129. innerAngle: number;
  113130. private _shadowAngleScale;
  113131. /**
  113132. * Allows scaling the angle of the light for shadow generation only.
  113133. */
  113134. /**
  113135. * Allows scaling the angle of the light for shadow generation only.
  113136. */
  113137. shadowAngleScale: number;
  113138. /**
  113139. * The light decay speed with the distance from the emission spot.
  113140. */
  113141. exponent: number;
  113142. private _projectionTextureMatrix;
  113143. /**
  113144. * Allows reading the projecton texture
  113145. */
  113146. readonly projectionTextureMatrix: Matrix;
  113147. protected _projectionTextureLightNear: number;
  113148. /**
  113149. * Gets the near clip of the Spotlight for texture projection.
  113150. */
  113151. /**
  113152. * Sets the near clip of the Spotlight for texture projection.
  113153. */
  113154. projectionTextureLightNear: number;
  113155. protected _projectionTextureLightFar: number;
  113156. /**
  113157. * Gets the far clip of the Spotlight for texture projection.
  113158. */
  113159. /**
  113160. * Sets the far clip of the Spotlight for texture projection.
  113161. */
  113162. projectionTextureLightFar: number;
  113163. protected _projectionTextureUpDirection: Vector3;
  113164. /**
  113165. * Gets the Up vector of the Spotlight for texture projection.
  113166. */
  113167. /**
  113168. * Sets the Up vector of the Spotlight for texture projection.
  113169. */
  113170. projectionTextureUpDirection: Vector3;
  113171. private _projectionTexture;
  113172. /**
  113173. * Gets the projection texture of the light.
  113174. */
  113175. /**
  113176. * Sets the projection texture of the light.
  113177. */
  113178. projectionTexture: Nullable<BaseTexture>;
  113179. private _projectionTextureViewLightDirty;
  113180. private _projectionTextureProjectionLightDirty;
  113181. private _projectionTextureDirty;
  113182. private _projectionTextureViewTargetVector;
  113183. private _projectionTextureViewLightMatrix;
  113184. private _projectionTextureProjectionLightMatrix;
  113185. private _projectionTextureScalingMatrix;
  113186. /**
  113187. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  113188. * It can cast shadows.
  113189. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113190. * @param name The light friendly name
  113191. * @param position The position of the spot light in the scene
  113192. * @param direction The direction of the light in the scene
  113193. * @param angle The cone angle of the light in Radians
  113194. * @param exponent The light decay speed with the distance from the emission spot
  113195. * @param scene The scene the lights belongs to
  113196. */
  113197. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  113198. /**
  113199. * Returns the string "SpotLight".
  113200. * @returns the class name
  113201. */
  113202. getClassName(): string;
  113203. /**
  113204. * Returns the integer 2.
  113205. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113206. */
  113207. getTypeID(): number;
  113208. /**
  113209. * Overrides the direction setter to recompute the projection texture view light Matrix.
  113210. */
  113211. protected _setDirection(value: Vector3): void;
  113212. /**
  113213. * Overrides the position setter to recompute the projection texture view light Matrix.
  113214. */
  113215. protected _setPosition(value: Vector3): void;
  113216. /**
  113217. * 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.
  113218. * Returns the SpotLight.
  113219. */
  113220. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113221. protected _computeProjectionTextureViewLightMatrix(): void;
  113222. protected _computeProjectionTextureProjectionLightMatrix(): void;
  113223. /**
  113224. * Main function for light texture projection matrix computing.
  113225. */
  113226. protected _computeProjectionTextureMatrix(): void;
  113227. protected _buildUniformLayout(): void;
  113228. private _computeAngleValues;
  113229. /**
  113230. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  113231. * @param effect The effect to update
  113232. * @param lightIndex The index of the light in the effect to update
  113233. * @returns The spot light
  113234. */
  113235. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  113236. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  113237. /**
  113238. * Disposes the light and the associated resources.
  113239. */
  113240. dispose(): void;
  113241. /**
  113242. * Prepares the list of defines specific to the light type.
  113243. * @param defines the list of defines
  113244. * @param lightIndex defines the index of the light for the effect
  113245. */
  113246. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113247. }
  113248. }
  113249. declare module BABYLON {
  113250. /**
  113251. * Gizmo that enables viewing a light
  113252. */
  113253. export class LightGizmo extends Gizmo {
  113254. private _lightMesh;
  113255. private _material;
  113256. private cachedPosition;
  113257. private cachedForward;
  113258. /**
  113259. * Creates a LightGizmo
  113260. * @param gizmoLayer The utility layer the gizmo will be added to
  113261. */
  113262. constructor(gizmoLayer?: UtilityLayerRenderer);
  113263. private _light;
  113264. /**
  113265. * The light that the gizmo is attached to
  113266. */
  113267. light: Nullable<Light>;
  113268. /**
  113269. * Gets the material used to render the light gizmo
  113270. */
  113271. readonly material: StandardMaterial;
  113272. /**
  113273. * @hidden
  113274. * Updates the gizmo to match the attached mesh's position/rotation
  113275. */
  113276. protected _update(): void;
  113277. private static _Scale;
  113278. /**
  113279. * Creates the lines for a light mesh
  113280. */
  113281. private static _createLightLines;
  113282. /**
  113283. * Disposes of the light gizmo
  113284. */
  113285. dispose(): void;
  113286. private static _CreateHemisphericLightMesh;
  113287. private static _CreatePointLightMesh;
  113288. private static _CreateSpotLightMesh;
  113289. private static _CreateDirectionalLightMesh;
  113290. }
  113291. }
  113292. declare module BABYLON {
  113293. /** @hidden */
  113294. export var backgroundFragmentDeclaration: {
  113295. name: string;
  113296. shader: string;
  113297. };
  113298. }
  113299. declare module BABYLON {
  113300. /** @hidden */
  113301. export var backgroundUboDeclaration: {
  113302. name: string;
  113303. shader: string;
  113304. };
  113305. }
  113306. declare module BABYLON {
  113307. /** @hidden */
  113308. export var backgroundPixelShader: {
  113309. name: string;
  113310. shader: string;
  113311. };
  113312. }
  113313. declare module BABYLON {
  113314. /** @hidden */
  113315. export var backgroundVertexDeclaration: {
  113316. name: string;
  113317. shader: string;
  113318. };
  113319. }
  113320. declare module BABYLON {
  113321. /** @hidden */
  113322. export var backgroundVertexShader: {
  113323. name: string;
  113324. shader: string;
  113325. };
  113326. }
  113327. declare module BABYLON {
  113328. /**
  113329. * Background material used to create an efficient environement around your scene.
  113330. */
  113331. export class BackgroundMaterial extends PushMaterial {
  113332. /**
  113333. * Standard reflectance value at parallel view angle.
  113334. */
  113335. static StandardReflectance0: number;
  113336. /**
  113337. * Standard reflectance value at grazing angle.
  113338. */
  113339. static StandardReflectance90: number;
  113340. protected _primaryColor: Color3;
  113341. /**
  113342. * Key light Color (multiply against the environement texture)
  113343. */
  113344. primaryColor: Color3;
  113345. protected __perceptualColor: Nullable<Color3>;
  113346. /**
  113347. * Experimental Internal Use Only.
  113348. *
  113349. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  113350. * This acts as a helper to set the primary color to a more "human friendly" value.
  113351. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  113352. * output color as close as possible from the chosen value.
  113353. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  113354. * part of lighting setup.)
  113355. */
  113356. _perceptualColor: Nullable<Color3>;
  113357. protected _primaryColorShadowLevel: float;
  113358. /**
  113359. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  113360. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  113361. */
  113362. primaryColorShadowLevel: float;
  113363. protected _primaryColorHighlightLevel: float;
  113364. /**
  113365. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  113366. * The primary color is used at the level chosen to define what the white area would look.
  113367. */
  113368. primaryColorHighlightLevel: float;
  113369. protected _reflectionTexture: Nullable<BaseTexture>;
  113370. /**
  113371. * Reflection Texture used in the material.
  113372. * Should be author in a specific way for the best result (refer to the documentation).
  113373. */
  113374. reflectionTexture: Nullable<BaseTexture>;
  113375. protected _reflectionBlur: float;
  113376. /**
  113377. * Reflection Texture level of blur.
  113378. *
  113379. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  113380. * texture twice.
  113381. */
  113382. reflectionBlur: float;
  113383. protected _diffuseTexture: Nullable<BaseTexture>;
  113384. /**
  113385. * Diffuse Texture used in the material.
  113386. * Should be author in a specific way for the best result (refer to the documentation).
  113387. */
  113388. diffuseTexture: Nullable<BaseTexture>;
  113389. protected _shadowLights: Nullable<IShadowLight[]>;
  113390. /**
  113391. * Specify the list of lights casting shadow on the material.
  113392. * All scene shadow lights will be included if null.
  113393. */
  113394. shadowLights: Nullable<IShadowLight[]>;
  113395. protected _shadowLevel: float;
  113396. /**
  113397. * Helps adjusting the shadow to a softer level if required.
  113398. * 0 means black shadows and 1 means no shadows.
  113399. */
  113400. shadowLevel: float;
  113401. protected _sceneCenter: Vector3;
  113402. /**
  113403. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  113404. * It is usually zero but might be interesting to modify according to your setup.
  113405. */
  113406. sceneCenter: Vector3;
  113407. protected _opacityFresnel: boolean;
  113408. /**
  113409. * This helps specifying that the material is falling off to the sky box at grazing angle.
  113410. * This helps ensuring a nice transition when the camera goes under the ground.
  113411. */
  113412. opacityFresnel: boolean;
  113413. protected _reflectionFresnel: boolean;
  113414. /**
  113415. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  113416. * This helps adding a mirror texture on the ground.
  113417. */
  113418. reflectionFresnel: boolean;
  113419. protected _reflectionFalloffDistance: number;
  113420. /**
  113421. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  113422. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  113423. */
  113424. reflectionFalloffDistance: number;
  113425. protected _reflectionAmount: number;
  113426. /**
  113427. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  113428. */
  113429. reflectionAmount: number;
  113430. protected _reflectionReflectance0: number;
  113431. /**
  113432. * This specifies the weight of the reflection at grazing angle.
  113433. */
  113434. reflectionReflectance0: number;
  113435. protected _reflectionReflectance90: number;
  113436. /**
  113437. * This specifies the weight of the reflection at a perpendicular point of view.
  113438. */
  113439. reflectionReflectance90: number;
  113440. /**
  113441. * Sets the reflection reflectance fresnel values according to the default standard
  113442. * empirically know to work well :-)
  113443. */
  113444. reflectionStandardFresnelWeight: number;
  113445. protected _useRGBColor: boolean;
  113446. /**
  113447. * Helps to directly use the maps channels instead of their level.
  113448. */
  113449. useRGBColor: boolean;
  113450. protected _enableNoise: boolean;
  113451. /**
  113452. * This helps reducing the banding effect that could occur on the background.
  113453. */
  113454. enableNoise: boolean;
  113455. /**
  113456. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113457. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  113458. * Recommended to be keep at 1.0 except for special cases.
  113459. */
  113460. fovMultiplier: number;
  113461. private _fovMultiplier;
  113462. /**
  113463. * Enable the FOV adjustment feature controlled by fovMultiplier.
  113464. */
  113465. useEquirectangularFOV: boolean;
  113466. private _maxSimultaneousLights;
  113467. /**
  113468. * Number of Simultaneous lights allowed on the material.
  113469. */
  113470. maxSimultaneousLights: int;
  113471. /**
  113472. * Default configuration related to image processing available in the Background Material.
  113473. */
  113474. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113475. /**
  113476. * Keep track of the image processing observer to allow dispose and replace.
  113477. */
  113478. private _imageProcessingObserver;
  113479. /**
  113480. * Attaches a new image processing configuration to the PBR Material.
  113481. * @param configuration (if null the scene configuration will be use)
  113482. */
  113483. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113484. /**
  113485. * Gets the image processing configuration used either in this material.
  113486. */
  113487. /**
  113488. * Sets the Default image processing configuration used either in the this material.
  113489. *
  113490. * If sets to null, the scene one is in use.
  113491. */
  113492. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  113493. /**
  113494. * Gets wether the color curves effect is enabled.
  113495. */
  113496. /**
  113497. * Sets wether the color curves effect is enabled.
  113498. */
  113499. cameraColorCurvesEnabled: boolean;
  113500. /**
  113501. * Gets wether the color grading effect is enabled.
  113502. */
  113503. /**
  113504. * Gets wether the color grading effect is enabled.
  113505. */
  113506. cameraColorGradingEnabled: boolean;
  113507. /**
  113508. * Gets wether tonemapping is enabled or not.
  113509. */
  113510. /**
  113511. * Sets wether tonemapping is enabled or not
  113512. */
  113513. cameraToneMappingEnabled: boolean;
  113514. /**
  113515. * The camera exposure used on this material.
  113516. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113517. * This corresponds to a photographic exposure.
  113518. */
  113519. /**
  113520. * The camera exposure used on this material.
  113521. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113522. * This corresponds to a photographic exposure.
  113523. */
  113524. cameraExposure: float;
  113525. /**
  113526. * Gets The camera contrast used on this material.
  113527. */
  113528. /**
  113529. * Sets The camera contrast used on this material.
  113530. */
  113531. cameraContrast: float;
  113532. /**
  113533. * Gets the Color Grading 2D Lookup Texture.
  113534. */
  113535. /**
  113536. * Sets the Color Grading 2D Lookup Texture.
  113537. */
  113538. cameraColorGradingTexture: Nullable<BaseTexture>;
  113539. /**
  113540. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113541. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113542. * 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;
  113543. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113544. */
  113545. /**
  113546. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113547. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113548. * 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;
  113549. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113550. */
  113551. cameraColorCurves: Nullable<ColorCurves>;
  113552. /**
  113553. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  113554. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  113555. */
  113556. switchToBGR: boolean;
  113557. private _renderTargets;
  113558. private _reflectionControls;
  113559. private _white;
  113560. private _primaryShadowColor;
  113561. private _primaryHighlightColor;
  113562. /**
  113563. * Instantiates a Background Material in the given scene
  113564. * @param name The friendly name of the material
  113565. * @param scene The scene to add the material to
  113566. */
  113567. constructor(name: string, scene: Scene);
  113568. /**
  113569. * Gets a boolean indicating that current material needs to register RTT
  113570. */
  113571. readonly hasRenderTargetTextures: boolean;
  113572. /**
  113573. * The entire material has been created in order to prevent overdraw.
  113574. * @returns false
  113575. */
  113576. needAlphaTesting(): boolean;
  113577. /**
  113578. * The entire material has been created in order to prevent overdraw.
  113579. * @returns true if blending is enable
  113580. */
  113581. needAlphaBlending(): boolean;
  113582. /**
  113583. * Checks wether the material is ready to be rendered for a given mesh.
  113584. * @param mesh The mesh to render
  113585. * @param subMesh The submesh to check against
  113586. * @param useInstances Specify wether or not the material is used with instances
  113587. * @returns true if all the dependencies are ready (Textures, Effects...)
  113588. */
  113589. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113590. /**
  113591. * Compute the primary color according to the chosen perceptual color.
  113592. */
  113593. private _computePrimaryColorFromPerceptualColor;
  113594. /**
  113595. * Compute the highlights and shadow colors according to their chosen levels.
  113596. */
  113597. private _computePrimaryColors;
  113598. /**
  113599. * Build the uniform buffer used in the material.
  113600. */
  113601. buildUniformLayout(): void;
  113602. /**
  113603. * Unbind the material.
  113604. */
  113605. unbind(): void;
  113606. /**
  113607. * Bind only the world matrix to the material.
  113608. * @param world The world matrix to bind.
  113609. */
  113610. bindOnlyWorldMatrix(world: Matrix): void;
  113611. /**
  113612. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  113613. * @param world The world matrix to bind.
  113614. * @param subMesh The submesh to bind for.
  113615. */
  113616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113617. /**
  113618. * Checks to see if a texture is used in the material.
  113619. * @param texture - Base texture to use.
  113620. * @returns - Boolean specifying if a texture is used in the material.
  113621. */
  113622. hasTexture(texture: BaseTexture): boolean;
  113623. /**
  113624. * Dispose the material.
  113625. * @param forceDisposeEffect Force disposal of the associated effect.
  113626. * @param forceDisposeTextures Force disposal of the associated textures.
  113627. */
  113628. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113629. /**
  113630. * Clones the material.
  113631. * @param name The cloned name.
  113632. * @returns The cloned material.
  113633. */
  113634. clone(name: string): BackgroundMaterial;
  113635. /**
  113636. * Serializes the current material to its JSON representation.
  113637. * @returns The JSON representation.
  113638. */
  113639. serialize(): any;
  113640. /**
  113641. * Gets the class name of the material
  113642. * @returns "BackgroundMaterial"
  113643. */
  113644. getClassName(): string;
  113645. /**
  113646. * Parse a JSON input to create back a background material.
  113647. * @param source The JSON data to parse
  113648. * @param scene The scene to create the parsed material in
  113649. * @param rootUrl The root url of the assets the material depends upon
  113650. * @returns the instantiated BackgroundMaterial.
  113651. */
  113652. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  113653. }
  113654. }
  113655. declare module BABYLON {
  113656. /**
  113657. * Represents the different options available during the creation of
  113658. * a Environment helper.
  113659. *
  113660. * This can control the default ground, skybox and image processing setup of your scene.
  113661. */
  113662. export interface IEnvironmentHelperOptions {
  113663. /**
  113664. * Specifies wether or not to create a ground.
  113665. * True by default.
  113666. */
  113667. createGround: boolean;
  113668. /**
  113669. * Specifies the ground size.
  113670. * 15 by default.
  113671. */
  113672. groundSize: number;
  113673. /**
  113674. * The texture used on the ground for the main color.
  113675. * Comes from the BabylonJS CDN by default.
  113676. *
  113677. * Remarks: Can be either a texture or a url.
  113678. */
  113679. groundTexture: string | BaseTexture;
  113680. /**
  113681. * The color mixed in the ground texture by default.
  113682. * BabylonJS clearColor by default.
  113683. */
  113684. groundColor: Color3;
  113685. /**
  113686. * Specifies the ground opacity.
  113687. * 1 by default.
  113688. */
  113689. groundOpacity: number;
  113690. /**
  113691. * Enables the ground to receive shadows.
  113692. * True by default.
  113693. */
  113694. enableGroundShadow: boolean;
  113695. /**
  113696. * Helps preventing the shadow to be fully black on the ground.
  113697. * 0.5 by default.
  113698. */
  113699. groundShadowLevel: number;
  113700. /**
  113701. * Creates a mirror texture attach to the ground.
  113702. * false by default.
  113703. */
  113704. enableGroundMirror: boolean;
  113705. /**
  113706. * Specifies the ground mirror size ratio.
  113707. * 0.3 by default as the default kernel is 64.
  113708. */
  113709. groundMirrorSizeRatio: number;
  113710. /**
  113711. * Specifies the ground mirror blur kernel size.
  113712. * 64 by default.
  113713. */
  113714. groundMirrorBlurKernel: number;
  113715. /**
  113716. * Specifies the ground mirror visibility amount.
  113717. * 1 by default
  113718. */
  113719. groundMirrorAmount: number;
  113720. /**
  113721. * Specifies the ground mirror reflectance weight.
  113722. * This uses the standard weight of the background material to setup the fresnel effect
  113723. * of the mirror.
  113724. * 1 by default.
  113725. */
  113726. groundMirrorFresnelWeight: number;
  113727. /**
  113728. * Specifies the ground mirror Falloff distance.
  113729. * This can helps reducing the size of the reflection.
  113730. * 0 by Default.
  113731. */
  113732. groundMirrorFallOffDistance: number;
  113733. /**
  113734. * Specifies the ground mirror texture type.
  113735. * Unsigned Int by Default.
  113736. */
  113737. groundMirrorTextureType: number;
  113738. /**
  113739. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  113740. * the shown objects.
  113741. */
  113742. groundYBias: number;
  113743. /**
  113744. * Specifies wether or not to create a skybox.
  113745. * True by default.
  113746. */
  113747. createSkybox: boolean;
  113748. /**
  113749. * Specifies the skybox size.
  113750. * 20 by default.
  113751. */
  113752. skyboxSize: number;
  113753. /**
  113754. * The texture used on the skybox for the main color.
  113755. * Comes from the BabylonJS CDN by default.
  113756. *
  113757. * Remarks: Can be either a texture or a url.
  113758. */
  113759. skyboxTexture: string | BaseTexture;
  113760. /**
  113761. * The color mixed in the skybox texture by default.
  113762. * BabylonJS clearColor by default.
  113763. */
  113764. skyboxColor: Color3;
  113765. /**
  113766. * The background rotation around the Y axis of the scene.
  113767. * This helps aligning the key lights of your scene with the background.
  113768. * 0 by default.
  113769. */
  113770. backgroundYRotation: number;
  113771. /**
  113772. * Compute automatically the size of the elements to best fit with the scene.
  113773. */
  113774. sizeAuto: boolean;
  113775. /**
  113776. * Default position of the rootMesh if autoSize is not true.
  113777. */
  113778. rootPosition: Vector3;
  113779. /**
  113780. * Sets up the image processing in the scene.
  113781. * true by default.
  113782. */
  113783. setupImageProcessing: boolean;
  113784. /**
  113785. * The texture used as your environment texture in the scene.
  113786. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113787. *
  113788. * Remarks: Can be either a texture or a url.
  113789. */
  113790. environmentTexture: string | BaseTexture;
  113791. /**
  113792. * The value of the exposure to apply to the scene.
  113793. * 0.6 by default if setupImageProcessing is true.
  113794. */
  113795. cameraExposure: number;
  113796. /**
  113797. * The value of the contrast to apply to the scene.
  113798. * 1.6 by default if setupImageProcessing is true.
  113799. */
  113800. cameraContrast: number;
  113801. /**
  113802. * Specifies wether or not tonemapping should be enabled in the scene.
  113803. * true by default if setupImageProcessing is true.
  113804. */
  113805. toneMappingEnabled: boolean;
  113806. }
  113807. /**
  113808. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113809. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113810. * It also helps with the default setup of your imageProcessing configuration.
  113811. */
  113812. export class EnvironmentHelper {
  113813. /**
  113814. * Default ground texture URL.
  113815. */
  113816. private static _groundTextureCDNUrl;
  113817. /**
  113818. * Default skybox texture URL.
  113819. */
  113820. private static _skyboxTextureCDNUrl;
  113821. /**
  113822. * Default environment texture URL.
  113823. */
  113824. private static _environmentTextureCDNUrl;
  113825. /**
  113826. * Creates the default options for the helper.
  113827. */
  113828. private static _getDefaultOptions;
  113829. private _rootMesh;
  113830. /**
  113831. * Gets the root mesh created by the helper.
  113832. */
  113833. readonly rootMesh: Mesh;
  113834. private _skybox;
  113835. /**
  113836. * Gets the skybox created by the helper.
  113837. */
  113838. readonly skybox: Nullable<Mesh>;
  113839. private _skyboxTexture;
  113840. /**
  113841. * Gets the skybox texture created by the helper.
  113842. */
  113843. readonly skyboxTexture: Nullable<BaseTexture>;
  113844. private _skyboxMaterial;
  113845. /**
  113846. * Gets the skybox material created by the helper.
  113847. */
  113848. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113849. private _ground;
  113850. /**
  113851. * Gets the ground mesh created by the helper.
  113852. */
  113853. readonly ground: Nullable<Mesh>;
  113854. private _groundTexture;
  113855. /**
  113856. * Gets the ground texture created by the helper.
  113857. */
  113858. readonly groundTexture: Nullable<BaseTexture>;
  113859. private _groundMirror;
  113860. /**
  113861. * Gets the ground mirror created by the helper.
  113862. */
  113863. readonly groundMirror: Nullable<MirrorTexture>;
  113864. /**
  113865. * Gets the ground mirror render list to helps pushing the meshes
  113866. * you wish in the ground reflection.
  113867. */
  113868. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113869. private _groundMaterial;
  113870. /**
  113871. * Gets the ground material created by the helper.
  113872. */
  113873. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113874. /**
  113875. * Stores the creation options.
  113876. */
  113877. private readonly _scene;
  113878. private _options;
  113879. /**
  113880. * This observable will be notified with any error during the creation of the environment,
  113881. * mainly texture creation errors.
  113882. */
  113883. onErrorObservable: Observable<{
  113884. message?: string;
  113885. exception?: any;
  113886. }>;
  113887. /**
  113888. * constructor
  113889. * @param options Defines the options we want to customize the helper
  113890. * @param scene The scene to add the material to
  113891. */
  113892. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113893. /**
  113894. * Updates the background according to the new options
  113895. * @param options
  113896. */
  113897. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113898. /**
  113899. * Sets the primary color of all the available elements.
  113900. * @param color the main color to affect to the ground and the background
  113901. */
  113902. setMainColor(color: Color3): void;
  113903. /**
  113904. * Setup the image processing according to the specified options.
  113905. */
  113906. private _setupImageProcessing;
  113907. /**
  113908. * Setup the environment texture according to the specified options.
  113909. */
  113910. private _setupEnvironmentTexture;
  113911. /**
  113912. * Setup the background according to the specified options.
  113913. */
  113914. private _setupBackground;
  113915. /**
  113916. * Get the scene sizes according to the setup.
  113917. */
  113918. private _getSceneSize;
  113919. /**
  113920. * Setup the ground according to the specified options.
  113921. */
  113922. private _setupGround;
  113923. /**
  113924. * Setup the ground material according to the specified options.
  113925. */
  113926. private _setupGroundMaterial;
  113927. /**
  113928. * Setup the ground diffuse texture according to the specified options.
  113929. */
  113930. private _setupGroundDiffuseTexture;
  113931. /**
  113932. * Setup the ground mirror texture according to the specified options.
  113933. */
  113934. private _setupGroundMirrorTexture;
  113935. /**
  113936. * Setup the ground to receive the mirror texture.
  113937. */
  113938. private _setupMirrorInGroundMaterial;
  113939. /**
  113940. * Setup the skybox according to the specified options.
  113941. */
  113942. private _setupSkybox;
  113943. /**
  113944. * Setup the skybox material according to the specified options.
  113945. */
  113946. private _setupSkyboxMaterial;
  113947. /**
  113948. * Setup the skybox reflection texture according to the specified options.
  113949. */
  113950. private _setupSkyboxReflectionTexture;
  113951. private _errorHandler;
  113952. /**
  113953. * Dispose all the elements created by the Helper.
  113954. */
  113955. dispose(): void;
  113956. }
  113957. }
  113958. declare module BABYLON {
  113959. /**
  113960. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113961. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113962. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113963. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113964. */
  113965. export class PhotoDome extends TransformNode {
  113966. /**
  113967. * Define the image as a Monoscopic panoramic 360 image.
  113968. */
  113969. static readonly MODE_MONOSCOPIC: number;
  113970. /**
  113971. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113972. */
  113973. static readonly MODE_TOPBOTTOM: number;
  113974. /**
  113975. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113976. */
  113977. static readonly MODE_SIDEBYSIDE: number;
  113978. private _useDirectMapping;
  113979. /**
  113980. * The texture being displayed on the sphere
  113981. */
  113982. protected _photoTexture: Texture;
  113983. /**
  113984. * Gets or sets the texture being displayed on the sphere
  113985. */
  113986. photoTexture: Texture;
  113987. /**
  113988. * Observable raised when an error occured while loading the 360 image
  113989. */
  113990. onLoadErrorObservable: Observable<string>;
  113991. /**
  113992. * The skybox material
  113993. */
  113994. protected _material: BackgroundMaterial;
  113995. /**
  113996. * The surface used for the skybox
  113997. */
  113998. protected _mesh: Mesh;
  113999. /**
  114000. * Gets the mesh used for the skybox.
  114001. */
  114002. readonly mesh: Mesh;
  114003. /**
  114004. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114005. * Also see the options.resolution property.
  114006. */
  114007. fovMultiplier: number;
  114008. private _imageMode;
  114009. /**
  114010. * Gets or set the current video mode for the video. It can be:
  114011. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  114012. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114013. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114014. */
  114015. imageMode: number;
  114016. /**
  114017. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  114018. * @param name Element's name, child elements will append suffixes for their own names.
  114019. * @param urlsOfPhoto defines the url of the photo to display
  114020. * @param options defines an object containing optional or exposed sub element properties
  114021. * @param onError defines a callback called when an error occured while loading the texture
  114022. */
  114023. constructor(name: string, urlOfPhoto: string, options: {
  114024. resolution?: number;
  114025. size?: number;
  114026. useDirectMapping?: boolean;
  114027. faceForward?: boolean;
  114028. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  114029. private _onBeforeCameraRenderObserver;
  114030. private _changeImageMode;
  114031. /**
  114032. * Releases resources associated with this node.
  114033. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114034. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114035. */
  114036. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114037. }
  114038. }
  114039. declare module BABYLON {
  114040. /**
  114041. * Class used to host RGBD texture specific utilities
  114042. */
  114043. export class RGBDTextureTools {
  114044. /**
  114045. * Expand the RGBD Texture from RGBD to Half Float if possible.
  114046. * @param texture the texture to expand.
  114047. */
  114048. static ExpandRGBDTexture(texture: Texture): void;
  114049. }
  114050. }
  114051. declare module BABYLON {
  114052. /**
  114053. * Class used to host texture specific utilities
  114054. */
  114055. export class BRDFTextureTools {
  114056. /**
  114057. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  114058. * @param scene defines the hosting scene
  114059. * @returns the environment BRDF texture
  114060. */
  114061. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  114062. private static _environmentBRDFBase64Texture;
  114063. }
  114064. }
  114065. declare module BABYLON {
  114066. /**
  114067. * @hidden
  114068. */
  114069. export interface IMaterialClearCoatDefines {
  114070. CLEARCOAT: boolean;
  114071. CLEARCOAT_DEFAULTIOR: boolean;
  114072. CLEARCOAT_TEXTURE: boolean;
  114073. CLEARCOAT_TEXTUREDIRECTUV: number;
  114074. CLEARCOAT_BUMP: boolean;
  114075. CLEARCOAT_BUMPDIRECTUV: number;
  114076. CLEARCOAT_TINT: boolean;
  114077. CLEARCOAT_TINT_TEXTURE: boolean;
  114078. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114079. /** @hidden */
  114080. _areTexturesDirty: boolean;
  114081. }
  114082. /**
  114083. * Define the code related to the clear coat parameters of the pbr material.
  114084. */
  114085. export class PBRClearCoatConfiguration {
  114086. /**
  114087. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114088. * The default fits with a polyurethane material.
  114089. */
  114090. private static readonly _DefaultIndexOfRefraction;
  114091. private _isEnabled;
  114092. /**
  114093. * Defines if the clear coat is enabled in the material.
  114094. */
  114095. isEnabled: boolean;
  114096. /**
  114097. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  114098. */
  114099. intensity: number;
  114100. /**
  114101. * Defines the clear coat layer roughness.
  114102. */
  114103. roughness: number;
  114104. private _indexOfRefraction;
  114105. /**
  114106. * Defines the index of refraction of the clear coat.
  114107. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114108. * The default fits with a polyurethane material.
  114109. * Changing the default value is more performance intensive.
  114110. */
  114111. indexOfRefraction: number;
  114112. private _texture;
  114113. /**
  114114. * Stores the clear coat values in a texture.
  114115. */
  114116. texture: Nullable<BaseTexture>;
  114117. private _bumpTexture;
  114118. /**
  114119. * Define the clear coat specific bump texture.
  114120. */
  114121. bumpTexture: Nullable<BaseTexture>;
  114122. private _isTintEnabled;
  114123. /**
  114124. * Defines if the clear coat tint is enabled in the material.
  114125. */
  114126. isTintEnabled: boolean;
  114127. /**
  114128. * Defines the clear coat tint of the material.
  114129. * This is only use if tint is enabled
  114130. */
  114131. tintColor: Color3;
  114132. /**
  114133. * Defines the distance at which the tint color should be found in the
  114134. * clear coat media.
  114135. * This is only use if tint is enabled
  114136. */
  114137. tintColorAtDistance: number;
  114138. /**
  114139. * Defines the clear coat layer thickness.
  114140. * This is only use if tint is enabled
  114141. */
  114142. tintThickness: number;
  114143. private _tintTexture;
  114144. /**
  114145. * Stores the clear tint values in a texture.
  114146. * rgb is tint
  114147. * a is a thickness factor
  114148. */
  114149. tintTexture: Nullable<BaseTexture>;
  114150. /** @hidden */
  114151. private _internalMarkAllSubMeshesAsTexturesDirty;
  114152. /** @hidden */
  114153. _markAllSubMeshesAsTexturesDirty(): void;
  114154. /**
  114155. * Instantiate a new istance of clear coat configuration.
  114156. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114157. */
  114158. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114159. /**
  114160. * Gets wehter the submesh is ready to be used or not.
  114161. * @param defines the list of "defines" to update.
  114162. * @param scene defines the scene the material belongs to.
  114163. * @param engine defines the engine the material belongs to.
  114164. * @param disableBumpMap defines wether the material disables bump or not.
  114165. * @returns - boolean indicating that the submesh is ready or not.
  114166. */
  114167. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  114168. /**
  114169. * Checks to see if a texture is used in the material.
  114170. * @param defines the list of "defines" to update.
  114171. * @param scene defines the scene to the material belongs to.
  114172. */
  114173. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  114174. /**
  114175. * Binds the material data.
  114176. * @param uniformBuffer defines the Uniform buffer to fill in.
  114177. * @param scene defines the scene the material belongs to.
  114178. * @param engine defines the engine the material belongs to.
  114179. * @param disableBumpMap defines wether the material disables bump or not.
  114180. * @param isFrozen defines wether the material is frozen or not.
  114181. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114182. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114183. */
  114184. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  114185. /**
  114186. * Checks to see if a texture is used in the material.
  114187. * @param texture - Base texture to use.
  114188. * @returns - Boolean specifying if a texture is used in the material.
  114189. */
  114190. hasTexture(texture: BaseTexture): boolean;
  114191. /**
  114192. * Returns an array of the actively used textures.
  114193. * @param activeTextures Array of BaseTextures
  114194. */
  114195. getActiveTextures(activeTextures: BaseTexture[]): void;
  114196. /**
  114197. * Returns the animatable textures.
  114198. * @param animatables Array of animatable textures.
  114199. */
  114200. getAnimatables(animatables: IAnimatable[]): void;
  114201. /**
  114202. * Disposes the resources of the material.
  114203. * @param forceDisposeTextures - Forces the disposal of all textures.
  114204. */
  114205. dispose(forceDisposeTextures?: boolean): void;
  114206. /**
  114207. * Get the current class name of the texture useful for serialization or dynamic coding.
  114208. * @returns "PBRClearCoatConfiguration"
  114209. */
  114210. getClassName(): string;
  114211. /**
  114212. * Add fallbacks to the effect fallbacks list.
  114213. * @param defines defines the Base texture to use.
  114214. * @param fallbacks defines the current fallback list.
  114215. * @param currentRank defines the current fallback rank.
  114216. * @returns the new fallback rank.
  114217. */
  114218. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114219. /**
  114220. * Add the required uniforms to the current list.
  114221. * @param uniforms defines the current uniform list.
  114222. */
  114223. static AddUniforms(uniforms: string[]): void;
  114224. /**
  114225. * Add the required samplers to the current list.
  114226. * @param samplers defines the current sampler list.
  114227. */
  114228. static AddSamplers(samplers: string[]): void;
  114229. /**
  114230. * Add the required uniforms to the current buffer.
  114231. * @param uniformBuffer defines the current uniform buffer.
  114232. */
  114233. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114234. /**
  114235. * Makes a duplicate of the current configuration into another one.
  114236. * @param clearCoatConfiguration define the config where to copy the info
  114237. */
  114238. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  114239. /**
  114240. * Serializes this clear coat configuration.
  114241. * @returns - An object with the serialized config.
  114242. */
  114243. serialize(): any;
  114244. /**
  114245. * Parses a anisotropy Configuration from a serialized object.
  114246. * @param source - Serialized object.
  114247. * @param scene Defines the scene we are parsing for
  114248. * @param rootUrl Defines the rootUrl to load from
  114249. */
  114250. parse(source: any, scene: Scene, rootUrl: string): void;
  114251. }
  114252. }
  114253. declare module BABYLON {
  114254. /**
  114255. * @hidden
  114256. */
  114257. export interface IMaterialAnisotropicDefines {
  114258. ANISOTROPIC: boolean;
  114259. ANISOTROPIC_TEXTURE: boolean;
  114260. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114261. MAINUV1: boolean;
  114262. _areTexturesDirty: boolean;
  114263. _needUVs: boolean;
  114264. }
  114265. /**
  114266. * Define the code related to the anisotropic parameters of the pbr material.
  114267. */
  114268. export class PBRAnisotropicConfiguration {
  114269. private _isEnabled;
  114270. /**
  114271. * Defines if the anisotropy is enabled in the material.
  114272. */
  114273. isEnabled: boolean;
  114274. /**
  114275. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  114276. */
  114277. intensity: number;
  114278. /**
  114279. * Defines if the effect is along the tangents, bitangents or in between.
  114280. * By default, the effect is "strectching" the highlights along the tangents.
  114281. */
  114282. direction: Vector2;
  114283. private _texture;
  114284. /**
  114285. * Stores the anisotropy values in a texture.
  114286. * rg is direction (like normal from -1 to 1)
  114287. * b is a intensity
  114288. */
  114289. texture: Nullable<BaseTexture>;
  114290. /** @hidden */
  114291. private _internalMarkAllSubMeshesAsTexturesDirty;
  114292. /** @hidden */
  114293. _markAllSubMeshesAsTexturesDirty(): void;
  114294. /**
  114295. * Instantiate a new istance of anisotropy configuration.
  114296. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114297. */
  114298. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114299. /**
  114300. * Specifies that the submesh is ready to be used.
  114301. * @param defines the list of "defines" to update.
  114302. * @param scene defines the scene the material belongs to.
  114303. * @returns - boolean indicating that the submesh is ready or not.
  114304. */
  114305. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  114306. /**
  114307. * Checks to see if a texture is used in the material.
  114308. * @param defines the list of "defines" to update.
  114309. * @param mesh the mesh we are preparing the defines for.
  114310. * @param scene defines the scene the material belongs to.
  114311. */
  114312. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  114313. /**
  114314. * Binds the material data.
  114315. * @param uniformBuffer defines the Uniform buffer to fill in.
  114316. * @param scene defines the scene the material belongs to.
  114317. * @param isFrozen defines wether the material is frozen or not.
  114318. */
  114319. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114320. /**
  114321. * Checks to see if a texture is used in the material.
  114322. * @param texture - Base texture to use.
  114323. * @returns - Boolean specifying if a texture is used in the material.
  114324. */
  114325. hasTexture(texture: BaseTexture): boolean;
  114326. /**
  114327. * Returns an array of the actively used textures.
  114328. * @param activeTextures Array of BaseTextures
  114329. */
  114330. getActiveTextures(activeTextures: BaseTexture[]): void;
  114331. /**
  114332. * Returns the animatable textures.
  114333. * @param animatables Array of animatable textures.
  114334. */
  114335. getAnimatables(animatables: IAnimatable[]): void;
  114336. /**
  114337. * Disposes the resources of the material.
  114338. * @param forceDisposeTextures - Forces the disposal of all textures.
  114339. */
  114340. dispose(forceDisposeTextures?: boolean): void;
  114341. /**
  114342. * Get the current class name of the texture useful for serialization or dynamic coding.
  114343. * @returns "PBRAnisotropicConfiguration"
  114344. */
  114345. getClassName(): string;
  114346. /**
  114347. * Add fallbacks to the effect fallbacks list.
  114348. * @param defines defines the Base texture to use.
  114349. * @param fallbacks defines the current fallback list.
  114350. * @param currentRank defines the current fallback rank.
  114351. * @returns the new fallback rank.
  114352. */
  114353. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114354. /**
  114355. * Add the required uniforms to the current list.
  114356. * @param uniforms defines the current uniform list.
  114357. */
  114358. static AddUniforms(uniforms: string[]): void;
  114359. /**
  114360. * Add the required uniforms to the current buffer.
  114361. * @param uniformBuffer defines the current uniform buffer.
  114362. */
  114363. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114364. /**
  114365. * Add the required samplers to the current list.
  114366. * @param samplers defines the current sampler list.
  114367. */
  114368. static AddSamplers(samplers: string[]): void;
  114369. /**
  114370. * Makes a duplicate of the current configuration into another one.
  114371. * @param anisotropicConfiguration define the config where to copy the info
  114372. */
  114373. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  114374. /**
  114375. * Serializes this anisotropy configuration.
  114376. * @returns - An object with the serialized config.
  114377. */
  114378. serialize(): any;
  114379. /**
  114380. * Parses a anisotropy Configuration from a serialized object.
  114381. * @param source - Serialized object.
  114382. * @param scene Defines the scene we are parsing for
  114383. * @param rootUrl Defines the rootUrl to load from
  114384. */
  114385. parse(source: any, scene: Scene, rootUrl: string): void;
  114386. }
  114387. }
  114388. declare module BABYLON {
  114389. /**
  114390. * @hidden
  114391. */
  114392. export interface IMaterialBRDFDefines {
  114393. BRDF_V_HEIGHT_CORRELATED: boolean;
  114394. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114395. SPHERICAL_HARMONICS: boolean;
  114396. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114397. /** @hidden */
  114398. _areMiscDirty: boolean;
  114399. }
  114400. /**
  114401. * Define the code related to the BRDF parameters of the pbr material.
  114402. */
  114403. export class PBRBRDFConfiguration {
  114404. /**
  114405. * Default value used for the energy conservation.
  114406. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114407. */
  114408. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  114409. /**
  114410. * Default value used for the Smith Visibility Height Correlated mode.
  114411. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114412. */
  114413. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  114414. /**
  114415. * Default value used for the IBL diffuse part.
  114416. * This can help switching back to the polynomials mode globally which is a tiny bit
  114417. * less GPU intensive at the drawback of a lower quality.
  114418. */
  114419. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  114420. /**
  114421. * Default value used for activating energy conservation for the specular workflow.
  114422. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114423. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114424. */
  114425. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  114426. private _useEnergyConservation;
  114427. /**
  114428. * Defines if the material uses energy conservation.
  114429. */
  114430. useEnergyConservation: boolean;
  114431. private _useSmithVisibilityHeightCorrelated;
  114432. /**
  114433. * LEGACY Mode set to false
  114434. * Defines if the material uses height smith correlated visibility term.
  114435. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  114436. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  114437. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  114438. * Not relying on height correlated will also disable energy conservation.
  114439. */
  114440. useSmithVisibilityHeightCorrelated: boolean;
  114441. private _useSphericalHarmonics;
  114442. /**
  114443. * LEGACY Mode set to false
  114444. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  114445. * diffuse part of the IBL.
  114446. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  114447. * to the ground truth.
  114448. */
  114449. useSphericalHarmonics: boolean;
  114450. private _useSpecularGlossinessInputEnergyConservation;
  114451. /**
  114452. * Defines if the material uses energy conservation, when the specular workflow is active.
  114453. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114454. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114455. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  114456. */
  114457. useSpecularGlossinessInputEnergyConservation: boolean;
  114458. /** @hidden */
  114459. private _internalMarkAllSubMeshesAsMiscDirty;
  114460. /** @hidden */
  114461. _markAllSubMeshesAsMiscDirty(): void;
  114462. /**
  114463. * Instantiate a new istance of clear coat configuration.
  114464. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  114465. */
  114466. constructor(markAllSubMeshesAsMiscDirty: () => void);
  114467. /**
  114468. * Checks to see if a texture is used in the material.
  114469. * @param defines the list of "defines" to update.
  114470. */
  114471. prepareDefines(defines: IMaterialBRDFDefines): void;
  114472. /**
  114473. * Get the current class name of the texture useful for serialization or dynamic coding.
  114474. * @returns "PBRClearCoatConfiguration"
  114475. */
  114476. getClassName(): string;
  114477. /**
  114478. * Makes a duplicate of the current configuration into another one.
  114479. * @param brdfConfiguration define the config where to copy the info
  114480. */
  114481. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  114482. /**
  114483. * Serializes this BRDF configuration.
  114484. * @returns - An object with the serialized config.
  114485. */
  114486. serialize(): any;
  114487. /**
  114488. * Parses a anisotropy Configuration from a serialized object.
  114489. * @param source - Serialized object.
  114490. * @param scene Defines the scene we are parsing for
  114491. * @param rootUrl Defines the rootUrl to load from
  114492. */
  114493. parse(source: any, scene: Scene, rootUrl: string): void;
  114494. }
  114495. }
  114496. declare module BABYLON {
  114497. /**
  114498. * @hidden
  114499. */
  114500. export interface IMaterialSheenDefines {
  114501. SHEEN: boolean;
  114502. SHEEN_TEXTURE: boolean;
  114503. SHEEN_TEXTUREDIRECTUV: number;
  114504. SHEEN_LINKWITHALBEDO: boolean;
  114505. /** @hidden */
  114506. _areTexturesDirty: boolean;
  114507. }
  114508. /**
  114509. * Define the code related to the Sheen parameters of the pbr material.
  114510. */
  114511. export class PBRSheenConfiguration {
  114512. private _isEnabled;
  114513. /**
  114514. * Defines if the material uses sheen.
  114515. */
  114516. isEnabled: boolean;
  114517. private _linkSheenWithAlbedo;
  114518. /**
  114519. * Defines if the sheen is linked to the sheen color.
  114520. */
  114521. linkSheenWithAlbedo: boolean;
  114522. /**
  114523. * Defines the sheen intensity.
  114524. */
  114525. intensity: number;
  114526. /**
  114527. * Defines the sheen color.
  114528. */
  114529. color: Color3;
  114530. private _texture;
  114531. /**
  114532. * Stores the sheen tint values in a texture.
  114533. * rgb is tint
  114534. * a is a intensity
  114535. */
  114536. texture: Nullable<BaseTexture>;
  114537. /** @hidden */
  114538. private _internalMarkAllSubMeshesAsTexturesDirty;
  114539. /** @hidden */
  114540. _markAllSubMeshesAsTexturesDirty(): void;
  114541. /**
  114542. * Instantiate a new istance of clear coat configuration.
  114543. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114544. */
  114545. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114546. /**
  114547. * Specifies that the submesh is ready to be used.
  114548. * @param defines the list of "defines" to update.
  114549. * @param scene defines the scene the material belongs to.
  114550. * @returns - boolean indicating that the submesh is ready or not.
  114551. */
  114552. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  114553. /**
  114554. * Checks to see if a texture is used in the material.
  114555. * @param defines the list of "defines" to update.
  114556. * @param scene defines the scene the material belongs to.
  114557. */
  114558. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  114559. /**
  114560. * Binds the material data.
  114561. * @param uniformBuffer defines the Uniform buffer to fill in.
  114562. * @param scene defines the scene the material belongs to.
  114563. * @param isFrozen defines wether the material is frozen or not.
  114564. */
  114565. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114566. /**
  114567. * Checks to see if a texture is used in the material.
  114568. * @param texture - Base texture to use.
  114569. * @returns - Boolean specifying if a texture is used in the material.
  114570. */
  114571. hasTexture(texture: BaseTexture): boolean;
  114572. /**
  114573. * Returns an array of the actively used textures.
  114574. * @param activeTextures Array of BaseTextures
  114575. */
  114576. getActiveTextures(activeTextures: BaseTexture[]): void;
  114577. /**
  114578. * Returns the animatable textures.
  114579. * @param animatables Array of animatable textures.
  114580. */
  114581. getAnimatables(animatables: IAnimatable[]): void;
  114582. /**
  114583. * Disposes the resources of the material.
  114584. * @param forceDisposeTextures - Forces the disposal of all textures.
  114585. */
  114586. dispose(forceDisposeTextures?: boolean): void;
  114587. /**
  114588. * Get the current class name of the texture useful for serialization or dynamic coding.
  114589. * @returns "PBRSheenConfiguration"
  114590. */
  114591. getClassName(): string;
  114592. /**
  114593. * Add fallbacks to the effect fallbacks list.
  114594. * @param defines defines the Base texture to use.
  114595. * @param fallbacks defines the current fallback list.
  114596. * @param currentRank defines the current fallback rank.
  114597. * @returns the new fallback rank.
  114598. */
  114599. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114600. /**
  114601. * Add the required uniforms to the current list.
  114602. * @param uniforms defines the current uniform list.
  114603. */
  114604. static AddUniforms(uniforms: string[]): void;
  114605. /**
  114606. * Add the required uniforms to the current buffer.
  114607. * @param uniformBuffer defines the current uniform buffer.
  114608. */
  114609. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114610. /**
  114611. * Add the required samplers to the current list.
  114612. * @param samplers defines the current sampler list.
  114613. */
  114614. static AddSamplers(samplers: string[]): void;
  114615. /**
  114616. * Makes a duplicate of the current configuration into another one.
  114617. * @param sheenConfiguration define the config where to copy the info
  114618. */
  114619. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  114620. /**
  114621. * Serializes this BRDF configuration.
  114622. * @returns - An object with the serialized config.
  114623. */
  114624. serialize(): any;
  114625. /**
  114626. * Parses a anisotropy Configuration from a serialized object.
  114627. * @param source - Serialized object.
  114628. * @param scene Defines the scene we are parsing for
  114629. * @param rootUrl Defines the rootUrl to load from
  114630. */
  114631. parse(source: any, scene: Scene, rootUrl: string): void;
  114632. }
  114633. }
  114634. declare module BABYLON {
  114635. /**
  114636. * @hidden
  114637. */
  114638. export interface IMaterialSubSurfaceDefines {
  114639. SUBSURFACE: boolean;
  114640. SS_REFRACTION: boolean;
  114641. SS_TRANSLUCENCY: boolean;
  114642. SS_SCATERRING: boolean;
  114643. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114644. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114645. SS_REFRACTIONMAP_3D: boolean;
  114646. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114647. SS_LODINREFRACTIONALPHA: boolean;
  114648. SS_GAMMAREFRACTION: boolean;
  114649. SS_RGBDREFRACTION: boolean;
  114650. SS_LINEARSPECULARREFRACTION: boolean;
  114651. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114652. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114653. /** @hidden */
  114654. _areTexturesDirty: boolean;
  114655. }
  114656. /**
  114657. * Define the code related to the sub surface parameters of the pbr material.
  114658. */
  114659. export class PBRSubSurfaceConfiguration {
  114660. private _isRefractionEnabled;
  114661. /**
  114662. * Defines if the refraction is enabled in the material.
  114663. */
  114664. isRefractionEnabled: boolean;
  114665. private _isTranslucencyEnabled;
  114666. /**
  114667. * Defines if the translucency is enabled in the material.
  114668. */
  114669. isTranslucencyEnabled: boolean;
  114670. private _isScatteringEnabled;
  114671. /**
  114672. * Defines the refraction intensity of the material.
  114673. * The refraction when enabled replaces the Diffuse part of the material.
  114674. * The intensity helps transitionning between diffuse and refraction.
  114675. */
  114676. refractionIntensity: number;
  114677. /**
  114678. * Defines the translucency intensity of the material.
  114679. * When translucency has been enabled, this defines how much of the "translucency"
  114680. * is addded to the diffuse part of the material.
  114681. */
  114682. translucencyIntensity: number;
  114683. /**
  114684. * Defines the scattering intensity of the material.
  114685. * When scattering has been enabled, this defines how much of the "scattered light"
  114686. * is addded to the diffuse part of the material.
  114687. */
  114688. scatteringIntensity: number;
  114689. private _thicknessTexture;
  114690. /**
  114691. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  114692. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  114693. * 0 would mean minimumThickness
  114694. * 1 would mean maximumThickness
  114695. * The other channels might be use as a mask to vary the different effects intensity.
  114696. */
  114697. thicknessTexture: Nullable<BaseTexture>;
  114698. private _refractionTexture;
  114699. /**
  114700. * Defines the texture to use for refraction.
  114701. */
  114702. refractionTexture: Nullable<BaseTexture>;
  114703. private _indexOfRefraction;
  114704. /**
  114705. * Defines the index of refraction used in the material.
  114706. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  114707. */
  114708. indexOfRefraction: number;
  114709. private _invertRefractionY;
  114710. /**
  114711. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114712. */
  114713. invertRefractionY: boolean;
  114714. private _linkRefractionWithTransparency;
  114715. /**
  114716. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114717. * Materials half opaque for instance using refraction could benefit from this control.
  114718. */
  114719. linkRefractionWithTransparency: boolean;
  114720. /**
  114721. * Defines the minimum thickness stored in the thickness map.
  114722. * If no thickness map is defined, this value will be used to simulate thickness.
  114723. */
  114724. minimumThickness: number;
  114725. /**
  114726. * Defines the maximum thickness stored in the thickness map.
  114727. */
  114728. maximumThickness: number;
  114729. /**
  114730. * Defines the volume tint of the material.
  114731. * This is used for both translucency and scattering.
  114732. */
  114733. tintColor: Color3;
  114734. /**
  114735. * Defines the distance at which the tint color should be found in the media.
  114736. * This is used for refraction only.
  114737. */
  114738. tintColorAtDistance: number;
  114739. /**
  114740. * Defines how far each channel transmit through the media.
  114741. * It is defined as a color to simplify it selection.
  114742. */
  114743. diffusionDistance: Color3;
  114744. private _useMaskFromThicknessTexture;
  114745. /**
  114746. * Stores the intensity of the different subsurface effects in the thickness texture.
  114747. * * the green channel is the translucency intensity.
  114748. * * the blue channel is the scattering intensity.
  114749. * * the alpha channel is the refraction intensity.
  114750. */
  114751. useMaskFromThicknessTexture: boolean;
  114752. /** @hidden */
  114753. private _internalMarkAllSubMeshesAsTexturesDirty;
  114754. /** @hidden */
  114755. _markAllSubMeshesAsTexturesDirty(): void;
  114756. /**
  114757. * Instantiate a new istance of sub surface configuration.
  114758. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114759. */
  114760. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114761. /**
  114762. * Gets wehter the submesh is ready to be used or not.
  114763. * @param defines the list of "defines" to update.
  114764. * @param scene defines the scene the material belongs to.
  114765. * @returns - boolean indicating that the submesh is ready or not.
  114766. */
  114767. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  114768. /**
  114769. * Checks to see if a texture is used in the material.
  114770. * @param defines the list of "defines" to update.
  114771. * @param scene defines the scene to the material belongs to.
  114772. */
  114773. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114774. /**
  114775. * Binds the material data.
  114776. * @param uniformBuffer defines the Uniform buffer to fill in.
  114777. * @param scene defines the scene the material belongs to.
  114778. * @param engine defines the engine the material belongs to.
  114779. * @param isFrozen defines wether the material is frozen or not.
  114780. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114781. */
  114782. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114783. /**
  114784. * Unbinds the material from the mesh.
  114785. * @param activeEffect defines the effect that should be unbound from.
  114786. * @returns true if unbound, otherwise false
  114787. */
  114788. unbind(activeEffect: Effect): boolean;
  114789. /**
  114790. * Returns the texture used for refraction or null if none is used.
  114791. * @param scene defines the scene the material belongs to.
  114792. * @returns - Refraction texture if present. If no refraction texture and refraction
  114793. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114794. */
  114795. private _getRefractionTexture;
  114796. /**
  114797. * Returns true if alpha blending should be disabled.
  114798. */
  114799. readonly disableAlphaBlending: boolean;
  114800. /**
  114801. * Fills the list of render target textures.
  114802. * @param renderTargets the list of render targets to update
  114803. */
  114804. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114805. /**
  114806. * Checks to see if a texture is used in the material.
  114807. * @param texture - Base texture to use.
  114808. * @returns - Boolean specifying if a texture is used in the material.
  114809. */
  114810. hasTexture(texture: BaseTexture): boolean;
  114811. /**
  114812. * Gets a boolean indicating that current material needs to register RTT
  114813. * @returns true if this uses a render target otherwise false.
  114814. */
  114815. hasRenderTargetTextures(): boolean;
  114816. /**
  114817. * Returns an array of the actively used textures.
  114818. * @param activeTextures Array of BaseTextures
  114819. */
  114820. getActiveTextures(activeTextures: BaseTexture[]): void;
  114821. /**
  114822. * Returns the animatable textures.
  114823. * @param animatables Array of animatable textures.
  114824. */
  114825. getAnimatables(animatables: IAnimatable[]): void;
  114826. /**
  114827. * Disposes the resources of the material.
  114828. * @param forceDisposeTextures - Forces the disposal of all textures.
  114829. */
  114830. dispose(forceDisposeTextures?: boolean): void;
  114831. /**
  114832. * Get the current class name of the texture useful for serialization or dynamic coding.
  114833. * @returns "PBRSubSurfaceConfiguration"
  114834. */
  114835. getClassName(): string;
  114836. /**
  114837. * Add fallbacks to the effect fallbacks list.
  114838. * @param defines defines the Base texture to use.
  114839. * @param fallbacks defines the current fallback list.
  114840. * @param currentRank defines the current fallback rank.
  114841. * @returns the new fallback rank.
  114842. */
  114843. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114844. /**
  114845. * Add the required uniforms to the current list.
  114846. * @param uniforms defines the current uniform list.
  114847. */
  114848. static AddUniforms(uniforms: string[]): void;
  114849. /**
  114850. * Add the required samplers to the current list.
  114851. * @param samplers defines the current sampler list.
  114852. */
  114853. static AddSamplers(samplers: string[]): void;
  114854. /**
  114855. * Add the required uniforms to the current buffer.
  114856. * @param uniformBuffer defines the current uniform buffer.
  114857. */
  114858. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114859. /**
  114860. * Makes a duplicate of the current configuration into another one.
  114861. * @param configuration define the config where to copy the info
  114862. */
  114863. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114864. /**
  114865. * Serializes this Sub Surface configuration.
  114866. * @returns - An object with the serialized config.
  114867. */
  114868. serialize(): any;
  114869. /**
  114870. * Parses a anisotropy Configuration from a serialized object.
  114871. * @param source - Serialized object.
  114872. * @param scene Defines the scene we are parsing for
  114873. * @param rootUrl Defines the rootUrl to load from
  114874. */
  114875. parse(source: any, scene: Scene, rootUrl: string): void;
  114876. }
  114877. }
  114878. declare module BABYLON {
  114879. /** @hidden */
  114880. export var pbrFragmentDeclaration: {
  114881. name: string;
  114882. shader: string;
  114883. };
  114884. }
  114885. declare module BABYLON {
  114886. /** @hidden */
  114887. export var pbrUboDeclaration: {
  114888. name: string;
  114889. shader: string;
  114890. };
  114891. }
  114892. declare module BABYLON {
  114893. /** @hidden */
  114894. export var pbrFragmentExtraDeclaration: {
  114895. name: string;
  114896. shader: string;
  114897. };
  114898. }
  114899. declare module BABYLON {
  114900. /** @hidden */
  114901. export var pbrFragmentSamplersDeclaration: {
  114902. name: string;
  114903. shader: string;
  114904. };
  114905. }
  114906. declare module BABYLON {
  114907. /** @hidden */
  114908. export var pbrHelperFunctions: {
  114909. name: string;
  114910. shader: string;
  114911. };
  114912. }
  114913. declare module BABYLON {
  114914. /** @hidden */
  114915. export var harmonicsFunctions: {
  114916. name: string;
  114917. shader: string;
  114918. };
  114919. }
  114920. declare module BABYLON {
  114921. /** @hidden */
  114922. export var pbrDirectLightingSetupFunctions: {
  114923. name: string;
  114924. shader: string;
  114925. };
  114926. }
  114927. declare module BABYLON {
  114928. /** @hidden */
  114929. export var pbrDirectLightingFalloffFunctions: {
  114930. name: string;
  114931. shader: string;
  114932. };
  114933. }
  114934. declare module BABYLON {
  114935. /** @hidden */
  114936. export var pbrBRDFFunctions: {
  114937. name: string;
  114938. shader: string;
  114939. };
  114940. }
  114941. declare module BABYLON {
  114942. /** @hidden */
  114943. export var pbrDirectLightingFunctions: {
  114944. name: string;
  114945. shader: string;
  114946. };
  114947. }
  114948. declare module BABYLON {
  114949. /** @hidden */
  114950. export var pbrIBLFunctions: {
  114951. name: string;
  114952. shader: string;
  114953. };
  114954. }
  114955. declare module BABYLON {
  114956. /** @hidden */
  114957. export var pbrDebug: {
  114958. name: string;
  114959. shader: string;
  114960. };
  114961. }
  114962. declare module BABYLON {
  114963. /** @hidden */
  114964. export var pbrPixelShader: {
  114965. name: string;
  114966. shader: string;
  114967. };
  114968. }
  114969. declare module BABYLON {
  114970. /** @hidden */
  114971. export var pbrVertexDeclaration: {
  114972. name: string;
  114973. shader: string;
  114974. };
  114975. }
  114976. declare module BABYLON {
  114977. /** @hidden */
  114978. export var pbrVertexShader: {
  114979. name: string;
  114980. shader: string;
  114981. };
  114982. }
  114983. declare module BABYLON {
  114984. /**
  114985. * Manages the defines for the PBR Material.
  114986. * @hidden
  114987. */
  114988. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114989. PBR: boolean;
  114990. MAINUV1: boolean;
  114991. MAINUV2: boolean;
  114992. UV1: boolean;
  114993. UV2: boolean;
  114994. ALBEDO: boolean;
  114995. ALBEDODIRECTUV: number;
  114996. VERTEXCOLOR: boolean;
  114997. AMBIENT: boolean;
  114998. AMBIENTDIRECTUV: number;
  114999. AMBIENTINGRAYSCALE: boolean;
  115000. OPACITY: boolean;
  115001. VERTEXALPHA: boolean;
  115002. OPACITYDIRECTUV: number;
  115003. OPACITYRGB: boolean;
  115004. ALPHATEST: boolean;
  115005. DEPTHPREPASS: boolean;
  115006. ALPHABLEND: boolean;
  115007. ALPHAFROMALBEDO: boolean;
  115008. ALPHATESTVALUE: string;
  115009. SPECULAROVERALPHA: boolean;
  115010. RADIANCEOVERALPHA: boolean;
  115011. ALPHAFRESNEL: boolean;
  115012. LINEARALPHAFRESNEL: boolean;
  115013. PREMULTIPLYALPHA: boolean;
  115014. EMISSIVE: boolean;
  115015. EMISSIVEDIRECTUV: number;
  115016. REFLECTIVITY: boolean;
  115017. REFLECTIVITYDIRECTUV: number;
  115018. SPECULARTERM: boolean;
  115019. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  115020. MICROSURFACEAUTOMATIC: boolean;
  115021. LODBASEDMICROSFURACE: boolean;
  115022. MICROSURFACEMAP: boolean;
  115023. MICROSURFACEMAPDIRECTUV: number;
  115024. METALLICWORKFLOW: boolean;
  115025. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  115026. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  115027. METALLNESSSTOREINMETALMAPBLUE: boolean;
  115028. AOSTOREINMETALMAPRED: boolean;
  115029. ENVIRONMENTBRDF: boolean;
  115030. ENVIRONMENTBRDF_RGBD: boolean;
  115031. NORMAL: boolean;
  115032. TANGENT: boolean;
  115033. BUMP: boolean;
  115034. BUMPDIRECTUV: number;
  115035. OBJECTSPACE_NORMALMAP: boolean;
  115036. PARALLAX: boolean;
  115037. PARALLAXOCCLUSION: boolean;
  115038. NORMALXYSCALE: boolean;
  115039. LIGHTMAP: boolean;
  115040. LIGHTMAPDIRECTUV: number;
  115041. USELIGHTMAPASSHADOWMAP: boolean;
  115042. GAMMALIGHTMAP: boolean;
  115043. RGBDLIGHTMAP: boolean;
  115044. REFLECTION: boolean;
  115045. REFLECTIONMAP_3D: boolean;
  115046. REFLECTIONMAP_SPHERICAL: boolean;
  115047. REFLECTIONMAP_PLANAR: boolean;
  115048. REFLECTIONMAP_CUBIC: boolean;
  115049. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  115050. REFLECTIONMAP_PROJECTION: boolean;
  115051. REFLECTIONMAP_SKYBOX: boolean;
  115052. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  115053. REFLECTIONMAP_EXPLICIT: boolean;
  115054. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  115055. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  115056. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  115057. INVERTCUBICMAP: boolean;
  115058. USESPHERICALFROMREFLECTIONMAP: boolean;
  115059. USEIRRADIANCEMAP: boolean;
  115060. SPHERICAL_HARMONICS: boolean;
  115061. USESPHERICALINVERTEX: boolean;
  115062. REFLECTIONMAP_OPPOSITEZ: boolean;
  115063. LODINREFLECTIONALPHA: boolean;
  115064. GAMMAREFLECTION: boolean;
  115065. RGBDREFLECTION: boolean;
  115066. LINEARSPECULARREFLECTION: boolean;
  115067. RADIANCEOCCLUSION: boolean;
  115068. HORIZONOCCLUSION: boolean;
  115069. INSTANCES: boolean;
  115070. NUM_BONE_INFLUENCERS: number;
  115071. BonesPerMesh: number;
  115072. BONETEXTURE: boolean;
  115073. NONUNIFORMSCALING: boolean;
  115074. MORPHTARGETS: boolean;
  115075. MORPHTARGETS_NORMAL: boolean;
  115076. MORPHTARGETS_TANGENT: boolean;
  115077. MORPHTARGETS_UV: boolean;
  115078. NUM_MORPH_INFLUENCERS: number;
  115079. IMAGEPROCESSING: boolean;
  115080. VIGNETTE: boolean;
  115081. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115082. VIGNETTEBLENDMODEOPAQUE: boolean;
  115083. TONEMAPPING: boolean;
  115084. TONEMAPPING_ACES: boolean;
  115085. CONTRAST: boolean;
  115086. COLORCURVES: boolean;
  115087. COLORGRADING: boolean;
  115088. COLORGRADING3D: boolean;
  115089. SAMPLER3DGREENDEPTH: boolean;
  115090. SAMPLER3DBGRMAP: boolean;
  115091. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115092. EXPOSURE: boolean;
  115093. MULTIVIEW: boolean;
  115094. USEPHYSICALLIGHTFALLOFF: boolean;
  115095. USEGLTFLIGHTFALLOFF: boolean;
  115096. TWOSIDEDLIGHTING: boolean;
  115097. SHADOWFLOAT: boolean;
  115098. CLIPPLANE: boolean;
  115099. CLIPPLANE2: boolean;
  115100. CLIPPLANE3: boolean;
  115101. CLIPPLANE4: boolean;
  115102. POINTSIZE: boolean;
  115103. FOG: boolean;
  115104. LOGARITHMICDEPTH: boolean;
  115105. FORCENORMALFORWARD: boolean;
  115106. SPECULARAA: boolean;
  115107. CLEARCOAT: boolean;
  115108. CLEARCOAT_DEFAULTIOR: boolean;
  115109. CLEARCOAT_TEXTURE: boolean;
  115110. CLEARCOAT_TEXTUREDIRECTUV: number;
  115111. CLEARCOAT_BUMP: boolean;
  115112. CLEARCOAT_BUMPDIRECTUV: number;
  115113. CLEARCOAT_TINT: boolean;
  115114. CLEARCOAT_TINT_TEXTURE: boolean;
  115115. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115116. ANISOTROPIC: boolean;
  115117. ANISOTROPIC_TEXTURE: boolean;
  115118. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115119. BRDF_V_HEIGHT_CORRELATED: boolean;
  115120. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115121. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115122. SHEEN: boolean;
  115123. SHEEN_TEXTURE: boolean;
  115124. SHEEN_TEXTUREDIRECTUV: number;
  115125. SHEEN_LINKWITHALBEDO: boolean;
  115126. SUBSURFACE: boolean;
  115127. SS_REFRACTION: boolean;
  115128. SS_TRANSLUCENCY: boolean;
  115129. SS_SCATERRING: boolean;
  115130. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115131. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115132. SS_REFRACTIONMAP_3D: boolean;
  115133. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115134. SS_LODINREFRACTIONALPHA: boolean;
  115135. SS_GAMMAREFRACTION: boolean;
  115136. SS_RGBDREFRACTION: boolean;
  115137. SS_LINEARSPECULARREFRACTION: boolean;
  115138. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115139. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115140. UNLIT: boolean;
  115141. DEBUGMODE: number;
  115142. /**
  115143. * Initializes the PBR Material defines.
  115144. */
  115145. constructor();
  115146. /**
  115147. * Resets the PBR Material defines.
  115148. */
  115149. reset(): void;
  115150. }
  115151. /**
  115152. * The Physically based material base class of BJS.
  115153. *
  115154. * This offers the main features of a standard PBR material.
  115155. * For more information, please refer to the documentation :
  115156. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115157. */
  115158. export abstract class PBRBaseMaterial extends PushMaterial {
  115159. /**
  115160. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115161. */
  115162. static readonly PBRMATERIAL_OPAQUE: number;
  115163. /**
  115164. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115165. */
  115166. static readonly PBRMATERIAL_ALPHATEST: number;
  115167. /**
  115168. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115169. */
  115170. static readonly PBRMATERIAL_ALPHABLEND: number;
  115171. /**
  115172. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115173. * They are also discarded below the alpha cutoff threshold to improve performances.
  115174. */
  115175. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115176. /**
  115177. * Defines the default value of how much AO map is occluding the analytical lights
  115178. * (point spot...).
  115179. */
  115180. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115181. /**
  115182. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  115183. */
  115184. static readonly LIGHTFALLOFF_PHYSICAL: number;
  115185. /**
  115186. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  115187. * to enhance interoperability with other engines.
  115188. */
  115189. static readonly LIGHTFALLOFF_GLTF: number;
  115190. /**
  115191. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  115192. * to enhance interoperability with other materials.
  115193. */
  115194. static readonly LIGHTFALLOFF_STANDARD: number;
  115195. /**
  115196. * Intensity of the direct lights e.g. the four lights available in your scene.
  115197. * This impacts both the direct diffuse and specular highlights.
  115198. */
  115199. protected _directIntensity: number;
  115200. /**
  115201. * Intensity of the emissive part of the material.
  115202. * This helps controlling the emissive effect without modifying the emissive color.
  115203. */
  115204. protected _emissiveIntensity: number;
  115205. /**
  115206. * Intensity of the environment e.g. how much the environment will light the object
  115207. * either through harmonics for rough material or through the refelction for shiny ones.
  115208. */
  115209. protected _environmentIntensity: number;
  115210. /**
  115211. * This is a special control allowing the reduction of the specular highlights coming from the
  115212. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115213. */
  115214. protected _specularIntensity: number;
  115215. /**
  115216. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  115217. */
  115218. private _lightingInfos;
  115219. /**
  115220. * Debug Control allowing disabling the bump map on this material.
  115221. */
  115222. protected _disableBumpMap: boolean;
  115223. /**
  115224. * AKA Diffuse Texture in standard nomenclature.
  115225. */
  115226. protected _albedoTexture: Nullable<BaseTexture>;
  115227. /**
  115228. * AKA Occlusion Texture in other nomenclature.
  115229. */
  115230. protected _ambientTexture: Nullable<BaseTexture>;
  115231. /**
  115232. * AKA Occlusion Texture Intensity in other nomenclature.
  115233. */
  115234. protected _ambientTextureStrength: number;
  115235. /**
  115236. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115237. * 1 means it completely occludes it
  115238. * 0 mean it has no impact
  115239. */
  115240. protected _ambientTextureImpactOnAnalyticalLights: number;
  115241. /**
  115242. * Stores the alpha values in a texture.
  115243. */
  115244. protected _opacityTexture: Nullable<BaseTexture>;
  115245. /**
  115246. * Stores the reflection values in a texture.
  115247. */
  115248. protected _reflectionTexture: Nullable<BaseTexture>;
  115249. /**
  115250. * Stores the emissive values in a texture.
  115251. */
  115252. protected _emissiveTexture: Nullable<BaseTexture>;
  115253. /**
  115254. * AKA Specular texture in other nomenclature.
  115255. */
  115256. protected _reflectivityTexture: Nullable<BaseTexture>;
  115257. /**
  115258. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115259. */
  115260. protected _metallicTexture: Nullable<BaseTexture>;
  115261. /**
  115262. * Specifies the metallic scalar of the metallic/roughness workflow.
  115263. * Can also be used to scale the metalness values of the metallic texture.
  115264. */
  115265. protected _metallic: Nullable<number>;
  115266. /**
  115267. * Specifies the roughness scalar of the metallic/roughness workflow.
  115268. * Can also be used to scale the roughness values of the metallic texture.
  115269. */
  115270. protected _roughness: Nullable<number>;
  115271. /**
  115272. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115273. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115274. */
  115275. protected _microSurfaceTexture: Nullable<BaseTexture>;
  115276. /**
  115277. * Stores surface normal data used to displace a mesh in a texture.
  115278. */
  115279. protected _bumpTexture: Nullable<BaseTexture>;
  115280. /**
  115281. * Stores the pre-calculated light information of a mesh in a texture.
  115282. */
  115283. protected _lightmapTexture: Nullable<BaseTexture>;
  115284. /**
  115285. * The color of a material in ambient lighting.
  115286. */
  115287. protected _ambientColor: Color3;
  115288. /**
  115289. * AKA Diffuse Color in other nomenclature.
  115290. */
  115291. protected _albedoColor: Color3;
  115292. /**
  115293. * AKA Specular Color in other nomenclature.
  115294. */
  115295. protected _reflectivityColor: Color3;
  115296. /**
  115297. * The color applied when light is reflected from a material.
  115298. */
  115299. protected _reflectionColor: Color3;
  115300. /**
  115301. * The color applied when light is emitted from a material.
  115302. */
  115303. protected _emissiveColor: Color3;
  115304. /**
  115305. * AKA Glossiness in other nomenclature.
  115306. */
  115307. protected _microSurface: number;
  115308. /**
  115309. * Specifies that the material will use the light map as a show map.
  115310. */
  115311. protected _useLightmapAsShadowmap: boolean;
  115312. /**
  115313. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115314. * makes the reflect vector face the model (under horizon).
  115315. */
  115316. protected _useHorizonOcclusion: boolean;
  115317. /**
  115318. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115319. * too much the area relying on ambient texture to define their ambient occlusion.
  115320. */
  115321. protected _useRadianceOcclusion: boolean;
  115322. /**
  115323. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115324. */
  115325. protected _useAlphaFromAlbedoTexture: boolean;
  115326. /**
  115327. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  115328. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115329. */
  115330. protected _useSpecularOverAlpha: boolean;
  115331. /**
  115332. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115333. */
  115334. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115335. /**
  115336. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115337. */
  115338. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  115339. /**
  115340. * Specifies if the metallic texture contains the roughness information in its green channel.
  115341. */
  115342. protected _useRoughnessFromMetallicTextureGreen: boolean;
  115343. /**
  115344. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115345. */
  115346. protected _useMetallnessFromMetallicTextureBlue: boolean;
  115347. /**
  115348. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115349. */
  115350. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  115351. /**
  115352. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115353. */
  115354. protected _useAmbientInGrayScale: boolean;
  115355. /**
  115356. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115357. * The material will try to infer what glossiness each pixel should be.
  115358. */
  115359. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  115360. /**
  115361. * Defines the falloff type used in this material.
  115362. * It by default is Physical.
  115363. */
  115364. protected _lightFalloff: number;
  115365. /**
  115366. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115367. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115368. */
  115369. protected _useRadianceOverAlpha: boolean;
  115370. /**
  115371. * Allows using an object space normal map (instead of tangent space).
  115372. */
  115373. protected _useObjectSpaceNormalMap: boolean;
  115374. /**
  115375. * Allows using the bump map in parallax mode.
  115376. */
  115377. protected _useParallax: boolean;
  115378. /**
  115379. * Allows using the bump map in parallax occlusion mode.
  115380. */
  115381. protected _useParallaxOcclusion: boolean;
  115382. /**
  115383. * Controls the scale bias of the parallax mode.
  115384. */
  115385. protected _parallaxScaleBias: number;
  115386. /**
  115387. * If sets to true, disables all the lights affecting the material.
  115388. */
  115389. protected _disableLighting: boolean;
  115390. /**
  115391. * Number of Simultaneous lights allowed on the material.
  115392. */
  115393. protected _maxSimultaneousLights: number;
  115394. /**
  115395. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115396. */
  115397. protected _invertNormalMapX: boolean;
  115398. /**
  115399. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115400. */
  115401. protected _invertNormalMapY: boolean;
  115402. /**
  115403. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115404. */
  115405. protected _twoSidedLighting: boolean;
  115406. /**
  115407. * Defines the alpha limits in alpha test mode.
  115408. */
  115409. protected _alphaCutOff: number;
  115410. /**
  115411. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115412. */
  115413. protected _forceAlphaTest: boolean;
  115414. /**
  115415. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115416. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115417. */
  115418. protected _useAlphaFresnel: boolean;
  115419. /**
  115420. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115421. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115422. */
  115423. protected _useLinearAlphaFresnel: boolean;
  115424. /**
  115425. * The transparency mode of the material.
  115426. */
  115427. protected _transparencyMode: Nullable<number>;
  115428. /**
  115429. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  115430. * from cos thetav and roughness:
  115431. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  115432. */
  115433. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  115434. /**
  115435. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115436. */
  115437. protected _forceIrradianceInFragment: boolean;
  115438. /**
  115439. * Force normal to face away from face.
  115440. */
  115441. protected _forceNormalForward: boolean;
  115442. /**
  115443. * Enables specular anti aliasing in the PBR shader.
  115444. * It will both interacts on the Geometry for analytical and IBL lighting.
  115445. * It also prefilter the roughness map based on the bump values.
  115446. */
  115447. protected _enableSpecularAntiAliasing: boolean;
  115448. /**
  115449. * Default configuration related to image processing available in the PBR Material.
  115450. */
  115451. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115452. /**
  115453. * Keep track of the image processing observer to allow dispose and replace.
  115454. */
  115455. private _imageProcessingObserver;
  115456. /**
  115457. * Attaches a new image processing configuration to the PBR Material.
  115458. * @param configuration
  115459. */
  115460. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115461. /**
  115462. * Stores the available render targets.
  115463. */
  115464. private _renderTargets;
  115465. /**
  115466. * Sets the global ambient color for the material used in lighting calculations.
  115467. */
  115468. private _globalAmbientColor;
  115469. /**
  115470. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  115471. */
  115472. private _useLogarithmicDepth;
  115473. /**
  115474. * If set to true, no lighting calculations will be applied.
  115475. */
  115476. private _unlit;
  115477. private _debugMode;
  115478. /**
  115479. * @hidden
  115480. * This is reserved for the inspector.
  115481. * Defines the material debug mode.
  115482. * It helps seeing only some components of the material while troubleshooting.
  115483. */
  115484. debugMode: number;
  115485. /**
  115486. * @hidden
  115487. * This is reserved for the inspector.
  115488. * Specify from where on screen the debug mode should start.
  115489. * The value goes from -1 (full screen) to 1 (not visible)
  115490. * It helps with side by side comparison against the final render
  115491. * This defaults to -1
  115492. */
  115493. private debugLimit;
  115494. /**
  115495. * @hidden
  115496. * This is reserved for the inspector.
  115497. * As the default viewing range might not be enough (if the ambient is really small for instance)
  115498. * You can use the factor to better multiply the final value.
  115499. */
  115500. private debugFactor;
  115501. /**
  115502. * Defines the clear coat layer parameters for the material.
  115503. */
  115504. readonly clearCoat: PBRClearCoatConfiguration;
  115505. /**
  115506. * Defines the anisotropic parameters for the material.
  115507. */
  115508. readonly anisotropy: PBRAnisotropicConfiguration;
  115509. /**
  115510. * Defines the BRDF parameters for the material.
  115511. */
  115512. readonly brdf: PBRBRDFConfiguration;
  115513. /**
  115514. * Defines the Sheen parameters for the material.
  115515. */
  115516. readonly sheen: PBRSheenConfiguration;
  115517. /**
  115518. * Defines the SubSurface parameters for the material.
  115519. */
  115520. readonly subSurface: PBRSubSurfaceConfiguration;
  115521. /**
  115522. * Custom callback helping to override the default shader used in the material.
  115523. */
  115524. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  115525. protected _rebuildInParallel: boolean;
  115526. /**
  115527. * Instantiates a new PBRMaterial instance.
  115528. *
  115529. * @param name The material name
  115530. * @param scene The scene the material will be use in.
  115531. */
  115532. constructor(name: string, scene: Scene);
  115533. /**
  115534. * Gets a boolean indicating that current material needs to register RTT
  115535. */
  115536. readonly hasRenderTargetTextures: boolean;
  115537. /**
  115538. * Gets the name of the material class.
  115539. */
  115540. getClassName(): string;
  115541. /**
  115542. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115543. */
  115544. /**
  115545. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115546. */
  115547. useLogarithmicDepth: boolean;
  115548. /**
  115549. * Gets the current transparency mode.
  115550. */
  115551. /**
  115552. * Sets the transparency mode of the material.
  115553. *
  115554. * | Value | Type | Description |
  115555. * | ----- | ----------------------------------- | ----------- |
  115556. * | 0 | OPAQUE | |
  115557. * | 1 | ALPHATEST | |
  115558. * | 2 | ALPHABLEND | |
  115559. * | 3 | ALPHATESTANDBLEND | |
  115560. *
  115561. */
  115562. transparencyMode: Nullable<number>;
  115563. /**
  115564. * Returns true if alpha blending should be disabled.
  115565. */
  115566. private readonly _disableAlphaBlending;
  115567. /**
  115568. * Specifies whether or not this material should be rendered in alpha blend mode.
  115569. */
  115570. needAlphaBlending(): boolean;
  115571. /**
  115572. * Specifies if the mesh will require alpha blending.
  115573. * @param mesh - BJS mesh.
  115574. */
  115575. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  115576. /**
  115577. * Specifies whether or not this material should be rendered in alpha test mode.
  115578. */
  115579. needAlphaTesting(): boolean;
  115580. /**
  115581. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  115582. */
  115583. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  115584. /**
  115585. * Gets the texture used for the alpha test.
  115586. */
  115587. getAlphaTestTexture(): Nullable<BaseTexture>;
  115588. /**
  115589. * Specifies that the submesh is ready to be used.
  115590. * @param mesh - BJS mesh.
  115591. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  115592. * @param useInstances - Specifies that instances should be used.
  115593. * @returns - boolean indicating that the submesh is ready or not.
  115594. */
  115595. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115596. /**
  115597. * Specifies if the material uses metallic roughness workflow.
  115598. * @returns boolean specifiying if the material uses metallic roughness workflow.
  115599. */
  115600. isMetallicWorkflow(): boolean;
  115601. private _prepareEffect;
  115602. private _prepareDefines;
  115603. /**
  115604. * Force shader compilation
  115605. */
  115606. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  115607. /**
  115608. * Initializes the uniform buffer layout for the shader.
  115609. */
  115610. buildUniformLayout(): void;
  115611. /**
  115612. * Unbinds the material from the mesh
  115613. */
  115614. unbind(): void;
  115615. /**
  115616. * Binds the submesh data.
  115617. * @param world - The world matrix.
  115618. * @param mesh - The BJS mesh.
  115619. * @param subMesh - A submesh of the BJS mesh.
  115620. */
  115621. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115622. /**
  115623. * Returns the animatable textures.
  115624. * @returns - Array of animatable textures.
  115625. */
  115626. getAnimatables(): IAnimatable[];
  115627. /**
  115628. * Returns the texture used for reflections.
  115629. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  115630. */
  115631. private _getReflectionTexture;
  115632. /**
  115633. * Returns an array of the actively used textures.
  115634. * @returns - Array of BaseTextures
  115635. */
  115636. getActiveTextures(): BaseTexture[];
  115637. /**
  115638. * Checks to see if a texture is used in the material.
  115639. * @param texture - Base texture to use.
  115640. * @returns - Boolean specifying if a texture is used in the material.
  115641. */
  115642. hasTexture(texture: BaseTexture): boolean;
  115643. /**
  115644. * Disposes the resources of the material.
  115645. * @param forceDisposeEffect - Forces the disposal of effects.
  115646. * @param forceDisposeTextures - Forces the disposal of all textures.
  115647. */
  115648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115649. }
  115650. }
  115651. declare module BABYLON {
  115652. /**
  115653. * The Physically based material of BJS.
  115654. *
  115655. * This offers the main features of a standard PBR material.
  115656. * For more information, please refer to the documentation :
  115657. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115658. */
  115659. export class PBRMaterial extends PBRBaseMaterial {
  115660. /**
  115661. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115662. */
  115663. static readonly PBRMATERIAL_OPAQUE: number;
  115664. /**
  115665. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115666. */
  115667. static readonly PBRMATERIAL_ALPHATEST: number;
  115668. /**
  115669. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115670. */
  115671. static readonly PBRMATERIAL_ALPHABLEND: number;
  115672. /**
  115673. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115674. * They are also discarded below the alpha cutoff threshold to improve performances.
  115675. */
  115676. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115677. /**
  115678. * Defines the default value of how much AO map is occluding the analytical lights
  115679. * (point spot...).
  115680. */
  115681. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115682. /**
  115683. * Intensity of the direct lights e.g. the four lights available in your scene.
  115684. * This impacts both the direct diffuse and specular highlights.
  115685. */
  115686. directIntensity: number;
  115687. /**
  115688. * Intensity of the emissive part of the material.
  115689. * This helps controlling the emissive effect without modifying the emissive color.
  115690. */
  115691. emissiveIntensity: number;
  115692. /**
  115693. * Intensity of the environment e.g. how much the environment will light the object
  115694. * either through harmonics for rough material or through the refelction for shiny ones.
  115695. */
  115696. environmentIntensity: number;
  115697. /**
  115698. * This is a special control allowing the reduction of the specular highlights coming from the
  115699. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115700. */
  115701. specularIntensity: number;
  115702. /**
  115703. * Debug Control allowing disabling the bump map on this material.
  115704. */
  115705. disableBumpMap: boolean;
  115706. /**
  115707. * AKA Diffuse Texture in standard nomenclature.
  115708. */
  115709. albedoTexture: BaseTexture;
  115710. /**
  115711. * AKA Occlusion Texture in other nomenclature.
  115712. */
  115713. ambientTexture: BaseTexture;
  115714. /**
  115715. * AKA Occlusion Texture Intensity in other nomenclature.
  115716. */
  115717. ambientTextureStrength: number;
  115718. /**
  115719. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115720. * 1 means it completely occludes it
  115721. * 0 mean it has no impact
  115722. */
  115723. ambientTextureImpactOnAnalyticalLights: number;
  115724. /**
  115725. * Stores the alpha values in a texture.
  115726. */
  115727. opacityTexture: BaseTexture;
  115728. /**
  115729. * Stores the reflection values in a texture.
  115730. */
  115731. reflectionTexture: Nullable<BaseTexture>;
  115732. /**
  115733. * Stores the emissive values in a texture.
  115734. */
  115735. emissiveTexture: BaseTexture;
  115736. /**
  115737. * AKA Specular texture in other nomenclature.
  115738. */
  115739. reflectivityTexture: BaseTexture;
  115740. /**
  115741. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115742. */
  115743. metallicTexture: BaseTexture;
  115744. /**
  115745. * Specifies the metallic scalar of the metallic/roughness workflow.
  115746. * Can also be used to scale the metalness values of the metallic texture.
  115747. */
  115748. metallic: Nullable<number>;
  115749. /**
  115750. * Specifies the roughness scalar of the metallic/roughness workflow.
  115751. * Can also be used to scale the roughness values of the metallic texture.
  115752. */
  115753. roughness: Nullable<number>;
  115754. /**
  115755. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115756. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115757. */
  115758. microSurfaceTexture: BaseTexture;
  115759. /**
  115760. * Stores surface normal data used to displace a mesh in a texture.
  115761. */
  115762. bumpTexture: BaseTexture;
  115763. /**
  115764. * Stores the pre-calculated light information of a mesh in a texture.
  115765. */
  115766. lightmapTexture: BaseTexture;
  115767. /**
  115768. * Stores the refracted light information in a texture.
  115769. */
  115770. refractionTexture: Nullable<BaseTexture>;
  115771. /**
  115772. * The color of a material in ambient lighting.
  115773. */
  115774. ambientColor: Color3;
  115775. /**
  115776. * AKA Diffuse Color in other nomenclature.
  115777. */
  115778. albedoColor: Color3;
  115779. /**
  115780. * AKA Specular Color in other nomenclature.
  115781. */
  115782. reflectivityColor: Color3;
  115783. /**
  115784. * The color reflected from the material.
  115785. */
  115786. reflectionColor: Color3;
  115787. /**
  115788. * The color emitted from the material.
  115789. */
  115790. emissiveColor: Color3;
  115791. /**
  115792. * AKA Glossiness in other nomenclature.
  115793. */
  115794. microSurface: number;
  115795. /**
  115796. * source material index of refraction (IOR)' / 'destination material IOR.
  115797. */
  115798. indexOfRefraction: number;
  115799. /**
  115800. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115801. */
  115802. invertRefractionY: boolean;
  115803. /**
  115804. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115805. * Materials half opaque for instance using refraction could benefit from this control.
  115806. */
  115807. linkRefractionWithTransparency: boolean;
  115808. /**
  115809. * If true, the light map contains occlusion information instead of lighting info.
  115810. */
  115811. useLightmapAsShadowmap: boolean;
  115812. /**
  115813. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115814. */
  115815. useAlphaFromAlbedoTexture: boolean;
  115816. /**
  115817. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115818. */
  115819. forceAlphaTest: boolean;
  115820. /**
  115821. * Defines the alpha limits in alpha test mode.
  115822. */
  115823. alphaCutOff: number;
  115824. /**
  115825. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115826. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115827. */
  115828. useSpecularOverAlpha: boolean;
  115829. /**
  115830. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115831. */
  115832. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115833. /**
  115834. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115835. */
  115836. useRoughnessFromMetallicTextureAlpha: boolean;
  115837. /**
  115838. * Specifies if the metallic texture contains the roughness information in its green channel.
  115839. */
  115840. useRoughnessFromMetallicTextureGreen: boolean;
  115841. /**
  115842. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115843. */
  115844. useMetallnessFromMetallicTextureBlue: boolean;
  115845. /**
  115846. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115847. */
  115848. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115849. /**
  115850. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115851. */
  115852. useAmbientInGrayScale: boolean;
  115853. /**
  115854. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115855. * The material will try to infer what glossiness each pixel should be.
  115856. */
  115857. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115858. /**
  115859. * BJS is using an harcoded light falloff based on a manually sets up range.
  115860. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115861. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115862. */
  115863. /**
  115864. * BJS is using an harcoded light falloff based on a manually sets up range.
  115865. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115866. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115867. */
  115868. usePhysicalLightFalloff: boolean;
  115869. /**
  115870. * In order to support the falloff compatibility with gltf, a special mode has been added
  115871. * to reproduce the gltf light falloff.
  115872. */
  115873. /**
  115874. * In order to support the falloff compatibility with gltf, a special mode has been added
  115875. * to reproduce the gltf light falloff.
  115876. */
  115877. useGLTFLightFalloff: boolean;
  115878. /**
  115879. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115880. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115881. */
  115882. useRadianceOverAlpha: boolean;
  115883. /**
  115884. * Allows using an object space normal map (instead of tangent space).
  115885. */
  115886. useObjectSpaceNormalMap: boolean;
  115887. /**
  115888. * Allows using the bump map in parallax mode.
  115889. */
  115890. useParallax: boolean;
  115891. /**
  115892. * Allows using the bump map in parallax occlusion mode.
  115893. */
  115894. useParallaxOcclusion: boolean;
  115895. /**
  115896. * Controls the scale bias of the parallax mode.
  115897. */
  115898. parallaxScaleBias: number;
  115899. /**
  115900. * If sets to true, disables all the lights affecting the material.
  115901. */
  115902. disableLighting: boolean;
  115903. /**
  115904. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115905. */
  115906. forceIrradianceInFragment: boolean;
  115907. /**
  115908. * Number of Simultaneous lights allowed on the material.
  115909. */
  115910. maxSimultaneousLights: number;
  115911. /**
  115912. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115913. */
  115914. invertNormalMapX: boolean;
  115915. /**
  115916. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115917. */
  115918. invertNormalMapY: boolean;
  115919. /**
  115920. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115921. */
  115922. twoSidedLighting: boolean;
  115923. /**
  115924. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115925. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115926. */
  115927. useAlphaFresnel: boolean;
  115928. /**
  115929. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115930. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115931. */
  115932. useLinearAlphaFresnel: boolean;
  115933. /**
  115934. * Let user defines the brdf lookup texture used for IBL.
  115935. * A default 8bit version is embedded but you could point at :
  115936. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115937. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115938. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115939. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115940. */
  115941. environmentBRDFTexture: Nullable<BaseTexture>;
  115942. /**
  115943. * Force normal to face away from face.
  115944. */
  115945. forceNormalForward: boolean;
  115946. /**
  115947. * Enables specular anti aliasing in the PBR shader.
  115948. * It will both interacts on the Geometry for analytical and IBL lighting.
  115949. * It also prefilter the roughness map based on the bump values.
  115950. */
  115951. enableSpecularAntiAliasing: boolean;
  115952. /**
  115953. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115954. * makes the reflect vector face the model (under horizon).
  115955. */
  115956. useHorizonOcclusion: boolean;
  115957. /**
  115958. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115959. * too much the area relying on ambient texture to define their ambient occlusion.
  115960. */
  115961. useRadianceOcclusion: boolean;
  115962. /**
  115963. * If set to true, no lighting calculations will be applied.
  115964. */
  115965. unlit: boolean;
  115966. /**
  115967. * Gets the image processing configuration used either in this material.
  115968. */
  115969. /**
  115970. * Sets the Default image processing configuration used either in the this material.
  115971. *
  115972. * If sets to null, the scene one is in use.
  115973. */
  115974. imageProcessingConfiguration: ImageProcessingConfiguration;
  115975. /**
  115976. * Gets wether the color curves effect is enabled.
  115977. */
  115978. /**
  115979. * Sets wether the color curves effect is enabled.
  115980. */
  115981. cameraColorCurvesEnabled: boolean;
  115982. /**
  115983. * Gets wether the color grading effect is enabled.
  115984. */
  115985. /**
  115986. * Gets wether the color grading effect is enabled.
  115987. */
  115988. cameraColorGradingEnabled: boolean;
  115989. /**
  115990. * Gets wether tonemapping is enabled or not.
  115991. */
  115992. /**
  115993. * Sets wether tonemapping is enabled or not
  115994. */
  115995. cameraToneMappingEnabled: boolean;
  115996. /**
  115997. * The camera exposure used on this material.
  115998. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115999. * This corresponds to a photographic exposure.
  116000. */
  116001. /**
  116002. * The camera exposure used on this material.
  116003. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116004. * This corresponds to a photographic exposure.
  116005. */
  116006. cameraExposure: number;
  116007. /**
  116008. * Gets The camera contrast used on this material.
  116009. */
  116010. /**
  116011. * Sets The camera contrast used on this material.
  116012. */
  116013. cameraContrast: number;
  116014. /**
  116015. * Gets the Color Grading 2D Lookup Texture.
  116016. */
  116017. /**
  116018. * Sets the Color Grading 2D Lookup Texture.
  116019. */
  116020. cameraColorGradingTexture: Nullable<BaseTexture>;
  116021. /**
  116022. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116023. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116024. * 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;
  116025. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116026. */
  116027. /**
  116028. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116029. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116030. * 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;
  116031. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116032. */
  116033. cameraColorCurves: Nullable<ColorCurves>;
  116034. /**
  116035. * Instantiates a new PBRMaterial instance.
  116036. *
  116037. * @param name The material name
  116038. * @param scene The scene the material will be use in.
  116039. */
  116040. constructor(name: string, scene: Scene);
  116041. /**
  116042. * Returns the name of this material class.
  116043. */
  116044. getClassName(): string;
  116045. /**
  116046. * Makes a duplicate of the current material.
  116047. * @param name - name to use for the new material.
  116048. */
  116049. clone(name: string): PBRMaterial;
  116050. /**
  116051. * Serializes this PBR Material.
  116052. * @returns - An object with the serialized material.
  116053. */
  116054. serialize(): any;
  116055. /**
  116056. * Parses a PBR Material from a serialized object.
  116057. * @param source - Serialized object.
  116058. * @param scene - BJS scene instance.
  116059. * @param rootUrl - url for the scene object
  116060. * @returns - PBRMaterial
  116061. */
  116062. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  116063. }
  116064. }
  116065. declare module BABYLON {
  116066. /**
  116067. * Direct draw surface info
  116068. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  116069. */
  116070. export interface DDSInfo {
  116071. /**
  116072. * Width of the texture
  116073. */
  116074. width: number;
  116075. /**
  116076. * Width of the texture
  116077. */
  116078. height: number;
  116079. /**
  116080. * Number of Mipmaps for the texture
  116081. * @see https://en.wikipedia.org/wiki/Mipmap
  116082. */
  116083. mipmapCount: number;
  116084. /**
  116085. * If the textures format is a known fourCC format
  116086. * @see https://www.fourcc.org/
  116087. */
  116088. isFourCC: boolean;
  116089. /**
  116090. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  116091. */
  116092. isRGB: boolean;
  116093. /**
  116094. * If the texture is a lumincance format
  116095. */
  116096. isLuminance: boolean;
  116097. /**
  116098. * If this is a cube texture
  116099. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  116100. */
  116101. isCube: boolean;
  116102. /**
  116103. * If the texture is a compressed format eg. FOURCC_DXT1
  116104. */
  116105. isCompressed: boolean;
  116106. /**
  116107. * The dxgiFormat of the texture
  116108. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  116109. */
  116110. dxgiFormat: number;
  116111. /**
  116112. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  116113. */
  116114. textureType: number;
  116115. /**
  116116. * Sphericle polynomial created for the dds texture
  116117. */
  116118. sphericalPolynomial?: SphericalPolynomial;
  116119. }
  116120. /**
  116121. * Class used to provide DDS decompression tools
  116122. */
  116123. export class DDSTools {
  116124. /**
  116125. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  116126. */
  116127. static StoreLODInAlphaChannel: boolean;
  116128. /**
  116129. * Gets DDS information from an array buffer
  116130. * @param arrayBuffer defines the array buffer to read data from
  116131. * @returns the DDS information
  116132. */
  116133. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  116134. private static _FloatView;
  116135. private static _Int32View;
  116136. private static _ToHalfFloat;
  116137. private static _FromHalfFloat;
  116138. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  116139. private static _GetHalfFloatRGBAArrayBuffer;
  116140. private static _GetFloatRGBAArrayBuffer;
  116141. private static _GetFloatAsUIntRGBAArrayBuffer;
  116142. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  116143. private static _GetRGBAArrayBuffer;
  116144. private static _ExtractLongWordOrder;
  116145. private static _GetRGBArrayBuffer;
  116146. private static _GetLuminanceArrayBuffer;
  116147. /**
  116148. * Uploads DDS Levels to a Babylon Texture
  116149. * @hidden
  116150. */
  116151. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  116152. }
  116153. interface ThinEngine {
  116154. /**
  116155. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  116156. * @param rootUrl defines the url where the file to load is located
  116157. * @param scene defines the current scene
  116158. * @param lodScale defines scale to apply to the mip map selection
  116159. * @param lodOffset defines offset to apply to the mip map selection
  116160. * @param onLoad defines an optional callback raised when the texture is loaded
  116161. * @param onError defines an optional callback raised if there is an issue to load the texture
  116162. * @param format defines the format of the data
  116163. * @param forcedExtension defines the extension to use to pick the right loader
  116164. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  116165. * @returns the cube texture as an InternalTexture
  116166. */
  116167. 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;
  116168. }
  116169. }
  116170. declare module BABYLON {
  116171. /**
  116172. * Implementation of the DDS Texture Loader.
  116173. * @hidden
  116174. */
  116175. export class _DDSTextureLoader implements IInternalTextureLoader {
  116176. /**
  116177. * Defines wether the loader supports cascade loading the different faces.
  116178. */
  116179. readonly supportCascades: boolean;
  116180. /**
  116181. * This returns if the loader support the current file information.
  116182. * @param extension defines the file extension of the file being loaded
  116183. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116184. * @param fallback defines the fallback internal texture if any
  116185. * @param isBase64 defines whether the texture is encoded as a base64
  116186. * @param isBuffer defines whether the texture data are stored as a buffer
  116187. * @returns true if the loader can load the specified file
  116188. */
  116189. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116190. /**
  116191. * Transform the url before loading if required.
  116192. * @param rootUrl the url of the texture
  116193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116194. * @returns the transformed texture
  116195. */
  116196. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116197. /**
  116198. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116199. * @param rootUrl the url of the texture
  116200. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116201. * @returns the fallback texture
  116202. */
  116203. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116204. /**
  116205. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116206. * @param data contains the texture data
  116207. * @param texture defines the BabylonJS internal texture
  116208. * @param createPolynomials will be true if polynomials have been requested
  116209. * @param onLoad defines the callback to trigger once the texture is ready
  116210. * @param onError defines the callback to trigger in case of error
  116211. */
  116212. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116213. /**
  116214. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116215. * @param data contains the texture data
  116216. * @param texture defines the BabylonJS internal texture
  116217. * @param callback defines the method to call once ready to upload
  116218. */
  116219. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116220. }
  116221. }
  116222. declare module BABYLON {
  116223. /**
  116224. * Implementation of the ENV Texture Loader.
  116225. * @hidden
  116226. */
  116227. export class _ENVTextureLoader implements IInternalTextureLoader {
  116228. /**
  116229. * Defines wether the loader supports cascade loading the different faces.
  116230. */
  116231. readonly supportCascades: boolean;
  116232. /**
  116233. * This returns if the loader support the current file information.
  116234. * @param extension defines the file extension of the file being loaded
  116235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116236. * @param fallback defines the fallback internal texture if any
  116237. * @param isBase64 defines whether the texture is encoded as a base64
  116238. * @param isBuffer defines whether the texture data are stored as a buffer
  116239. * @returns true if the loader can load the specified file
  116240. */
  116241. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116242. /**
  116243. * Transform the url before loading if required.
  116244. * @param rootUrl the url of the texture
  116245. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116246. * @returns the transformed texture
  116247. */
  116248. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116249. /**
  116250. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116251. * @param rootUrl the url of the texture
  116252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116253. * @returns the fallback texture
  116254. */
  116255. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116256. /**
  116257. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116258. * @param data contains the texture data
  116259. * @param texture defines the BabylonJS internal texture
  116260. * @param createPolynomials will be true if polynomials have been requested
  116261. * @param onLoad defines the callback to trigger once the texture is ready
  116262. * @param onError defines the callback to trigger in case of error
  116263. */
  116264. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116265. /**
  116266. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116267. * @param data contains the texture data
  116268. * @param texture defines the BabylonJS internal texture
  116269. * @param callback defines the method to call once ready to upload
  116270. */
  116271. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116272. }
  116273. }
  116274. declare module BABYLON {
  116275. /**
  116276. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  116277. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  116278. */
  116279. export class KhronosTextureContainer {
  116280. /** contents of the KTX container file */
  116281. arrayBuffer: any;
  116282. private static HEADER_LEN;
  116283. private static COMPRESSED_2D;
  116284. private static COMPRESSED_3D;
  116285. private static TEX_2D;
  116286. private static TEX_3D;
  116287. /**
  116288. * Gets the openGL type
  116289. */
  116290. glType: number;
  116291. /**
  116292. * Gets the openGL type size
  116293. */
  116294. glTypeSize: number;
  116295. /**
  116296. * Gets the openGL format
  116297. */
  116298. glFormat: number;
  116299. /**
  116300. * Gets the openGL internal format
  116301. */
  116302. glInternalFormat: number;
  116303. /**
  116304. * Gets the base internal format
  116305. */
  116306. glBaseInternalFormat: number;
  116307. /**
  116308. * Gets image width in pixel
  116309. */
  116310. pixelWidth: number;
  116311. /**
  116312. * Gets image height in pixel
  116313. */
  116314. pixelHeight: number;
  116315. /**
  116316. * Gets image depth in pixels
  116317. */
  116318. pixelDepth: number;
  116319. /**
  116320. * Gets the number of array elements
  116321. */
  116322. numberOfArrayElements: number;
  116323. /**
  116324. * Gets the number of faces
  116325. */
  116326. numberOfFaces: number;
  116327. /**
  116328. * Gets the number of mipmap levels
  116329. */
  116330. numberOfMipmapLevels: number;
  116331. /**
  116332. * Gets the bytes of key value data
  116333. */
  116334. bytesOfKeyValueData: number;
  116335. /**
  116336. * Gets the load type
  116337. */
  116338. loadType: number;
  116339. /**
  116340. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  116341. */
  116342. isInvalid: boolean;
  116343. /**
  116344. * Creates a new KhronosTextureContainer
  116345. * @param arrayBuffer contents of the KTX container file
  116346. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  116347. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  116348. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  116349. */
  116350. constructor(
  116351. /** contents of the KTX container file */
  116352. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  116353. /**
  116354. * Uploads KTX content to a Babylon Texture.
  116355. * It is assumed that the texture has already been created & is currently bound
  116356. * @hidden
  116357. */
  116358. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  116359. private _upload2DCompressedLevels;
  116360. }
  116361. }
  116362. declare module BABYLON {
  116363. /**
  116364. * Implementation of the KTX Texture Loader.
  116365. * @hidden
  116366. */
  116367. export class _KTXTextureLoader implements IInternalTextureLoader {
  116368. /**
  116369. * Defines wether the loader supports cascade loading the different faces.
  116370. */
  116371. readonly supportCascades: boolean;
  116372. /**
  116373. * This returns if the loader support the current file information.
  116374. * @param extension defines the file extension of the file being loaded
  116375. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116376. * @param fallback defines the fallback internal texture if any
  116377. * @param isBase64 defines whether the texture is encoded as a base64
  116378. * @param isBuffer defines whether the texture data are stored as a buffer
  116379. * @returns true if the loader can load the specified file
  116380. */
  116381. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116382. /**
  116383. * Transform the url before loading if required.
  116384. * @param rootUrl the url of the texture
  116385. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116386. * @returns the transformed texture
  116387. */
  116388. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116389. /**
  116390. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116391. * @param rootUrl the url of the texture
  116392. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116393. * @returns the fallback texture
  116394. */
  116395. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116396. /**
  116397. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116398. * @param data contains the texture data
  116399. * @param texture defines the BabylonJS internal texture
  116400. * @param createPolynomials will be true if polynomials have been requested
  116401. * @param onLoad defines the callback to trigger once the texture is ready
  116402. * @param onError defines the callback to trigger in case of error
  116403. */
  116404. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116405. /**
  116406. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116407. * @param data contains the texture data
  116408. * @param texture defines the BabylonJS internal texture
  116409. * @param callback defines the method to call once ready to upload
  116410. */
  116411. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  116412. }
  116413. }
  116414. declare module BABYLON {
  116415. /**
  116416. * Options for the default xr helper
  116417. */
  116418. export class WebXRDefaultExperienceOptions {
  116419. /**
  116420. * Floor meshes that should be used for teleporting
  116421. */
  116422. floorMeshes: Array<AbstractMesh>;
  116423. }
  116424. /**
  116425. * Default experience which provides a similar setup to the previous webVRExperience
  116426. */
  116427. export class WebXRDefaultExperience {
  116428. /**
  116429. * Base experience
  116430. */
  116431. baseExperience: WebXRExperienceHelper;
  116432. /**
  116433. * Input experience extension
  116434. */
  116435. input: WebXRInput;
  116436. /**
  116437. * Loads the controller models
  116438. */
  116439. controllerModelLoader: WebXRControllerModelLoader;
  116440. /**
  116441. * Enables laser pointer and selection
  116442. */
  116443. pointerSelection: WebXRControllerPointerSelection;
  116444. /**
  116445. * Enables teleportation
  116446. */
  116447. teleportation: WebXRControllerTeleportation;
  116448. /**
  116449. * Enables ui for enetering/exiting xr
  116450. */
  116451. enterExitUI: WebXREnterExitUI;
  116452. /**
  116453. * Default output canvas xr should render to
  116454. */
  116455. outputCanvas: WebXRManagedOutputCanvas;
  116456. /**
  116457. * Creates the default xr experience
  116458. * @param scene scene
  116459. * @param options options for basic configuration
  116460. * @returns resulting WebXRDefaultExperience
  116461. */
  116462. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116463. private constructor();
  116464. /**
  116465. * DIsposes of the experience helper
  116466. */
  116467. dispose(): void;
  116468. }
  116469. }
  116470. declare module BABYLON {
  116471. /** @hidden */
  116472. export var _forceSceneHelpersToBundle: boolean;
  116473. interface Scene {
  116474. /**
  116475. * Creates a default light for the scene.
  116476. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  116477. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  116478. */
  116479. createDefaultLight(replace?: boolean): void;
  116480. /**
  116481. * Creates a default camera for the scene.
  116482. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  116483. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116484. * @param replace has default false, when true replaces the active camera in the scene
  116485. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  116486. */
  116487. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116488. /**
  116489. * Creates a default camera and a default light.
  116490. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  116491. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116492. * @param replace has the default false, when true replaces the active camera/light in the scene
  116493. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  116494. */
  116495. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116496. /**
  116497. * Creates a new sky box
  116498. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  116499. * @param environmentTexture defines the texture to use as environment texture
  116500. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  116501. * @param scale defines the overall scale of the skybox
  116502. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  116503. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  116504. * @returns a new mesh holding the sky box
  116505. */
  116506. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  116507. /**
  116508. * Creates a new environment
  116509. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  116510. * @param options defines the options you can use to configure the environment
  116511. * @returns the new EnvironmentHelper
  116512. */
  116513. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  116514. /**
  116515. * Creates a new VREXperienceHelper
  116516. * @see http://doc.babylonjs.com/how_to/webvr_helper
  116517. * @param webVROptions defines the options used to create the new VREXperienceHelper
  116518. * @returns a new VREXperienceHelper
  116519. */
  116520. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  116521. /**
  116522. * Creates a new WebXRDefaultExperience
  116523. * @see http://doc.babylonjs.com/how_to/webxr
  116524. * @param options experience options
  116525. * @returns a promise for a new WebXRDefaultExperience
  116526. */
  116527. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116528. }
  116529. }
  116530. declare module BABYLON {
  116531. /**
  116532. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  116533. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  116534. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  116535. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116536. */
  116537. export class VideoDome extends TransformNode {
  116538. /**
  116539. * Define the video source as a Monoscopic panoramic 360 video.
  116540. */
  116541. static readonly MODE_MONOSCOPIC: number;
  116542. /**
  116543. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116544. */
  116545. static readonly MODE_TOPBOTTOM: number;
  116546. /**
  116547. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116548. */
  116549. static readonly MODE_SIDEBYSIDE: number;
  116550. private _halfDome;
  116551. private _useDirectMapping;
  116552. /**
  116553. * The video texture being displayed on the sphere
  116554. */
  116555. protected _videoTexture: VideoTexture;
  116556. /**
  116557. * Gets the video texture being displayed on the sphere
  116558. */
  116559. readonly videoTexture: VideoTexture;
  116560. /**
  116561. * The skybox material
  116562. */
  116563. protected _material: BackgroundMaterial;
  116564. /**
  116565. * The surface used for the skybox
  116566. */
  116567. protected _mesh: Mesh;
  116568. /**
  116569. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  116570. */
  116571. private _halfDomeMask;
  116572. /**
  116573. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116574. * Also see the options.resolution property.
  116575. */
  116576. fovMultiplier: number;
  116577. private _videoMode;
  116578. /**
  116579. * Gets or set the current video mode for the video. It can be:
  116580. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  116581. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116582. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116583. */
  116584. videoMode: number;
  116585. /**
  116586. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  116587. *
  116588. */
  116589. /**
  116590. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  116591. */
  116592. halfDome: boolean;
  116593. /**
  116594. * Oberserver used in Stereoscopic VR Mode.
  116595. */
  116596. private _onBeforeCameraRenderObserver;
  116597. /**
  116598. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  116599. * @param name Element's name, child elements will append suffixes for their own names.
  116600. * @param urlsOrVideo defines the url(s) or the video element to use
  116601. * @param options An object containing optional or exposed sub element properties
  116602. */
  116603. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  116604. resolution?: number;
  116605. clickToPlay?: boolean;
  116606. autoPlay?: boolean;
  116607. loop?: boolean;
  116608. size?: number;
  116609. poster?: string;
  116610. faceForward?: boolean;
  116611. useDirectMapping?: boolean;
  116612. halfDomeMode?: boolean;
  116613. }, scene: Scene);
  116614. private _changeVideoMode;
  116615. /**
  116616. * Releases resources associated with this node.
  116617. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116618. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116619. */
  116620. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116621. }
  116622. }
  116623. declare module BABYLON {
  116624. /**
  116625. * This class can be used to get instrumentation data from a Babylon engine
  116626. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116627. */
  116628. export class EngineInstrumentation implements IDisposable {
  116629. /**
  116630. * Define the instrumented engine.
  116631. */
  116632. engine: Engine;
  116633. private _captureGPUFrameTime;
  116634. private _gpuFrameTimeToken;
  116635. private _gpuFrameTime;
  116636. private _captureShaderCompilationTime;
  116637. private _shaderCompilationTime;
  116638. private _onBeginFrameObserver;
  116639. private _onEndFrameObserver;
  116640. private _onBeforeShaderCompilationObserver;
  116641. private _onAfterShaderCompilationObserver;
  116642. /**
  116643. * Gets the perf counter used for GPU frame time
  116644. */
  116645. readonly gpuFrameTimeCounter: PerfCounter;
  116646. /**
  116647. * Gets the GPU frame time capture status
  116648. */
  116649. /**
  116650. * Enable or disable the GPU frame time capture
  116651. */
  116652. captureGPUFrameTime: boolean;
  116653. /**
  116654. * Gets the perf counter used for shader compilation time
  116655. */
  116656. readonly shaderCompilationTimeCounter: PerfCounter;
  116657. /**
  116658. * Gets the shader compilation time capture status
  116659. */
  116660. /**
  116661. * Enable or disable the shader compilation time capture
  116662. */
  116663. captureShaderCompilationTime: boolean;
  116664. /**
  116665. * Instantiates a new engine instrumentation.
  116666. * This class can be used to get instrumentation data from a Babylon engine
  116667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116668. * @param engine Defines the engine to instrument
  116669. */
  116670. constructor(
  116671. /**
  116672. * Define the instrumented engine.
  116673. */
  116674. engine: Engine);
  116675. /**
  116676. * Dispose and release associated resources.
  116677. */
  116678. dispose(): void;
  116679. }
  116680. }
  116681. declare module BABYLON {
  116682. /**
  116683. * This class can be used to get instrumentation data from a Babylon engine
  116684. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116685. */
  116686. export class SceneInstrumentation implements IDisposable {
  116687. /**
  116688. * Defines the scene to instrument
  116689. */
  116690. scene: Scene;
  116691. private _captureActiveMeshesEvaluationTime;
  116692. private _activeMeshesEvaluationTime;
  116693. private _captureRenderTargetsRenderTime;
  116694. private _renderTargetsRenderTime;
  116695. private _captureFrameTime;
  116696. private _frameTime;
  116697. private _captureRenderTime;
  116698. private _renderTime;
  116699. private _captureInterFrameTime;
  116700. private _interFrameTime;
  116701. private _captureParticlesRenderTime;
  116702. private _particlesRenderTime;
  116703. private _captureSpritesRenderTime;
  116704. private _spritesRenderTime;
  116705. private _capturePhysicsTime;
  116706. private _physicsTime;
  116707. private _captureAnimationsTime;
  116708. private _animationsTime;
  116709. private _captureCameraRenderTime;
  116710. private _cameraRenderTime;
  116711. private _onBeforeActiveMeshesEvaluationObserver;
  116712. private _onAfterActiveMeshesEvaluationObserver;
  116713. private _onBeforeRenderTargetsRenderObserver;
  116714. private _onAfterRenderTargetsRenderObserver;
  116715. private _onAfterRenderObserver;
  116716. private _onBeforeDrawPhaseObserver;
  116717. private _onAfterDrawPhaseObserver;
  116718. private _onBeforeAnimationsObserver;
  116719. private _onBeforeParticlesRenderingObserver;
  116720. private _onAfterParticlesRenderingObserver;
  116721. private _onBeforeSpritesRenderingObserver;
  116722. private _onAfterSpritesRenderingObserver;
  116723. private _onBeforePhysicsObserver;
  116724. private _onAfterPhysicsObserver;
  116725. private _onAfterAnimationsObserver;
  116726. private _onBeforeCameraRenderObserver;
  116727. private _onAfterCameraRenderObserver;
  116728. /**
  116729. * Gets the perf counter used for active meshes evaluation time
  116730. */
  116731. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  116732. /**
  116733. * Gets the active meshes evaluation time capture status
  116734. */
  116735. /**
  116736. * Enable or disable the active meshes evaluation time capture
  116737. */
  116738. captureActiveMeshesEvaluationTime: boolean;
  116739. /**
  116740. * Gets the perf counter used for render targets render time
  116741. */
  116742. readonly renderTargetsRenderTimeCounter: PerfCounter;
  116743. /**
  116744. * Gets the render targets render time capture status
  116745. */
  116746. /**
  116747. * Enable or disable the render targets render time capture
  116748. */
  116749. captureRenderTargetsRenderTime: boolean;
  116750. /**
  116751. * Gets the perf counter used for particles render time
  116752. */
  116753. readonly particlesRenderTimeCounter: PerfCounter;
  116754. /**
  116755. * Gets the particles render time capture status
  116756. */
  116757. /**
  116758. * Enable or disable the particles render time capture
  116759. */
  116760. captureParticlesRenderTime: boolean;
  116761. /**
  116762. * Gets the perf counter used for sprites render time
  116763. */
  116764. readonly spritesRenderTimeCounter: PerfCounter;
  116765. /**
  116766. * Gets the sprites render time capture status
  116767. */
  116768. /**
  116769. * Enable or disable the sprites render time capture
  116770. */
  116771. captureSpritesRenderTime: boolean;
  116772. /**
  116773. * Gets the perf counter used for physics time
  116774. */
  116775. readonly physicsTimeCounter: PerfCounter;
  116776. /**
  116777. * Gets the physics time capture status
  116778. */
  116779. /**
  116780. * Enable or disable the physics time capture
  116781. */
  116782. capturePhysicsTime: boolean;
  116783. /**
  116784. * Gets the perf counter used for animations time
  116785. */
  116786. readonly animationsTimeCounter: PerfCounter;
  116787. /**
  116788. * Gets the animations time capture status
  116789. */
  116790. /**
  116791. * Enable or disable the animations time capture
  116792. */
  116793. captureAnimationsTime: boolean;
  116794. /**
  116795. * Gets the perf counter used for frame time capture
  116796. */
  116797. readonly frameTimeCounter: PerfCounter;
  116798. /**
  116799. * Gets the frame time capture status
  116800. */
  116801. /**
  116802. * Enable or disable the frame time capture
  116803. */
  116804. captureFrameTime: boolean;
  116805. /**
  116806. * Gets the perf counter used for inter-frames time capture
  116807. */
  116808. readonly interFrameTimeCounter: PerfCounter;
  116809. /**
  116810. * Gets the inter-frames time capture status
  116811. */
  116812. /**
  116813. * Enable or disable the inter-frames time capture
  116814. */
  116815. captureInterFrameTime: boolean;
  116816. /**
  116817. * Gets the perf counter used for render time capture
  116818. */
  116819. readonly renderTimeCounter: PerfCounter;
  116820. /**
  116821. * Gets the render time capture status
  116822. */
  116823. /**
  116824. * Enable or disable the render time capture
  116825. */
  116826. captureRenderTime: boolean;
  116827. /**
  116828. * Gets the perf counter used for camera render time capture
  116829. */
  116830. readonly cameraRenderTimeCounter: PerfCounter;
  116831. /**
  116832. * Gets the camera render time capture status
  116833. */
  116834. /**
  116835. * Enable or disable the camera render time capture
  116836. */
  116837. captureCameraRenderTime: boolean;
  116838. /**
  116839. * Gets the perf counter used for draw calls
  116840. */
  116841. readonly drawCallsCounter: PerfCounter;
  116842. /**
  116843. * Instantiates a new scene instrumentation.
  116844. * This class can be used to get instrumentation data from a Babylon engine
  116845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116846. * @param scene Defines the scene to instrument
  116847. */
  116848. constructor(
  116849. /**
  116850. * Defines the scene to instrument
  116851. */
  116852. scene: Scene);
  116853. /**
  116854. * Dispose and release associated resources.
  116855. */
  116856. dispose(): void;
  116857. }
  116858. }
  116859. declare module BABYLON {
  116860. /** @hidden */
  116861. export var glowMapGenerationPixelShader: {
  116862. name: string;
  116863. shader: string;
  116864. };
  116865. }
  116866. declare module BABYLON {
  116867. /** @hidden */
  116868. export var glowMapGenerationVertexShader: {
  116869. name: string;
  116870. shader: string;
  116871. };
  116872. }
  116873. declare module BABYLON {
  116874. /**
  116875. * Effect layer options. This helps customizing the behaviour
  116876. * of the effect layer.
  116877. */
  116878. export interface IEffectLayerOptions {
  116879. /**
  116880. * Multiplication factor apply to the canvas size to compute the render target size
  116881. * used to generated the objects (the smaller the faster).
  116882. */
  116883. mainTextureRatio: number;
  116884. /**
  116885. * Enforces a fixed size texture to ensure effect stability across devices.
  116886. */
  116887. mainTextureFixedSize?: number;
  116888. /**
  116889. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116890. */
  116891. alphaBlendingMode: number;
  116892. /**
  116893. * The camera attached to the layer.
  116894. */
  116895. camera: Nullable<Camera>;
  116896. /**
  116897. * The rendering group to draw the layer in.
  116898. */
  116899. renderingGroupId: number;
  116900. }
  116901. /**
  116902. * The effect layer Helps adding post process effect blended with the main pass.
  116903. *
  116904. * This can be for instance use to generate glow or higlight effects on the scene.
  116905. *
  116906. * The effect layer class can not be used directly and is intented to inherited from to be
  116907. * customized per effects.
  116908. */
  116909. export abstract class EffectLayer {
  116910. private _vertexBuffers;
  116911. private _indexBuffer;
  116912. private _cachedDefines;
  116913. private _effectLayerMapGenerationEffect;
  116914. private _effectLayerOptions;
  116915. private _mergeEffect;
  116916. protected _scene: Scene;
  116917. protected _engine: Engine;
  116918. protected _maxSize: number;
  116919. protected _mainTextureDesiredSize: ISize;
  116920. protected _mainTexture: RenderTargetTexture;
  116921. protected _shouldRender: boolean;
  116922. protected _postProcesses: PostProcess[];
  116923. protected _textures: BaseTexture[];
  116924. protected _emissiveTextureAndColor: {
  116925. texture: Nullable<BaseTexture>;
  116926. color: Color4;
  116927. };
  116928. /**
  116929. * The name of the layer
  116930. */
  116931. name: string;
  116932. /**
  116933. * The clear color of the texture used to generate the glow map.
  116934. */
  116935. neutralColor: Color4;
  116936. /**
  116937. * Specifies wether the highlight layer is enabled or not.
  116938. */
  116939. isEnabled: boolean;
  116940. /**
  116941. * Gets the camera attached to the layer.
  116942. */
  116943. readonly camera: Nullable<Camera>;
  116944. /**
  116945. * Gets the rendering group id the layer should render in.
  116946. */
  116947. renderingGroupId: number;
  116948. /**
  116949. * An event triggered when the effect layer has been disposed.
  116950. */
  116951. onDisposeObservable: Observable<EffectLayer>;
  116952. /**
  116953. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116954. */
  116955. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116956. /**
  116957. * An event triggered when the generated texture is being merged in the scene.
  116958. */
  116959. onBeforeComposeObservable: Observable<EffectLayer>;
  116960. /**
  116961. * An event triggered when the generated texture has been merged in the scene.
  116962. */
  116963. onAfterComposeObservable: Observable<EffectLayer>;
  116964. /**
  116965. * An event triggered when the efffect layer changes its size.
  116966. */
  116967. onSizeChangedObservable: Observable<EffectLayer>;
  116968. /** @hidden */
  116969. static _SceneComponentInitialization: (scene: Scene) => void;
  116970. /**
  116971. * Instantiates a new effect Layer and references it in the scene.
  116972. * @param name The name of the layer
  116973. * @param scene The scene to use the layer in
  116974. */
  116975. constructor(
  116976. /** The Friendly of the effect in the scene */
  116977. name: string, scene: Scene);
  116978. /**
  116979. * Get the effect name of the layer.
  116980. * @return The effect name
  116981. */
  116982. abstract getEffectName(): string;
  116983. /**
  116984. * Checks for the readiness of the element composing the layer.
  116985. * @param subMesh the mesh to check for
  116986. * @param useInstances specify wether or not to use instances to render the mesh
  116987. * @return true if ready otherwise, false
  116988. */
  116989. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116990. /**
  116991. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116992. * @returns true if the effect requires stencil during the main canvas render pass.
  116993. */
  116994. abstract needStencil(): boolean;
  116995. /**
  116996. * Create the merge effect. This is the shader use to blit the information back
  116997. * to the main canvas at the end of the scene rendering.
  116998. * @returns The effect containing the shader used to merge the effect on the main canvas
  116999. */
  117000. protected abstract _createMergeEffect(): Effect;
  117001. /**
  117002. * Creates the render target textures and post processes used in the effect layer.
  117003. */
  117004. protected abstract _createTextureAndPostProcesses(): void;
  117005. /**
  117006. * Implementation specific of rendering the generating effect on the main canvas.
  117007. * @param effect The effect used to render through
  117008. */
  117009. protected abstract _internalRender(effect: Effect): void;
  117010. /**
  117011. * Sets the required values for both the emissive texture and and the main color.
  117012. */
  117013. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117014. /**
  117015. * Free any resources and references associated to a mesh.
  117016. * Internal use
  117017. * @param mesh The mesh to free.
  117018. */
  117019. abstract _disposeMesh(mesh: Mesh): void;
  117020. /**
  117021. * Serializes this layer (Glow or Highlight for example)
  117022. * @returns a serialized layer object
  117023. */
  117024. abstract serialize?(): any;
  117025. /**
  117026. * Initializes the effect layer with the required options.
  117027. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  117028. */
  117029. protected _init(options: Partial<IEffectLayerOptions>): void;
  117030. /**
  117031. * Generates the index buffer of the full screen quad blending to the main canvas.
  117032. */
  117033. private _generateIndexBuffer;
  117034. /**
  117035. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  117036. */
  117037. private _generateVertexBuffer;
  117038. /**
  117039. * Sets the main texture desired size which is the closest power of two
  117040. * of the engine canvas size.
  117041. */
  117042. private _setMainTextureSize;
  117043. /**
  117044. * Creates the main texture for the effect layer.
  117045. */
  117046. protected _createMainTexture(): void;
  117047. /**
  117048. * Adds specific effects defines.
  117049. * @param defines The defines to add specifics to.
  117050. */
  117051. protected _addCustomEffectDefines(defines: string[]): void;
  117052. /**
  117053. * Checks for the readiness of the element composing the layer.
  117054. * @param subMesh the mesh to check for
  117055. * @param useInstances specify wether or not to use instances to render the mesh
  117056. * @param emissiveTexture the associated emissive texture used to generate the glow
  117057. * @return true if ready otherwise, false
  117058. */
  117059. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  117060. /**
  117061. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  117062. */
  117063. render(): void;
  117064. /**
  117065. * Determine if a given mesh will be used in the current effect.
  117066. * @param mesh mesh to test
  117067. * @returns true if the mesh will be used
  117068. */
  117069. hasMesh(mesh: AbstractMesh): boolean;
  117070. /**
  117071. * Returns true if the layer contains information to display, otherwise false.
  117072. * @returns true if the glow layer should be rendered
  117073. */
  117074. shouldRender(): boolean;
  117075. /**
  117076. * Returns true if the mesh should render, otherwise false.
  117077. * @param mesh The mesh to render
  117078. * @returns true if it should render otherwise false
  117079. */
  117080. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  117081. /**
  117082. * Returns true if the mesh can be rendered, otherwise false.
  117083. * @param mesh The mesh to render
  117084. * @param material The material used on the mesh
  117085. * @returns true if it can be rendered otherwise false
  117086. */
  117087. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117088. /**
  117089. * Returns true if the mesh should render, otherwise false.
  117090. * @param mesh The mesh to render
  117091. * @returns true if it should render otherwise false
  117092. */
  117093. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  117094. /**
  117095. * Renders the submesh passed in parameter to the generation map.
  117096. */
  117097. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  117098. /**
  117099. * Rebuild the required buffers.
  117100. * @hidden Internal use only.
  117101. */
  117102. _rebuild(): void;
  117103. /**
  117104. * Dispose only the render target textures and post process.
  117105. */
  117106. private _disposeTextureAndPostProcesses;
  117107. /**
  117108. * Dispose the highlight layer and free resources.
  117109. */
  117110. dispose(): void;
  117111. /**
  117112. * Gets the class name of the effect layer
  117113. * @returns the string with the class name of the effect layer
  117114. */
  117115. getClassName(): string;
  117116. /**
  117117. * Creates an effect layer from parsed effect layer data
  117118. * @param parsedEffectLayer defines effect layer data
  117119. * @param scene defines the current scene
  117120. * @param rootUrl defines the root URL containing the effect layer information
  117121. * @returns a parsed effect Layer
  117122. */
  117123. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  117124. }
  117125. }
  117126. declare module BABYLON {
  117127. interface AbstractScene {
  117128. /**
  117129. * The list of effect layers (highlights/glow) added to the scene
  117130. * @see http://doc.babylonjs.com/how_to/highlight_layer
  117131. * @see http://doc.babylonjs.com/how_to/glow_layer
  117132. */
  117133. effectLayers: Array<EffectLayer>;
  117134. /**
  117135. * Removes the given effect layer from this scene.
  117136. * @param toRemove defines the effect layer to remove
  117137. * @returns the index of the removed effect layer
  117138. */
  117139. removeEffectLayer(toRemove: EffectLayer): number;
  117140. /**
  117141. * Adds the given effect layer to this scene
  117142. * @param newEffectLayer defines the effect layer to add
  117143. */
  117144. addEffectLayer(newEffectLayer: EffectLayer): void;
  117145. }
  117146. /**
  117147. * Defines the layer scene component responsible to manage any effect layers
  117148. * in a given scene.
  117149. */
  117150. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  117151. /**
  117152. * The component name helpfull to identify the component in the list of scene components.
  117153. */
  117154. readonly name: string;
  117155. /**
  117156. * The scene the component belongs to.
  117157. */
  117158. scene: Scene;
  117159. private _engine;
  117160. private _renderEffects;
  117161. private _needStencil;
  117162. private _previousStencilState;
  117163. /**
  117164. * Creates a new instance of the component for the given scene
  117165. * @param scene Defines the scene to register the component in
  117166. */
  117167. constructor(scene: Scene);
  117168. /**
  117169. * Registers the component in a given scene
  117170. */
  117171. register(): void;
  117172. /**
  117173. * Rebuilds the elements related to this component in case of
  117174. * context lost for instance.
  117175. */
  117176. rebuild(): void;
  117177. /**
  117178. * Serializes the component data to the specified json object
  117179. * @param serializationObject The object to serialize to
  117180. */
  117181. serialize(serializationObject: any): void;
  117182. /**
  117183. * Adds all the elements from the container to the scene
  117184. * @param container the container holding the elements
  117185. */
  117186. addFromContainer(container: AbstractScene): void;
  117187. /**
  117188. * Removes all the elements in the container from the scene
  117189. * @param container contains the elements to remove
  117190. * @param dispose if the removed element should be disposed (default: false)
  117191. */
  117192. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117193. /**
  117194. * Disposes the component and the associated ressources.
  117195. */
  117196. dispose(): void;
  117197. private _isReadyForMesh;
  117198. private _renderMainTexture;
  117199. private _setStencil;
  117200. private _setStencilBack;
  117201. private _draw;
  117202. private _drawCamera;
  117203. private _drawRenderingGroup;
  117204. }
  117205. }
  117206. declare module BABYLON {
  117207. /** @hidden */
  117208. export var glowMapMergePixelShader: {
  117209. name: string;
  117210. shader: string;
  117211. };
  117212. }
  117213. declare module BABYLON {
  117214. /** @hidden */
  117215. export var glowMapMergeVertexShader: {
  117216. name: string;
  117217. shader: string;
  117218. };
  117219. }
  117220. declare module BABYLON {
  117221. interface AbstractScene {
  117222. /**
  117223. * Return a the first highlight layer of the scene with a given name.
  117224. * @param name The name of the highlight layer to look for.
  117225. * @return The highlight layer if found otherwise null.
  117226. */
  117227. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  117228. }
  117229. /**
  117230. * Glow layer options. This helps customizing the behaviour
  117231. * of the glow layer.
  117232. */
  117233. export interface IGlowLayerOptions {
  117234. /**
  117235. * Multiplication factor apply to the canvas size to compute the render target size
  117236. * used to generated the glowing objects (the smaller the faster).
  117237. */
  117238. mainTextureRatio: number;
  117239. /**
  117240. * Enforces a fixed size texture to ensure resize independant blur.
  117241. */
  117242. mainTextureFixedSize?: number;
  117243. /**
  117244. * How big is the kernel of the blur texture.
  117245. */
  117246. blurKernelSize: number;
  117247. /**
  117248. * The camera attached to the layer.
  117249. */
  117250. camera: Nullable<Camera>;
  117251. /**
  117252. * Enable MSAA by chosing the number of samples.
  117253. */
  117254. mainTextureSamples?: number;
  117255. /**
  117256. * The rendering group to draw the layer in.
  117257. */
  117258. renderingGroupId: number;
  117259. }
  117260. /**
  117261. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  117262. *
  117263. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  117264. * glowy meshes to your scene.
  117265. *
  117266. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  117267. */
  117268. export class GlowLayer extends EffectLayer {
  117269. /**
  117270. * Effect Name of the layer.
  117271. */
  117272. static readonly EffectName: string;
  117273. /**
  117274. * The default blur kernel size used for the glow.
  117275. */
  117276. static DefaultBlurKernelSize: number;
  117277. /**
  117278. * The default texture size ratio used for the glow.
  117279. */
  117280. static DefaultTextureRatio: number;
  117281. /**
  117282. * Sets the kernel size of the blur.
  117283. */
  117284. /**
  117285. * Gets the kernel size of the blur.
  117286. */
  117287. blurKernelSize: number;
  117288. /**
  117289. * Sets the glow intensity.
  117290. */
  117291. /**
  117292. * Gets the glow intensity.
  117293. */
  117294. intensity: number;
  117295. private _options;
  117296. private _intensity;
  117297. private _horizontalBlurPostprocess1;
  117298. private _verticalBlurPostprocess1;
  117299. private _horizontalBlurPostprocess2;
  117300. private _verticalBlurPostprocess2;
  117301. private _blurTexture1;
  117302. private _blurTexture2;
  117303. private _postProcesses1;
  117304. private _postProcesses2;
  117305. private _includedOnlyMeshes;
  117306. private _excludedMeshes;
  117307. /**
  117308. * Callback used to let the user override the color selection on a per mesh basis
  117309. */
  117310. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  117311. /**
  117312. * Callback used to let the user override the texture selection on a per mesh basis
  117313. */
  117314. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  117315. /**
  117316. * Instantiates a new glow Layer and references it to the scene.
  117317. * @param name The name of the layer
  117318. * @param scene The scene to use the layer in
  117319. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  117320. */
  117321. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  117322. /**
  117323. * Get the effect name of the layer.
  117324. * @return The effect name
  117325. */
  117326. getEffectName(): string;
  117327. /**
  117328. * Create the merge effect. This is the shader use to blit the information back
  117329. * to the main canvas at the end of the scene rendering.
  117330. */
  117331. protected _createMergeEffect(): Effect;
  117332. /**
  117333. * Creates the render target textures and post processes used in the glow layer.
  117334. */
  117335. protected _createTextureAndPostProcesses(): void;
  117336. /**
  117337. * Checks for the readiness of the element composing the layer.
  117338. * @param subMesh the mesh to check for
  117339. * @param useInstances specify wether or not to use instances to render the mesh
  117340. * @param emissiveTexture the associated emissive texture used to generate the glow
  117341. * @return true if ready otherwise, false
  117342. */
  117343. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117344. /**
  117345. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117346. */
  117347. needStencil(): boolean;
  117348. /**
  117349. * Returns true if the mesh can be rendered, otherwise false.
  117350. * @param mesh The mesh to render
  117351. * @param material The material used on the mesh
  117352. * @returns true if it can be rendered otherwise false
  117353. */
  117354. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117355. /**
  117356. * Implementation specific of rendering the generating effect on the main canvas.
  117357. * @param effect The effect used to render through
  117358. */
  117359. protected _internalRender(effect: Effect): void;
  117360. /**
  117361. * Sets the required values for both the emissive texture and and the main color.
  117362. */
  117363. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117364. /**
  117365. * Returns true if the mesh should render, otherwise false.
  117366. * @param mesh The mesh to render
  117367. * @returns true if it should render otherwise false
  117368. */
  117369. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117370. /**
  117371. * Adds specific effects defines.
  117372. * @param defines The defines to add specifics to.
  117373. */
  117374. protected _addCustomEffectDefines(defines: string[]): void;
  117375. /**
  117376. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  117377. * @param mesh The mesh to exclude from the glow layer
  117378. */
  117379. addExcludedMesh(mesh: Mesh): void;
  117380. /**
  117381. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  117382. * @param mesh The mesh to remove
  117383. */
  117384. removeExcludedMesh(mesh: Mesh): void;
  117385. /**
  117386. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  117387. * @param mesh The mesh to include in the glow layer
  117388. */
  117389. addIncludedOnlyMesh(mesh: Mesh): void;
  117390. /**
  117391. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  117392. * @param mesh The mesh to remove
  117393. */
  117394. removeIncludedOnlyMesh(mesh: Mesh): void;
  117395. /**
  117396. * Determine if a given mesh will be used in the glow layer
  117397. * @param mesh The mesh to test
  117398. * @returns true if the mesh will be highlighted by the current glow layer
  117399. */
  117400. hasMesh(mesh: AbstractMesh): boolean;
  117401. /**
  117402. * Free any resources and references associated to a mesh.
  117403. * Internal use
  117404. * @param mesh The mesh to free.
  117405. * @hidden
  117406. */
  117407. _disposeMesh(mesh: Mesh): void;
  117408. /**
  117409. * Gets the class name of the effect layer
  117410. * @returns the string with the class name of the effect layer
  117411. */
  117412. getClassName(): string;
  117413. /**
  117414. * Serializes this glow layer
  117415. * @returns a serialized glow layer object
  117416. */
  117417. serialize(): any;
  117418. /**
  117419. * Creates a Glow Layer from parsed glow layer data
  117420. * @param parsedGlowLayer defines glow layer data
  117421. * @param scene defines the current scene
  117422. * @param rootUrl defines the root URL containing the glow layer information
  117423. * @returns a parsed Glow Layer
  117424. */
  117425. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  117426. }
  117427. }
  117428. declare module BABYLON {
  117429. /** @hidden */
  117430. export var glowBlurPostProcessPixelShader: {
  117431. name: string;
  117432. shader: string;
  117433. };
  117434. }
  117435. declare module BABYLON {
  117436. interface AbstractScene {
  117437. /**
  117438. * Return a the first highlight layer of the scene with a given name.
  117439. * @param name The name of the highlight layer to look for.
  117440. * @return The highlight layer if found otherwise null.
  117441. */
  117442. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  117443. }
  117444. /**
  117445. * Highlight layer options. This helps customizing the behaviour
  117446. * of the highlight layer.
  117447. */
  117448. export interface IHighlightLayerOptions {
  117449. /**
  117450. * Multiplication factor apply to the canvas size to compute the render target size
  117451. * used to generated the glowing objects (the smaller the faster).
  117452. */
  117453. mainTextureRatio: number;
  117454. /**
  117455. * Enforces a fixed size texture to ensure resize independant blur.
  117456. */
  117457. mainTextureFixedSize?: number;
  117458. /**
  117459. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  117460. * of the picture to blur (the smaller the faster).
  117461. */
  117462. blurTextureSizeRatio: number;
  117463. /**
  117464. * How big in texel of the blur texture is the vertical blur.
  117465. */
  117466. blurVerticalSize: number;
  117467. /**
  117468. * How big in texel of the blur texture is the horizontal blur.
  117469. */
  117470. blurHorizontalSize: number;
  117471. /**
  117472. * Alpha blending mode used to apply the blur. Default is combine.
  117473. */
  117474. alphaBlendingMode: number;
  117475. /**
  117476. * The camera attached to the layer.
  117477. */
  117478. camera: Nullable<Camera>;
  117479. /**
  117480. * Should we display highlight as a solid stroke?
  117481. */
  117482. isStroke?: boolean;
  117483. /**
  117484. * The rendering group to draw the layer in.
  117485. */
  117486. renderingGroupId: number;
  117487. }
  117488. /**
  117489. * The highlight layer Helps adding a glow effect around a mesh.
  117490. *
  117491. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  117492. * glowy meshes to your scene.
  117493. *
  117494. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  117495. */
  117496. export class HighlightLayer extends EffectLayer {
  117497. name: string;
  117498. /**
  117499. * Effect Name of the highlight layer.
  117500. */
  117501. static readonly EffectName: string;
  117502. /**
  117503. * The neutral color used during the preparation of the glow effect.
  117504. * This is black by default as the blend operation is a blend operation.
  117505. */
  117506. static NeutralColor: Color4;
  117507. /**
  117508. * Stencil value used for glowing meshes.
  117509. */
  117510. static GlowingMeshStencilReference: number;
  117511. /**
  117512. * Stencil value used for the other meshes in the scene.
  117513. */
  117514. static NormalMeshStencilReference: number;
  117515. /**
  117516. * Specifies whether or not the inner glow is ACTIVE in the layer.
  117517. */
  117518. innerGlow: boolean;
  117519. /**
  117520. * Specifies whether or not the outer glow is ACTIVE in the layer.
  117521. */
  117522. outerGlow: boolean;
  117523. /**
  117524. * Specifies the horizontal size of the blur.
  117525. */
  117526. /**
  117527. * Gets the horizontal size of the blur.
  117528. */
  117529. blurHorizontalSize: number;
  117530. /**
  117531. * Specifies the vertical size of the blur.
  117532. */
  117533. /**
  117534. * Gets the vertical size of the blur.
  117535. */
  117536. blurVerticalSize: number;
  117537. /**
  117538. * An event triggered when the highlight layer is being blurred.
  117539. */
  117540. onBeforeBlurObservable: Observable<HighlightLayer>;
  117541. /**
  117542. * An event triggered when the highlight layer has been blurred.
  117543. */
  117544. onAfterBlurObservable: Observable<HighlightLayer>;
  117545. private _instanceGlowingMeshStencilReference;
  117546. private _options;
  117547. private _downSamplePostprocess;
  117548. private _horizontalBlurPostprocess;
  117549. private _verticalBlurPostprocess;
  117550. private _blurTexture;
  117551. private _meshes;
  117552. private _excludedMeshes;
  117553. /**
  117554. * Instantiates a new highlight Layer and references it to the scene..
  117555. * @param name The name of the layer
  117556. * @param scene The scene to use the layer in
  117557. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  117558. */
  117559. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  117560. /**
  117561. * Get the effect name of the layer.
  117562. * @return The effect name
  117563. */
  117564. getEffectName(): string;
  117565. /**
  117566. * Create the merge effect. This is the shader use to blit the information back
  117567. * to the main canvas at the end of the scene rendering.
  117568. */
  117569. protected _createMergeEffect(): Effect;
  117570. /**
  117571. * Creates the render target textures and post processes used in the highlight layer.
  117572. */
  117573. protected _createTextureAndPostProcesses(): void;
  117574. /**
  117575. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117576. */
  117577. needStencil(): boolean;
  117578. /**
  117579. * Checks for the readiness of the element composing the layer.
  117580. * @param subMesh the mesh to check for
  117581. * @param useInstances specify wether or not to use instances to render the mesh
  117582. * @param emissiveTexture the associated emissive texture used to generate the glow
  117583. * @return true if ready otherwise, false
  117584. */
  117585. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117586. /**
  117587. * Implementation specific of rendering the generating effect on the main canvas.
  117588. * @param effect The effect used to render through
  117589. */
  117590. protected _internalRender(effect: Effect): void;
  117591. /**
  117592. * Returns true if the layer contains information to display, otherwise false.
  117593. */
  117594. shouldRender(): boolean;
  117595. /**
  117596. * Returns true if the mesh should render, otherwise false.
  117597. * @param mesh The mesh to render
  117598. * @returns true if it should render otherwise false
  117599. */
  117600. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117601. /**
  117602. * Sets the required values for both the emissive texture and and the main color.
  117603. */
  117604. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117605. /**
  117606. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  117607. * @param mesh The mesh to exclude from the highlight layer
  117608. */
  117609. addExcludedMesh(mesh: Mesh): void;
  117610. /**
  117611. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  117612. * @param mesh The mesh to highlight
  117613. */
  117614. removeExcludedMesh(mesh: Mesh): void;
  117615. /**
  117616. * Determine if a given mesh will be highlighted by the current HighlightLayer
  117617. * @param mesh mesh to test
  117618. * @returns true if the mesh will be highlighted by the current HighlightLayer
  117619. */
  117620. hasMesh(mesh: AbstractMesh): boolean;
  117621. /**
  117622. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  117623. * @param mesh The mesh to highlight
  117624. * @param color The color of the highlight
  117625. * @param glowEmissiveOnly Extract the glow from the emissive texture
  117626. */
  117627. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  117628. /**
  117629. * Remove a mesh from the highlight layer in order to make it stop glowing.
  117630. * @param mesh The mesh to highlight
  117631. */
  117632. removeMesh(mesh: Mesh): void;
  117633. /**
  117634. * Force the stencil to the normal expected value for none glowing parts
  117635. */
  117636. private _defaultStencilReference;
  117637. /**
  117638. * Free any resources and references associated to a mesh.
  117639. * Internal use
  117640. * @param mesh The mesh to free.
  117641. * @hidden
  117642. */
  117643. _disposeMesh(mesh: Mesh): void;
  117644. /**
  117645. * Dispose the highlight layer and free resources.
  117646. */
  117647. dispose(): void;
  117648. /**
  117649. * Gets the class name of the effect layer
  117650. * @returns the string with the class name of the effect layer
  117651. */
  117652. getClassName(): string;
  117653. /**
  117654. * Serializes this Highlight layer
  117655. * @returns a serialized Highlight layer object
  117656. */
  117657. serialize(): any;
  117658. /**
  117659. * Creates a Highlight layer from parsed Highlight layer data
  117660. * @param parsedHightlightLayer defines the Highlight layer data
  117661. * @param scene defines the current scene
  117662. * @param rootUrl defines the root URL containing the Highlight layer information
  117663. * @returns a parsed Highlight layer
  117664. */
  117665. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  117666. }
  117667. }
  117668. declare module BABYLON {
  117669. interface AbstractScene {
  117670. /**
  117671. * The list of layers (background and foreground) of the scene
  117672. */
  117673. layers: Array<Layer>;
  117674. }
  117675. /**
  117676. * Defines the layer scene component responsible to manage any layers
  117677. * in a given scene.
  117678. */
  117679. export class LayerSceneComponent implements ISceneComponent {
  117680. /**
  117681. * The component name helpfull to identify the component in the list of scene components.
  117682. */
  117683. readonly name: string;
  117684. /**
  117685. * The scene the component belongs to.
  117686. */
  117687. scene: Scene;
  117688. private _engine;
  117689. /**
  117690. * Creates a new instance of the component for the given scene
  117691. * @param scene Defines the scene to register the component in
  117692. */
  117693. constructor(scene: Scene);
  117694. /**
  117695. * Registers the component in a given scene
  117696. */
  117697. register(): void;
  117698. /**
  117699. * Rebuilds the elements related to this component in case of
  117700. * context lost for instance.
  117701. */
  117702. rebuild(): void;
  117703. /**
  117704. * Disposes the component and the associated ressources.
  117705. */
  117706. dispose(): void;
  117707. private _draw;
  117708. private _drawCameraPredicate;
  117709. private _drawCameraBackground;
  117710. private _drawCameraForeground;
  117711. private _drawRenderTargetPredicate;
  117712. private _drawRenderTargetBackground;
  117713. private _drawRenderTargetForeground;
  117714. /**
  117715. * Adds all the elements from the container to the scene
  117716. * @param container the container holding the elements
  117717. */
  117718. addFromContainer(container: AbstractScene): void;
  117719. /**
  117720. * Removes all the elements in the container from the scene
  117721. * @param container contains the elements to remove
  117722. * @param dispose if the removed element should be disposed (default: false)
  117723. */
  117724. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117725. }
  117726. }
  117727. declare module BABYLON {
  117728. /** @hidden */
  117729. export var layerPixelShader: {
  117730. name: string;
  117731. shader: string;
  117732. };
  117733. }
  117734. declare module BABYLON {
  117735. /** @hidden */
  117736. export var layerVertexShader: {
  117737. name: string;
  117738. shader: string;
  117739. };
  117740. }
  117741. declare module BABYLON {
  117742. /**
  117743. * This represents a full screen 2d layer.
  117744. * This can be useful to display a picture in the background of your scene for instance.
  117745. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117746. */
  117747. export class Layer {
  117748. /**
  117749. * Define the name of the layer.
  117750. */
  117751. name: string;
  117752. /**
  117753. * Define the texture the layer should display.
  117754. */
  117755. texture: Nullable<Texture>;
  117756. /**
  117757. * Is the layer in background or foreground.
  117758. */
  117759. isBackground: boolean;
  117760. /**
  117761. * Define the color of the layer (instead of texture).
  117762. */
  117763. color: Color4;
  117764. /**
  117765. * Define the scale of the layer in order to zoom in out of the texture.
  117766. */
  117767. scale: Vector2;
  117768. /**
  117769. * Define an offset for the layer in order to shift the texture.
  117770. */
  117771. offset: Vector2;
  117772. /**
  117773. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117774. */
  117775. alphaBlendingMode: number;
  117776. /**
  117777. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117778. * Alpha test will not mix with the background color in case of transparency.
  117779. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117780. */
  117781. alphaTest: boolean;
  117782. /**
  117783. * Define a mask to restrict the layer to only some of the scene cameras.
  117784. */
  117785. layerMask: number;
  117786. /**
  117787. * Define the list of render target the layer is visible into.
  117788. */
  117789. renderTargetTextures: RenderTargetTexture[];
  117790. /**
  117791. * Define if the layer is only used in renderTarget or if it also
  117792. * renders in the main frame buffer of the canvas.
  117793. */
  117794. renderOnlyInRenderTargetTextures: boolean;
  117795. private _scene;
  117796. private _vertexBuffers;
  117797. private _indexBuffer;
  117798. private _effect;
  117799. private _alphaTestEffect;
  117800. /**
  117801. * An event triggered when the layer is disposed.
  117802. */
  117803. onDisposeObservable: Observable<Layer>;
  117804. private _onDisposeObserver;
  117805. /**
  117806. * Back compatibility with callback before the onDisposeObservable existed.
  117807. * The set callback will be triggered when the layer has been disposed.
  117808. */
  117809. onDispose: () => void;
  117810. /**
  117811. * An event triggered before rendering the scene
  117812. */
  117813. onBeforeRenderObservable: Observable<Layer>;
  117814. private _onBeforeRenderObserver;
  117815. /**
  117816. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117817. * The set callback will be triggered just before rendering the layer.
  117818. */
  117819. onBeforeRender: () => void;
  117820. /**
  117821. * An event triggered after rendering the scene
  117822. */
  117823. onAfterRenderObservable: Observable<Layer>;
  117824. private _onAfterRenderObserver;
  117825. /**
  117826. * Back compatibility with callback before the onAfterRenderObservable existed.
  117827. * The set callback will be triggered just after rendering the layer.
  117828. */
  117829. onAfterRender: () => void;
  117830. /**
  117831. * Instantiates a new layer.
  117832. * This represents a full screen 2d layer.
  117833. * This can be useful to display a picture in the background of your scene for instance.
  117834. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117835. * @param name Define the name of the layer in the scene
  117836. * @param imgUrl Define the url of the texture to display in the layer
  117837. * @param scene Define the scene the layer belongs to
  117838. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117839. * @param color Defines a color for the layer
  117840. */
  117841. constructor(
  117842. /**
  117843. * Define the name of the layer.
  117844. */
  117845. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117846. private _createIndexBuffer;
  117847. /** @hidden */
  117848. _rebuild(): void;
  117849. /**
  117850. * Renders the layer in the scene.
  117851. */
  117852. render(): void;
  117853. /**
  117854. * Disposes and releases the associated ressources.
  117855. */
  117856. dispose(): void;
  117857. }
  117858. }
  117859. declare module BABYLON {
  117860. /** @hidden */
  117861. export var lensFlarePixelShader: {
  117862. name: string;
  117863. shader: string;
  117864. };
  117865. }
  117866. declare module BABYLON {
  117867. /** @hidden */
  117868. export var lensFlareVertexShader: {
  117869. name: string;
  117870. shader: string;
  117871. };
  117872. }
  117873. declare module BABYLON {
  117874. /**
  117875. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117876. * It is usually composed of several `lensFlare`.
  117877. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117878. */
  117879. export class LensFlareSystem {
  117880. /**
  117881. * Define the name of the lens flare system
  117882. */
  117883. name: string;
  117884. /**
  117885. * List of lens flares used in this system.
  117886. */
  117887. lensFlares: LensFlare[];
  117888. /**
  117889. * Define a limit from the border the lens flare can be visible.
  117890. */
  117891. borderLimit: number;
  117892. /**
  117893. * Define a viewport border we do not want to see the lens flare in.
  117894. */
  117895. viewportBorder: number;
  117896. /**
  117897. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117898. */
  117899. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117900. /**
  117901. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117902. */
  117903. layerMask: number;
  117904. /**
  117905. * Define the id of the lens flare system in the scene.
  117906. * (equal to name by default)
  117907. */
  117908. id: string;
  117909. private _scene;
  117910. private _emitter;
  117911. private _vertexBuffers;
  117912. private _indexBuffer;
  117913. private _effect;
  117914. private _positionX;
  117915. private _positionY;
  117916. private _isEnabled;
  117917. /** @hidden */
  117918. static _SceneComponentInitialization: (scene: Scene) => void;
  117919. /**
  117920. * Instantiates a lens flare system.
  117921. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117922. * It is usually composed of several `lensFlare`.
  117923. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117924. * @param name Define the name of the lens flare system in the scene
  117925. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117926. * @param scene Define the scene the lens flare system belongs to
  117927. */
  117928. constructor(
  117929. /**
  117930. * Define the name of the lens flare system
  117931. */
  117932. name: string, emitter: any, scene: Scene);
  117933. /**
  117934. * Define if the lens flare system is enabled.
  117935. */
  117936. isEnabled: boolean;
  117937. /**
  117938. * Get the scene the effects belongs to.
  117939. * @returns the scene holding the lens flare system
  117940. */
  117941. getScene(): Scene;
  117942. /**
  117943. * Get the emitter of the lens flare system.
  117944. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117945. * @returns the emitter of the lens flare system
  117946. */
  117947. getEmitter(): any;
  117948. /**
  117949. * Set the emitter of the lens flare system.
  117950. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117951. * @param newEmitter Define the new emitter of the system
  117952. */
  117953. setEmitter(newEmitter: any): void;
  117954. /**
  117955. * Get the lens flare system emitter position.
  117956. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117957. * @returns the position
  117958. */
  117959. getEmitterPosition(): Vector3;
  117960. /**
  117961. * @hidden
  117962. */
  117963. computeEffectivePosition(globalViewport: Viewport): boolean;
  117964. /** @hidden */
  117965. _isVisible(): boolean;
  117966. /**
  117967. * @hidden
  117968. */
  117969. render(): boolean;
  117970. /**
  117971. * Dispose and release the lens flare with its associated resources.
  117972. */
  117973. dispose(): void;
  117974. /**
  117975. * Parse a lens flare system from a JSON repressentation
  117976. * @param parsedLensFlareSystem Define the JSON to parse
  117977. * @param scene Define the scene the parsed system should be instantiated in
  117978. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117979. * @returns the parsed system
  117980. */
  117981. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117982. /**
  117983. * Serialize the current Lens Flare System into a JSON representation.
  117984. * @returns the serialized JSON
  117985. */
  117986. serialize(): any;
  117987. }
  117988. }
  117989. declare module BABYLON {
  117990. /**
  117991. * This represents one of the lens effect in a `lensFlareSystem`.
  117992. * It controls one of the indiviual texture used in the effect.
  117993. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117994. */
  117995. export class LensFlare {
  117996. /**
  117997. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117998. */
  117999. size: number;
  118000. /**
  118001. * 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.
  118002. */
  118003. position: number;
  118004. /**
  118005. * Define the lens color.
  118006. */
  118007. color: Color3;
  118008. /**
  118009. * Define the lens texture.
  118010. */
  118011. texture: Nullable<Texture>;
  118012. /**
  118013. * Define the alpha mode to render this particular lens.
  118014. */
  118015. alphaMode: number;
  118016. private _system;
  118017. /**
  118018. * Creates a new Lens Flare.
  118019. * This represents one of the lens effect in a `lensFlareSystem`.
  118020. * It controls one of the indiviual texture used in the effect.
  118021. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118022. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  118023. * @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.
  118024. * @param color Define the lens color
  118025. * @param imgUrl Define the lens texture url
  118026. * @param system Define the `lensFlareSystem` this flare is part of
  118027. * @returns The newly created Lens Flare
  118028. */
  118029. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  118030. /**
  118031. * Instantiates a new Lens Flare.
  118032. * This represents one of the lens effect in a `lensFlareSystem`.
  118033. * It controls one of the indiviual texture used in the effect.
  118034. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118035. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  118036. * @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.
  118037. * @param color Define the lens color
  118038. * @param imgUrl Define the lens texture url
  118039. * @param system Define the `lensFlareSystem` this flare is part of
  118040. */
  118041. constructor(
  118042. /**
  118043. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  118044. */
  118045. size: number,
  118046. /**
  118047. * 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.
  118048. */
  118049. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  118050. /**
  118051. * Dispose and release the lens flare with its associated resources.
  118052. */
  118053. dispose(): void;
  118054. }
  118055. }
  118056. declare module BABYLON {
  118057. interface AbstractScene {
  118058. /**
  118059. * The list of lens flare system added to the scene
  118060. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118061. */
  118062. lensFlareSystems: Array<LensFlareSystem>;
  118063. /**
  118064. * Removes the given lens flare system from this scene.
  118065. * @param toRemove The lens flare system to remove
  118066. * @returns The index of the removed lens flare system
  118067. */
  118068. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  118069. /**
  118070. * Adds the given lens flare system to this scene
  118071. * @param newLensFlareSystem The lens flare system to add
  118072. */
  118073. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  118074. /**
  118075. * Gets a lens flare system using its name
  118076. * @param name defines the name to look for
  118077. * @returns the lens flare system or null if not found
  118078. */
  118079. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  118080. /**
  118081. * Gets a lens flare system using its id
  118082. * @param id defines the id to look for
  118083. * @returns the lens flare system or null if not found
  118084. */
  118085. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  118086. }
  118087. /**
  118088. * Defines the lens flare scene component responsible to manage any lens flares
  118089. * in a given scene.
  118090. */
  118091. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  118092. /**
  118093. * The component name helpfull to identify the component in the list of scene components.
  118094. */
  118095. readonly name: string;
  118096. /**
  118097. * The scene the component belongs to.
  118098. */
  118099. scene: Scene;
  118100. /**
  118101. * Creates a new instance of the component for the given scene
  118102. * @param scene Defines the scene to register the component in
  118103. */
  118104. constructor(scene: Scene);
  118105. /**
  118106. * Registers the component in a given scene
  118107. */
  118108. register(): void;
  118109. /**
  118110. * Rebuilds the elements related to this component in case of
  118111. * context lost for instance.
  118112. */
  118113. rebuild(): void;
  118114. /**
  118115. * Adds all the elements from the container to the scene
  118116. * @param container the container holding the elements
  118117. */
  118118. addFromContainer(container: AbstractScene): void;
  118119. /**
  118120. * Removes all the elements in the container from the scene
  118121. * @param container contains the elements to remove
  118122. * @param dispose if the removed element should be disposed (default: false)
  118123. */
  118124. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118125. /**
  118126. * Serializes the component data to the specified json object
  118127. * @param serializationObject The object to serialize to
  118128. */
  118129. serialize(serializationObject: any): void;
  118130. /**
  118131. * Disposes the component and the associated ressources.
  118132. */
  118133. dispose(): void;
  118134. private _draw;
  118135. }
  118136. }
  118137. declare module BABYLON {
  118138. /**
  118139. * Defines the shadow generator component responsible to manage any shadow generators
  118140. * in a given scene.
  118141. */
  118142. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  118143. /**
  118144. * The component name helpfull to identify the component in the list of scene components.
  118145. */
  118146. readonly name: string;
  118147. /**
  118148. * The scene the component belongs to.
  118149. */
  118150. scene: Scene;
  118151. /**
  118152. * Creates a new instance of the component for the given scene
  118153. * @param scene Defines the scene to register the component in
  118154. */
  118155. constructor(scene: Scene);
  118156. /**
  118157. * Registers the component in a given scene
  118158. */
  118159. register(): void;
  118160. /**
  118161. * Rebuilds the elements related to this component in case of
  118162. * context lost for instance.
  118163. */
  118164. rebuild(): void;
  118165. /**
  118166. * Serializes the component data to the specified json object
  118167. * @param serializationObject The object to serialize to
  118168. */
  118169. serialize(serializationObject: any): void;
  118170. /**
  118171. * Adds all the elements from the container to the scene
  118172. * @param container the container holding the elements
  118173. */
  118174. addFromContainer(container: AbstractScene): void;
  118175. /**
  118176. * Removes all the elements in the container from the scene
  118177. * @param container contains the elements to remove
  118178. * @param dispose if the removed element should be disposed (default: false)
  118179. */
  118180. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118181. /**
  118182. * Rebuilds the elements related to this component in case of
  118183. * context lost for instance.
  118184. */
  118185. dispose(): void;
  118186. private _gatherRenderTargets;
  118187. }
  118188. }
  118189. declare module BABYLON {
  118190. /**
  118191. * A point light is a light defined by an unique point in world space.
  118192. * The light is emitted in every direction from this point.
  118193. * A good example of a point light is a standard light bulb.
  118194. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118195. */
  118196. export class PointLight extends ShadowLight {
  118197. private _shadowAngle;
  118198. /**
  118199. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118200. * This specifies what angle the shadow will use to be created.
  118201. *
  118202. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118203. */
  118204. /**
  118205. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118206. * This specifies what angle the shadow will use to be created.
  118207. *
  118208. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118209. */
  118210. shadowAngle: number;
  118211. /**
  118212. * Gets the direction if it has been set.
  118213. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118214. */
  118215. /**
  118216. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118217. */
  118218. direction: Vector3;
  118219. /**
  118220. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  118221. * A PointLight emits the light in every direction.
  118222. * It can cast shadows.
  118223. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  118224. * ```javascript
  118225. * var pointLight = new PointLight("pl", camera.position, scene);
  118226. * ```
  118227. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118228. * @param name The light friendly name
  118229. * @param position The position of the point light in the scene
  118230. * @param scene The scene the lights belongs to
  118231. */
  118232. constructor(name: string, position: Vector3, scene: Scene);
  118233. /**
  118234. * Returns the string "PointLight"
  118235. * @returns the class name
  118236. */
  118237. getClassName(): string;
  118238. /**
  118239. * Returns the integer 0.
  118240. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118241. */
  118242. getTypeID(): number;
  118243. /**
  118244. * Specifies wether or not the shadowmap should be a cube texture.
  118245. * @returns true if the shadowmap needs to be a cube texture.
  118246. */
  118247. needCube(): boolean;
  118248. /**
  118249. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  118250. * @param faceIndex The index of the face we are computed the direction to generate shadow
  118251. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  118252. */
  118253. getShadowDirection(faceIndex?: number): Vector3;
  118254. /**
  118255. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  118256. * - fov = PI / 2
  118257. * - aspect ratio : 1.0
  118258. * - z-near and far equal to the active camera minZ and maxZ.
  118259. * Returns the PointLight.
  118260. */
  118261. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118262. protected _buildUniformLayout(): void;
  118263. /**
  118264. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  118265. * @param effect The effect to update
  118266. * @param lightIndex The index of the light in the effect to update
  118267. * @returns The point light
  118268. */
  118269. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  118270. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118271. /**
  118272. * Prepares the list of defines specific to the light type.
  118273. * @param defines the list of defines
  118274. * @param lightIndex defines the index of the light for the effect
  118275. */
  118276. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118277. }
  118278. }
  118279. declare module BABYLON {
  118280. /**
  118281. * Header information of HDR texture files.
  118282. */
  118283. export interface HDRInfo {
  118284. /**
  118285. * The height of the texture in pixels.
  118286. */
  118287. height: number;
  118288. /**
  118289. * The width of the texture in pixels.
  118290. */
  118291. width: number;
  118292. /**
  118293. * The index of the beginning of the data in the binary file.
  118294. */
  118295. dataPosition: number;
  118296. }
  118297. /**
  118298. * This groups tools to convert HDR texture to native colors array.
  118299. */
  118300. export class HDRTools {
  118301. private static Ldexp;
  118302. private static Rgbe2float;
  118303. private static readStringLine;
  118304. /**
  118305. * Reads header information from an RGBE texture stored in a native array.
  118306. * More information on this format are available here:
  118307. * https://en.wikipedia.org/wiki/RGBE_image_format
  118308. *
  118309. * @param uint8array The binary file stored in native array.
  118310. * @return The header information.
  118311. */
  118312. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  118313. /**
  118314. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  118315. * This RGBE texture needs to store the information as a panorama.
  118316. *
  118317. * More information on this format are available here:
  118318. * https://en.wikipedia.org/wiki/RGBE_image_format
  118319. *
  118320. * @param buffer The binary file stored in an array buffer.
  118321. * @param size The expected size of the extracted cubemap.
  118322. * @return The Cube Map information.
  118323. */
  118324. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  118325. /**
  118326. * Returns the pixels data extracted from an RGBE texture.
  118327. * This pixels will be stored left to right up to down in the R G B order in one array.
  118328. *
  118329. * More information on this format are available here:
  118330. * https://en.wikipedia.org/wiki/RGBE_image_format
  118331. *
  118332. * @param uint8array The binary file stored in an array buffer.
  118333. * @param hdrInfo The header information of the file.
  118334. * @return The pixels data in RGB right to left up to down order.
  118335. */
  118336. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  118337. private static RGBE_ReadPixels_RLE;
  118338. }
  118339. }
  118340. declare module BABYLON {
  118341. /**
  118342. * This represents a texture coming from an HDR input.
  118343. *
  118344. * The only supported format is currently panorama picture stored in RGBE format.
  118345. * Example of such files can be found on HDRLib: http://hdrlib.com/
  118346. */
  118347. export class HDRCubeTexture extends BaseTexture {
  118348. private static _facesMapping;
  118349. private _generateHarmonics;
  118350. private _noMipmap;
  118351. private _textureMatrix;
  118352. private _size;
  118353. private _onLoad;
  118354. private _onError;
  118355. /**
  118356. * The texture URL.
  118357. */
  118358. url: string;
  118359. /**
  118360. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  118361. */
  118362. coordinatesMode: number;
  118363. protected _isBlocking: boolean;
  118364. /**
  118365. * Sets wether or not the texture is blocking during loading.
  118366. */
  118367. /**
  118368. * Gets wether or not the texture is blocking during loading.
  118369. */
  118370. isBlocking: boolean;
  118371. protected _rotationY: number;
  118372. /**
  118373. * Sets texture matrix rotation angle around Y axis in radians.
  118374. */
  118375. /**
  118376. * Gets texture matrix rotation angle around Y axis radians.
  118377. */
  118378. rotationY: number;
  118379. /**
  118380. * Gets or sets the center of the bounding box associated with the cube texture
  118381. * It must define where the camera used to render the texture was set
  118382. */
  118383. boundingBoxPosition: Vector3;
  118384. private _boundingBoxSize;
  118385. /**
  118386. * Gets or sets the size of the bounding box associated with the cube texture
  118387. * When defined, the cubemap will switch to local mode
  118388. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  118389. * @example https://www.babylonjs-playground.com/#RNASML
  118390. */
  118391. boundingBoxSize: Vector3;
  118392. /**
  118393. * Instantiates an HDRTexture from the following parameters.
  118394. *
  118395. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  118396. * @param scene The scene the texture will be used in
  118397. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118398. * @param noMipmap Forces to not generate the mipmap if true
  118399. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  118400. * @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)
  118401. * @param reserved Reserved flag for internal use.
  118402. */
  118403. 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>);
  118404. /**
  118405. * Get the current class name of the texture useful for serialization or dynamic coding.
  118406. * @returns "HDRCubeTexture"
  118407. */
  118408. getClassName(): string;
  118409. /**
  118410. * Occurs when the file is raw .hdr file.
  118411. */
  118412. private loadTexture;
  118413. clone(): HDRCubeTexture;
  118414. delayLoad(): void;
  118415. /**
  118416. * Get the texture reflection matrix used to rotate/transform the reflection.
  118417. * @returns the reflection matrix
  118418. */
  118419. getReflectionTextureMatrix(): Matrix;
  118420. /**
  118421. * Set the texture reflection matrix used to rotate/transform the reflection.
  118422. * @param value Define the reflection matrix to set
  118423. */
  118424. setReflectionTextureMatrix(value: Matrix): void;
  118425. /**
  118426. * Parses a JSON representation of an HDR Texture in order to create the texture
  118427. * @param parsedTexture Define the JSON representation
  118428. * @param scene Define the scene the texture should be created in
  118429. * @param rootUrl Define the root url in case we need to load relative dependencies
  118430. * @returns the newly created texture after parsing
  118431. */
  118432. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  118433. serialize(): any;
  118434. }
  118435. }
  118436. declare module BABYLON {
  118437. /**
  118438. * Class used to control physics engine
  118439. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  118440. */
  118441. export class PhysicsEngine implements IPhysicsEngine {
  118442. private _physicsPlugin;
  118443. /**
  118444. * Global value used to control the smallest number supported by the simulation
  118445. */
  118446. static Epsilon: number;
  118447. private _impostors;
  118448. private _joints;
  118449. /**
  118450. * Gets the gravity vector used by the simulation
  118451. */
  118452. gravity: Vector3;
  118453. /**
  118454. * Factory used to create the default physics plugin.
  118455. * @returns The default physics plugin
  118456. */
  118457. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  118458. /**
  118459. * Creates a new Physics Engine
  118460. * @param gravity defines the gravity vector used by the simulation
  118461. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  118462. */
  118463. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  118464. /**
  118465. * Sets the gravity vector used by the simulation
  118466. * @param gravity defines the gravity vector to use
  118467. */
  118468. setGravity(gravity: Vector3): void;
  118469. /**
  118470. * Set the time step of the physics engine.
  118471. * Default is 1/60.
  118472. * To slow it down, enter 1/600 for example.
  118473. * To speed it up, 1/30
  118474. * @param newTimeStep defines the new timestep to apply to this world.
  118475. */
  118476. setTimeStep(newTimeStep?: number): void;
  118477. /**
  118478. * Get the time step of the physics engine.
  118479. * @returns the current time step
  118480. */
  118481. getTimeStep(): number;
  118482. /**
  118483. * Release all resources
  118484. */
  118485. dispose(): void;
  118486. /**
  118487. * Gets the name of the current physics plugin
  118488. * @returns the name of the plugin
  118489. */
  118490. getPhysicsPluginName(): string;
  118491. /**
  118492. * Adding a new impostor for the impostor tracking.
  118493. * This will be done by the impostor itself.
  118494. * @param impostor the impostor to add
  118495. */
  118496. addImpostor(impostor: PhysicsImpostor): void;
  118497. /**
  118498. * Remove an impostor from the engine.
  118499. * This impostor and its mesh will not longer be updated by the physics engine.
  118500. * @param impostor the impostor to remove
  118501. */
  118502. removeImpostor(impostor: PhysicsImpostor): void;
  118503. /**
  118504. * Add a joint to the physics engine
  118505. * @param mainImpostor defines the main impostor to which the joint is added.
  118506. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  118507. * @param joint defines the joint that will connect both impostors.
  118508. */
  118509. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118510. /**
  118511. * Removes a joint from the simulation
  118512. * @param mainImpostor defines the impostor used with the joint
  118513. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  118514. * @param joint defines the joint to remove
  118515. */
  118516. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118517. /**
  118518. * Called by the scene. No need to call it.
  118519. * @param delta defines the timespam between frames
  118520. */
  118521. _step(delta: number): void;
  118522. /**
  118523. * Gets the current plugin used to run the simulation
  118524. * @returns current plugin
  118525. */
  118526. getPhysicsPlugin(): IPhysicsEnginePlugin;
  118527. /**
  118528. * Gets the list of physic impostors
  118529. * @returns an array of PhysicsImpostor
  118530. */
  118531. getImpostors(): Array<PhysicsImpostor>;
  118532. /**
  118533. * Gets the impostor for a physics enabled object
  118534. * @param object defines the object impersonated by the impostor
  118535. * @returns the PhysicsImpostor or null if not found
  118536. */
  118537. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  118538. /**
  118539. * Gets the impostor for a physics body object
  118540. * @param body defines physics body used by the impostor
  118541. * @returns the PhysicsImpostor or null if not found
  118542. */
  118543. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  118544. /**
  118545. * Does a raycast in the physics world
  118546. * @param from when should the ray start?
  118547. * @param to when should the ray end?
  118548. * @returns PhysicsRaycastResult
  118549. */
  118550. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118551. }
  118552. }
  118553. declare module BABYLON {
  118554. /** @hidden */
  118555. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  118556. private _useDeltaForWorldStep;
  118557. world: any;
  118558. name: string;
  118559. private _physicsMaterials;
  118560. private _fixedTimeStep;
  118561. private _cannonRaycastResult;
  118562. private _raycastResult;
  118563. private _physicsBodysToRemoveAfterStep;
  118564. BJSCANNON: any;
  118565. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  118566. setGravity(gravity: Vector3): void;
  118567. setTimeStep(timeStep: number): void;
  118568. getTimeStep(): number;
  118569. executeStep(delta: number): void;
  118570. private _removeMarkedPhysicsBodiesFromWorld;
  118571. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118572. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118573. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118574. private _processChildMeshes;
  118575. removePhysicsBody(impostor: PhysicsImpostor): void;
  118576. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118577. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118578. private _addMaterial;
  118579. private _checkWithEpsilon;
  118580. private _createShape;
  118581. private _createHeightmap;
  118582. private _minus90X;
  118583. private _plus90X;
  118584. private _tmpPosition;
  118585. private _tmpDeltaPosition;
  118586. private _tmpUnityRotation;
  118587. private _updatePhysicsBodyTransformation;
  118588. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118589. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118590. isSupported(): boolean;
  118591. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118592. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118593. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118594. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118595. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118596. getBodyMass(impostor: PhysicsImpostor): number;
  118597. getBodyFriction(impostor: PhysicsImpostor): number;
  118598. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118599. getBodyRestitution(impostor: PhysicsImpostor): number;
  118600. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118601. sleepBody(impostor: PhysicsImpostor): void;
  118602. wakeUpBody(impostor: PhysicsImpostor): void;
  118603. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  118604. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118605. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118606. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118607. getRadius(impostor: PhysicsImpostor): number;
  118608. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118609. dispose(): void;
  118610. private _extendNamespace;
  118611. /**
  118612. * Does a raycast in the physics world
  118613. * @param from when should the ray start?
  118614. * @param to when should the ray end?
  118615. * @returns PhysicsRaycastResult
  118616. */
  118617. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118618. }
  118619. }
  118620. declare module BABYLON {
  118621. /** @hidden */
  118622. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  118623. world: any;
  118624. name: string;
  118625. BJSOIMO: any;
  118626. private _raycastResult;
  118627. constructor(iterations?: number, oimoInjection?: any);
  118628. setGravity(gravity: Vector3): void;
  118629. setTimeStep(timeStep: number): void;
  118630. getTimeStep(): number;
  118631. private _tmpImpostorsArray;
  118632. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118633. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118634. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118635. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118636. private _tmpPositionVector;
  118637. removePhysicsBody(impostor: PhysicsImpostor): void;
  118638. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118639. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118640. isSupported(): boolean;
  118641. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118642. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118643. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118644. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118645. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118646. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118647. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118648. getBodyMass(impostor: PhysicsImpostor): number;
  118649. getBodyFriction(impostor: PhysicsImpostor): number;
  118650. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118651. getBodyRestitution(impostor: PhysicsImpostor): number;
  118652. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118653. sleepBody(impostor: PhysicsImpostor): void;
  118654. wakeUpBody(impostor: PhysicsImpostor): void;
  118655. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118656. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  118657. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  118658. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118659. getRadius(impostor: PhysicsImpostor): number;
  118660. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118661. dispose(): void;
  118662. /**
  118663. * Does a raycast in the physics world
  118664. * @param from when should the ray start?
  118665. * @param to when should the ray end?
  118666. * @returns PhysicsRaycastResult
  118667. */
  118668. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118669. }
  118670. }
  118671. declare module BABYLON {
  118672. /**
  118673. * Class containing static functions to help procedurally build meshes
  118674. */
  118675. export class RibbonBuilder {
  118676. /**
  118677. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118678. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  118679. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  118680. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  118681. * * 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
  118682. * * 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
  118683. * * 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
  118684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118687. * * 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
  118688. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  118689. * * 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
  118690. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  118691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118692. * @param name defines the name of the mesh
  118693. * @param options defines the options used to create the mesh
  118694. * @param scene defines the hosting scene
  118695. * @returns the ribbon mesh
  118696. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  118697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118698. */
  118699. static CreateRibbon(name: string, options: {
  118700. pathArray: Vector3[][];
  118701. closeArray?: boolean;
  118702. closePath?: boolean;
  118703. offset?: number;
  118704. updatable?: boolean;
  118705. sideOrientation?: number;
  118706. frontUVs?: Vector4;
  118707. backUVs?: Vector4;
  118708. instance?: Mesh;
  118709. invertUV?: boolean;
  118710. uvs?: Vector2[];
  118711. colors?: Color4[];
  118712. }, scene?: Nullable<Scene>): Mesh;
  118713. }
  118714. }
  118715. declare module BABYLON {
  118716. /**
  118717. * Class containing static functions to help procedurally build meshes
  118718. */
  118719. export class ShapeBuilder {
  118720. /**
  118721. * 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.
  118722. * * 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.
  118723. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118724. * * 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.
  118725. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118726. * * 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
  118727. * * 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
  118728. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118731. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118733. * @param name defines the name of the mesh
  118734. * @param options defines the options used to create the mesh
  118735. * @param scene defines the hosting scene
  118736. * @returns the extruded shape mesh
  118737. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118739. */
  118740. static ExtrudeShape(name: string, options: {
  118741. shape: Vector3[];
  118742. path: Vector3[];
  118743. scale?: number;
  118744. rotation?: number;
  118745. cap?: number;
  118746. updatable?: boolean;
  118747. sideOrientation?: number;
  118748. frontUVs?: Vector4;
  118749. backUVs?: Vector4;
  118750. instance?: Mesh;
  118751. invertUV?: boolean;
  118752. }, scene?: Nullable<Scene>): Mesh;
  118753. /**
  118754. * Creates an custom extruded shape mesh.
  118755. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118756. * * 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.
  118757. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118758. * * 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
  118759. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118760. * * 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
  118761. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118762. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118763. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118764. * * 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
  118765. * * 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
  118766. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118771. * @param name defines the name of the mesh
  118772. * @param options defines the options used to create the mesh
  118773. * @param scene defines the hosting scene
  118774. * @returns the custom extruded shape mesh
  118775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118776. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118778. */
  118779. static ExtrudeShapeCustom(name: string, options: {
  118780. shape: Vector3[];
  118781. path: Vector3[];
  118782. scaleFunction?: any;
  118783. rotationFunction?: any;
  118784. ribbonCloseArray?: boolean;
  118785. ribbonClosePath?: boolean;
  118786. cap?: number;
  118787. updatable?: boolean;
  118788. sideOrientation?: number;
  118789. frontUVs?: Vector4;
  118790. backUVs?: Vector4;
  118791. instance?: Mesh;
  118792. invertUV?: boolean;
  118793. }, scene?: Nullable<Scene>): Mesh;
  118794. private static _ExtrudeShapeGeneric;
  118795. }
  118796. }
  118797. declare module BABYLON {
  118798. /**
  118799. * AmmoJS Physics plugin
  118800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118801. * @see https://github.com/kripken/ammo.js/
  118802. */
  118803. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118804. private _useDeltaForWorldStep;
  118805. /**
  118806. * Reference to the Ammo library
  118807. */
  118808. bjsAMMO: any;
  118809. /**
  118810. * Created ammoJS world which physics bodies are added to
  118811. */
  118812. world: any;
  118813. /**
  118814. * Name of the plugin
  118815. */
  118816. name: string;
  118817. private _timeStep;
  118818. private _fixedTimeStep;
  118819. private _maxSteps;
  118820. private _tmpQuaternion;
  118821. private _tmpAmmoTransform;
  118822. private _tmpAmmoQuaternion;
  118823. private _tmpAmmoConcreteContactResultCallback;
  118824. private _collisionConfiguration;
  118825. private _dispatcher;
  118826. private _overlappingPairCache;
  118827. private _solver;
  118828. private _softBodySolver;
  118829. private _tmpAmmoVectorA;
  118830. private _tmpAmmoVectorB;
  118831. private _tmpAmmoVectorC;
  118832. private _tmpAmmoVectorD;
  118833. private _tmpContactCallbackResult;
  118834. private _tmpAmmoVectorRCA;
  118835. private _tmpAmmoVectorRCB;
  118836. private _raycastResult;
  118837. private static readonly DISABLE_COLLISION_FLAG;
  118838. private static readonly KINEMATIC_FLAG;
  118839. private static readonly DISABLE_DEACTIVATION_FLAG;
  118840. /**
  118841. * Initializes the ammoJS plugin
  118842. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118843. * @param ammoInjection can be used to inject your own ammo reference
  118844. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118845. */
  118846. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118847. /**
  118848. * Sets the gravity of the physics world (m/(s^2))
  118849. * @param gravity Gravity to set
  118850. */
  118851. setGravity(gravity: Vector3): void;
  118852. /**
  118853. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118854. * @param timeStep timestep to use in seconds
  118855. */
  118856. setTimeStep(timeStep: number): void;
  118857. /**
  118858. * 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)
  118859. * @param fixedTimeStep fixedTimeStep to use in seconds
  118860. */
  118861. setFixedTimeStep(fixedTimeStep: number): void;
  118862. /**
  118863. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118864. * @param maxSteps the maximum number of steps by the physics engine per frame
  118865. */
  118866. setMaxSteps(maxSteps: number): void;
  118867. /**
  118868. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118869. * @returns the current timestep in seconds
  118870. */
  118871. getTimeStep(): number;
  118872. private _isImpostorInContact;
  118873. private _isImpostorPairInContact;
  118874. private _stepSimulation;
  118875. /**
  118876. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118877. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118878. * After the step the babylon meshes are set to the position of the physics imposters
  118879. * @param delta amount of time to step forward
  118880. * @param impostors array of imposters to update before/after the step
  118881. */
  118882. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118883. /**
  118884. * Update babylon mesh to match physics world object
  118885. * @param impostor imposter to match
  118886. */
  118887. private _afterSoftStep;
  118888. /**
  118889. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118890. * @param impostor imposter to match
  118891. */
  118892. private _ropeStep;
  118893. /**
  118894. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118895. * @param impostor imposter to match
  118896. */
  118897. private _softbodyOrClothStep;
  118898. private _tmpVector;
  118899. private _tmpMatrix;
  118900. /**
  118901. * Applies an impulse on the imposter
  118902. * @param impostor imposter to apply impulse to
  118903. * @param force amount of force to be applied to the imposter
  118904. * @param contactPoint the location to apply the impulse on the imposter
  118905. */
  118906. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118907. /**
  118908. * Applies a force on the imposter
  118909. * @param impostor imposter to apply force
  118910. * @param force amount of force to be applied to the imposter
  118911. * @param contactPoint the location to apply the force on the imposter
  118912. */
  118913. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118914. /**
  118915. * Creates a physics body using the plugin
  118916. * @param impostor the imposter to create the physics body on
  118917. */
  118918. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118919. /**
  118920. * Removes the physics body from the imposter and disposes of the body's memory
  118921. * @param impostor imposter to remove the physics body from
  118922. */
  118923. removePhysicsBody(impostor: PhysicsImpostor): void;
  118924. /**
  118925. * Generates a joint
  118926. * @param impostorJoint the imposter joint to create the joint with
  118927. */
  118928. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118929. /**
  118930. * Removes a joint
  118931. * @param impostorJoint the imposter joint to remove the joint from
  118932. */
  118933. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118934. private _addMeshVerts;
  118935. /**
  118936. * Initialise the soft body vertices to match its object's (mesh) vertices
  118937. * Softbody vertices (nodes) are in world space and to match this
  118938. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118939. * @param impostor to create the softbody for
  118940. */
  118941. private _softVertexData;
  118942. /**
  118943. * Create an impostor's soft body
  118944. * @param impostor to create the softbody for
  118945. */
  118946. private _createSoftbody;
  118947. /**
  118948. * Create cloth for an impostor
  118949. * @param impostor to create the softbody for
  118950. */
  118951. private _createCloth;
  118952. /**
  118953. * Create rope for an impostor
  118954. * @param impostor to create the softbody for
  118955. */
  118956. private _createRope;
  118957. private _addHullVerts;
  118958. private _createShape;
  118959. /**
  118960. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118961. * @param impostor imposter containing the physics body and babylon object
  118962. */
  118963. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118964. /**
  118965. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118966. * @param impostor imposter containing the physics body and babylon object
  118967. * @param newPosition new position
  118968. * @param newRotation new rotation
  118969. */
  118970. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118971. /**
  118972. * If this plugin is supported
  118973. * @returns true if its supported
  118974. */
  118975. isSupported(): boolean;
  118976. /**
  118977. * Sets the linear velocity of the physics body
  118978. * @param impostor imposter to set the velocity on
  118979. * @param velocity velocity to set
  118980. */
  118981. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118982. /**
  118983. * Sets the angular velocity of the physics body
  118984. * @param impostor imposter to set the velocity on
  118985. * @param velocity velocity to set
  118986. */
  118987. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118988. /**
  118989. * gets the linear velocity
  118990. * @param impostor imposter to get linear velocity from
  118991. * @returns linear velocity
  118992. */
  118993. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118994. /**
  118995. * gets the angular velocity
  118996. * @param impostor imposter to get angular velocity from
  118997. * @returns angular velocity
  118998. */
  118999. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119000. /**
  119001. * Sets the mass of physics body
  119002. * @param impostor imposter to set the mass on
  119003. * @param mass mass to set
  119004. */
  119005. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119006. /**
  119007. * Gets the mass of the physics body
  119008. * @param impostor imposter to get the mass from
  119009. * @returns mass
  119010. */
  119011. getBodyMass(impostor: PhysicsImpostor): number;
  119012. /**
  119013. * Gets friction of the impostor
  119014. * @param impostor impostor to get friction from
  119015. * @returns friction value
  119016. */
  119017. getBodyFriction(impostor: PhysicsImpostor): number;
  119018. /**
  119019. * Sets friction of the impostor
  119020. * @param impostor impostor to set friction on
  119021. * @param friction friction value
  119022. */
  119023. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119024. /**
  119025. * Gets restitution of the impostor
  119026. * @param impostor impostor to get restitution from
  119027. * @returns restitution value
  119028. */
  119029. getBodyRestitution(impostor: PhysicsImpostor): number;
  119030. /**
  119031. * Sets resitution of the impostor
  119032. * @param impostor impostor to set resitution on
  119033. * @param restitution resitution value
  119034. */
  119035. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119036. /**
  119037. * Gets pressure inside the impostor
  119038. * @param impostor impostor to get pressure from
  119039. * @returns pressure value
  119040. */
  119041. getBodyPressure(impostor: PhysicsImpostor): number;
  119042. /**
  119043. * Sets pressure inside a soft body impostor
  119044. * Cloth and rope must remain 0 pressure
  119045. * @param impostor impostor to set pressure on
  119046. * @param pressure pressure value
  119047. */
  119048. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  119049. /**
  119050. * Gets stiffness of the impostor
  119051. * @param impostor impostor to get stiffness from
  119052. * @returns pressure value
  119053. */
  119054. getBodyStiffness(impostor: PhysicsImpostor): number;
  119055. /**
  119056. * Sets stiffness of the impostor
  119057. * @param impostor impostor to set stiffness on
  119058. * @param stiffness stiffness value from 0 to 1
  119059. */
  119060. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  119061. /**
  119062. * Gets velocityIterations of the impostor
  119063. * @param impostor impostor to get velocity iterations from
  119064. * @returns velocityIterations value
  119065. */
  119066. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  119067. /**
  119068. * Sets velocityIterations of the impostor
  119069. * @param impostor impostor to set velocity iterations on
  119070. * @param velocityIterations velocityIterations value
  119071. */
  119072. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  119073. /**
  119074. * Gets positionIterations of the impostor
  119075. * @param impostor impostor to get position iterations from
  119076. * @returns positionIterations value
  119077. */
  119078. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  119079. /**
  119080. * Sets positionIterations of the impostor
  119081. * @param impostor impostor to set position on
  119082. * @param positionIterations positionIterations value
  119083. */
  119084. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  119085. /**
  119086. * Append an anchor to a cloth object
  119087. * @param impostor is the cloth impostor to add anchor to
  119088. * @param otherImpostor is the rigid impostor to anchor to
  119089. * @param width ratio across width from 0 to 1
  119090. * @param height ratio up height from 0 to 1
  119091. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  119092. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119093. */
  119094. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119095. /**
  119096. * Append an hook to a rope object
  119097. * @param impostor is the rope impostor to add hook to
  119098. * @param otherImpostor is the rigid impostor to hook to
  119099. * @param length ratio along the rope from 0 to 1
  119100. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  119101. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119102. */
  119103. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119104. /**
  119105. * Sleeps the physics body and stops it from being active
  119106. * @param impostor impostor to sleep
  119107. */
  119108. sleepBody(impostor: PhysicsImpostor): void;
  119109. /**
  119110. * Activates the physics body
  119111. * @param impostor impostor to activate
  119112. */
  119113. wakeUpBody(impostor: PhysicsImpostor): void;
  119114. /**
  119115. * Updates the distance parameters of the joint
  119116. * @param joint joint to update
  119117. * @param maxDistance maximum distance of the joint
  119118. * @param minDistance minimum distance of the joint
  119119. */
  119120. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119121. /**
  119122. * Sets a motor on the joint
  119123. * @param joint joint to set motor on
  119124. * @param speed speed of the motor
  119125. * @param maxForce maximum force of the motor
  119126. * @param motorIndex index of the motor
  119127. */
  119128. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119129. /**
  119130. * Sets the motors limit
  119131. * @param joint joint to set limit on
  119132. * @param upperLimit upper limit
  119133. * @param lowerLimit lower limit
  119134. */
  119135. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119136. /**
  119137. * Syncs the position and rotation of a mesh with the impostor
  119138. * @param mesh mesh to sync
  119139. * @param impostor impostor to update the mesh with
  119140. */
  119141. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119142. /**
  119143. * Gets the radius of the impostor
  119144. * @param impostor impostor to get radius from
  119145. * @returns the radius
  119146. */
  119147. getRadius(impostor: PhysicsImpostor): number;
  119148. /**
  119149. * Gets the box size of the impostor
  119150. * @param impostor impostor to get box size from
  119151. * @param result the resulting box size
  119152. */
  119153. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119154. /**
  119155. * Disposes of the impostor
  119156. */
  119157. dispose(): void;
  119158. /**
  119159. * Does a raycast in the physics world
  119160. * @param from when should the ray start?
  119161. * @param to when should the ray end?
  119162. * @returns PhysicsRaycastResult
  119163. */
  119164. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119165. }
  119166. }
  119167. declare module BABYLON {
  119168. interface AbstractScene {
  119169. /**
  119170. * The list of reflection probes added to the scene
  119171. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119172. */
  119173. reflectionProbes: Array<ReflectionProbe>;
  119174. /**
  119175. * Removes the given reflection probe from this scene.
  119176. * @param toRemove The reflection probe to remove
  119177. * @returns The index of the removed reflection probe
  119178. */
  119179. removeReflectionProbe(toRemove: ReflectionProbe): number;
  119180. /**
  119181. * Adds the given reflection probe to this scene.
  119182. * @param newReflectionProbe The reflection probe to add
  119183. */
  119184. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  119185. }
  119186. /**
  119187. * Class used to generate realtime reflection / refraction cube textures
  119188. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119189. */
  119190. export class ReflectionProbe {
  119191. /** defines the name of the probe */
  119192. name: string;
  119193. private _scene;
  119194. private _renderTargetTexture;
  119195. private _projectionMatrix;
  119196. private _viewMatrix;
  119197. private _target;
  119198. private _add;
  119199. private _attachedMesh;
  119200. private _invertYAxis;
  119201. /** Gets or sets probe position (center of the cube map) */
  119202. position: Vector3;
  119203. /**
  119204. * Creates a new reflection probe
  119205. * @param name defines the name of the probe
  119206. * @param size defines the texture resolution (for each face)
  119207. * @param scene defines the hosting scene
  119208. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119209. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119210. */
  119211. constructor(
  119212. /** defines the name of the probe */
  119213. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  119214. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119215. samples: number;
  119216. /** Gets or sets the refresh rate to use (on every frame by default) */
  119217. refreshRate: number;
  119218. /**
  119219. * Gets the hosting scene
  119220. * @returns a Scene
  119221. */
  119222. getScene(): Scene;
  119223. /** Gets the internal CubeTexture used to render to */
  119224. readonly cubeTexture: RenderTargetTexture;
  119225. /** Gets the list of meshes to render */
  119226. readonly renderList: Nullable<AbstractMesh[]>;
  119227. /**
  119228. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  119229. * @param mesh defines the mesh to attach to
  119230. */
  119231. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  119232. /**
  119233. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  119234. * @param renderingGroupId The rendering group id corresponding to its index
  119235. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119236. */
  119237. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119238. /**
  119239. * Clean all associated resources
  119240. */
  119241. dispose(): void;
  119242. /**
  119243. * Converts the reflection probe information to a readable string for debug purpose.
  119244. * @param fullDetails Supports for multiple levels of logging within scene loading
  119245. * @returns the human readable reflection probe info
  119246. */
  119247. toString(fullDetails?: boolean): string;
  119248. /**
  119249. * Get the class name of the relfection probe.
  119250. * @returns "ReflectionProbe"
  119251. */
  119252. getClassName(): string;
  119253. /**
  119254. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  119255. * @returns The JSON representation of the texture
  119256. */
  119257. serialize(): any;
  119258. /**
  119259. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  119260. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  119261. * @param scene Define the scene the parsed reflection probe should be instantiated in
  119262. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  119263. * @returns The parsed reflection probe if successful
  119264. */
  119265. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  119266. }
  119267. }
  119268. declare module BABYLON {
  119269. /** @hidden */
  119270. export var _BabylonLoaderRegistered: boolean;
  119271. }
  119272. declare module BABYLON {
  119273. /**
  119274. * The Physically based simple base material of BJS.
  119275. *
  119276. * This enables better naming and convention enforcements on top of the pbrMaterial.
  119277. * It is used as the base class for both the specGloss and metalRough conventions.
  119278. */
  119279. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  119280. /**
  119281. * Number of Simultaneous lights allowed on the material.
  119282. */
  119283. maxSimultaneousLights: number;
  119284. /**
  119285. * If sets to true, disables all the lights affecting the material.
  119286. */
  119287. disableLighting: boolean;
  119288. /**
  119289. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  119290. */
  119291. environmentTexture: BaseTexture;
  119292. /**
  119293. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  119294. */
  119295. invertNormalMapX: boolean;
  119296. /**
  119297. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  119298. */
  119299. invertNormalMapY: boolean;
  119300. /**
  119301. * Normal map used in the model.
  119302. */
  119303. normalTexture: BaseTexture;
  119304. /**
  119305. * Emissivie color used to self-illuminate the model.
  119306. */
  119307. emissiveColor: Color3;
  119308. /**
  119309. * Emissivie texture used to self-illuminate the model.
  119310. */
  119311. emissiveTexture: BaseTexture;
  119312. /**
  119313. * Occlusion Channel Strenght.
  119314. */
  119315. occlusionStrength: number;
  119316. /**
  119317. * Occlusion Texture of the material (adding extra occlusion effects).
  119318. */
  119319. occlusionTexture: BaseTexture;
  119320. /**
  119321. * Defines the alpha limits in alpha test mode.
  119322. */
  119323. alphaCutOff: number;
  119324. /**
  119325. * Gets the current double sided mode.
  119326. */
  119327. /**
  119328. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  119329. */
  119330. doubleSided: boolean;
  119331. /**
  119332. * Stores the pre-calculated light information of a mesh in a texture.
  119333. */
  119334. lightmapTexture: BaseTexture;
  119335. /**
  119336. * If true, the light map contains occlusion information instead of lighting info.
  119337. */
  119338. useLightmapAsShadowmap: boolean;
  119339. /**
  119340. * Instantiates a new PBRMaterial instance.
  119341. *
  119342. * @param name The material name
  119343. * @param scene The scene the material will be use in.
  119344. */
  119345. constructor(name: string, scene: Scene);
  119346. getClassName(): string;
  119347. }
  119348. }
  119349. declare module BABYLON {
  119350. /**
  119351. * The PBR material of BJS following the metal roughness convention.
  119352. *
  119353. * This fits to the PBR convention in the GLTF definition:
  119354. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  119355. */
  119356. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  119357. /**
  119358. * The base color has two different interpretations depending on the value of metalness.
  119359. * When the material is a metal, the base color is the specific measured reflectance value
  119360. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  119361. * of the material.
  119362. */
  119363. baseColor: Color3;
  119364. /**
  119365. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  119366. * well as opacity information in the alpha channel.
  119367. */
  119368. baseTexture: BaseTexture;
  119369. /**
  119370. * Specifies the metallic scalar value of the material.
  119371. * Can also be used to scale the metalness values of the metallic texture.
  119372. */
  119373. metallic: number;
  119374. /**
  119375. * Specifies the roughness scalar value of the material.
  119376. * Can also be used to scale the roughness values of the metallic texture.
  119377. */
  119378. roughness: number;
  119379. /**
  119380. * Texture containing both the metallic value in the B channel and the
  119381. * roughness value in the G channel to keep better precision.
  119382. */
  119383. metallicRoughnessTexture: BaseTexture;
  119384. /**
  119385. * Instantiates a new PBRMetalRoughnessMaterial instance.
  119386. *
  119387. * @param name The material name
  119388. * @param scene The scene the material will be use in.
  119389. */
  119390. constructor(name: string, scene: Scene);
  119391. /**
  119392. * Return the currrent class name of the material.
  119393. */
  119394. getClassName(): string;
  119395. /**
  119396. * Makes a duplicate of the current material.
  119397. * @param name - name to use for the new material.
  119398. */
  119399. clone(name: string): PBRMetallicRoughnessMaterial;
  119400. /**
  119401. * Serialize the material to a parsable JSON object.
  119402. */
  119403. serialize(): any;
  119404. /**
  119405. * Parses a JSON object correponding to the serialize function.
  119406. */
  119407. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  119408. }
  119409. }
  119410. declare module BABYLON {
  119411. /**
  119412. * The PBR material of BJS following the specular glossiness convention.
  119413. *
  119414. * This fits to the PBR convention in the GLTF definition:
  119415. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  119416. */
  119417. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  119418. /**
  119419. * Specifies the diffuse color of the material.
  119420. */
  119421. diffuseColor: Color3;
  119422. /**
  119423. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  119424. * channel.
  119425. */
  119426. diffuseTexture: BaseTexture;
  119427. /**
  119428. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  119429. */
  119430. specularColor: Color3;
  119431. /**
  119432. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  119433. */
  119434. glossiness: number;
  119435. /**
  119436. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  119437. */
  119438. specularGlossinessTexture: BaseTexture;
  119439. /**
  119440. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  119441. *
  119442. * @param name The material name
  119443. * @param scene The scene the material will be use in.
  119444. */
  119445. constructor(name: string, scene: Scene);
  119446. /**
  119447. * Return the currrent class name of the material.
  119448. */
  119449. getClassName(): string;
  119450. /**
  119451. * Makes a duplicate of the current material.
  119452. * @param name - name to use for the new material.
  119453. */
  119454. clone(name: string): PBRSpecularGlossinessMaterial;
  119455. /**
  119456. * Serialize the material to a parsable JSON object.
  119457. */
  119458. serialize(): any;
  119459. /**
  119460. * Parses a JSON object correponding to the serialize function.
  119461. */
  119462. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  119463. }
  119464. }
  119465. declare module BABYLON {
  119466. /**
  119467. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  119468. * It can help converting any input color in a desired output one. This can then be used to create effects
  119469. * from sepia, black and white to sixties or futuristic rendering...
  119470. *
  119471. * The only supported format is currently 3dl.
  119472. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  119473. */
  119474. export class ColorGradingTexture extends BaseTexture {
  119475. /**
  119476. * The current texture matrix. (will always be identity in color grading texture)
  119477. */
  119478. private _textureMatrix;
  119479. /**
  119480. * The texture URL.
  119481. */
  119482. url: string;
  119483. /**
  119484. * Empty line regex stored for GC.
  119485. */
  119486. private static _noneEmptyLineRegex;
  119487. private _engine;
  119488. /**
  119489. * Instantiates a ColorGradingTexture from the following parameters.
  119490. *
  119491. * @param url The location of the color gradind data (currently only supporting 3dl)
  119492. * @param scene The scene the texture will be used in
  119493. */
  119494. constructor(url: string, scene: Scene);
  119495. /**
  119496. * Returns the texture matrix used in most of the material.
  119497. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  119498. */
  119499. getTextureMatrix(): Matrix;
  119500. /**
  119501. * Occurs when the file being loaded is a .3dl LUT file.
  119502. */
  119503. private load3dlTexture;
  119504. /**
  119505. * Starts the loading process of the texture.
  119506. */
  119507. private loadTexture;
  119508. /**
  119509. * Clones the color gradind texture.
  119510. */
  119511. clone(): ColorGradingTexture;
  119512. /**
  119513. * Called during delayed load for textures.
  119514. */
  119515. delayLoad(): void;
  119516. /**
  119517. * Parses a color grading texture serialized by Babylon.
  119518. * @param parsedTexture The texture information being parsedTexture
  119519. * @param scene The scene to load the texture in
  119520. * @param rootUrl The root url of the data assets to load
  119521. * @return A color gradind texture
  119522. */
  119523. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  119524. /**
  119525. * Serializes the LUT texture to json format.
  119526. */
  119527. serialize(): any;
  119528. }
  119529. }
  119530. declare module BABYLON {
  119531. /**
  119532. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  119533. */
  119534. export class EquiRectangularCubeTexture extends BaseTexture {
  119535. /** The six faces of the cube. */
  119536. private static _FacesMapping;
  119537. private _noMipmap;
  119538. private _onLoad;
  119539. private _onError;
  119540. /** The size of the cubemap. */
  119541. private _size;
  119542. /** The buffer of the image. */
  119543. private _buffer;
  119544. /** The width of the input image. */
  119545. private _width;
  119546. /** The height of the input image. */
  119547. private _height;
  119548. /** The URL to the image. */
  119549. url: string;
  119550. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  119551. coordinatesMode: number;
  119552. /**
  119553. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  119554. * @param url The location of the image
  119555. * @param scene The scene the texture will be used in
  119556. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119557. * @param noMipmap Forces to not generate the mipmap if true
  119558. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  119559. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  119560. * @param onLoad — defines a callback called when texture is loaded
  119561. * @param onError — defines a callback called if there is an error
  119562. */
  119563. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  119564. /**
  119565. * Load the image data, by putting the image on a canvas and extracting its buffer.
  119566. */
  119567. private loadImage;
  119568. /**
  119569. * Convert the image buffer into a cubemap and create a CubeTexture.
  119570. */
  119571. private loadTexture;
  119572. /**
  119573. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  119574. * @param buffer The ArrayBuffer that should be converted.
  119575. * @returns The buffer as Float32Array.
  119576. */
  119577. private getFloat32ArrayFromArrayBuffer;
  119578. /**
  119579. * Get the current class name of the texture useful for serialization or dynamic coding.
  119580. * @returns "EquiRectangularCubeTexture"
  119581. */
  119582. getClassName(): string;
  119583. /**
  119584. * Create a clone of the current EquiRectangularCubeTexture and return it.
  119585. * @returns A clone of the current EquiRectangularCubeTexture.
  119586. */
  119587. clone(): EquiRectangularCubeTexture;
  119588. }
  119589. }
  119590. declare module BABYLON {
  119591. /**
  119592. * Based on jsTGALoader - Javascript loader for TGA file
  119593. * By Vincent Thibault
  119594. * @see http://blog.robrowser.com/javascript-tga-loader.html
  119595. */
  119596. export class TGATools {
  119597. private static _TYPE_INDEXED;
  119598. private static _TYPE_RGB;
  119599. private static _TYPE_GREY;
  119600. private static _TYPE_RLE_INDEXED;
  119601. private static _TYPE_RLE_RGB;
  119602. private static _TYPE_RLE_GREY;
  119603. private static _ORIGIN_MASK;
  119604. private static _ORIGIN_SHIFT;
  119605. private static _ORIGIN_BL;
  119606. private static _ORIGIN_BR;
  119607. private static _ORIGIN_UL;
  119608. private static _ORIGIN_UR;
  119609. /**
  119610. * Gets the header of a TGA file
  119611. * @param data defines the TGA data
  119612. * @returns the header
  119613. */
  119614. static GetTGAHeader(data: Uint8Array): any;
  119615. /**
  119616. * Uploads TGA content to a Babylon Texture
  119617. * @hidden
  119618. */
  119619. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  119620. /** @hidden */
  119621. 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;
  119622. /** @hidden */
  119623. 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;
  119624. /** @hidden */
  119625. 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;
  119626. /** @hidden */
  119627. 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;
  119628. /** @hidden */
  119629. 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;
  119630. /** @hidden */
  119631. 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;
  119632. }
  119633. }
  119634. declare module BABYLON {
  119635. /**
  119636. * Implementation of the TGA Texture Loader.
  119637. * @hidden
  119638. */
  119639. export class _TGATextureLoader implements IInternalTextureLoader {
  119640. /**
  119641. * Defines wether the loader supports cascade loading the different faces.
  119642. */
  119643. readonly supportCascades: boolean;
  119644. /**
  119645. * This returns if the loader support the current file information.
  119646. * @param extension defines the file extension of the file being loaded
  119647. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119648. * @param fallback defines the fallback internal texture if any
  119649. * @param isBase64 defines whether the texture is encoded as a base64
  119650. * @param isBuffer defines whether the texture data are stored as a buffer
  119651. * @returns true if the loader can load the specified file
  119652. */
  119653. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119654. /**
  119655. * Transform the url before loading if required.
  119656. * @param rootUrl the url of the texture
  119657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119658. * @returns the transformed texture
  119659. */
  119660. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119661. /**
  119662. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119663. * @param rootUrl the url of the texture
  119664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119665. * @returns the fallback texture
  119666. */
  119667. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119668. /**
  119669. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119670. * @param data contains the texture data
  119671. * @param texture defines the BabylonJS internal texture
  119672. * @param createPolynomials will be true if polynomials have been requested
  119673. * @param onLoad defines the callback to trigger once the texture is ready
  119674. * @param onError defines the callback to trigger in case of error
  119675. */
  119676. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119677. /**
  119678. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119679. * @param data contains the texture data
  119680. * @param texture defines the BabylonJS internal texture
  119681. * @param callback defines the method to call once ready to upload
  119682. */
  119683. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119684. }
  119685. }
  119686. declare module BABYLON {
  119687. /**
  119688. * Info about the .basis files
  119689. */
  119690. class BasisFileInfo {
  119691. /**
  119692. * If the file has alpha
  119693. */
  119694. hasAlpha: boolean;
  119695. /**
  119696. * Info about each image of the basis file
  119697. */
  119698. images: Array<{
  119699. levels: Array<{
  119700. width: number;
  119701. height: number;
  119702. transcodedPixels: ArrayBufferView;
  119703. }>;
  119704. }>;
  119705. }
  119706. /**
  119707. * Result of transcoding a basis file
  119708. */
  119709. class TranscodeResult {
  119710. /**
  119711. * Info about the .basis file
  119712. */
  119713. fileInfo: BasisFileInfo;
  119714. /**
  119715. * Format to use when loading the file
  119716. */
  119717. format: number;
  119718. }
  119719. /**
  119720. * Configuration options for the Basis transcoder
  119721. */
  119722. export class BasisTranscodeConfiguration {
  119723. /**
  119724. * Supported compression formats used to determine the supported output format of the transcoder
  119725. */
  119726. supportedCompressionFormats?: {
  119727. /**
  119728. * etc1 compression format
  119729. */
  119730. etc1?: boolean;
  119731. /**
  119732. * s3tc compression format
  119733. */
  119734. s3tc?: boolean;
  119735. /**
  119736. * pvrtc compression format
  119737. */
  119738. pvrtc?: boolean;
  119739. /**
  119740. * etc2 compression format
  119741. */
  119742. etc2?: boolean;
  119743. };
  119744. /**
  119745. * If mipmap levels should be loaded for transcoded images (Default: true)
  119746. */
  119747. loadMipmapLevels?: boolean;
  119748. /**
  119749. * Index of a single image to load (Default: all images)
  119750. */
  119751. loadSingleImage?: number;
  119752. }
  119753. /**
  119754. * Used to load .Basis files
  119755. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  119756. */
  119757. export class BasisTools {
  119758. private static _IgnoreSupportedFormats;
  119759. /**
  119760. * URL to use when loading the basis transcoder
  119761. */
  119762. static JSModuleURL: string;
  119763. /**
  119764. * URL to use when loading the wasm module for the transcoder
  119765. */
  119766. static WasmModuleURL: string;
  119767. /**
  119768. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119769. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119770. * @returns internal format corresponding to the Basis format
  119771. */
  119772. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119773. private static _WorkerPromise;
  119774. private static _Worker;
  119775. private static _actionId;
  119776. private static _CreateWorkerAsync;
  119777. /**
  119778. * Transcodes a loaded image file to compressed pixel data
  119779. * @param imageData image data to transcode
  119780. * @param config configuration options for the transcoding
  119781. * @returns a promise resulting in the transcoded image
  119782. */
  119783. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119784. /**
  119785. * Loads a texture from the transcode result
  119786. * @param texture texture load to
  119787. * @param transcodeResult the result of transcoding the basis file to load from
  119788. */
  119789. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119790. }
  119791. }
  119792. declare module BABYLON {
  119793. /**
  119794. * Loader for .basis file format
  119795. */
  119796. export class _BasisTextureLoader implements IInternalTextureLoader {
  119797. /**
  119798. * Defines whether the loader supports cascade loading the different faces.
  119799. */
  119800. readonly supportCascades: boolean;
  119801. /**
  119802. * This returns if the loader support the current file information.
  119803. * @param extension defines the file extension of the file being loaded
  119804. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119805. * @param fallback defines the fallback internal texture if any
  119806. * @param isBase64 defines whether the texture is encoded as a base64
  119807. * @param isBuffer defines whether the texture data are stored as a buffer
  119808. * @returns true if the loader can load the specified file
  119809. */
  119810. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119811. /**
  119812. * Transform the url before loading if required.
  119813. * @param rootUrl the url of the texture
  119814. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119815. * @returns the transformed texture
  119816. */
  119817. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119818. /**
  119819. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119820. * @param rootUrl the url of the texture
  119821. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119822. * @returns the fallback texture
  119823. */
  119824. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119825. /**
  119826. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119827. * @param data contains the texture data
  119828. * @param texture defines the BabylonJS internal texture
  119829. * @param createPolynomials will be true if polynomials have been requested
  119830. * @param onLoad defines the callback to trigger once the texture is ready
  119831. * @param onError defines the callback to trigger in case of error
  119832. */
  119833. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119834. /**
  119835. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119836. * @param data contains the texture data
  119837. * @param texture defines the BabylonJS internal texture
  119838. * @param callback defines the method to call once ready to upload
  119839. */
  119840. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119841. }
  119842. }
  119843. declare module BABYLON {
  119844. /**
  119845. * 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.
  119846. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119847. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119848. */
  119849. export class CustomProceduralTexture extends ProceduralTexture {
  119850. private _animate;
  119851. private _time;
  119852. private _config;
  119853. private _texturePath;
  119854. /**
  119855. * Instantiates a new Custom Procedural Texture.
  119856. * 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.
  119857. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119858. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119859. * @param name Define the name of the texture
  119860. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119861. * @param size Define the size of the texture to create
  119862. * @param scene Define the scene the texture belongs to
  119863. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119864. * @param generateMipMaps Define if the texture should creates mip maps or not
  119865. */
  119866. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119867. private _loadJson;
  119868. /**
  119869. * Is the texture ready to be used ? (rendered at least once)
  119870. * @returns true if ready, otherwise, false.
  119871. */
  119872. isReady(): boolean;
  119873. /**
  119874. * Render the texture to its associated render target.
  119875. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119876. */
  119877. render(useCameraPostProcess?: boolean): void;
  119878. /**
  119879. * Update the list of dependant textures samplers in the shader.
  119880. */
  119881. updateTextures(): void;
  119882. /**
  119883. * Update the uniform values of the procedural texture in the shader.
  119884. */
  119885. updateShaderUniforms(): void;
  119886. /**
  119887. * Define if the texture animates or not.
  119888. */
  119889. animate: boolean;
  119890. }
  119891. }
  119892. declare module BABYLON {
  119893. /** @hidden */
  119894. export var noisePixelShader: {
  119895. name: string;
  119896. shader: string;
  119897. };
  119898. }
  119899. declare module BABYLON {
  119900. /**
  119901. * Class used to generate noise procedural textures
  119902. */
  119903. export class NoiseProceduralTexture extends ProceduralTexture {
  119904. private _time;
  119905. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119906. brightness: number;
  119907. /** Defines the number of octaves to process */
  119908. octaves: number;
  119909. /** Defines the level of persistence (0.8 by default) */
  119910. persistence: number;
  119911. /** Gets or sets animation speed factor (default is 1) */
  119912. animationSpeedFactor: number;
  119913. /**
  119914. * Creates a new NoiseProceduralTexture
  119915. * @param name defines the name fo the texture
  119916. * @param size defines the size of the texture (default is 256)
  119917. * @param scene defines the hosting scene
  119918. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119919. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119920. */
  119921. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119922. private _updateShaderUniforms;
  119923. protected _getDefines(): string;
  119924. /** Generate the current state of the procedural texture */
  119925. render(useCameraPostProcess?: boolean): void;
  119926. /**
  119927. * Serializes this noise procedural texture
  119928. * @returns a serialized noise procedural texture object
  119929. */
  119930. serialize(): any;
  119931. /**
  119932. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119933. * @param parsedTexture defines parsed texture data
  119934. * @param scene defines the current scene
  119935. * @param rootUrl defines the root URL containing noise procedural texture information
  119936. * @returns a parsed NoiseProceduralTexture
  119937. */
  119938. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119939. }
  119940. }
  119941. declare module BABYLON {
  119942. /**
  119943. * Raw cube texture where the raw buffers are passed in
  119944. */
  119945. export class RawCubeTexture extends CubeTexture {
  119946. /**
  119947. * Creates a cube texture where the raw buffers are passed in.
  119948. * @param scene defines the scene the texture is attached to
  119949. * @param data defines the array of data to use to create each face
  119950. * @param size defines the size of the textures
  119951. * @param format defines the format of the data
  119952. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119953. * @param generateMipMaps defines if the engine should generate the mip levels
  119954. * @param invertY defines if data must be stored with Y axis inverted
  119955. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119956. * @param compression defines the compression used (null by default)
  119957. */
  119958. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119959. /**
  119960. * Updates the raw cube texture.
  119961. * @param data defines the data to store
  119962. * @param format defines the data format
  119963. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119964. * @param invertY defines if data must be stored with Y axis inverted
  119965. * @param compression defines the compression used (null by default)
  119966. * @param level defines which level of the texture to update
  119967. */
  119968. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119969. /**
  119970. * Updates a raw cube texture with RGBD encoded data.
  119971. * @param data defines the array of data [mipmap][face] to use to create each face
  119972. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119973. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119974. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119975. * @returns a promsie that resolves when the operation is complete
  119976. */
  119977. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119978. /**
  119979. * Clones the raw cube texture.
  119980. * @return a new cube texture
  119981. */
  119982. clone(): CubeTexture;
  119983. /** @hidden */
  119984. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119985. }
  119986. }
  119987. declare module BABYLON {
  119988. /**
  119989. * Class used to store 3D textures containing user data
  119990. */
  119991. export class RawTexture3D extends Texture {
  119992. /** Gets or sets the texture format to use */
  119993. format: number;
  119994. private _engine;
  119995. /**
  119996. * Create a new RawTexture3D
  119997. * @param data defines the data of the texture
  119998. * @param width defines the width of the texture
  119999. * @param height defines the height of the texture
  120000. * @param depth defines the depth of the texture
  120001. * @param format defines the texture format to use
  120002. * @param scene defines the hosting scene
  120003. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  120004. * @param invertY defines if texture must be stored with Y axis inverted
  120005. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120006. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  120007. */
  120008. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  120009. /** Gets or sets the texture format to use */
  120010. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  120011. /**
  120012. * Update the texture with new data
  120013. * @param data defines the data to store in the texture
  120014. */
  120015. update(data: ArrayBufferView): void;
  120016. }
  120017. }
  120018. declare module BABYLON {
  120019. /**
  120020. * Creates a refraction texture used by refraction channel of the standard material.
  120021. * It is like a mirror but to see through a material.
  120022. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120023. */
  120024. export class RefractionTexture extends RenderTargetTexture {
  120025. /**
  120026. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  120027. * 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.
  120028. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120029. */
  120030. refractionPlane: Plane;
  120031. /**
  120032. * Define how deep under the surface we should see.
  120033. */
  120034. depth: number;
  120035. /**
  120036. * Creates a refraction texture used by refraction channel of the standard material.
  120037. * It is like a mirror but to see through a material.
  120038. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120039. * @param name Define the texture name
  120040. * @param size Define the size of the underlying texture
  120041. * @param scene Define the scene the refraction belongs to
  120042. * @param generateMipMaps Define if we need to generate mips level for the refraction
  120043. */
  120044. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  120045. /**
  120046. * Clone the refraction texture.
  120047. * @returns the cloned texture
  120048. */
  120049. clone(): RefractionTexture;
  120050. /**
  120051. * Serialize the texture to a JSON representation you could use in Parse later on
  120052. * @returns the serialized JSON representation
  120053. */
  120054. serialize(): any;
  120055. }
  120056. }
  120057. declare module BABYLON {
  120058. /**
  120059. * Defines the options related to the creation of an HtmlElementTexture
  120060. */
  120061. export interface IHtmlElementTextureOptions {
  120062. /**
  120063. * Defines wether mip maps should be created or not.
  120064. */
  120065. generateMipMaps?: boolean;
  120066. /**
  120067. * Defines the sampling mode of the texture.
  120068. */
  120069. samplingMode?: number;
  120070. /**
  120071. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  120072. */
  120073. engine: Nullable<ThinEngine>;
  120074. /**
  120075. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  120076. */
  120077. scene: Nullable<Scene>;
  120078. }
  120079. /**
  120080. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  120081. * To be as efficient as possible depending on your constraints nothing aside the first upload
  120082. * is automatically managed.
  120083. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  120084. * in your application.
  120085. *
  120086. * As the update is not automatic, you need to call them manually.
  120087. */
  120088. export class HtmlElementTexture extends BaseTexture {
  120089. /**
  120090. * The texture URL.
  120091. */
  120092. element: HTMLVideoElement | HTMLCanvasElement;
  120093. private static readonly DefaultOptions;
  120094. private _textureMatrix;
  120095. private _engine;
  120096. private _isVideo;
  120097. private _generateMipMaps;
  120098. private _samplingMode;
  120099. /**
  120100. * Instantiates a HtmlElementTexture from the following parameters.
  120101. *
  120102. * @param name Defines the name of the texture
  120103. * @param element Defines the video or canvas the texture is filled with
  120104. * @param options Defines the other none mandatory texture creation options
  120105. */
  120106. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  120107. private _createInternalTexture;
  120108. /**
  120109. * Returns the texture matrix used in most of the material.
  120110. */
  120111. getTextureMatrix(): Matrix;
  120112. /**
  120113. * Updates the content of the texture.
  120114. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  120115. */
  120116. update(invertY?: Nullable<boolean>): void;
  120117. }
  120118. }
  120119. declare module BABYLON {
  120120. /**
  120121. * Enum used to define the target of a block
  120122. */
  120123. export enum NodeMaterialBlockTargets {
  120124. /** Vertex shader */
  120125. Vertex = 1,
  120126. /** Fragment shader */
  120127. Fragment = 2,
  120128. /** Neutral */
  120129. Neutral = 4,
  120130. /** Vertex and Fragment */
  120131. VertexAndFragment = 3
  120132. }
  120133. }
  120134. declare module BABYLON {
  120135. /**
  120136. * Defines the kind of connection point for node based material
  120137. */
  120138. export enum NodeMaterialBlockConnectionPointTypes {
  120139. /** Float */
  120140. Float = 1,
  120141. /** Int */
  120142. Int = 2,
  120143. /** Vector2 */
  120144. Vector2 = 4,
  120145. /** Vector3 */
  120146. Vector3 = 8,
  120147. /** Vector4 */
  120148. Vector4 = 16,
  120149. /** Color3 */
  120150. Color3 = 32,
  120151. /** Color4 */
  120152. Color4 = 64,
  120153. /** Matrix */
  120154. Matrix = 128,
  120155. /** Detect type based on connection */
  120156. AutoDetect = 1024,
  120157. /** Output type that will be defined by input type */
  120158. BasedOnInput = 2048
  120159. }
  120160. }
  120161. declare module BABYLON {
  120162. /**
  120163. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  120164. */
  120165. export enum NodeMaterialBlockConnectionPointMode {
  120166. /** Value is an uniform */
  120167. Uniform = 0,
  120168. /** Value is a mesh attribute */
  120169. Attribute = 1,
  120170. /** Value is a varying between vertex and fragment shaders */
  120171. Varying = 2,
  120172. /** Mode is undefined */
  120173. Undefined = 3
  120174. }
  120175. }
  120176. declare module BABYLON {
  120177. /**
  120178. * Enum used to define system values e.g. values automatically provided by the system
  120179. */
  120180. export enum NodeMaterialSystemValues {
  120181. /** World */
  120182. World = 1,
  120183. /** View */
  120184. View = 2,
  120185. /** Projection */
  120186. Projection = 3,
  120187. /** ViewProjection */
  120188. ViewProjection = 4,
  120189. /** WorldView */
  120190. WorldView = 5,
  120191. /** WorldViewProjection */
  120192. WorldViewProjection = 6,
  120193. /** CameraPosition */
  120194. CameraPosition = 7,
  120195. /** Fog Color */
  120196. FogColor = 8,
  120197. /** Delta time */
  120198. DeltaTime = 9
  120199. }
  120200. }
  120201. declare module BABYLON {
  120202. /**
  120203. * Root class for all node material optimizers
  120204. */
  120205. export class NodeMaterialOptimizer {
  120206. /**
  120207. * Function used to optimize a NodeMaterial graph
  120208. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  120209. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  120210. */
  120211. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  120212. }
  120213. }
  120214. declare module BABYLON {
  120215. /**
  120216. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  120217. */
  120218. export class TransformBlock extends NodeMaterialBlock {
  120219. /**
  120220. * Defines the value to use to complement W value to transform it to a Vector4
  120221. */
  120222. complementW: number;
  120223. /**
  120224. * Defines the value to use to complement z value to transform it to a Vector4
  120225. */
  120226. complementZ: number;
  120227. /**
  120228. * Creates a new TransformBlock
  120229. * @param name defines the block name
  120230. */
  120231. constructor(name: string);
  120232. /**
  120233. * Gets the current class name
  120234. * @returns the class name
  120235. */
  120236. getClassName(): string;
  120237. /**
  120238. * Gets the vector input
  120239. */
  120240. readonly vector: NodeMaterialConnectionPoint;
  120241. /**
  120242. * Gets the output component
  120243. */
  120244. readonly output: NodeMaterialConnectionPoint;
  120245. /**
  120246. * Gets the matrix transform input
  120247. */
  120248. readonly transform: NodeMaterialConnectionPoint;
  120249. protected _buildBlock(state: NodeMaterialBuildState): this;
  120250. serialize(): any;
  120251. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120252. protected _dumpPropertiesCode(): string;
  120253. }
  120254. }
  120255. declare module BABYLON {
  120256. /**
  120257. * Block used to output the vertex position
  120258. */
  120259. export class VertexOutputBlock extends NodeMaterialBlock {
  120260. /**
  120261. * Creates a new VertexOutputBlock
  120262. * @param name defines the block name
  120263. */
  120264. constructor(name: string);
  120265. /**
  120266. * Gets the current class name
  120267. * @returns the class name
  120268. */
  120269. getClassName(): string;
  120270. /**
  120271. * Gets the vector input component
  120272. */
  120273. readonly vector: NodeMaterialConnectionPoint;
  120274. protected _buildBlock(state: NodeMaterialBuildState): this;
  120275. }
  120276. }
  120277. declare module BABYLON {
  120278. /**
  120279. * Block used to output the final color
  120280. */
  120281. export class FragmentOutputBlock extends NodeMaterialBlock {
  120282. /**
  120283. * Create a new FragmentOutputBlock
  120284. * @param name defines the block name
  120285. */
  120286. constructor(name: string);
  120287. /**
  120288. * Gets the current class name
  120289. * @returns the class name
  120290. */
  120291. getClassName(): string;
  120292. /**
  120293. * Gets the rgba input component
  120294. */
  120295. readonly rgba: NodeMaterialConnectionPoint;
  120296. /**
  120297. * Gets the rgb input component
  120298. */
  120299. readonly rgb: NodeMaterialConnectionPoint;
  120300. /**
  120301. * Gets the a input component
  120302. */
  120303. readonly a: NodeMaterialConnectionPoint;
  120304. protected _buildBlock(state: NodeMaterialBuildState): this;
  120305. }
  120306. }
  120307. declare module BABYLON {
  120308. /**
  120309. * Block used to read a reflection texture from a sampler
  120310. */
  120311. export class ReflectionTextureBlock extends NodeMaterialBlock {
  120312. private _define3DName;
  120313. private _defineCubicName;
  120314. private _defineExplicitName;
  120315. private _defineProjectionName;
  120316. private _defineLocalCubicName;
  120317. private _defineSphericalName;
  120318. private _definePlanarName;
  120319. private _defineEquirectangularName;
  120320. private _defineMirroredEquirectangularFixedName;
  120321. private _defineEquirectangularFixedName;
  120322. private _defineSkyboxName;
  120323. private _cubeSamplerName;
  120324. private _2DSamplerName;
  120325. private _positionUVWName;
  120326. private _directionWName;
  120327. private _reflectionCoordsName;
  120328. private _reflection2DCoordsName;
  120329. private _reflectionColorName;
  120330. private _reflectionMatrixName;
  120331. /**
  120332. * Gets or sets the texture associated with the node
  120333. */
  120334. texture: Nullable<BaseTexture>;
  120335. /**
  120336. * Create a new TextureBlock
  120337. * @param name defines the block name
  120338. */
  120339. constructor(name: string);
  120340. /**
  120341. * Gets the current class name
  120342. * @returns the class name
  120343. */
  120344. getClassName(): string;
  120345. /**
  120346. * Gets the world position input component
  120347. */
  120348. readonly position: NodeMaterialConnectionPoint;
  120349. /**
  120350. * Gets the world position input component
  120351. */
  120352. readonly worldPosition: NodeMaterialConnectionPoint;
  120353. /**
  120354. * Gets the world normal input component
  120355. */
  120356. readonly worldNormal: NodeMaterialConnectionPoint;
  120357. /**
  120358. * Gets the world input component
  120359. */
  120360. readonly world: NodeMaterialConnectionPoint;
  120361. /**
  120362. * Gets the camera (or eye) position component
  120363. */
  120364. readonly cameraPosition: NodeMaterialConnectionPoint;
  120365. /**
  120366. * Gets the view input component
  120367. */
  120368. readonly view: NodeMaterialConnectionPoint;
  120369. /**
  120370. * Gets the rgb output component
  120371. */
  120372. readonly rgb: NodeMaterialConnectionPoint;
  120373. /**
  120374. * Gets the r output component
  120375. */
  120376. readonly r: NodeMaterialConnectionPoint;
  120377. /**
  120378. * Gets the g output component
  120379. */
  120380. readonly g: NodeMaterialConnectionPoint;
  120381. /**
  120382. * Gets the b output component
  120383. */
  120384. readonly b: NodeMaterialConnectionPoint;
  120385. autoConfigure(material: NodeMaterial): void;
  120386. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120387. isReady(): boolean;
  120388. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120389. private _injectVertexCode;
  120390. private _writeOutput;
  120391. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120392. serialize(): any;
  120393. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120394. }
  120395. }
  120396. declare module BABYLON {
  120397. /**
  120398. * Interface used to configure the node material editor
  120399. */
  120400. export interface INodeMaterialEditorOptions {
  120401. /** Define the URl to load node editor script */
  120402. editorURL?: string;
  120403. }
  120404. /** @hidden */
  120405. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  120406. /** BONES */
  120407. NUM_BONE_INFLUENCERS: number;
  120408. BonesPerMesh: number;
  120409. BONETEXTURE: boolean;
  120410. /** MORPH TARGETS */
  120411. MORPHTARGETS: boolean;
  120412. MORPHTARGETS_NORMAL: boolean;
  120413. MORPHTARGETS_TANGENT: boolean;
  120414. MORPHTARGETS_UV: boolean;
  120415. NUM_MORPH_INFLUENCERS: number;
  120416. /** IMAGE PROCESSING */
  120417. IMAGEPROCESSING: boolean;
  120418. VIGNETTE: boolean;
  120419. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120420. VIGNETTEBLENDMODEOPAQUE: boolean;
  120421. TONEMAPPING: boolean;
  120422. TONEMAPPING_ACES: boolean;
  120423. CONTRAST: boolean;
  120424. EXPOSURE: boolean;
  120425. COLORCURVES: boolean;
  120426. COLORGRADING: boolean;
  120427. COLORGRADING3D: boolean;
  120428. SAMPLER3DGREENDEPTH: boolean;
  120429. SAMPLER3DBGRMAP: boolean;
  120430. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120431. /** MISC. */
  120432. BUMPDIRECTUV: number;
  120433. constructor();
  120434. setValue(name: string, value: boolean): void;
  120435. }
  120436. /**
  120437. * Class used to configure NodeMaterial
  120438. */
  120439. export interface INodeMaterialOptions {
  120440. /**
  120441. * Defines if blocks should emit comments
  120442. */
  120443. emitComments: boolean;
  120444. }
  120445. /**
  120446. * Class used to create a node based material built by assembling shader blocks
  120447. */
  120448. export class NodeMaterial extends PushMaterial {
  120449. private static _BuildIdGenerator;
  120450. private _options;
  120451. private _vertexCompilationState;
  120452. private _fragmentCompilationState;
  120453. private _sharedData;
  120454. private _buildId;
  120455. private _buildWasSuccessful;
  120456. private _cachedWorldViewMatrix;
  120457. private _cachedWorldViewProjectionMatrix;
  120458. private _optimizers;
  120459. private _animationFrame;
  120460. /** Define the URl to load node editor script */
  120461. static EditorURL: string;
  120462. private BJSNODEMATERIALEDITOR;
  120463. /** Get the inspector from bundle or global */
  120464. private _getGlobalNodeMaterialEditor;
  120465. /**
  120466. * 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)
  120467. */
  120468. ignoreAlpha: boolean;
  120469. /**
  120470. * Defines the maximum number of lights that can be used in the material
  120471. */
  120472. maxSimultaneousLights: number;
  120473. /**
  120474. * Observable raised when the material is built
  120475. */
  120476. onBuildObservable: Observable<NodeMaterial>;
  120477. /**
  120478. * Gets or sets the root nodes of the material vertex shader
  120479. */
  120480. _vertexOutputNodes: NodeMaterialBlock[];
  120481. /**
  120482. * Gets or sets the root nodes of the material fragment (pixel) shader
  120483. */
  120484. _fragmentOutputNodes: NodeMaterialBlock[];
  120485. /** Gets or sets options to control the node material overall behavior */
  120486. options: INodeMaterialOptions;
  120487. /**
  120488. * Default configuration related to image processing available in the standard Material.
  120489. */
  120490. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120491. /**
  120492. * Gets the image processing configuration used either in this material.
  120493. */
  120494. /**
  120495. * Sets the Default image processing configuration used either in the this material.
  120496. *
  120497. * If sets to null, the scene one is in use.
  120498. */
  120499. imageProcessingConfiguration: ImageProcessingConfiguration;
  120500. /**
  120501. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  120502. */
  120503. attachedBlocks: NodeMaterialBlock[];
  120504. /**
  120505. * Create a new node based material
  120506. * @param name defines the material name
  120507. * @param scene defines the hosting scene
  120508. * @param options defines creation option
  120509. */
  120510. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  120511. /**
  120512. * Gets the current class name of the material e.g. "NodeMaterial"
  120513. * @returns the class name
  120514. */
  120515. getClassName(): string;
  120516. /**
  120517. * Keep track of the image processing observer to allow dispose and replace.
  120518. */
  120519. private _imageProcessingObserver;
  120520. /**
  120521. * Attaches a new image processing configuration to the Standard Material.
  120522. * @param configuration
  120523. */
  120524. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120525. /**
  120526. * Get a block by its name
  120527. * @param name defines the name of the block to retrieve
  120528. * @returns the required block or null if not found
  120529. */
  120530. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  120531. /**
  120532. * Get a block by its name
  120533. * @param predicate defines the predicate used to find the good candidate
  120534. * @returns the required block or null if not found
  120535. */
  120536. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  120537. /**
  120538. * Get an input block by its name
  120539. * @param predicate defines the predicate used to find the good candidate
  120540. * @returns the required input block or null if not found
  120541. */
  120542. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  120543. /**
  120544. * Gets the list of input blocks attached to this material
  120545. * @returns an array of InputBlocks
  120546. */
  120547. getInputBlocks(): InputBlock[];
  120548. /**
  120549. * Adds a new optimizer to the list of optimizers
  120550. * @param optimizer defines the optimizers to add
  120551. * @returns the current material
  120552. */
  120553. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120554. /**
  120555. * Remove an optimizer from the list of optimizers
  120556. * @param optimizer defines the optimizers to remove
  120557. * @returns the current material
  120558. */
  120559. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120560. /**
  120561. * Add a new block to the list of output nodes
  120562. * @param node defines the node to add
  120563. * @returns the current material
  120564. */
  120565. addOutputNode(node: NodeMaterialBlock): this;
  120566. /**
  120567. * Remove a block from the list of root nodes
  120568. * @param node defines the node to remove
  120569. * @returns the current material
  120570. */
  120571. removeOutputNode(node: NodeMaterialBlock): this;
  120572. private _addVertexOutputNode;
  120573. private _removeVertexOutputNode;
  120574. private _addFragmentOutputNode;
  120575. private _removeFragmentOutputNode;
  120576. /**
  120577. * Specifies if the material will require alpha blending
  120578. * @returns a boolean specifying if alpha blending is needed
  120579. */
  120580. needAlphaBlending(): boolean;
  120581. /**
  120582. * Specifies if this material should be rendered in alpha test mode
  120583. * @returns a boolean specifying if an alpha test is needed.
  120584. */
  120585. needAlphaTesting(): boolean;
  120586. private _initializeBlock;
  120587. private _resetDualBlocks;
  120588. /**
  120589. * Build the material and generates the inner effect
  120590. * @param verbose defines if the build should log activity
  120591. */
  120592. build(verbose?: boolean): void;
  120593. /**
  120594. * Runs an otpimization phase to try to improve the shader code
  120595. */
  120596. optimize(): void;
  120597. private _prepareDefinesForAttributes;
  120598. /**
  120599. * Get if the submesh is ready to be used and all its information available.
  120600. * Child classes can use it to update shaders
  120601. * @param mesh defines the mesh to check
  120602. * @param subMesh defines which submesh to check
  120603. * @param useInstances specifies that instances should be used
  120604. * @returns a boolean indicating that the submesh is ready or not
  120605. */
  120606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120607. /**
  120608. * Get a string representing the shaders built by the current node graph
  120609. */
  120610. readonly compiledShaders: string;
  120611. /**
  120612. * Binds the world matrix to the material
  120613. * @param world defines the world transformation matrix
  120614. */
  120615. bindOnlyWorldMatrix(world: Matrix): void;
  120616. /**
  120617. * Binds the submesh to this material by preparing the effect and shader to draw
  120618. * @param world defines the world transformation matrix
  120619. * @param mesh defines the mesh containing the submesh
  120620. * @param subMesh defines the submesh to bind the material to
  120621. */
  120622. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120623. /**
  120624. * Gets the active textures from the material
  120625. * @returns an array of textures
  120626. */
  120627. getActiveTextures(): BaseTexture[];
  120628. /**
  120629. * Gets the list of texture blocks
  120630. * @returns an array of texture blocks
  120631. */
  120632. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  120633. /**
  120634. * Specifies if the material uses a texture
  120635. * @param texture defines the texture to check against the material
  120636. * @returns a boolean specifying if the material uses the texture
  120637. */
  120638. hasTexture(texture: BaseTexture): boolean;
  120639. /**
  120640. * Disposes the material
  120641. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  120642. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  120643. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  120644. */
  120645. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  120646. /** Creates the node editor window. */
  120647. private _createNodeEditor;
  120648. /**
  120649. * Launch the node material editor
  120650. * @param config Define the configuration of the editor
  120651. * @return a promise fulfilled when the node editor is visible
  120652. */
  120653. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  120654. /**
  120655. * Clear the current material
  120656. */
  120657. clear(): void;
  120658. /**
  120659. * Clear the current material and set it to a default state
  120660. */
  120661. setToDefault(): void;
  120662. /**
  120663. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  120664. * @param url defines the url to load from
  120665. * @returns a promise that will fullfil when the material is fully loaded
  120666. */
  120667. loadAsync(url: string): Promise<void>;
  120668. private _gatherBlocks;
  120669. /**
  120670. * Generate a string containing the code declaration required to create an equivalent of this material
  120671. * @returns a string
  120672. */
  120673. generateCode(): string;
  120674. /**
  120675. * Serializes this material in a JSON representation
  120676. * @returns the serialized material object
  120677. */
  120678. serialize(): any;
  120679. private _restoreConnections;
  120680. /**
  120681. * Clear the current graph and load a new one from a serialization object
  120682. * @param source defines the JSON representation of the material
  120683. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120684. */
  120685. loadFromSerialization(source: any, rootUrl?: string): void;
  120686. /**
  120687. * Creates a node material from parsed material data
  120688. * @param source defines the JSON representation of the material
  120689. * @param scene defines the hosting scene
  120690. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120691. * @returns a new node material
  120692. */
  120693. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  120694. /**
  120695. * Creates a new node material set to default basic configuration
  120696. * @param name defines the name of the material
  120697. * @param scene defines the hosting scene
  120698. * @returns a new NodeMaterial
  120699. */
  120700. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  120701. }
  120702. }
  120703. declare module BABYLON {
  120704. /**
  120705. * Block used to read a texture from a sampler
  120706. */
  120707. export class TextureBlock extends NodeMaterialBlock {
  120708. private _defineName;
  120709. private _linearDefineName;
  120710. private _samplerName;
  120711. private _transformedUVName;
  120712. private _textureTransformName;
  120713. private _textureInfoName;
  120714. private _mainUVName;
  120715. private _mainUVDefineName;
  120716. /**
  120717. * Gets or sets the texture associated with the node
  120718. */
  120719. texture: Nullable<Texture>;
  120720. /**
  120721. * Create a new TextureBlock
  120722. * @param name defines the block name
  120723. */
  120724. constructor(name: string);
  120725. /**
  120726. * Gets the current class name
  120727. * @returns the class name
  120728. */
  120729. getClassName(): string;
  120730. /**
  120731. * Gets the uv input component
  120732. */
  120733. readonly uv: NodeMaterialConnectionPoint;
  120734. /**
  120735. * Gets the rgba output component
  120736. */
  120737. readonly rgba: NodeMaterialConnectionPoint;
  120738. /**
  120739. * Gets the rgb output component
  120740. */
  120741. readonly rgb: NodeMaterialConnectionPoint;
  120742. /**
  120743. * Gets the r output component
  120744. */
  120745. readonly r: NodeMaterialConnectionPoint;
  120746. /**
  120747. * Gets the g output component
  120748. */
  120749. readonly g: NodeMaterialConnectionPoint;
  120750. /**
  120751. * Gets the b output component
  120752. */
  120753. readonly b: NodeMaterialConnectionPoint;
  120754. /**
  120755. * Gets the a output component
  120756. */
  120757. readonly a: NodeMaterialConnectionPoint;
  120758. readonly target: NodeMaterialBlockTargets;
  120759. autoConfigure(material: NodeMaterial): void;
  120760. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120762. isReady(): boolean;
  120763. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120764. private readonly _isMixed;
  120765. private _injectVertexCode;
  120766. private _writeOutput;
  120767. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120768. protected _dumpPropertiesCode(): string;
  120769. serialize(): any;
  120770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120771. }
  120772. }
  120773. declare module BABYLON {
  120774. /**
  120775. * Class used to store shared data between 2 NodeMaterialBuildState
  120776. */
  120777. export class NodeMaterialBuildStateSharedData {
  120778. /**
  120779. * Gets the list of emitted varyings
  120780. */
  120781. temps: string[];
  120782. /**
  120783. * Gets the list of emitted varyings
  120784. */
  120785. varyings: string[];
  120786. /**
  120787. * Gets the varying declaration string
  120788. */
  120789. varyingDeclaration: string;
  120790. /**
  120791. * Input blocks
  120792. */
  120793. inputBlocks: InputBlock[];
  120794. /**
  120795. * Input blocks
  120796. */
  120797. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120798. /**
  120799. * Bindable blocks (Blocks that need to set data to the effect)
  120800. */
  120801. bindableBlocks: NodeMaterialBlock[];
  120802. /**
  120803. * List of blocks that can provide a compilation fallback
  120804. */
  120805. blocksWithFallbacks: NodeMaterialBlock[];
  120806. /**
  120807. * List of blocks that can provide a define update
  120808. */
  120809. blocksWithDefines: NodeMaterialBlock[];
  120810. /**
  120811. * List of blocks that can provide a repeatable content
  120812. */
  120813. repeatableContentBlocks: NodeMaterialBlock[];
  120814. /**
  120815. * List of blocks that can provide a dynamic list of uniforms
  120816. */
  120817. dynamicUniformBlocks: NodeMaterialBlock[];
  120818. /**
  120819. * List of blocks that can block the isReady function for the material
  120820. */
  120821. blockingBlocks: NodeMaterialBlock[];
  120822. /**
  120823. * Gets the list of animated inputs
  120824. */
  120825. animatedInputs: InputBlock[];
  120826. /**
  120827. * Build Id used to avoid multiple recompilations
  120828. */
  120829. buildId: number;
  120830. /** List of emitted variables */
  120831. variableNames: {
  120832. [key: string]: number;
  120833. };
  120834. /** List of emitted defines */
  120835. defineNames: {
  120836. [key: string]: number;
  120837. };
  120838. /** Should emit comments? */
  120839. emitComments: boolean;
  120840. /** Emit build activity */
  120841. verbose: boolean;
  120842. /** Gets or sets the hosting scene */
  120843. scene: Scene;
  120844. /**
  120845. * Gets the compilation hints emitted at compilation time
  120846. */
  120847. hints: {
  120848. needWorldViewMatrix: boolean;
  120849. needWorldViewProjectionMatrix: boolean;
  120850. needAlphaBlending: boolean;
  120851. needAlphaTesting: boolean;
  120852. };
  120853. /**
  120854. * List of compilation checks
  120855. */
  120856. checks: {
  120857. emitVertex: boolean;
  120858. emitFragment: boolean;
  120859. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120860. };
  120861. /** Creates a new shared data */
  120862. constructor();
  120863. /**
  120864. * Emits console errors and exceptions if there is a failing check
  120865. */
  120866. emitErrors(): void;
  120867. }
  120868. }
  120869. declare module BABYLON {
  120870. /**
  120871. * Class used to store node based material build state
  120872. */
  120873. export class NodeMaterialBuildState {
  120874. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120875. supportUniformBuffers: boolean;
  120876. /**
  120877. * Gets the list of emitted attributes
  120878. */
  120879. attributes: string[];
  120880. /**
  120881. * Gets the list of emitted uniforms
  120882. */
  120883. uniforms: string[];
  120884. /**
  120885. * Gets the list of emitted constants
  120886. */
  120887. constants: string[];
  120888. /**
  120889. * Gets the list of emitted samplers
  120890. */
  120891. samplers: string[];
  120892. /**
  120893. * Gets the list of emitted functions
  120894. */
  120895. functions: {
  120896. [key: string]: string;
  120897. };
  120898. /**
  120899. * Gets the list of emitted extensions
  120900. */
  120901. extensions: {
  120902. [key: string]: string;
  120903. };
  120904. /**
  120905. * Gets the target of the compilation state
  120906. */
  120907. target: NodeMaterialBlockTargets;
  120908. /**
  120909. * Gets the list of emitted counters
  120910. */
  120911. counters: {
  120912. [key: string]: number;
  120913. };
  120914. /**
  120915. * Shared data between multiple NodeMaterialBuildState instances
  120916. */
  120917. sharedData: NodeMaterialBuildStateSharedData;
  120918. /** @hidden */
  120919. _vertexState: NodeMaterialBuildState;
  120920. /** @hidden */
  120921. _attributeDeclaration: string;
  120922. /** @hidden */
  120923. _uniformDeclaration: string;
  120924. /** @hidden */
  120925. _constantDeclaration: string;
  120926. /** @hidden */
  120927. _samplerDeclaration: string;
  120928. /** @hidden */
  120929. _varyingTransfer: string;
  120930. private _repeatableContentAnchorIndex;
  120931. /** @hidden */
  120932. _builtCompilationString: string;
  120933. /**
  120934. * Gets the emitted compilation strings
  120935. */
  120936. compilationString: string;
  120937. /**
  120938. * Finalize the compilation strings
  120939. * @param state defines the current compilation state
  120940. */
  120941. finalize(state: NodeMaterialBuildState): void;
  120942. /** @hidden */
  120943. readonly _repeatableContentAnchor: string;
  120944. /** @hidden */
  120945. _getFreeVariableName(prefix: string): string;
  120946. /** @hidden */
  120947. _getFreeDefineName(prefix: string): string;
  120948. /** @hidden */
  120949. _excludeVariableName(name: string): void;
  120950. /** @hidden */
  120951. _emit2DSampler(name: string): void;
  120952. /** @hidden */
  120953. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120954. /** @hidden */
  120955. _emitExtension(name: string, extension: string): void;
  120956. /** @hidden */
  120957. _emitFunction(name: string, code: string, comments: string): void;
  120958. /** @hidden */
  120959. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120960. replaceStrings?: {
  120961. search: RegExp;
  120962. replace: string;
  120963. }[];
  120964. repeatKey?: string;
  120965. }): string;
  120966. /** @hidden */
  120967. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120968. repeatKey?: string;
  120969. removeAttributes?: boolean;
  120970. removeUniforms?: boolean;
  120971. removeVaryings?: boolean;
  120972. removeIfDef?: boolean;
  120973. replaceStrings?: {
  120974. search: RegExp;
  120975. replace: string;
  120976. }[];
  120977. }, storeKey?: string): void;
  120978. /** @hidden */
  120979. _registerTempVariable(name: string): boolean;
  120980. /** @hidden */
  120981. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120982. /** @hidden */
  120983. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120984. /** @hidden */
  120985. _emitFloat(value: number): string;
  120986. }
  120987. }
  120988. declare module BABYLON {
  120989. /**
  120990. * Defines a block that can be used inside a node based material
  120991. */
  120992. export class NodeMaterialBlock {
  120993. private _buildId;
  120994. private _buildTarget;
  120995. private _target;
  120996. private _isFinalMerger;
  120997. private _isInput;
  120998. /** @hidden */
  120999. _codeVariableName: string;
  121000. /** @hidden */
  121001. _inputs: NodeMaterialConnectionPoint[];
  121002. /** @hidden */
  121003. _outputs: NodeMaterialConnectionPoint[];
  121004. /** @hidden */
  121005. _preparationId: number;
  121006. /**
  121007. * Gets or sets the name of the block
  121008. */
  121009. name: string;
  121010. /**
  121011. * Gets or sets the unique id of the node
  121012. */
  121013. uniqueId: number;
  121014. /**
  121015. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  121016. */
  121017. readonly isFinalMerger: boolean;
  121018. /**
  121019. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  121020. */
  121021. readonly isInput: boolean;
  121022. /**
  121023. * Gets or sets the build Id
  121024. */
  121025. buildId: number;
  121026. /**
  121027. * Gets or sets the target of the block
  121028. */
  121029. target: NodeMaterialBlockTargets;
  121030. /**
  121031. * Gets the list of input points
  121032. */
  121033. readonly inputs: NodeMaterialConnectionPoint[];
  121034. /** Gets the list of output points */
  121035. readonly outputs: NodeMaterialConnectionPoint[];
  121036. /**
  121037. * Find an input by its name
  121038. * @param name defines the name of the input to look for
  121039. * @returns the input or null if not found
  121040. */
  121041. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121042. /**
  121043. * Find an output by its name
  121044. * @param name defines the name of the outputto look for
  121045. * @returns the output or null if not found
  121046. */
  121047. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121048. /**
  121049. * Creates a new NodeMaterialBlock
  121050. * @param name defines the block name
  121051. * @param target defines the target of that block (Vertex by default)
  121052. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  121053. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  121054. */
  121055. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  121056. /**
  121057. * Initialize the block and prepare the context for build
  121058. * @param state defines the state that will be used for the build
  121059. */
  121060. initialize(state: NodeMaterialBuildState): void;
  121061. /**
  121062. * Bind data to effect. Will only be called for blocks with isBindable === true
  121063. * @param effect defines the effect to bind data to
  121064. * @param nodeMaterial defines the hosting NodeMaterial
  121065. * @param mesh defines the mesh that will be rendered
  121066. */
  121067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121068. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  121069. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  121070. protected _writeFloat(value: number): string;
  121071. /**
  121072. * Gets the current class name e.g. "NodeMaterialBlock"
  121073. * @returns the class name
  121074. */
  121075. getClassName(): string;
  121076. /**
  121077. * Register a new input. Must be called inside a block constructor
  121078. * @param name defines the connection point name
  121079. * @param type defines the connection point type
  121080. * @param isOptional defines a boolean indicating that this input can be omitted
  121081. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121082. * @returns the current block
  121083. */
  121084. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  121085. /**
  121086. * Register a new output. Must be called inside a block constructor
  121087. * @param name defines the connection point name
  121088. * @param type defines the connection point type
  121089. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121090. * @returns the current block
  121091. */
  121092. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  121093. /**
  121094. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  121095. * @param forOutput defines an optional connection point to check compatibility with
  121096. * @returns the first available input or null
  121097. */
  121098. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  121099. /**
  121100. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  121101. * @param forBlock defines an optional block to check compatibility with
  121102. * @returns the first available input or null
  121103. */
  121104. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  121105. /**
  121106. * Gets the sibling of the given output
  121107. * @param current defines the current output
  121108. * @returns the next output in the list or null
  121109. */
  121110. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  121111. /**
  121112. * Connect current block with another block
  121113. * @param other defines the block to connect with
  121114. * @param options define the various options to help pick the right connections
  121115. * @returns the current block
  121116. */
  121117. connectTo(other: NodeMaterialBlock, options?: {
  121118. input?: string;
  121119. output?: string;
  121120. outputSwizzle?: string;
  121121. }): this | undefined;
  121122. protected _buildBlock(state: NodeMaterialBuildState): void;
  121123. /**
  121124. * Add uniforms, samplers and uniform buffers at compilation time
  121125. * @param state defines the state to update
  121126. * @param nodeMaterial defines the node material requesting the update
  121127. * @param defines defines the material defines to update
  121128. * @param uniformBuffers defines the list of uniform buffer names
  121129. */
  121130. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121131. /**
  121132. * Add potential fallbacks if shader compilation fails
  121133. * @param mesh defines the mesh to be rendered
  121134. * @param fallbacks defines the current prioritized list of fallbacks
  121135. */
  121136. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121137. /**
  121138. * Initialize defines for shader compilation
  121139. * @param mesh defines the mesh to be rendered
  121140. * @param nodeMaterial defines the node material requesting the update
  121141. * @param defines defines the material defines to update
  121142. * @param useInstances specifies that instances should be used
  121143. */
  121144. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121145. /**
  121146. * Update defines for shader compilation
  121147. * @param mesh defines the mesh to be rendered
  121148. * @param nodeMaterial defines the node material requesting the update
  121149. * @param defines defines the material defines to update
  121150. * @param useInstances specifies that instances should be used
  121151. */
  121152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121153. /**
  121154. * Lets the block try to connect some inputs automatically
  121155. * @param material defines the hosting NodeMaterial
  121156. */
  121157. autoConfigure(material: NodeMaterial): void;
  121158. /**
  121159. * Function called when a block is declared as repeatable content generator
  121160. * @param vertexShaderState defines the current compilation state for the vertex shader
  121161. * @param fragmentShaderState defines the current compilation state for the fragment shader
  121162. * @param mesh defines the mesh to be rendered
  121163. * @param defines defines the material defines to update
  121164. */
  121165. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121166. /**
  121167. * Checks if the block is ready
  121168. * @param mesh defines the mesh to be rendered
  121169. * @param nodeMaterial defines the node material requesting the update
  121170. * @param defines defines the material defines to update
  121171. * @param useInstances specifies that instances should be used
  121172. * @returns true if the block is ready
  121173. */
  121174. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  121175. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  121176. private _processBuild;
  121177. /**
  121178. * Compile the current node and generate the shader code
  121179. * @param state defines the current compilation state (uniforms, samplers, current string)
  121180. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  121181. * @returns true if already built
  121182. */
  121183. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  121184. protected _inputRename(name: string): string;
  121185. protected _outputRename(name: string): string;
  121186. protected _dumpPropertiesCode(): string;
  121187. /** @hidden */
  121188. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  121189. /**
  121190. * Clone the current block to a new identical block
  121191. * @param scene defines the hosting scene
  121192. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121193. * @returns a copy of the current block
  121194. */
  121195. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  121196. /**
  121197. * Serializes this block in a JSON representation
  121198. * @returns the serialized block object
  121199. */
  121200. serialize(): any;
  121201. /** @hidden */
  121202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121203. }
  121204. }
  121205. declare module BABYLON {
  121206. /**
  121207. * Enum defining the type of animations supported by InputBlock
  121208. */
  121209. export enum AnimatedInputBlockTypes {
  121210. /** No animation */
  121211. None = 0,
  121212. /** Time based animation. Will only work for floats */
  121213. Time = 1
  121214. }
  121215. }
  121216. declare module BABYLON {
  121217. /**
  121218. * Block used to expose an input value
  121219. */
  121220. export class InputBlock extends NodeMaterialBlock {
  121221. private _mode;
  121222. private _associatedVariableName;
  121223. private _storedValue;
  121224. private _valueCallback;
  121225. private _type;
  121226. private _animationType;
  121227. /** Gets or set a value used to limit the range of float values */
  121228. min: number;
  121229. /** Gets or set a value used to limit the range of float values */
  121230. max: number;
  121231. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  121232. matrixMode: number;
  121233. /** @hidden */
  121234. _systemValue: Nullable<NodeMaterialSystemValues>;
  121235. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  121236. visibleInInspector: boolean;
  121237. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  121238. isConstant: boolean;
  121239. /**
  121240. * Gets or sets the connection point type (default is float)
  121241. */
  121242. readonly type: NodeMaterialBlockConnectionPointTypes;
  121243. /**
  121244. * Creates a new InputBlock
  121245. * @param name defines the block name
  121246. * @param target defines the target of that block (Vertex by default)
  121247. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  121248. */
  121249. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  121250. /**
  121251. * Gets the output component
  121252. */
  121253. readonly output: NodeMaterialConnectionPoint;
  121254. /**
  121255. * Set the source of this connection point to a vertex attribute
  121256. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  121257. * @returns the current connection point
  121258. */
  121259. setAsAttribute(attributeName?: string): InputBlock;
  121260. /**
  121261. * Set the source of this connection point to a system value
  121262. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  121263. * @returns the current connection point
  121264. */
  121265. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  121266. /**
  121267. * Gets or sets the value of that point.
  121268. * Please note that this value will be ignored if valueCallback is defined
  121269. */
  121270. value: any;
  121271. /**
  121272. * Gets or sets a callback used to get the value of that point.
  121273. * Please note that setting this value will force the connection point to ignore the value property
  121274. */
  121275. valueCallback: () => any;
  121276. /**
  121277. * Gets or sets the associated variable name in the shader
  121278. */
  121279. associatedVariableName: string;
  121280. /** Gets or sets the type of animation applied to the input */
  121281. animationType: AnimatedInputBlockTypes;
  121282. /**
  121283. * Gets a boolean indicating that this connection point not defined yet
  121284. */
  121285. readonly isUndefined: boolean;
  121286. /**
  121287. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  121288. * In this case the connection point name must be the name of the uniform to use.
  121289. * Can only be set on inputs
  121290. */
  121291. isUniform: boolean;
  121292. /**
  121293. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  121294. * In this case the connection point name must be the name of the attribute to use
  121295. * Can only be set on inputs
  121296. */
  121297. isAttribute: boolean;
  121298. /**
  121299. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  121300. * Can only be set on exit points
  121301. */
  121302. isVarying: boolean;
  121303. /**
  121304. * Gets a boolean indicating that the current connection point is a system value
  121305. */
  121306. readonly isSystemValue: boolean;
  121307. /**
  121308. * Gets or sets the current well known value or null if not defined as a system value
  121309. */
  121310. systemValue: Nullable<NodeMaterialSystemValues>;
  121311. /**
  121312. * Gets the current class name
  121313. * @returns the class name
  121314. */
  121315. getClassName(): string;
  121316. /**
  121317. * Animate the input if animationType !== None
  121318. * @param scene defines the rendering scene
  121319. */
  121320. animate(scene: Scene): void;
  121321. private _emitDefine;
  121322. initialize(state: NodeMaterialBuildState): void;
  121323. /**
  121324. * Set the input block to its default value (based on its type)
  121325. */
  121326. setDefaultValue(): void;
  121327. private _emitConstant;
  121328. private _emit;
  121329. /** @hidden */
  121330. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  121331. /** @hidden */
  121332. _transmit(effect: Effect, scene: Scene): void;
  121333. protected _buildBlock(state: NodeMaterialBuildState): void;
  121334. protected _dumpPropertiesCode(): string;
  121335. serialize(): any;
  121336. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121337. }
  121338. }
  121339. declare module BABYLON {
  121340. /**
  121341. * Defines a connection point for a block
  121342. */
  121343. export class NodeMaterialConnectionPoint {
  121344. /** @hidden */
  121345. _ownerBlock: NodeMaterialBlock;
  121346. /** @hidden */
  121347. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121348. private _endpoints;
  121349. private _associatedVariableName;
  121350. /** @hidden */
  121351. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121352. /** @hidden */
  121353. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121354. private _type;
  121355. /** @hidden */
  121356. _enforceAssociatedVariableName: boolean;
  121357. /**
  121358. * Gets or sets the additional types supported by this connection point
  121359. */
  121360. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121361. /**
  121362. * Gets or sets the additional types excluded by this connection point
  121363. */
  121364. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121365. /**
  121366. * Gets or sets the associated variable name in the shader
  121367. */
  121368. associatedVariableName: string;
  121369. /**
  121370. * Gets or sets the connection point type (default is float)
  121371. */
  121372. type: NodeMaterialBlockConnectionPointTypes;
  121373. /**
  121374. * Gets or sets the connection point name
  121375. */
  121376. name: string;
  121377. /**
  121378. * Gets or sets a boolean indicating that this connection point can be omitted
  121379. */
  121380. isOptional: boolean;
  121381. /**
  121382. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  121383. */
  121384. define: string;
  121385. /** Gets or sets the target of that connection point */
  121386. target: NodeMaterialBlockTargets;
  121387. /**
  121388. * Gets a boolean indicating that the current point is connected
  121389. */
  121390. readonly isConnected: boolean;
  121391. /**
  121392. * Gets a boolean indicating that the current point is connected to an input block
  121393. */
  121394. readonly isConnectedToInputBlock: boolean;
  121395. /**
  121396. * Gets a the connected input block (if any)
  121397. */
  121398. readonly connectInputBlock: Nullable<InputBlock>;
  121399. /** Get the other side of the connection (if any) */
  121400. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121401. /** Get the block that owns this connection point */
  121402. readonly ownerBlock: NodeMaterialBlock;
  121403. /** Get the block connected on the other side of this connection (if any) */
  121404. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  121405. /** Get the block connected on the endpoints of this connection (if any) */
  121406. readonly connectedBlocks: Array<NodeMaterialBlock>;
  121407. /** Gets the list of connected endpoints */
  121408. readonly endpoints: NodeMaterialConnectionPoint[];
  121409. /** Gets a boolean indicating if that output point is connected to at least one input */
  121410. readonly hasEndpoints: boolean;
  121411. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  121412. readonly isConnectedInVertexShader: boolean;
  121413. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  121414. readonly isConnectedInFragmentShader: boolean;
  121415. /**
  121416. * Creates a new connection point
  121417. * @param name defines the connection point name
  121418. * @param ownerBlock defines the block hosting this connection point
  121419. */
  121420. constructor(name: string, ownerBlock: NodeMaterialBlock);
  121421. /**
  121422. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  121423. * @returns the class name
  121424. */
  121425. getClassName(): string;
  121426. /**
  121427. * Gets an boolean indicating if the current point can be connected to another point
  121428. * @param connectionPoint defines the other connection point
  121429. * @returns true if the connection is possible
  121430. */
  121431. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  121432. /**
  121433. * Connect this point to another connection point
  121434. * @param connectionPoint defines the other connection point
  121435. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  121436. * @returns the current connection point
  121437. */
  121438. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  121439. /**
  121440. * Disconnect this point from one of his endpoint
  121441. * @param endpoint defines the other connection point
  121442. * @returns the current connection point
  121443. */
  121444. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  121445. /**
  121446. * Serializes this point in a JSON representation
  121447. * @returns the serialized point object
  121448. */
  121449. serialize(): any;
  121450. }
  121451. }
  121452. declare module BABYLON {
  121453. /**
  121454. * Block used to add support for vertex skinning (bones)
  121455. */
  121456. export class BonesBlock extends NodeMaterialBlock {
  121457. /**
  121458. * Creates a new BonesBlock
  121459. * @param name defines the block name
  121460. */
  121461. constructor(name: string);
  121462. /**
  121463. * Initialize the block and prepare the context for build
  121464. * @param state defines the state that will be used for the build
  121465. */
  121466. initialize(state: NodeMaterialBuildState): void;
  121467. /**
  121468. * Gets the current class name
  121469. * @returns the class name
  121470. */
  121471. getClassName(): string;
  121472. /**
  121473. * Gets the matrix indices input component
  121474. */
  121475. readonly matricesIndices: NodeMaterialConnectionPoint;
  121476. /**
  121477. * Gets the matrix weights input component
  121478. */
  121479. readonly matricesWeights: NodeMaterialConnectionPoint;
  121480. /**
  121481. * Gets the extra matrix indices input component
  121482. */
  121483. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  121484. /**
  121485. * Gets the extra matrix weights input component
  121486. */
  121487. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  121488. /**
  121489. * Gets the world input component
  121490. */
  121491. readonly world: NodeMaterialConnectionPoint;
  121492. /**
  121493. * Gets the output component
  121494. */
  121495. readonly output: NodeMaterialConnectionPoint;
  121496. autoConfigure(material: NodeMaterial): void;
  121497. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121498. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121499. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121500. protected _buildBlock(state: NodeMaterialBuildState): this;
  121501. }
  121502. }
  121503. declare module BABYLON {
  121504. /**
  121505. * Block used to add support for instances
  121506. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  121507. */
  121508. export class InstancesBlock extends NodeMaterialBlock {
  121509. /**
  121510. * Creates a new InstancesBlock
  121511. * @param name defines the block name
  121512. */
  121513. constructor(name: string);
  121514. /**
  121515. * Gets the current class name
  121516. * @returns the class name
  121517. */
  121518. getClassName(): string;
  121519. /**
  121520. * Gets the first world row input component
  121521. */
  121522. readonly world0: NodeMaterialConnectionPoint;
  121523. /**
  121524. * Gets the second world row input component
  121525. */
  121526. readonly world1: NodeMaterialConnectionPoint;
  121527. /**
  121528. * Gets the third world row input component
  121529. */
  121530. readonly world2: NodeMaterialConnectionPoint;
  121531. /**
  121532. * Gets the forth world row input component
  121533. */
  121534. readonly world3: NodeMaterialConnectionPoint;
  121535. /**
  121536. * Gets the world input component
  121537. */
  121538. readonly world: NodeMaterialConnectionPoint;
  121539. /**
  121540. * Gets the output component
  121541. */
  121542. readonly output: NodeMaterialConnectionPoint;
  121543. autoConfigure(material: NodeMaterial): void;
  121544. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121545. protected _buildBlock(state: NodeMaterialBuildState): this;
  121546. }
  121547. }
  121548. declare module BABYLON {
  121549. /**
  121550. * Block used to add morph targets support to vertex shader
  121551. */
  121552. export class MorphTargetsBlock extends NodeMaterialBlock {
  121553. private _repeatableContentAnchor;
  121554. private _repeatebleContentGenerated;
  121555. /**
  121556. * Create a new MorphTargetsBlock
  121557. * @param name defines the block name
  121558. */
  121559. constructor(name: string);
  121560. /**
  121561. * Gets the current class name
  121562. * @returns the class name
  121563. */
  121564. getClassName(): string;
  121565. /**
  121566. * Gets the position input component
  121567. */
  121568. readonly position: NodeMaterialConnectionPoint;
  121569. /**
  121570. * Gets the normal input component
  121571. */
  121572. readonly normal: NodeMaterialConnectionPoint;
  121573. /**
  121574. * Gets the tangent input component
  121575. */
  121576. readonly tangent: NodeMaterialConnectionPoint;
  121577. /**
  121578. * Gets the tangent input component
  121579. */
  121580. readonly uv: NodeMaterialConnectionPoint;
  121581. /**
  121582. * Gets the position output component
  121583. */
  121584. readonly positionOutput: NodeMaterialConnectionPoint;
  121585. /**
  121586. * Gets the normal output component
  121587. */
  121588. readonly normalOutput: NodeMaterialConnectionPoint;
  121589. /**
  121590. * Gets the tangent output component
  121591. */
  121592. readonly tangentOutput: NodeMaterialConnectionPoint;
  121593. /**
  121594. * Gets the tangent output component
  121595. */
  121596. readonly uvOutput: NodeMaterialConnectionPoint;
  121597. initialize(state: NodeMaterialBuildState): void;
  121598. autoConfigure(material: NodeMaterial): void;
  121599. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121601. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121602. protected _buildBlock(state: NodeMaterialBuildState): this;
  121603. }
  121604. }
  121605. declare module BABYLON {
  121606. /**
  121607. * Block used to get data information from a light
  121608. */
  121609. export class LightInformationBlock extends NodeMaterialBlock {
  121610. private _lightDataUniformName;
  121611. private _lightColorUniformName;
  121612. private _lightTypeDefineName;
  121613. /**
  121614. * Gets or sets the light associated with this block
  121615. */
  121616. light: Nullable<Light>;
  121617. /**
  121618. * Creates a new LightInformationBlock
  121619. * @param name defines the block name
  121620. */
  121621. constructor(name: string);
  121622. /**
  121623. * Gets the current class name
  121624. * @returns the class name
  121625. */
  121626. getClassName(): string;
  121627. /**
  121628. * Gets the world position input component
  121629. */
  121630. readonly worldPosition: NodeMaterialConnectionPoint;
  121631. /**
  121632. * Gets the direction output component
  121633. */
  121634. readonly direction: NodeMaterialConnectionPoint;
  121635. /**
  121636. * Gets the direction output component
  121637. */
  121638. readonly color: NodeMaterialConnectionPoint;
  121639. /**
  121640. * Gets the direction output component
  121641. */
  121642. readonly intensity: NodeMaterialConnectionPoint;
  121643. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121644. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121645. protected _buildBlock(state: NodeMaterialBuildState): this;
  121646. serialize(): any;
  121647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121648. }
  121649. }
  121650. declare module BABYLON {
  121651. /**
  121652. * Block used to add image processing support to fragment shader
  121653. */
  121654. export class ImageProcessingBlock extends NodeMaterialBlock {
  121655. /**
  121656. * Create a new ImageProcessingBlock
  121657. * @param name defines the block name
  121658. */
  121659. constructor(name: string);
  121660. /**
  121661. * Gets the current class name
  121662. * @returns the class name
  121663. */
  121664. getClassName(): string;
  121665. /**
  121666. * Gets the color input component
  121667. */
  121668. readonly color: NodeMaterialConnectionPoint;
  121669. /**
  121670. * Gets the output component
  121671. */
  121672. readonly output: NodeMaterialConnectionPoint;
  121673. /**
  121674. * Initialize the block and prepare the context for build
  121675. * @param state defines the state that will be used for the build
  121676. */
  121677. initialize(state: NodeMaterialBuildState): void;
  121678. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  121679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121680. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121681. protected _buildBlock(state: NodeMaterialBuildState): this;
  121682. }
  121683. }
  121684. declare module BABYLON {
  121685. /**
  121686. * Block used to pertub normals based on a normal map
  121687. */
  121688. export class PerturbNormalBlock extends NodeMaterialBlock {
  121689. private _tangentSpaceParameterName;
  121690. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  121691. invertX: boolean;
  121692. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  121693. invertY: boolean;
  121694. /**
  121695. * Create a new PerturbNormalBlock
  121696. * @param name defines the block name
  121697. */
  121698. constructor(name: string);
  121699. /**
  121700. * Gets the current class name
  121701. * @returns the class name
  121702. */
  121703. getClassName(): string;
  121704. /**
  121705. * Gets the world position input component
  121706. */
  121707. readonly worldPosition: NodeMaterialConnectionPoint;
  121708. /**
  121709. * Gets the world normal input component
  121710. */
  121711. readonly worldNormal: NodeMaterialConnectionPoint;
  121712. /**
  121713. * Gets the uv input component
  121714. */
  121715. readonly uv: NodeMaterialConnectionPoint;
  121716. /**
  121717. * Gets the normal map color input component
  121718. */
  121719. readonly normalMapColor: NodeMaterialConnectionPoint;
  121720. /**
  121721. * Gets the strength input component
  121722. */
  121723. readonly strength: NodeMaterialConnectionPoint;
  121724. /**
  121725. * Gets the output component
  121726. */
  121727. readonly output: NodeMaterialConnectionPoint;
  121728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121729. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121730. autoConfigure(material: NodeMaterial): void;
  121731. protected _buildBlock(state: NodeMaterialBuildState): this;
  121732. protected _dumpPropertiesCode(): string;
  121733. serialize(): any;
  121734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121735. }
  121736. }
  121737. declare module BABYLON {
  121738. /**
  121739. * Block used to discard a pixel if a value is smaller than a cutoff
  121740. */
  121741. export class DiscardBlock extends NodeMaterialBlock {
  121742. /**
  121743. * Create a new DiscardBlock
  121744. * @param name defines the block name
  121745. */
  121746. constructor(name: string);
  121747. /**
  121748. * Gets the current class name
  121749. * @returns the class name
  121750. */
  121751. getClassName(): string;
  121752. /**
  121753. * Gets the color input component
  121754. */
  121755. readonly value: NodeMaterialConnectionPoint;
  121756. /**
  121757. * Gets the cutoff input component
  121758. */
  121759. readonly cutoff: NodeMaterialConnectionPoint;
  121760. protected _buildBlock(state: NodeMaterialBuildState): this;
  121761. }
  121762. }
  121763. declare module BABYLON {
  121764. /**
  121765. * Block used to add support for scene fog
  121766. */
  121767. export class FogBlock extends NodeMaterialBlock {
  121768. private _fogDistanceName;
  121769. private _fogParameters;
  121770. /**
  121771. * Create a new FogBlock
  121772. * @param name defines the block name
  121773. */
  121774. constructor(name: string);
  121775. /**
  121776. * Gets the current class name
  121777. * @returns the class name
  121778. */
  121779. getClassName(): string;
  121780. /**
  121781. * Gets the world position input component
  121782. */
  121783. readonly worldPosition: NodeMaterialConnectionPoint;
  121784. /**
  121785. * Gets the view input component
  121786. */
  121787. readonly view: NodeMaterialConnectionPoint;
  121788. /**
  121789. * Gets the color input component
  121790. */
  121791. readonly input: NodeMaterialConnectionPoint;
  121792. /**
  121793. * Gets the fog color input component
  121794. */
  121795. readonly fogColor: NodeMaterialConnectionPoint;
  121796. /**
  121797. * Gets the output component
  121798. */
  121799. readonly output: NodeMaterialConnectionPoint;
  121800. autoConfigure(material: NodeMaterial): void;
  121801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121802. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121803. protected _buildBlock(state: NodeMaterialBuildState): this;
  121804. }
  121805. }
  121806. declare module BABYLON {
  121807. /**
  121808. * Block used to add light in the fragment shader
  121809. */
  121810. export class LightBlock extends NodeMaterialBlock {
  121811. private _lightId;
  121812. /**
  121813. * Gets or sets the light associated with this block
  121814. */
  121815. light: Nullable<Light>;
  121816. /**
  121817. * Create a new LightBlock
  121818. * @param name defines the block name
  121819. */
  121820. constructor(name: string);
  121821. /**
  121822. * Gets the current class name
  121823. * @returns the class name
  121824. */
  121825. getClassName(): string;
  121826. /**
  121827. * Gets the world position input component
  121828. */
  121829. readonly worldPosition: NodeMaterialConnectionPoint;
  121830. /**
  121831. * Gets the world normal input component
  121832. */
  121833. readonly worldNormal: NodeMaterialConnectionPoint;
  121834. /**
  121835. * Gets the camera (or eye) position component
  121836. */
  121837. readonly cameraPosition: NodeMaterialConnectionPoint;
  121838. /**
  121839. * Gets the glossiness component
  121840. */
  121841. readonly glossiness: NodeMaterialConnectionPoint;
  121842. /**
  121843. * Gets the glossinness power component
  121844. */
  121845. readonly glossPower: NodeMaterialConnectionPoint;
  121846. /**
  121847. * Gets the diffuse color component
  121848. */
  121849. readonly diffuseColor: NodeMaterialConnectionPoint;
  121850. /**
  121851. * Gets the specular color component
  121852. */
  121853. readonly specularColor: NodeMaterialConnectionPoint;
  121854. /**
  121855. * Gets the diffuse output component
  121856. */
  121857. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121858. /**
  121859. * Gets the specular output component
  121860. */
  121861. readonly specularOutput: NodeMaterialConnectionPoint;
  121862. autoConfigure(material: NodeMaterial): void;
  121863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121864. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121865. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121866. private _injectVertexCode;
  121867. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121868. serialize(): any;
  121869. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121870. }
  121871. }
  121872. declare module BABYLON {
  121873. /**
  121874. * Block used to multiply 2 values
  121875. */
  121876. export class MultiplyBlock extends NodeMaterialBlock {
  121877. /**
  121878. * Creates a new MultiplyBlock
  121879. * @param name defines the block name
  121880. */
  121881. constructor(name: string);
  121882. /**
  121883. * Gets the current class name
  121884. * @returns the class name
  121885. */
  121886. getClassName(): string;
  121887. /**
  121888. * Gets the left operand input component
  121889. */
  121890. readonly left: NodeMaterialConnectionPoint;
  121891. /**
  121892. * Gets the right operand input component
  121893. */
  121894. readonly right: NodeMaterialConnectionPoint;
  121895. /**
  121896. * Gets the output component
  121897. */
  121898. readonly output: NodeMaterialConnectionPoint;
  121899. protected _buildBlock(state: NodeMaterialBuildState): this;
  121900. }
  121901. }
  121902. declare module BABYLON {
  121903. /**
  121904. * Block used to add 2 vectors
  121905. */
  121906. export class AddBlock extends NodeMaterialBlock {
  121907. /**
  121908. * Creates a new AddBlock
  121909. * @param name defines the block name
  121910. */
  121911. constructor(name: string);
  121912. /**
  121913. * Gets the current class name
  121914. * @returns the class name
  121915. */
  121916. getClassName(): string;
  121917. /**
  121918. * Gets the left operand input component
  121919. */
  121920. readonly left: NodeMaterialConnectionPoint;
  121921. /**
  121922. * Gets the right operand input component
  121923. */
  121924. readonly right: NodeMaterialConnectionPoint;
  121925. /**
  121926. * Gets the output component
  121927. */
  121928. readonly output: NodeMaterialConnectionPoint;
  121929. protected _buildBlock(state: NodeMaterialBuildState): this;
  121930. }
  121931. }
  121932. declare module BABYLON {
  121933. /**
  121934. * Block used to scale a vector by a float
  121935. */
  121936. export class ScaleBlock extends NodeMaterialBlock {
  121937. /**
  121938. * Creates a new ScaleBlock
  121939. * @param name defines the block name
  121940. */
  121941. constructor(name: string);
  121942. /**
  121943. * Gets the current class name
  121944. * @returns the class name
  121945. */
  121946. getClassName(): string;
  121947. /**
  121948. * Gets the input component
  121949. */
  121950. readonly input: NodeMaterialConnectionPoint;
  121951. /**
  121952. * Gets the factor input component
  121953. */
  121954. readonly factor: NodeMaterialConnectionPoint;
  121955. /**
  121956. * Gets the output component
  121957. */
  121958. readonly output: NodeMaterialConnectionPoint;
  121959. protected _buildBlock(state: NodeMaterialBuildState): this;
  121960. }
  121961. }
  121962. declare module BABYLON {
  121963. /**
  121964. * Block used to clamp a float
  121965. */
  121966. export class ClampBlock extends NodeMaterialBlock {
  121967. /** Gets or sets the minimum range */
  121968. minimum: number;
  121969. /** Gets or sets the maximum range */
  121970. maximum: number;
  121971. /**
  121972. * Creates a new ClampBlock
  121973. * @param name defines the block name
  121974. */
  121975. constructor(name: string);
  121976. /**
  121977. * Gets the current class name
  121978. * @returns the class name
  121979. */
  121980. getClassName(): string;
  121981. /**
  121982. * Gets the value input component
  121983. */
  121984. readonly value: NodeMaterialConnectionPoint;
  121985. /**
  121986. * Gets the output component
  121987. */
  121988. readonly output: NodeMaterialConnectionPoint;
  121989. protected _buildBlock(state: NodeMaterialBuildState): this;
  121990. protected _dumpPropertiesCode(): string;
  121991. serialize(): any;
  121992. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121993. }
  121994. }
  121995. declare module BABYLON {
  121996. /**
  121997. * Block used to apply a cross product between 2 vectors
  121998. */
  121999. export class CrossBlock extends NodeMaterialBlock {
  122000. /**
  122001. * Creates a new CrossBlock
  122002. * @param name defines the block name
  122003. */
  122004. constructor(name: string);
  122005. /**
  122006. * Gets the current class name
  122007. * @returns the class name
  122008. */
  122009. getClassName(): string;
  122010. /**
  122011. * Gets the left operand input component
  122012. */
  122013. readonly left: NodeMaterialConnectionPoint;
  122014. /**
  122015. * Gets the right operand input component
  122016. */
  122017. readonly right: NodeMaterialConnectionPoint;
  122018. /**
  122019. * Gets the output component
  122020. */
  122021. readonly output: NodeMaterialConnectionPoint;
  122022. protected _buildBlock(state: NodeMaterialBuildState): this;
  122023. }
  122024. }
  122025. declare module BABYLON {
  122026. /**
  122027. * Block used to apply a dot product between 2 vectors
  122028. */
  122029. export class DotBlock extends NodeMaterialBlock {
  122030. /**
  122031. * Creates a new DotBlock
  122032. * @param name defines the block name
  122033. */
  122034. constructor(name: string);
  122035. /**
  122036. * Gets the current class name
  122037. * @returns the class name
  122038. */
  122039. getClassName(): string;
  122040. /**
  122041. * Gets the left operand input component
  122042. */
  122043. readonly left: NodeMaterialConnectionPoint;
  122044. /**
  122045. * Gets the right operand input component
  122046. */
  122047. readonly right: NodeMaterialConnectionPoint;
  122048. /**
  122049. * Gets the output component
  122050. */
  122051. readonly output: NodeMaterialConnectionPoint;
  122052. protected _buildBlock(state: NodeMaterialBuildState): this;
  122053. }
  122054. }
  122055. declare module BABYLON {
  122056. /**
  122057. * Block used to remap a float from a range to a new one
  122058. */
  122059. export class RemapBlock extends NodeMaterialBlock {
  122060. /**
  122061. * Gets or sets the source range
  122062. */
  122063. sourceRange: Vector2;
  122064. /**
  122065. * Gets or sets the target range
  122066. */
  122067. targetRange: Vector2;
  122068. /**
  122069. * Creates a new RemapBlock
  122070. * @param name defines the block name
  122071. */
  122072. constructor(name: string);
  122073. /**
  122074. * Gets the current class name
  122075. * @returns the class name
  122076. */
  122077. getClassName(): string;
  122078. /**
  122079. * Gets the input component
  122080. */
  122081. readonly input: NodeMaterialConnectionPoint;
  122082. /**
  122083. * Gets the source min input component
  122084. */
  122085. readonly sourceMin: NodeMaterialConnectionPoint;
  122086. /**
  122087. * Gets the source max input component
  122088. */
  122089. readonly sourceMax: NodeMaterialConnectionPoint;
  122090. /**
  122091. * Gets the target min input component
  122092. */
  122093. readonly targetMin: NodeMaterialConnectionPoint;
  122094. /**
  122095. * Gets the target max input component
  122096. */
  122097. readonly targetMax: NodeMaterialConnectionPoint;
  122098. /**
  122099. * Gets the output component
  122100. */
  122101. readonly output: NodeMaterialConnectionPoint;
  122102. protected _buildBlock(state: NodeMaterialBuildState): this;
  122103. protected _dumpPropertiesCode(): string;
  122104. serialize(): any;
  122105. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122106. }
  122107. }
  122108. declare module BABYLON {
  122109. /**
  122110. * Block used to normalize a vector
  122111. */
  122112. export class NormalizeBlock extends NodeMaterialBlock {
  122113. /**
  122114. * Creates a new NormalizeBlock
  122115. * @param name defines the block name
  122116. */
  122117. constructor(name: string);
  122118. /**
  122119. * Gets the current class name
  122120. * @returns the class name
  122121. */
  122122. getClassName(): string;
  122123. /**
  122124. * Gets the input component
  122125. */
  122126. readonly input: NodeMaterialConnectionPoint;
  122127. /**
  122128. * Gets the output component
  122129. */
  122130. readonly output: NodeMaterialConnectionPoint;
  122131. protected _buildBlock(state: NodeMaterialBuildState): this;
  122132. }
  122133. }
  122134. declare module BABYLON {
  122135. /**
  122136. * Operations supported by the Trigonometry block
  122137. */
  122138. export enum TrigonometryBlockOperations {
  122139. /** Cos */
  122140. Cos = 0,
  122141. /** Sin */
  122142. Sin = 1,
  122143. /** Abs */
  122144. Abs = 2,
  122145. /** Exp */
  122146. Exp = 3,
  122147. /** Exp2 */
  122148. Exp2 = 4,
  122149. /** Round */
  122150. Round = 5,
  122151. /** Floor */
  122152. Floor = 6,
  122153. /** Ceiling */
  122154. Ceiling = 7,
  122155. /** Square root */
  122156. Sqrt = 8,
  122157. /** Log */
  122158. Log = 9,
  122159. /** Tangent */
  122160. Tan = 10,
  122161. /** Arc tangent */
  122162. ArcTan = 11,
  122163. /** Arc cosinus */
  122164. ArcCos = 12,
  122165. /** Arc sinus */
  122166. ArcSin = 13,
  122167. /** Fraction */
  122168. Fract = 14,
  122169. /** Sign */
  122170. Sign = 15,
  122171. /** To radians (from degrees) */
  122172. Radians = 16,
  122173. /** To degrees (from radians) */
  122174. Degrees = 17
  122175. }
  122176. /**
  122177. * Block used to apply trigonometry operation to floats
  122178. */
  122179. export class TrigonometryBlock extends NodeMaterialBlock {
  122180. /**
  122181. * Gets or sets the operation applied by the block
  122182. */
  122183. operation: TrigonometryBlockOperations;
  122184. /**
  122185. * Creates a new TrigonometryBlock
  122186. * @param name defines the block name
  122187. */
  122188. constructor(name: string);
  122189. /**
  122190. * Gets the current class name
  122191. * @returns the class name
  122192. */
  122193. getClassName(): string;
  122194. /**
  122195. * Gets the input component
  122196. */
  122197. readonly input: NodeMaterialConnectionPoint;
  122198. /**
  122199. * Gets the output component
  122200. */
  122201. readonly output: NodeMaterialConnectionPoint;
  122202. protected _buildBlock(state: NodeMaterialBuildState): this;
  122203. serialize(): any;
  122204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122205. }
  122206. }
  122207. declare module BABYLON {
  122208. /**
  122209. * Block used to create a Color3/4 out of individual inputs (one for each component)
  122210. */
  122211. export class ColorMergerBlock extends NodeMaterialBlock {
  122212. /**
  122213. * Create a new ColorMergerBlock
  122214. * @param name defines the block name
  122215. */
  122216. constructor(name: string);
  122217. /**
  122218. * Gets the current class name
  122219. * @returns the class name
  122220. */
  122221. getClassName(): string;
  122222. /**
  122223. * Gets the r component (input)
  122224. */
  122225. readonly r: NodeMaterialConnectionPoint;
  122226. /**
  122227. * Gets the g component (input)
  122228. */
  122229. readonly g: NodeMaterialConnectionPoint;
  122230. /**
  122231. * Gets the b component (input)
  122232. */
  122233. readonly b: NodeMaterialConnectionPoint;
  122234. /**
  122235. * Gets the a component (input)
  122236. */
  122237. readonly a: NodeMaterialConnectionPoint;
  122238. /**
  122239. * Gets the rgba component (output)
  122240. */
  122241. readonly rgba: NodeMaterialConnectionPoint;
  122242. /**
  122243. * Gets the rgb component (output)
  122244. */
  122245. readonly rgb: NodeMaterialConnectionPoint;
  122246. protected _buildBlock(state: NodeMaterialBuildState): this;
  122247. }
  122248. }
  122249. declare module BABYLON {
  122250. /**
  122251. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  122252. */
  122253. export class VectorMergerBlock extends NodeMaterialBlock {
  122254. /**
  122255. * Create a new VectorMergerBlock
  122256. * @param name defines the block name
  122257. */
  122258. constructor(name: string);
  122259. /**
  122260. * Gets the current class name
  122261. * @returns the class name
  122262. */
  122263. getClassName(): string;
  122264. /**
  122265. * Gets the x component (input)
  122266. */
  122267. readonly x: NodeMaterialConnectionPoint;
  122268. /**
  122269. * Gets the y component (input)
  122270. */
  122271. readonly y: NodeMaterialConnectionPoint;
  122272. /**
  122273. * Gets the z component (input)
  122274. */
  122275. readonly z: NodeMaterialConnectionPoint;
  122276. /**
  122277. * Gets the w component (input)
  122278. */
  122279. readonly w: NodeMaterialConnectionPoint;
  122280. /**
  122281. * Gets the xyzw component (output)
  122282. */
  122283. readonly xyzw: NodeMaterialConnectionPoint;
  122284. /**
  122285. * Gets the xyz component (output)
  122286. */
  122287. readonly xyz: NodeMaterialConnectionPoint;
  122288. /**
  122289. * Gets the xy component (output)
  122290. */
  122291. readonly xy: NodeMaterialConnectionPoint;
  122292. protected _buildBlock(state: NodeMaterialBuildState): this;
  122293. }
  122294. }
  122295. declare module BABYLON {
  122296. /**
  122297. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  122298. */
  122299. export class ColorSplitterBlock extends NodeMaterialBlock {
  122300. /**
  122301. * Create a new ColorSplitterBlock
  122302. * @param name defines the block name
  122303. */
  122304. constructor(name: string);
  122305. /**
  122306. * Gets the current class name
  122307. * @returns the class name
  122308. */
  122309. getClassName(): string;
  122310. /**
  122311. * Gets the rgba component (input)
  122312. */
  122313. readonly rgba: NodeMaterialConnectionPoint;
  122314. /**
  122315. * Gets the rgb component (input)
  122316. */
  122317. readonly rgbIn: NodeMaterialConnectionPoint;
  122318. /**
  122319. * Gets the rgb component (output)
  122320. */
  122321. readonly rgbOut: NodeMaterialConnectionPoint;
  122322. /**
  122323. * Gets the r component (output)
  122324. */
  122325. readonly r: NodeMaterialConnectionPoint;
  122326. /**
  122327. * Gets the g component (output)
  122328. */
  122329. readonly g: NodeMaterialConnectionPoint;
  122330. /**
  122331. * Gets the b component (output)
  122332. */
  122333. readonly b: NodeMaterialConnectionPoint;
  122334. /**
  122335. * Gets the a component (output)
  122336. */
  122337. readonly a: NodeMaterialConnectionPoint;
  122338. protected _inputRename(name: string): string;
  122339. protected _outputRename(name: string): string;
  122340. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122341. }
  122342. }
  122343. declare module BABYLON {
  122344. /**
  122345. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  122346. */
  122347. export class VectorSplitterBlock extends NodeMaterialBlock {
  122348. /**
  122349. * Create a new VectorSplitterBlock
  122350. * @param name defines the block name
  122351. */
  122352. constructor(name: string);
  122353. /**
  122354. * Gets the current class name
  122355. * @returns the class name
  122356. */
  122357. getClassName(): string;
  122358. /**
  122359. * Gets the xyzw component (input)
  122360. */
  122361. readonly xyzw: NodeMaterialConnectionPoint;
  122362. /**
  122363. * Gets the xyz component (input)
  122364. */
  122365. readonly xyzIn: NodeMaterialConnectionPoint;
  122366. /**
  122367. * Gets the xy component (input)
  122368. */
  122369. readonly xyIn: NodeMaterialConnectionPoint;
  122370. /**
  122371. * Gets the xyz component (output)
  122372. */
  122373. readonly xyzOut: NodeMaterialConnectionPoint;
  122374. /**
  122375. * Gets the xy component (output)
  122376. */
  122377. readonly xyOut: NodeMaterialConnectionPoint;
  122378. /**
  122379. * Gets the x component (output)
  122380. */
  122381. readonly x: NodeMaterialConnectionPoint;
  122382. /**
  122383. * Gets the y component (output)
  122384. */
  122385. readonly y: NodeMaterialConnectionPoint;
  122386. /**
  122387. * Gets the z component (output)
  122388. */
  122389. readonly z: NodeMaterialConnectionPoint;
  122390. /**
  122391. * Gets the w component (output)
  122392. */
  122393. readonly w: NodeMaterialConnectionPoint;
  122394. protected _inputRename(name: string): string;
  122395. protected _outputRename(name: string): string;
  122396. protected _buildBlock(state: NodeMaterialBuildState): this;
  122397. }
  122398. }
  122399. declare module BABYLON {
  122400. /**
  122401. * Block used to lerp between 2 values
  122402. */
  122403. export class LerpBlock extends NodeMaterialBlock {
  122404. /**
  122405. * Creates a new LerpBlock
  122406. * @param name defines the block name
  122407. */
  122408. constructor(name: string);
  122409. /**
  122410. * Gets the current class name
  122411. * @returns the class name
  122412. */
  122413. getClassName(): string;
  122414. /**
  122415. * Gets the left operand input component
  122416. */
  122417. readonly left: NodeMaterialConnectionPoint;
  122418. /**
  122419. * Gets the right operand input component
  122420. */
  122421. readonly right: NodeMaterialConnectionPoint;
  122422. /**
  122423. * Gets the gradient operand input component
  122424. */
  122425. readonly gradient: NodeMaterialConnectionPoint;
  122426. /**
  122427. * Gets the output component
  122428. */
  122429. readonly output: NodeMaterialConnectionPoint;
  122430. protected _buildBlock(state: NodeMaterialBuildState): this;
  122431. }
  122432. }
  122433. declare module BABYLON {
  122434. /**
  122435. * Block used to divide 2 vectors
  122436. */
  122437. export class DivideBlock extends NodeMaterialBlock {
  122438. /**
  122439. * Creates a new DivideBlock
  122440. * @param name defines the block name
  122441. */
  122442. constructor(name: string);
  122443. /**
  122444. * Gets the current class name
  122445. * @returns the class name
  122446. */
  122447. getClassName(): string;
  122448. /**
  122449. * Gets the left operand input component
  122450. */
  122451. readonly left: NodeMaterialConnectionPoint;
  122452. /**
  122453. * Gets the right operand input component
  122454. */
  122455. readonly right: NodeMaterialConnectionPoint;
  122456. /**
  122457. * Gets the output component
  122458. */
  122459. readonly output: NodeMaterialConnectionPoint;
  122460. protected _buildBlock(state: NodeMaterialBuildState): this;
  122461. }
  122462. }
  122463. declare module BABYLON {
  122464. /**
  122465. * Block used to subtract 2 vectors
  122466. */
  122467. export class SubtractBlock extends NodeMaterialBlock {
  122468. /**
  122469. * Creates a new SubtractBlock
  122470. * @param name defines the block name
  122471. */
  122472. constructor(name: string);
  122473. /**
  122474. * Gets the current class name
  122475. * @returns the class name
  122476. */
  122477. getClassName(): string;
  122478. /**
  122479. * Gets the left operand input component
  122480. */
  122481. readonly left: NodeMaterialConnectionPoint;
  122482. /**
  122483. * Gets the right operand input component
  122484. */
  122485. readonly right: NodeMaterialConnectionPoint;
  122486. /**
  122487. * Gets the output component
  122488. */
  122489. readonly output: NodeMaterialConnectionPoint;
  122490. protected _buildBlock(state: NodeMaterialBuildState): this;
  122491. }
  122492. }
  122493. declare module BABYLON {
  122494. /**
  122495. * Block used to step a value
  122496. */
  122497. export class StepBlock extends NodeMaterialBlock {
  122498. /**
  122499. * Creates a new StepBlock
  122500. * @param name defines the block name
  122501. */
  122502. constructor(name: string);
  122503. /**
  122504. * Gets the current class name
  122505. * @returns the class name
  122506. */
  122507. getClassName(): string;
  122508. /**
  122509. * Gets the value operand input component
  122510. */
  122511. readonly value: NodeMaterialConnectionPoint;
  122512. /**
  122513. * Gets the edge operand input component
  122514. */
  122515. readonly edge: NodeMaterialConnectionPoint;
  122516. /**
  122517. * Gets the output component
  122518. */
  122519. readonly output: NodeMaterialConnectionPoint;
  122520. protected _buildBlock(state: NodeMaterialBuildState): this;
  122521. }
  122522. }
  122523. declare module BABYLON {
  122524. /**
  122525. * Block used to get the opposite (1 - x) of a value
  122526. */
  122527. export class OneMinusBlock extends NodeMaterialBlock {
  122528. /**
  122529. * Creates a new OneMinusBlock
  122530. * @param name defines the block name
  122531. */
  122532. constructor(name: string);
  122533. /**
  122534. * Gets the current class name
  122535. * @returns the class name
  122536. */
  122537. getClassName(): string;
  122538. /**
  122539. * Gets the input component
  122540. */
  122541. readonly input: NodeMaterialConnectionPoint;
  122542. /**
  122543. * Gets the output component
  122544. */
  122545. readonly output: NodeMaterialConnectionPoint;
  122546. protected _buildBlock(state: NodeMaterialBuildState): this;
  122547. }
  122548. }
  122549. declare module BABYLON {
  122550. /**
  122551. * Block used to get the view direction
  122552. */
  122553. export class ViewDirectionBlock extends NodeMaterialBlock {
  122554. /**
  122555. * Creates a new ViewDirectionBlock
  122556. * @param name defines the block name
  122557. */
  122558. constructor(name: string);
  122559. /**
  122560. * Gets the current class name
  122561. * @returns the class name
  122562. */
  122563. getClassName(): string;
  122564. /**
  122565. * Gets the world position component
  122566. */
  122567. readonly worldPosition: NodeMaterialConnectionPoint;
  122568. /**
  122569. * Gets the camera position component
  122570. */
  122571. readonly cameraPosition: NodeMaterialConnectionPoint;
  122572. /**
  122573. * Gets the output component
  122574. */
  122575. readonly output: NodeMaterialConnectionPoint;
  122576. autoConfigure(material: NodeMaterial): void;
  122577. protected _buildBlock(state: NodeMaterialBuildState): this;
  122578. }
  122579. }
  122580. declare module BABYLON {
  122581. /**
  122582. * Block used to compute fresnel value
  122583. */
  122584. export class FresnelBlock extends NodeMaterialBlock {
  122585. /**
  122586. * Create a new FresnelBlock
  122587. * @param name defines the block name
  122588. */
  122589. constructor(name: string);
  122590. /**
  122591. * Gets the current class name
  122592. * @returns the class name
  122593. */
  122594. getClassName(): string;
  122595. /**
  122596. * Gets the world normal input component
  122597. */
  122598. readonly worldNormal: NodeMaterialConnectionPoint;
  122599. /**
  122600. * Gets the view direction input component
  122601. */
  122602. readonly viewDirection: NodeMaterialConnectionPoint;
  122603. /**
  122604. * Gets the bias input component
  122605. */
  122606. readonly bias: NodeMaterialConnectionPoint;
  122607. /**
  122608. * Gets the camera (or eye) position component
  122609. */
  122610. readonly power: NodeMaterialConnectionPoint;
  122611. /**
  122612. * Gets the fresnel output component
  122613. */
  122614. readonly fresnel: NodeMaterialConnectionPoint;
  122615. autoConfigure(material: NodeMaterial): void;
  122616. protected _buildBlock(state: NodeMaterialBuildState): this;
  122617. }
  122618. }
  122619. declare module BABYLON {
  122620. /**
  122621. * Block used to get the max of 2 values
  122622. */
  122623. export class MaxBlock extends NodeMaterialBlock {
  122624. /**
  122625. * Creates a new MaxBlock
  122626. * @param name defines the block name
  122627. */
  122628. constructor(name: string);
  122629. /**
  122630. * Gets the current class name
  122631. * @returns the class name
  122632. */
  122633. getClassName(): string;
  122634. /**
  122635. * Gets the left operand input component
  122636. */
  122637. readonly left: NodeMaterialConnectionPoint;
  122638. /**
  122639. * Gets the right operand input component
  122640. */
  122641. readonly right: NodeMaterialConnectionPoint;
  122642. /**
  122643. * Gets the output component
  122644. */
  122645. readonly output: NodeMaterialConnectionPoint;
  122646. protected _buildBlock(state: NodeMaterialBuildState): this;
  122647. }
  122648. }
  122649. declare module BABYLON {
  122650. /**
  122651. * Block used to get the min of 2 values
  122652. */
  122653. export class MinBlock extends NodeMaterialBlock {
  122654. /**
  122655. * Creates a new MinBlock
  122656. * @param name defines the block name
  122657. */
  122658. constructor(name: string);
  122659. /**
  122660. * Gets the current class name
  122661. * @returns the class name
  122662. */
  122663. getClassName(): string;
  122664. /**
  122665. * Gets the left operand input component
  122666. */
  122667. readonly left: NodeMaterialConnectionPoint;
  122668. /**
  122669. * Gets the right operand input component
  122670. */
  122671. readonly right: NodeMaterialConnectionPoint;
  122672. /**
  122673. * Gets the output component
  122674. */
  122675. readonly output: NodeMaterialConnectionPoint;
  122676. protected _buildBlock(state: NodeMaterialBuildState): this;
  122677. }
  122678. }
  122679. declare module BABYLON {
  122680. /**
  122681. * Block used to get the distance between 2 values
  122682. */
  122683. export class DistanceBlock extends NodeMaterialBlock {
  122684. /**
  122685. * Creates a new DistanceBlock
  122686. * @param name defines the block name
  122687. */
  122688. constructor(name: string);
  122689. /**
  122690. * Gets the current class name
  122691. * @returns the class name
  122692. */
  122693. getClassName(): string;
  122694. /**
  122695. * Gets the left operand input component
  122696. */
  122697. readonly left: NodeMaterialConnectionPoint;
  122698. /**
  122699. * Gets the right operand input component
  122700. */
  122701. readonly right: NodeMaterialConnectionPoint;
  122702. /**
  122703. * Gets the output component
  122704. */
  122705. readonly output: NodeMaterialConnectionPoint;
  122706. protected _buildBlock(state: NodeMaterialBuildState): this;
  122707. }
  122708. }
  122709. declare module BABYLON {
  122710. /**
  122711. * Block used to get the length of a vector
  122712. */
  122713. export class LengthBlock extends NodeMaterialBlock {
  122714. /**
  122715. * Creates a new LengthBlock
  122716. * @param name defines the block name
  122717. */
  122718. constructor(name: string);
  122719. /**
  122720. * Gets the current class name
  122721. * @returns the class name
  122722. */
  122723. getClassName(): string;
  122724. /**
  122725. * Gets the value input component
  122726. */
  122727. readonly value: NodeMaterialConnectionPoint;
  122728. /**
  122729. * Gets the output component
  122730. */
  122731. readonly output: NodeMaterialConnectionPoint;
  122732. protected _buildBlock(state: NodeMaterialBuildState): this;
  122733. }
  122734. }
  122735. declare module BABYLON {
  122736. /**
  122737. * Block used to get negative version of a value (i.e. x * -1)
  122738. */
  122739. export class NegateBlock extends NodeMaterialBlock {
  122740. /**
  122741. * Creates a new NegateBlock
  122742. * @param name defines the block name
  122743. */
  122744. constructor(name: string);
  122745. /**
  122746. * Gets the current class name
  122747. * @returns the class name
  122748. */
  122749. getClassName(): string;
  122750. /**
  122751. * Gets the value input component
  122752. */
  122753. readonly value: NodeMaterialConnectionPoint;
  122754. /**
  122755. * Gets the output component
  122756. */
  122757. readonly output: NodeMaterialConnectionPoint;
  122758. protected _buildBlock(state: NodeMaterialBuildState): this;
  122759. }
  122760. }
  122761. declare module BABYLON {
  122762. /**
  122763. * Block used to get the value of the first parameter raised to the power of the second
  122764. */
  122765. export class PowBlock extends NodeMaterialBlock {
  122766. /**
  122767. * Creates a new PowBlock
  122768. * @param name defines the block name
  122769. */
  122770. constructor(name: string);
  122771. /**
  122772. * Gets the current class name
  122773. * @returns the class name
  122774. */
  122775. getClassName(): string;
  122776. /**
  122777. * Gets the value operand input component
  122778. */
  122779. readonly value: NodeMaterialConnectionPoint;
  122780. /**
  122781. * Gets the power operand input component
  122782. */
  122783. readonly power: NodeMaterialConnectionPoint;
  122784. /**
  122785. * Gets the output component
  122786. */
  122787. readonly output: NodeMaterialConnectionPoint;
  122788. protected _buildBlock(state: NodeMaterialBuildState): this;
  122789. }
  122790. }
  122791. declare module BABYLON {
  122792. /**
  122793. * Block used to get a random number
  122794. */
  122795. export class RandomNumberBlock extends NodeMaterialBlock {
  122796. /**
  122797. * Creates a new RandomNumberBlock
  122798. * @param name defines the block name
  122799. */
  122800. constructor(name: string);
  122801. /**
  122802. * Gets the current class name
  122803. * @returns the class name
  122804. */
  122805. getClassName(): string;
  122806. /**
  122807. * Gets the seed input component
  122808. */
  122809. readonly seed: NodeMaterialConnectionPoint;
  122810. /**
  122811. * Gets the output component
  122812. */
  122813. readonly output: NodeMaterialConnectionPoint;
  122814. protected _buildBlock(state: NodeMaterialBuildState): this;
  122815. }
  122816. }
  122817. declare module BABYLON {
  122818. /**
  122819. * Block used to compute arc tangent of 2 values
  122820. */
  122821. export class ArcTan2Block extends NodeMaterialBlock {
  122822. /**
  122823. * Creates a new ArcTan2Block
  122824. * @param name defines the block name
  122825. */
  122826. constructor(name: string);
  122827. /**
  122828. * Gets the current class name
  122829. * @returns the class name
  122830. */
  122831. getClassName(): string;
  122832. /**
  122833. * Gets the x operand input component
  122834. */
  122835. readonly x: NodeMaterialConnectionPoint;
  122836. /**
  122837. * Gets the y operand input component
  122838. */
  122839. readonly y: NodeMaterialConnectionPoint;
  122840. /**
  122841. * Gets the output component
  122842. */
  122843. readonly output: NodeMaterialConnectionPoint;
  122844. protected _buildBlock(state: NodeMaterialBuildState): this;
  122845. }
  122846. }
  122847. declare module BABYLON {
  122848. /**
  122849. * Block used to smooth step a value
  122850. */
  122851. export class SmoothStepBlock extends NodeMaterialBlock {
  122852. /**
  122853. * Creates a new SmoothStepBlock
  122854. * @param name defines the block name
  122855. */
  122856. constructor(name: string);
  122857. /**
  122858. * Gets the current class name
  122859. * @returns the class name
  122860. */
  122861. getClassName(): string;
  122862. /**
  122863. * Gets the value operand input component
  122864. */
  122865. readonly value: NodeMaterialConnectionPoint;
  122866. /**
  122867. * Gets the first edge operand input component
  122868. */
  122869. readonly edge0: NodeMaterialConnectionPoint;
  122870. /**
  122871. * Gets the second edge operand input component
  122872. */
  122873. readonly edge1: NodeMaterialConnectionPoint;
  122874. /**
  122875. * Gets the output component
  122876. */
  122877. readonly output: NodeMaterialConnectionPoint;
  122878. protected _buildBlock(state: NodeMaterialBuildState): this;
  122879. }
  122880. }
  122881. declare module BABYLON {
  122882. /**
  122883. * Block used to get the reciprocal (1 / x) of a value
  122884. */
  122885. export class ReciprocalBlock extends NodeMaterialBlock {
  122886. /**
  122887. * Creates a new ReciprocalBlock
  122888. * @param name defines the block name
  122889. */
  122890. constructor(name: string);
  122891. /**
  122892. * Gets the current class name
  122893. * @returns the class name
  122894. */
  122895. getClassName(): string;
  122896. /**
  122897. * Gets the input component
  122898. */
  122899. readonly input: NodeMaterialConnectionPoint;
  122900. /**
  122901. * Gets the output component
  122902. */
  122903. readonly output: NodeMaterialConnectionPoint;
  122904. protected _buildBlock(state: NodeMaterialBuildState): this;
  122905. }
  122906. }
  122907. declare module BABYLON {
  122908. /**
  122909. * Block used to replace a color by another one
  122910. */
  122911. export class ReplaceColorBlock extends NodeMaterialBlock {
  122912. /**
  122913. * Creates a new ReplaceColorBlock
  122914. * @param name defines the block name
  122915. */
  122916. constructor(name: string);
  122917. /**
  122918. * Gets the current class name
  122919. * @returns the class name
  122920. */
  122921. getClassName(): string;
  122922. /**
  122923. * Gets the value input component
  122924. */
  122925. readonly value: NodeMaterialConnectionPoint;
  122926. /**
  122927. * Gets the reference input component
  122928. */
  122929. readonly reference: NodeMaterialConnectionPoint;
  122930. /**
  122931. * Gets the distance input component
  122932. */
  122933. readonly distance: NodeMaterialConnectionPoint;
  122934. /**
  122935. * Gets the replacement input component
  122936. */
  122937. readonly replacement: NodeMaterialConnectionPoint;
  122938. /**
  122939. * Gets the output component
  122940. */
  122941. readonly output: NodeMaterialConnectionPoint;
  122942. protected _buildBlock(state: NodeMaterialBuildState): this;
  122943. }
  122944. }
  122945. declare module BABYLON {
  122946. /**
  122947. * Block used to posterize a value
  122948. * @see https://en.wikipedia.org/wiki/Posterization
  122949. */
  122950. export class PosterizeBlock extends NodeMaterialBlock {
  122951. /**
  122952. * Creates a new PosterizeBlock
  122953. * @param name defines the block name
  122954. */
  122955. constructor(name: string);
  122956. /**
  122957. * Gets the current class name
  122958. * @returns the class name
  122959. */
  122960. getClassName(): string;
  122961. /**
  122962. * Gets the value input component
  122963. */
  122964. readonly value: NodeMaterialConnectionPoint;
  122965. /**
  122966. * Gets the steps input component
  122967. */
  122968. readonly steps: NodeMaterialConnectionPoint;
  122969. /**
  122970. * Gets the output component
  122971. */
  122972. readonly output: NodeMaterialConnectionPoint;
  122973. protected _buildBlock(state: NodeMaterialBuildState): this;
  122974. }
  122975. }
  122976. declare module BABYLON {
  122977. /**
  122978. * Operations supported by the Wave block
  122979. */
  122980. export enum WaveBlockKind {
  122981. /** SawTooth */
  122982. SawTooth = 0,
  122983. /** Square */
  122984. Square = 1,
  122985. /** Triangle */
  122986. Triangle = 2
  122987. }
  122988. /**
  122989. * Block used to apply wave operation to floats
  122990. */
  122991. export class WaveBlock extends NodeMaterialBlock {
  122992. /**
  122993. * Gets or sets the kibnd of wave to be applied by the block
  122994. */
  122995. kind: WaveBlockKind;
  122996. /**
  122997. * Creates a new WaveBlock
  122998. * @param name defines the block name
  122999. */
  123000. constructor(name: string);
  123001. /**
  123002. * Gets the current class name
  123003. * @returns the class name
  123004. */
  123005. getClassName(): string;
  123006. /**
  123007. * Gets the input component
  123008. */
  123009. readonly input: NodeMaterialConnectionPoint;
  123010. /**
  123011. * Gets the output component
  123012. */
  123013. readonly output: NodeMaterialConnectionPoint;
  123014. protected _buildBlock(state: NodeMaterialBuildState): this;
  123015. serialize(): any;
  123016. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123017. }
  123018. }
  123019. declare module BABYLON {
  123020. /**
  123021. * Class used to store a color step for the GradientBlock
  123022. */
  123023. export class GradientBlockColorStep {
  123024. /**
  123025. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123026. */
  123027. step: number;
  123028. /**
  123029. * Gets or sets the color associated with this step
  123030. */
  123031. color: Color3;
  123032. /**
  123033. * Creates a new GradientBlockColorStep
  123034. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  123035. * @param color defines the color associated with this step
  123036. */
  123037. constructor(
  123038. /**
  123039. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123040. */
  123041. step: number,
  123042. /**
  123043. * Gets or sets the color associated with this step
  123044. */
  123045. color: Color3);
  123046. }
  123047. /**
  123048. * Block used to return a color from a gradient based on an input value between 0 and 1
  123049. */
  123050. export class GradientBlock extends NodeMaterialBlock {
  123051. /**
  123052. * Gets or sets the list of color steps
  123053. */
  123054. colorSteps: GradientBlockColorStep[];
  123055. /**
  123056. * Creates a new GradientBlock
  123057. * @param name defines the block name
  123058. */
  123059. constructor(name: string);
  123060. /**
  123061. * Gets the current class name
  123062. * @returns the class name
  123063. */
  123064. getClassName(): string;
  123065. /**
  123066. * Gets the gradient input component
  123067. */
  123068. readonly gradient: NodeMaterialConnectionPoint;
  123069. /**
  123070. * Gets the output component
  123071. */
  123072. readonly output: NodeMaterialConnectionPoint;
  123073. private _writeColorConstant;
  123074. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123075. serialize(): any;
  123076. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123077. protected _dumpPropertiesCode(): string;
  123078. }
  123079. }
  123080. declare module BABYLON {
  123081. /**
  123082. * Block used to normalize lerp between 2 values
  123083. */
  123084. export class NLerpBlock extends NodeMaterialBlock {
  123085. /**
  123086. * Creates a new NLerpBlock
  123087. * @param name defines the block name
  123088. */
  123089. constructor(name: string);
  123090. /**
  123091. * Gets the current class name
  123092. * @returns the class name
  123093. */
  123094. getClassName(): string;
  123095. /**
  123096. * Gets the left operand input component
  123097. */
  123098. readonly left: NodeMaterialConnectionPoint;
  123099. /**
  123100. * Gets the right operand input component
  123101. */
  123102. readonly right: NodeMaterialConnectionPoint;
  123103. /**
  123104. * Gets the gradient operand input component
  123105. */
  123106. readonly gradient: NodeMaterialConnectionPoint;
  123107. /**
  123108. * Gets the output component
  123109. */
  123110. readonly output: NodeMaterialConnectionPoint;
  123111. protected _buildBlock(state: NodeMaterialBuildState): this;
  123112. }
  123113. }
  123114. declare module BABYLON {
  123115. /**
  123116. * Effect Render Options
  123117. */
  123118. export interface IEffectRendererOptions {
  123119. /**
  123120. * Defines the vertices positions.
  123121. */
  123122. positions?: number[];
  123123. /**
  123124. * Defines the indices.
  123125. */
  123126. indices?: number[];
  123127. }
  123128. /**
  123129. * Helper class to render one or more effects
  123130. */
  123131. export class EffectRenderer {
  123132. private engine;
  123133. private static _DefaultOptions;
  123134. private _vertexBuffers;
  123135. private _indexBuffer;
  123136. private _ringBufferIndex;
  123137. private _ringScreenBuffer;
  123138. private _fullscreenViewport;
  123139. private _getNextFrameBuffer;
  123140. /**
  123141. * Creates an effect renderer
  123142. * @param engine the engine to use for rendering
  123143. * @param options defines the options of the effect renderer
  123144. */
  123145. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  123146. /**
  123147. * Sets the current viewport in normalized coordinates 0-1
  123148. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  123149. */
  123150. setViewport(viewport?: Viewport): void;
  123151. /**
  123152. * Binds the embedded attributes buffer to the effect.
  123153. * @param effect Defines the effect to bind the attributes for
  123154. */
  123155. bindBuffers(effect: Effect): void;
  123156. /**
  123157. * Sets the current effect wrapper to use during draw.
  123158. * The effect needs to be ready before calling this api.
  123159. * This also sets the default full screen position attribute.
  123160. * @param effectWrapper Defines the effect to draw with
  123161. */
  123162. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  123163. /**
  123164. * Draws a full screen quad.
  123165. */
  123166. draw(): void;
  123167. /**
  123168. * renders one or more effects to a specified texture
  123169. * @param effectWrappers list of effects to renderer
  123170. * @param outputTexture texture to draw to, if null it will render to the screen
  123171. */
  123172. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  123173. /**
  123174. * Disposes of the effect renderer
  123175. */
  123176. dispose(): void;
  123177. }
  123178. /**
  123179. * Options to create an EffectWrapper
  123180. */
  123181. interface EffectWrapperCreationOptions {
  123182. /**
  123183. * Engine to use to create the effect
  123184. */
  123185. engine: ThinEngine;
  123186. /**
  123187. * Fragment shader for the effect
  123188. */
  123189. fragmentShader: string;
  123190. /**
  123191. * Vertex shader for the effect
  123192. */
  123193. vertexShader?: string;
  123194. /**
  123195. * Attributes to use in the shader
  123196. */
  123197. attributeNames?: Array<string>;
  123198. /**
  123199. * Uniforms to use in the shader
  123200. */
  123201. uniformNames?: Array<string>;
  123202. /**
  123203. * Texture sampler names to use in the shader
  123204. */
  123205. samplerNames?: Array<string>;
  123206. /**
  123207. * The friendly name of the effect displayed in Spector.
  123208. */
  123209. name?: string;
  123210. }
  123211. /**
  123212. * Wraps an effect to be used for rendering
  123213. */
  123214. export class EffectWrapper {
  123215. /**
  123216. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  123217. */
  123218. onApplyObservable: Observable<{}>;
  123219. /**
  123220. * The underlying effect
  123221. */
  123222. effect: Effect;
  123223. /**
  123224. * Creates an effect to be renderer
  123225. * @param creationOptions options to create the effect
  123226. */
  123227. constructor(creationOptions: EffectWrapperCreationOptions);
  123228. /**
  123229. * Disposes of the effect wrapper
  123230. */
  123231. dispose(): void;
  123232. }
  123233. }
  123234. declare module BABYLON {
  123235. /**
  123236. * Helper class to push actions to a pool of workers.
  123237. */
  123238. export class WorkerPool implements IDisposable {
  123239. private _workerInfos;
  123240. private _pendingActions;
  123241. /**
  123242. * Constructor
  123243. * @param workers Array of workers to use for actions
  123244. */
  123245. constructor(workers: Array<Worker>);
  123246. /**
  123247. * Terminates all workers and clears any pending actions.
  123248. */
  123249. dispose(): void;
  123250. /**
  123251. * Pushes an action to the worker pool. If all the workers are active, the action will be
  123252. * pended until a worker has completed its action.
  123253. * @param action The action to perform. Call onComplete when the action is complete.
  123254. */
  123255. push(action: (worker: Worker, onComplete: () => void) => void): void;
  123256. private _execute;
  123257. }
  123258. }
  123259. declare module BABYLON {
  123260. /**
  123261. * Configuration for Draco compression
  123262. */
  123263. export interface IDracoCompressionConfiguration {
  123264. /**
  123265. * Configuration for the decoder.
  123266. */
  123267. decoder: {
  123268. /**
  123269. * The url to the WebAssembly module.
  123270. */
  123271. wasmUrl?: string;
  123272. /**
  123273. * The url to the WebAssembly binary.
  123274. */
  123275. wasmBinaryUrl?: string;
  123276. /**
  123277. * The url to the fallback JavaScript module.
  123278. */
  123279. fallbackUrl?: string;
  123280. };
  123281. }
  123282. /**
  123283. * Draco compression (https://google.github.io/draco/)
  123284. *
  123285. * This class wraps the Draco module.
  123286. *
  123287. * **Encoder**
  123288. *
  123289. * The encoder is not currently implemented.
  123290. *
  123291. * **Decoder**
  123292. *
  123293. * 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.
  123294. *
  123295. * To update the configuration, use the following code:
  123296. * ```javascript
  123297. * DracoCompression.Configuration = {
  123298. * decoder: {
  123299. * wasmUrl: "<url to the WebAssembly library>",
  123300. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  123301. * fallbackUrl: "<url to the fallback JavaScript library>",
  123302. * }
  123303. * };
  123304. * ```
  123305. *
  123306. * 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.
  123307. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  123308. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  123309. *
  123310. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  123311. * ```javascript
  123312. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  123313. * ```
  123314. *
  123315. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  123316. */
  123317. export class DracoCompression implements IDisposable {
  123318. private _workerPoolPromise?;
  123319. private _decoderModulePromise?;
  123320. /**
  123321. * The configuration. Defaults to the following urls:
  123322. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  123323. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  123324. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  123325. */
  123326. static Configuration: IDracoCompressionConfiguration;
  123327. /**
  123328. * Returns true if the decoder configuration is available.
  123329. */
  123330. static readonly DecoderAvailable: boolean;
  123331. /**
  123332. * Default number of workers to create when creating the draco compression object.
  123333. */
  123334. static DefaultNumWorkers: number;
  123335. private static GetDefaultNumWorkers;
  123336. private static _Default;
  123337. /**
  123338. * Default instance for the draco compression object.
  123339. */
  123340. static readonly Default: DracoCompression;
  123341. /**
  123342. * Constructor
  123343. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  123344. */
  123345. constructor(numWorkers?: number);
  123346. /**
  123347. * Stop all async operations and release resources.
  123348. */
  123349. dispose(): void;
  123350. /**
  123351. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  123352. * @returns a promise that resolves when ready
  123353. */
  123354. whenReadyAsync(): Promise<void>;
  123355. /**
  123356. * Decode Draco compressed mesh data to vertex data.
  123357. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  123358. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  123359. * @returns A promise that resolves with the decoded vertex data
  123360. */
  123361. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  123362. [kind: string]: number;
  123363. }): Promise<VertexData>;
  123364. }
  123365. }
  123366. declare module BABYLON {
  123367. /**
  123368. * Class for building Constructive Solid Geometry
  123369. */
  123370. export class CSG {
  123371. private polygons;
  123372. /**
  123373. * The world matrix
  123374. */
  123375. matrix: Matrix;
  123376. /**
  123377. * Stores the position
  123378. */
  123379. position: Vector3;
  123380. /**
  123381. * Stores the rotation
  123382. */
  123383. rotation: Vector3;
  123384. /**
  123385. * Stores the rotation quaternion
  123386. */
  123387. rotationQuaternion: Nullable<Quaternion>;
  123388. /**
  123389. * Stores the scaling vector
  123390. */
  123391. scaling: Vector3;
  123392. /**
  123393. * Convert the Mesh to CSG
  123394. * @param mesh The Mesh to convert to CSG
  123395. * @returns A new CSG from the Mesh
  123396. */
  123397. static FromMesh(mesh: Mesh): CSG;
  123398. /**
  123399. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  123400. * @param polygons Polygons used to construct a CSG solid
  123401. */
  123402. private static FromPolygons;
  123403. /**
  123404. * Clones, or makes a deep copy, of the CSG
  123405. * @returns A new CSG
  123406. */
  123407. clone(): CSG;
  123408. /**
  123409. * Unions this CSG with another CSG
  123410. * @param csg The CSG to union against this CSG
  123411. * @returns The unioned CSG
  123412. */
  123413. union(csg: CSG): CSG;
  123414. /**
  123415. * Unions this CSG with another CSG in place
  123416. * @param csg The CSG to union against this CSG
  123417. */
  123418. unionInPlace(csg: CSG): void;
  123419. /**
  123420. * Subtracts this CSG with another CSG
  123421. * @param csg The CSG to subtract against this CSG
  123422. * @returns A new CSG
  123423. */
  123424. subtract(csg: CSG): CSG;
  123425. /**
  123426. * Subtracts this CSG with another CSG in place
  123427. * @param csg The CSG to subtact against this CSG
  123428. */
  123429. subtractInPlace(csg: CSG): void;
  123430. /**
  123431. * Intersect this CSG with another CSG
  123432. * @param csg The CSG to intersect against this CSG
  123433. * @returns A new CSG
  123434. */
  123435. intersect(csg: CSG): CSG;
  123436. /**
  123437. * Intersects this CSG with another CSG in place
  123438. * @param csg The CSG to intersect against this CSG
  123439. */
  123440. intersectInPlace(csg: CSG): void;
  123441. /**
  123442. * Return a new CSG solid with solid and empty space switched. This solid is
  123443. * not modified.
  123444. * @returns A new CSG solid with solid and empty space switched
  123445. */
  123446. inverse(): CSG;
  123447. /**
  123448. * Inverses the CSG in place
  123449. */
  123450. inverseInPlace(): void;
  123451. /**
  123452. * This is used to keep meshes transformations so they can be restored
  123453. * when we build back a Babylon Mesh
  123454. * NB : All CSG operations are performed in world coordinates
  123455. * @param csg The CSG to copy the transform attributes from
  123456. * @returns This CSG
  123457. */
  123458. copyTransformAttributes(csg: CSG): CSG;
  123459. /**
  123460. * Build Raw mesh from CSG
  123461. * Coordinates here are in world space
  123462. * @param name The name of the mesh geometry
  123463. * @param scene The Scene
  123464. * @param keepSubMeshes Specifies if the submeshes should be kept
  123465. * @returns A new Mesh
  123466. */
  123467. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123468. /**
  123469. * Build Mesh from CSG taking material and transforms into account
  123470. * @param name The name of the Mesh
  123471. * @param material The material of the Mesh
  123472. * @param scene The Scene
  123473. * @param keepSubMeshes Specifies if submeshes should be kept
  123474. * @returns The new Mesh
  123475. */
  123476. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123477. }
  123478. }
  123479. declare module BABYLON {
  123480. /**
  123481. * Class used to create a trail following a mesh
  123482. */
  123483. export class TrailMesh extends Mesh {
  123484. private _generator;
  123485. private _autoStart;
  123486. private _running;
  123487. private _diameter;
  123488. private _length;
  123489. private _sectionPolygonPointsCount;
  123490. private _sectionVectors;
  123491. private _sectionNormalVectors;
  123492. private _beforeRenderObserver;
  123493. /**
  123494. * @constructor
  123495. * @param name The value used by scene.getMeshByName() to do a lookup.
  123496. * @param generator The mesh to generate a trail.
  123497. * @param scene The scene to add this mesh to.
  123498. * @param diameter Diameter of trailing mesh. Default is 1.
  123499. * @param length Length of trailing mesh. Default is 60.
  123500. * @param autoStart Automatically start trailing mesh. Default true.
  123501. */
  123502. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  123503. /**
  123504. * "TrailMesh"
  123505. * @returns "TrailMesh"
  123506. */
  123507. getClassName(): string;
  123508. private _createMesh;
  123509. /**
  123510. * Start trailing mesh.
  123511. */
  123512. start(): void;
  123513. /**
  123514. * Stop trailing mesh.
  123515. */
  123516. stop(): void;
  123517. /**
  123518. * Update trailing mesh geometry.
  123519. */
  123520. update(): void;
  123521. /**
  123522. * Returns a new TrailMesh object.
  123523. * @param name is a string, the name given to the new mesh
  123524. * @param newGenerator use new generator object for cloned trail mesh
  123525. * @returns a new mesh
  123526. */
  123527. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  123528. /**
  123529. * Serializes this trail mesh
  123530. * @param serializationObject object to write serialization to
  123531. */
  123532. serialize(serializationObject: any): void;
  123533. /**
  123534. * Parses a serialized trail mesh
  123535. * @param parsedMesh the serialized mesh
  123536. * @param scene the scene to create the trail mesh in
  123537. * @returns the created trail mesh
  123538. */
  123539. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  123540. }
  123541. }
  123542. declare module BABYLON {
  123543. /**
  123544. * Class containing static functions to help procedurally build meshes
  123545. */
  123546. export class TiledBoxBuilder {
  123547. /**
  123548. * Creates a box mesh
  123549. * 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)
  123550. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123554. * @param name defines the name of the mesh
  123555. * @param options defines the options used to create the mesh
  123556. * @param scene defines the hosting scene
  123557. * @returns the box mesh
  123558. */
  123559. static CreateTiledBox(name: string, options: {
  123560. pattern?: number;
  123561. width?: number;
  123562. height?: number;
  123563. depth?: number;
  123564. tileSize?: number;
  123565. tileWidth?: number;
  123566. tileHeight?: number;
  123567. alignHorizontal?: number;
  123568. alignVertical?: number;
  123569. faceUV?: Vector4[];
  123570. faceColors?: Color4[];
  123571. sideOrientation?: number;
  123572. updatable?: boolean;
  123573. }, scene?: Nullable<Scene>): Mesh;
  123574. }
  123575. }
  123576. declare module BABYLON {
  123577. /**
  123578. * Class containing static functions to help procedurally build meshes
  123579. */
  123580. export class TorusKnotBuilder {
  123581. /**
  123582. * Creates a torus knot mesh
  123583. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123584. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123585. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123586. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123590. * @param name defines the name of the mesh
  123591. * @param options defines the options used to create the mesh
  123592. * @param scene defines the hosting scene
  123593. * @returns the torus knot mesh
  123594. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123595. */
  123596. static CreateTorusKnot(name: string, options: {
  123597. radius?: number;
  123598. tube?: number;
  123599. radialSegments?: number;
  123600. tubularSegments?: number;
  123601. p?: number;
  123602. q?: number;
  123603. updatable?: boolean;
  123604. sideOrientation?: number;
  123605. frontUVs?: Vector4;
  123606. backUVs?: Vector4;
  123607. }, scene: any): Mesh;
  123608. }
  123609. }
  123610. declare module BABYLON {
  123611. /**
  123612. * Polygon
  123613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  123614. */
  123615. export class Polygon {
  123616. /**
  123617. * Creates a rectangle
  123618. * @param xmin bottom X coord
  123619. * @param ymin bottom Y coord
  123620. * @param xmax top X coord
  123621. * @param ymax top Y coord
  123622. * @returns points that make the resulting rectation
  123623. */
  123624. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  123625. /**
  123626. * Creates a circle
  123627. * @param radius radius of circle
  123628. * @param cx scale in x
  123629. * @param cy scale in y
  123630. * @param numberOfSides number of sides that make up the circle
  123631. * @returns points that make the resulting circle
  123632. */
  123633. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  123634. /**
  123635. * Creates a polygon from input string
  123636. * @param input Input polygon data
  123637. * @returns the parsed points
  123638. */
  123639. static Parse(input: string): Vector2[];
  123640. /**
  123641. * Starts building a polygon from x and y coordinates
  123642. * @param x x coordinate
  123643. * @param y y coordinate
  123644. * @returns the started path2
  123645. */
  123646. static StartingAt(x: number, y: number): Path2;
  123647. }
  123648. /**
  123649. * Builds a polygon
  123650. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  123651. */
  123652. export class PolygonMeshBuilder {
  123653. private _points;
  123654. private _outlinepoints;
  123655. private _holes;
  123656. private _name;
  123657. private _scene;
  123658. private _epoints;
  123659. private _eholes;
  123660. private _addToepoint;
  123661. /**
  123662. * Babylon reference to the earcut plugin.
  123663. */
  123664. bjsEarcut: any;
  123665. /**
  123666. * Creates a PolygonMeshBuilder
  123667. * @param name name of the builder
  123668. * @param contours Path of the polygon
  123669. * @param scene scene to add to when creating the mesh
  123670. * @param earcutInjection can be used to inject your own earcut reference
  123671. */
  123672. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  123673. /**
  123674. * Adds a whole within the polygon
  123675. * @param hole Array of points defining the hole
  123676. * @returns this
  123677. */
  123678. addHole(hole: Vector2[]): PolygonMeshBuilder;
  123679. /**
  123680. * Creates the polygon
  123681. * @param updatable If the mesh should be updatable
  123682. * @param depth The depth of the mesh created
  123683. * @returns the created mesh
  123684. */
  123685. build(updatable?: boolean, depth?: number): Mesh;
  123686. /**
  123687. * Creates the polygon
  123688. * @param depth The depth of the mesh created
  123689. * @returns the created VertexData
  123690. */
  123691. buildVertexData(depth?: number): VertexData;
  123692. /**
  123693. * Adds a side to the polygon
  123694. * @param positions points that make the polygon
  123695. * @param normals normals of the polygon
  123696. * @param uvs uvs of the polygon
  123697. * @param indices indices of the polygon
  123698. * @param bounds bounds of the polygon
  123699. * @param points points of the polygon
  123700. * @param depth depth of the polygon
  123701. * @param flip flip of the polygon
  123702. */
  123703. private addSide;
  123704. }
  123705. }
  123706. declare module BABYLON {
  123707. /**
  123708. * Class containing static functions to help procedurally build meshes
  123709. */
  123710. export class PolygonBuilder {
  123711. /**
  123712. * Creates a polygon mesh
  123713. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123714. * * 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
  123715. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123718. * * Remember you can only change the shape positions, not their number when updating a polygon
  123719. * @param name defines the name of the mesh
  123720. * @param options defines the options used to create the mesh
  123721. * @param scene defines the hosting scene
  123722. * @param earcutInjection can be used to inject your own earcut reference
  123723. * @returns the polygon mesh
  123724. */
  123725. static CreatePolygon(name: string, options: {
  123726. shape: Vector3[];
  123727. holes?: Vector3[][];
  123728. depth?: number;
  123729. faceUV?: Vector4[];
  123730. faceColors?: Color4[];
  123731. updatable?: boolean;
  123732. sideOrientation?: number;
  123733. frontUVs?: Vector4;
  123734. backUVs?: Vector4;
  123735. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123736. /**
  123737. * Creates an extruded polygon mesh, with depth in the Y direction.
  123738. * * 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)
  123739. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123740. * @param name defines the name of the mesh
  123741. * @param options defines the options used to create the mesh
  123742. * @param scene defines the hosting scene
  123743. * @param earcutInjection can be used to inject your own earcut reference
  123744. * @returns the polygon mesh
  123745. */
  123746. static ExtrudePolygon(name: string, options: {
  123747. shape: Vector3[];
  123748. holes?: Vector3[][];
  123749. depth?: number;
  123750. faceUV?: Vector4[];
  123751. faceColors?: Color4[];
  123752. updatable?: boolean;
  123753. sideOrientation?: number;
  123754. frontUVs?: Vector4;
  123755. backUVs?: Vector4;
  123756. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123757. }
  123758. }
  123759. declare module BABYLON {
  123760. /**
  123761. * Class containing static functions to help procedurally build meshes
  123762. */
  123763. export class LatheBuilder {
  123764. /**
  123765. * Creates lathe mesh.
  123766. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123767. * * 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
  123768. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123769. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123770. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123771. * * 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
  123772. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123773. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123778. * @param name defines the name of the mesh
  123779. * @param options defines the options used to create the mesh
  123780. * @param scene defines the hosting scene
  123781. * @returns the lathe mesh
  123782. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123783. */
  123784. static CreateLathe(name: string, options: {
  123785. shape: Vector3[];
  123786. radius?: number;
  123787. tessellation?: number;
  123788. clip?: number;
  123789. arc?: number;
  123790. closed?: boolean;
  123791. updatable?: boolean;
  123792. sideOrientation?: number;
  123793. frontUVs?: Vector4;
  123794. backUVs?: Vector4;
  123795. cap?: number;
  123796. invertUV?: boolean;
  123797. }, scene?: Nullable<Scene>): Mesh;
  123798. }
  123799. }
  123800. declare module BABYLON {
  123801. /**
  123802. * Class containing static functions to help procedurally build meshes
  123803. */
  123804. export class TiledPlaneBuilder {
  123805. /**
  123806. * Creates a tiled plane mesh
  123807. * * The parameter `pattern` will, depending on value, do nothing or
  123808. * * * flip (reflect about central vertical) alternate tiles across and up
  123809. * * * flip every tile on alternate rows
  123810. * * * rotate (180 degs) alternate tiles across and up
  123811. * * * rotate every tile on alternate rows
  123812. * * * flip and rotate alternate tiles across and up
  123813. * * * flip and rotate every tile on alternate rows
  123814. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123815. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123817. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123818. * * 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)
  123819. * * 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)
  123820. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123821. * @param name defines the name of the mesh
  123822. * @param options defines the options used to create the mesh
  123823. * @param scene defines the hosting scene
  123824. * @returns the box mesh
  123825. */
  123826. static CreateTiledPlane(name: string, options: {
  123827. pattern?: number;
  123828. tileSize?: number;
  123829. tileWidth?: number;
  123830. tileHeight?: number;
  123831. size?: number;
  123832. width?: number;
  123833. height?: number;
  123834. alignHorizontal?: number;
  123835. alignVertical?: number;
  123836. sideOrientation?: number;
  123837. frontUVs?: Vector4;
  123838. backUVs?: Vector4;
  123839. updatable?: boolean;
  123840. }, scene?: Nullable<Scene>): Mesh;
  123841. }
  123842. }
  123843. declare module BABYLON {
  123844. /**
  123845. * Class containing static functions to help procedurally build meshes
  123846. */
  123847. export class TubeBuilder {
  123848. /**
  123849. * Creates a tube mesh.
  123850. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123851. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123852. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123853. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123854. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123855. * * 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)
  123856. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123857. * * 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
  123858. * * 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
  123859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123861. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123863. * @param name defines the name of the mesh
  123864. * @param options defines the options used to create the mesh
  123865. * @param scene defines the hosting scene
  123866. * @returns the tube mesh
  123867. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123868. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123869. */
  123870. static CreateTube(name: string, options: {
  123871. path: Vector3[];
  123872. radius?: number;
  123873. tessellation?: number;
  123874. radiusFunction?: {
  123875. (i: number, distance: number): number;
  123876. };
  123877. cap?: number;
  123878. arc?: number;
  123879. updatable?: boolean;
  123880. sideOrientation?: number;
  123881. frontUVs?: Vector4;
  123882. backUVs?: Vector4;
  123883. instance?: Mesh;
  123884. invertUV?: boolean;
  123885. }, scene?: Nullable<Scene>): Mesh;
  123886. }
  123887. }
  123888. declare module BABYLON {
  123889. /**
  123890. * Class containing static functions to help procedurally build meshes
  123891. */
  123892. export class IcoSphereBuilder {
  123893. /**
  123894. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123895. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123896. * * 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`)
  123897. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123898. * * 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
  123899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123902. * @param name defines the name of the mesh
  123903. * @param options defines the options used to create the mesh
  123904. * @param scene defines the hosting scene
  123905. * @returns the icosahedron mesh
  123906. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123907. */
  123908. static CreateIcoSphere(name: string, options: {
  123909. radius?: number;
  123910. radiusX?: number;
  123911. radiusY?: number;
  123912. radiusZ?: number;
  123913. flat?: boolean;
  123914. subdivisions?: number;
  123915. sideOrientation?: number;
  123916. frontUVs?: Vector4;
  123917. backUVs?: Vector4;
  123918. updatable?: boolean;
  123919. }, scene?: Nullable<Scene>): Mesh;
  123920. }
  123921. }
  123922. declare module BABYLON {
  123923. /**
  123924. * Class containing static functions to help procedurally build meshes
  123925. */
  123926. export class DecalBuilder {
  123927. /**
  123928. * Creates a decal mesh.
  123929. * 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
  123930. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123931. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123932. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123933. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123934. * @param name defines the name of the mesh
  123935. * @param sourceMesh defines the mesh where the decal must be applied
  123936. * @param options defines the options used to create the mesh
  123937. * @param scene defines the hosting scene
  123938. * @returns the decal mesh
  123939. * @see https://doc.babylonjs.com/how_to/decals
  123940. */
  123941. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123942. position?: Vector3;
  123943. normal?: Vector3;
  123944. size?: Vector3;
  123945. angle?: number;
  123946. }): Mesh;
  123947. }
  123948. }
  123949. declare module BABYLON {
  123950. /**
  123951. * Class containing static functions to help procedurally build meshes
  123952. */
  123953. export class MeshBuilder {
  123954. /**
  123955. * Creates a box mesh
  123956. * * The parameter `size` sets the size (float) of each box side (default 1)
  123957. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123958. * * 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)
  123959. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123963. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123964. * @param name defines the name of the mesh
  123965. * @param options defines the options used to create the mesh
  123966. * @param scene defines the hosting scene
  123967. * @returns the box mesh
  123968. */
  123969. static CreateBox(name: string, options: {
  123970. size?: number;
  123971. width?: number;
  123972. height?: number;
  123973. depth?: number;
  123974. faceUV?: Vector4[];
  123975. faceColors?: Color4[];
  123976. sideOrientation?: number;
  123977. frontUVs?: Vector4;
  123978. backUVs?: Vector4;
  123979. updatable?: boolean;
  123980. }, scene?: Nullable<Scene>): Mesh;
  123981. /**
  123982. * Creates a tiled box mesh
  123983. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123985. * @param name defines the name of the mesh
  123986. * @param options defines the options used to create the mesh
  123987. * @param scene defines the hosting scene
  123988. * @returns the tiled box mesh
  123989. */
  123990. static CreateTiledBox(name: string, options: {
  123991. pattern?: number;
  123992. size?: number;
  123993. width?: number;
  123994. height?: number;
  123995. depth: number;
  123996. tileSize?: number;
  123997. tileWidth?: number;
  123998. tileHeight?: number;
  123999. faceUV?: Vector4[];
  124000. faceColors?: Color4[];
  124001. alignHorizontal?: number;
  124002. alignVertical?: number;
  124003. sideOrientation?: number;
  124004. updatable?: boolean;
  124005. }, scene?: Nullable<Scene>): Mesh;
  124006. /**
  124007. * Creates a sphere mesh
  124008. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124009. * * 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`)
  124010. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124011. * * 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
  124012. * * 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)
  124013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124016. * @param name defines the name of the mesh
  124017. * @param options defines the options used to create the mesh
  124018. * @param scene defines the hosting scene
  124019. * @returns the sphere mesh
  124020. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124021. */
  124022. static CreateSphere(name: string, options: {
  124023. segments?: number;
  124024. diameter?: number;
  124025. diameterX?: number;
  124026. diameterY?: number;
  124027. diameterZ?: number;
  124028. arc?: number;
  124029. slice?: number;
  124030. sideOrientation?: number;
  124031. frontUVs?: Vector4;
  124032. backUVs?: Vector4;
  124033. updatable?: boolean;
  124034. }, scene?: Nullable<Scene>): Mesh;
  124035. /**
  124036. * Creates a plane polygonal mesh. By default, this is a disc
  124037. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  124038. * * 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
  124039. * * 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
  124040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124043. * @param name defines the name of the mesh
  124044. * @param options defines the options used to create the mesh
  124045. * @param scene defines the hosting scene
  124046. * @returns the plane polygonal mesh
  124047. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  124048. */
  124049. static CreateDisc(name: string, options: {
  124050. radius?: number;
  124051. tessellation?: number;
  124052. arc?: number;
  124053. updatable?: boolean;
  124054. sideOrientation?: number;
  124055. frontUVs?: Vector4;
  124056. backUVs?: Vector4;
  124057. }, scene?: Nullable<Scene>): Mesh;
  124058. /**
  124059. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124060. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124061. * * 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`)
  124062. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124063. * * 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
  124064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124067. * @param name defines the name of the mesh
  124068. * @param options defines the options used to create the mesh
  124069. * @param scene defines the hosting scene
  124070. * @returns the icosahedron mesh
  124071. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  124072. */
  124073. static CreateIcoSphere(name: string, options: {
  124074. radius?: number;
  124075. radiusX?: number;
  124076. radiusY?: number;
  124077. radiusZ?: number;
  124078. flat?: boolean;
  124079. subdivisions?: number;
  124080. sideOrientation?: number;
  124081. frontUVs?: Vector4;
  124082. backUVs?: Vector4;
  124083. updatable?: boolean;
  124084. }, scene?: Nullable<Scene>): Mesh;
  124085. /**
  124086. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124087. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124088. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124089. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124090. * * 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
  124091. * * 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
  124092. * * 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
  124093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124096. * * 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
  124097. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124098. * * 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
  124099. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124101. * @param name defines the name of the mesh
  124102. * @param options defines the options used to create the mesh
  124103. * @param scene defines the hosting scene
  124104. * @returns the ribbon mesh
  124105. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124106. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124107. */
  124108. static CreateRibbon(name: string, options: {
  124109. pathArray: Vector3[][];
  124110. closeArray?: boolean;
  124111. closePath?: boolean;
  124112. offset?: number;
  124113. updatable?: boolean;
  124114. sideOrientation?: number;
  124115. frontUVs?: Vector4;
  124116. backUVs?: Vector4;
  124117. instance?: Mesh;
  124118. invertUV?: boolean;
  124119. uvs?: Vector2[];
  124120. colors?: Color4[];
  124121. }, scene?: Nullable<Scene>): Mesh;
  124122. /**
  124123. * Creates a cylinder or a cone mesh
  124124. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124125. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124126. * * 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.
  124127. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124128. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124129. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124130. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124131. * * 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).
  124132. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124133. * * 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).
  124134. * * 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
  124135. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124136. * * 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
  124137. * * 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.
  124138. * * If `enclose` is false, a ring surface is one element.
  124139. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124140. * * 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
  124141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124144. * @param name defines the name of the mesh
  124145. * @param options defines the options used to create the mesh
  124146. * @param scene defines the hosting scene
  124147. * @returns the cylinder mesh
  124148. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124149. */
  124150. static CreateCylinder(name: string, options: {
  124151. height?: number;
  124152. diameterTop?: number;
  124153. diameterBottom?: number;
  124154. diameter?: number;
  124155. tessellation?: number;
  124156. subdivisions?: number;
  124157. arc?: number;
  124158. faceColors?: Color4[];
  124159. faceUV?: Vector4[];
  124160. updatable?: boolean;
  124161. hasRings?: boolean;
  124162. enclose?: boolean;
  124163. cap?: number;
  124164. sideOrientation?: number;
  124165. frontUVs?: Vector4;
  124166. backUVs?: Vector4;
  124167. }, scene?: Nullable<Scene>): Mesh;
  124168. /**
  124169. * Creates a torus mesh
  124170. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124171. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124172. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124176. * @param name defines the name of the mesh
  124177. * @param options defines the options used to create the mesh
  124178. * @param scene defines the hosting scene
  124179. * @returns the torus mesh
  124180. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124181. */
  124182. static CreateTorus(name: string, options: {
  124183. diameter?: number;
  124184. thickness?: number;
  124185. tessellation?: number;
  124186. updatable?: boolean;
  124187. sideOrientation?: number;
  124188. frontUVs?: Vector4;
  124189. backUVs?: Vector4;
  124190. }, scene?: Nullable<Scene>): Mesh;
  124191. /**
  124192. * Creates a torus knot mesh
  124193. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124194. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124195. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124196. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124200. * @param name defines the name of the mesh
  124201. * @param options defines the options used to create the mesh
  124202. * @param scene defines the hosting scene
  124203. * @returns the torus knot mesh
  124204. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124205. */
  124206. static CreateTorusKnot(name: string, options: {
  124207. radius?: number;
  124208. tube?: number;
  124209. radialSegments?: number;
  124210. tubularSegments?: number;
  124211. p?: number;
  124212. q?: number;
  124213. updatable?: boolean;
  124214. sideOrientation?: number;
  124215. frontUVs?: Vector4;
  124216. backUVs?: Vector4;
  124217. }, scene?: Nullable<Scene>): Mesh;
  124218. /**
  124219. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124220. * * 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
  124221. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124222. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124223. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124224. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124225. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124226. * * 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
  124227. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124230. * @param name defines the name of the new line system
  124231. * @param options defines the options used to create the line system
  124232. * @param scene defines the hosting scene
  124233. * @returns a new line system mesh
  124234. */
  124235. static CreateLineSystem(name: string, options: {
  124236. lines: Vector3[][];
  124237. updatable?: boolean;
  124238. instance?: Nullable<LinesMesh>;
  124239. colors?: Nullable<Color4[][]>;
  124240. useVertexAlpha?: boolean;
  124241. }, scene: Nullable<Scene>): LinesMesh;
  124242. /**
  124243. * Creates a line mesh
  124244. * 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
  124245. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124246. * * The parameter `points` is an array successive Vector3
  124247. * * 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
  124248. * * The optional parameter `colors` is an array of successive Color4, one per line point
  124249. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  124250. * * When updating an instance, remember that only point positions can change, not the number of points
  124251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  124253. * @param name defines the name of the new line system
  124254. * @param options defines the options used to create the line system
  124255. * @param scene defines the hosting scene
  124256. * @returns a new line mesh
  124257. */
  124258. static CreateLines(name: string, options: {
  124259. points: Vector3[];
  124260. updatable?: boolean;
  124261. instance?: Nullable<LinesMesh>;
  124262. colors?: Color4[];
  124263. useVertexAlpha?: boolean;
  124264. }, scene?: Nullable<Scene>): LinesMesh;
  124265. /**
  124266. * Creates a dashed line mesh
  124267. * * 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
  124268. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124269. * * The parameter `points` is an array successive Vector3
  124270. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  124271. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  124272. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  124273. * * 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
  124274. * * When updating an instance, remember that only point positions can change, not the number of points
  124275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124276. * @param name defines the name of the mesh
  124277. * @param options defines the options used to create the mesh
  124278. * @param scene defines the hosting scene
  124279. * @returns the dashed line mesh
  124280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  124281. */
  124282. static CreateDashedLines(name: string, options: {
  124283. points: Vector3[];
  124284. dashSize?: number;
  124285. gapSize?: number;
  124286. dashNb?: number;
  124287. updatable?: boolean;
  124288. instance?: LinesMesh;
  124289. }, scene?: Nullable<Scene>): LinesMesh;
  124290. /**
  124291. * 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.
  124292. * * 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.
  124293. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124294. * * 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.
  124295. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124296. * * 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
  124297. * * 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
  124298. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124303. * @param name defines the name of the mesh
  124304. * @param options defines the options used to create the mesh
  124305. * @param scene defines the hosting scene
  124306. * @returns the extruded shape mesh
  124307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124309. */
  124310. static ExtrudeShape(name: string, options: {
  124311. shape: Vector3[];
  124312. path: Vector3[];
  124313. scale?: number;
  124314. rotation?: number;
  124315. cap?: number;
  124316. updatable?: boolean;
  124317. sideOrientation?: number;
  124318. frontUVs?: Vector4;
  124319. backUVs?: Vector4;
  124320. instance?: Mesh;
  124321. invertUV?: boolean;
  124322. }, scene?: Nullable<Scene>): Mesh;
  124323. /**
  124324. * Creates an custom extruded shape mesh.
  124325. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124326. * * 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.
  124327. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124328. * * 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
  124329. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124330. * * 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
  124331. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124332. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124333. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124334. * * 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
  124335. * * 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
  124336. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124341. * @param name defines the name of the mesh
  124342. * @param options defines the options used to create the mesh
  124343. * @param scene defines the hosting scene
  124344. * @returns the custom extruded shape mesh
  124345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124346. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124348. */
  124349. static ExtrudeShapeCustom(name: string, options: {
  124350. shape: Vector3[];
  124351. path: Vector3[];
  124352. scaleFunction?: any;
  124353. rotationFunction?: any;
  124354. ribbonCloseArray?: boolean;
  124355. ribbonClosePath?: boolean;
  124356. cap?: number;
  124357. updatable?: boolean;
  124358. sideOrientation?: number;
  124359. frontUVs?: Vector4;
  124360. backUVs?: Vector4;
  124361. instance?: Mesh;
  124362. invertUV?: boolean;
  124363. }, scene?: Nullable<Scene>): Mesh;
  124364. /**
  124365. * Creates lathe mesh.
  124366. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124367. * * 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
  124368. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124369. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124370. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124371. * * 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
  124372. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124373. * * 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
  124374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124376. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124378. * @param name defines the name of the mesh
  124379. * @param options defines the options used to create the mesh
  124380. * @param scene defines the hosting scene
  124381. * @returns the lathe mesh
  124382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124383. */
  124384. static CreateLathe(name: string, options: {
  124385. shape: Vector3[];
  124386. radius?: number;
  124387. tessellation?: number;
  124388. clip?: number;
  124389. arc?: number;
  124390. closed?: boolean;
  124391. updatable?: boolean;
  124392. sideOrientation?: number;
  124393. frontUVs?: Vector4;
  124394. backUVs?: Vector4;
  124395. cap?: number;
  124396. invertUV?: boolean;
  124397. }, scene?: Nullable<Scene>): Mesh;
  124398. /**
  124399. * Creates a tiled plane mesh
  124400. * * You can set a limited pattern arrangement with the tiles
  124401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124404. * @param name defines the name of the mesh
  124405. * @param options defines the options used to create the mesh
  124406. * @param scene defines the hosting scene
  124407. * @returns the plane mesh
  124408. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124409. */
  124410. static CreateTiledPlane(name: string, options: {
  124411. pattern?: number;
  124412. tileSize?: number;
  124413. tileWidth?: number;
  124414. tileHeight?: number;
  124415. size?: number;
  124416. width?: number;
  124417. height?: number;
  124418. alignHorizontal?: number;
  124419. alignVertical?: number;
  124420. sideOrientation?: number;
  124421. frontUVs?: Vector4;
  124422. backUVs?: Vector4;
  124423. updatable?: boolean;
  124424. }, scene?: Nullable<Scene>): Mesh;
  124425. /**
  124426. * Creates a plane mesh
  124427. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  124428. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  124429. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  124430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124433. * @param name defines the name of the mesh
  124434. * @param options defines the options used to create the mesh
  124435. * @param scene defines the hosting scene
  124436. * @returns the plane mesh
  124437. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124438. */
  124439. static CreatePlane(name: string, options: {
  124440. size?: number;
  124441. width?: number;
  124442. height?: number;
  124443. sideOrientation?: number;
  124444. frontUVs?: Vector4;
  124445. backUVs?: Vector4;
  124446. updatable?: boolean;
  124447. sourcePlane?: Plane;
  124448. }, scene?: Nullable<Scene>): Mesh;
  124449. /**
  124450. * Creates a ground mesh
  124451. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124452. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124454. * @param name defines the name of the mesh
  124455. * @param options defines the options used to create the mesh
  124456. * @param scene defines the hosting scene
  124457. * @returns the ground mesh
  124458. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124459. */
  124460. static CreateGround(name: string, options: {
  124461. width?: number;
  124462. height?: number;
  124463. subdivisions?: number;
  124464. subdivisionsX?: number;
  124465. subdivisionsY?: number;
  124466. updatable?: boolean;
  124467. }, scene?: Nullable<Scene>): Mesh;
  124468. /**
  124469. * Creates a tiled ground mesh
  124470. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124471. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124472. * * 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
  124473. * * 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
  124474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124475. * @param name defines the name of the mesh
  124476. * @param options defines the options used to create the mesh
  124477. * @param scene defines the hosting scene
  124478. * @returns the tiled ground mesh
  124479. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124480. */
  124481. static CreateTiledGround(name: string, options: {
  124482. xmin: number;
  124483. zmin: number;
  124484. xmax: number;
  124485. zmax: number;
  124486. subdivisions?: {
  124487. w: number;
  124488. h: number;
  124489. };
  124490. precision?: {
  124491. w: number;
  124492. h: number;
  124493. };
  124494. updatable?: boolean;
  124495. }, scene?: Nullable<Scene>): Mesh;
  124496. /**
  124497. * Creates a ground mesh from a height map
  124498. * * The parameter `url` sets the URL of the height map image resource.
  124499. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124500. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124501. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124502. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124503. * * 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.
  124504. * * 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).
  124505. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124507. * @param name defines the name of the mesh
  124508. * @param url defines the url to the height map
  124509. * @param options defines the options used to create the mesh
  124510. * @param scene defines the hosting scene
  124511. * @returns the ground mesh
  124512. * @see https://doc.babylonjs.com/babylon101/height_map
  124513. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124514. */
  124515. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124516. width?: number;
  124517. height?: number;
  124518. subdivisions?: number;
  124519. minHeight?: number;
  124520. maxHeight?: number;
  124521. colorFilter?: Color3;
  124522. alphaFilter?: number;
  124523. updatable?: boolean;
  124524. onReady?: (mesh: GroundMesh) => void;
  124525. }, scene?: Nullable<Scene>): GroundMesh;
  124526. /**
  124527. * Creates a polygon mesh
  124528. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124529. * * 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
  124530. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124533. * * Remember you can only change the shape positions, not their number when updating a polygon
  124534. * @param name defines the name of the mesh
  124535. * @param options defines the options used to create the mesh
  124536. * @param scene defines the hosting scene
  124537. * @param earcutInjection can be used to inject your own earcut reference
  124538. * @returns the polygon mesh
  124539. */
  124540. static CreatePolygon(name: string, options: {
  124541. shape: Vector3[];
  124542. holes?: Vector3[][];
  124543. depth?: number;
  124544. faceUV?: Vector4[];
  124545. faceColors?: Color4[];
  124546. updatable?: boolean;
  124547. sideOrientation?: number;
  124548. frontUVs?: Vector4;
  124549. backUVs?: Vector4;
  124550. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124551. /**
  124552. * Creates an extruded polygon mesh, with depth in the Y direction.
  124553. * * 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)
  124554. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124555. * @param name defines the name of the mesh
  124556. * @param options defines the options used to create the mesh
  124557. * @param scene defines the hosting scene
  124558. * @param earcutInjection can be used to inject your own earcut reference
  124559. * @returns the polygon mesh
  124560. */
  124561. static ExtrudePolygon(name: string, options: {
  124562. shape: Vector3[];
  124563. holes?: Vector3[][];
  124564. depth?: number;
  124565. faceUV?: Vector4[];
  124566. faceColors?: Color4[];
  124567. updatable?: boolean;
  124568. sideOrientation?: number;
  124569. frontUVs?: Vector4;
  124570. backUVs?: Vector4;
  124571. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124572. /**
  124573. * Creates a tube mesh.
  124574. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124575. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124576. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124577. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124578. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124579. * * 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)
  124580. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124581. * * 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
  124582. * * 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
  124583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124585. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124587. * @param name defines the name of the mesh
  124588. * @param options defines the options used to create the mesh
  124589. * @param scene defines the hosting scene
  124590. * @returns the tube mesh
  124591. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124592. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124593. */
  124594. static CreateTube(name: string, options: {
  124595. path: Vector3[];
  124596. radius?: number;
  124597. tessellation?: number;
  124598. radiusFunction?: {
  124599. (i: number, distance: number): number;
  124600. };
  124601. cap?: number;
  124602. arc?: number;
  124603. updatable?: boolean;
  124604. sideOrientation?: number;
  124605. frontUVs?: Vector4;
  124606. backUVs?: Vector4;
  124607. instance?: Mesh;
  124608. invertUV?: boolean;
  124609. }, scene?: Nullable<Scene>): Mesh;
  124610. /**
  124611. * Creates a polyhedron mesh
  124612. * * 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
  124613. * * The parameter `size` (positive float, default 1) sets the polygon size
  124614. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  124615. * * 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`
  124616. * * 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
  124617. * * 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)`)
  124618. * * 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
  124619. * * 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
  124620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124623. * @param name defines the name of the mesh
  124624. * @param options defines the options used to create the mesh
  124625. * @param scene defines the hosting scene
  124626. * @returns the polyhedron mesh
  124627. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  124628. */
  124629. static CreatePolyhedron(name: string, options: {
  124630. type?: number;
  124631. size?: number;
  124632. sizeX?: number;
  124633. sizeY?: number;
  124634. sizeZ?: number;
  124635. custom?: any;
  124636. faceUV?: Vector4[];
  124637. faceColors?: Color4[];
  124638. flat?: boolean;
  124639. updatable?: boolean;
  124640. sideOrientation?: number;
  124641. frontUVs?: Vector4;
  124642. backUVs?: Vector4;
  124643. }, scene?: Nullable<Scene>): Mesh;
  124644. /**
  124645. * Creates a decal mesh.
  124646. * 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
  124647. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  124648. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  124649. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  124650. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  124651. * @param name defines the name of the mesh
  124652. * @param sourceMesh defines the mesh where the decal must be applied
  124653. * @param options defines the options used to create the mesh
  124654. * @param scene defines the hosting scene
  124655. * @returns the decal mesh
  124656. * @see https://doc.babylonjs.com/how_to/decals
  124657. */
  124658. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  124659. position?: Vector3;
  124660. normal?: Vector3;
  124661. size?: Vector3;
  124662. angle?: number;
  124663. }): Mesh;
  124664. }
  124665. }
  124666. declare module BABYLON {
  124667. /**
  124668. * A simplifier interface for future simplification implementations
  124669. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124670. */
  124671. export interface ISimplifier {
  124672. /**
  124673. * Simplification of a given mesh according to the given settings.
  124674. * Since this requires computation, it is assumed that the function runs async.
  124675. * @param settings The settings of the simplification, including quality and distance
  124676. * @param successCallback A callback that will be called after the mesh was simplified.
  124677. * @param errorCallback in case of an error, this callback will be called. optional.
  124678. */
  124679. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  124680. }
  124681. /**
  124682. * Expected simplification settings.
  124683. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  124684. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124685. */
  124686. export interface ISimplificationSettings {
  124687. /**
  124688. * Gets or sets the expected quality
  124689. */
  124690. quality: number;
  124691. /**
  124692. * Gets or sets the distance when this optimized version should be used
  124693. */
  124694. distance: number;
  124695. /**
  124696. * Gets an already optimized mesh
  124697. */
  124698. optimizeMesh?: boolean;
  124699. }
  124700. /**
  124701. * Class used to specify simplification options
  124702. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124703. */
  124704. export class SimplificationSettings implements ISimplificationSettings {
  124705. /** expected quality */
  124706. quality: number;
  124707. /** distance when this optimized version should be used */
  124708. distance: number;
  124709. /** already optimized mesh */
  124710. optimizeMesh?: boolean | undefined;
  124711. /**
  124712. * Creates a SimplificationSettings
  124713. * @param quality expected quality
  124714. * @param distance distance when this optimized version should be used
  124715. * @param optimizeMesh already optimized mesh
  124716. */
  124717. constructor(
  124718. /** expected quality */
  124719. quality: number,
  124720. /** distance when this optimized version should be used */
  124721. distance: number,
  124722. /** already optimized mesh */
  124723. optimizeMesh?: boolean | undefined);
  124724. }
  124725. /**
  124726. * Interface used to define a simplification task
  124727. */
  124728. export interface ISimplificationTask {
  124729. /**
  124730. * Array of settings
  124731. */
  124732. settings: Array<ISimplificationSettings>;
  124733. /**
  124734. * Simplification type
  124735. */
  124736. simplificationType: SimplificationType;
  124737. /**
  124738. * Mesh to simplify
  124739. */
  124740. mesh: Mesh;
  124741. /**
  124742. * Callback called on success
  124743. */
  124744. successCallback?: () => void;
  124745. /**
  124746. * Defines if parallel processing can be used
  124747. */
  124748. parallelProcessing: boolean;
  124749. }
  124750. /**
  124751. * Queue used to order the simplification tasks
  124752. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124753. */
  124754. export class SimplificationQueue {
  124755. private _simplificationArray;
  124756. /**
  124757. * Gets a boolean indicating that the process is still running
  124758. */
  124759. running: boolean;
  124760. /**
  124761. * Creates a new queue
  124762. */
  124763. constructor();
  124764. /**
  124765. * Adds a new simplification task
  124766. * @param task defines a task to add
  124767. */
  124768. addTask(task: ISimplificationTask): void;
  124769. /**
  124770. * Execute next task
  124771. */
  124772. executeNext(): void;
  124773. /**
  124774. * Execute a simplification task
  124775. * @param task defines the task to run
  124776. */
  124777. runSimplification(task: ISimplificationTask): void;
  124778. private getSimplifier;
  124779. }
  124780. /**
  124781. * The implemented types of simplification
  124782. * At the moment only Quadratic Error Decimation is implemented
  124783. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124784. */
  124785. export enum SimplificationType {
  124786. /** Quadratic error decimation */
  124787. QUADRATIC = 0
  124788. }
  124789. }
  124790. declare module BABYLON {
  124791. interface Scene {
  124792. /** @hidden (Backing field) */
  124793. _simplificationQueue: SimplificationQueue;
  124794. /**
  124795. * Gets or sets the simplification queue attached to the scene
  124796. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124797. */
  124798. simplificationQueue: SimplificationQueue;
  124799. }
  124800. interface Mesh {
  124801. /**
  124802. * Simplify the mesh according to the given array of settings.
  124803. * Function will return immediately and will simplify async
  124804. * @param settings a collection of simplification settings
  124805. * @param parallelProcessing should all levels calculate parallel or one after the other
  124806. * @param simplificationType the type of simplification to run
  124807. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124808. * @returns the current mesh
  124809. */
  124810. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124811. }
  124812. /**
  124813. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124814. * created in a scene
  124815. */
  124816. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124817. /**
  124818. * The component name helpfull to identify the component in the list of scene components.
  124819. */
  124820. readonly name: string;
  124821. /**
  124822. * The scene the component belongs to.
  124823. */
  124824. scene: Scene;
  124825. /**
  124826. * Creates a new instance of the component for the given scene
  124827. * @param scene Defines the scene to register the component in
  124828. */
  124829. constructor(scene: Scene);
  124830. /**
  124831. * Registers the component in a given scene
  124832. */
  124833. register(): void;
  124834. /**
  124835. * Rebuilds the elements related to this component in case of
  124836. * context lost for instance.
  124837. */
  124838. rebuild(): void;
  124839. /**
  124840. * Disposes the component and the associated ressources
  124841. */
  124842. dispose(): void;
  124843. private _beforeCameraUpdate;
  124844. }
  124845. }
  124846. declare module BABYLON {
  124847. /**
  124848. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124849. */
  124850. export interface INavigationEnginePlugin {
  124851. /**
  124852. * plugin name
  124853. */
  124854. name: string;
  124855. /**
  124856. * Creates a navigation mesh
  124857. * @param meshes array of all the geometry used to compute the navigatio mesh
  124858. * @param parameters bunch of parameters used to filter geometry
  124859. */
  124860. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124861. /**
  124862. * Create a navigation mesh debug mesh
  124863. * @param scene is where the mesh will be added
  124864. * @returns debug display mesh
  124865. */
  124866. createDebugNavMesh(scene: Scene): Mesh;
  124867. /**
  124868. * Get a navigation mesh constrained position, closest to the parameter position
  124869. * @param position world position
  124870. * @returns the closest point to position constrained by the navigation mesh
  124871. */
  124872. getClosestPoint(position: Vector3): Vector3;
  124873. /**
  124874. * Get a navigation mesh constrained position, within a particular radius
  124875. * @param position world position
  124876. * @param maxRadius the maximum distance to the constrained world position
  124877. * @returns the closest point to position constrained by the navigation mesh
  124878. */
  124879. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124880. /**
  124881. * Compute the final position from a segment made of destination-position
  124882. * @param position world position
  124883. * @param destination world position
  124884. * @returns the resulting point along the navmesh
  124885. */
  124886. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124887. /**
  124888. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124889. * @param start world position
  124890. * @param end world position
  124891. * @returns array containing world position composing the path
  124892. */
  124893. computePath(start: Vector3, end: Vector3): Vector3[];
  124894. /**
  124895. * If this plugin is supported
  124896. * @returns true if plugin is supported
  124897. */
  124898. isSupported(): boolean;
  124899. /**
  124900. * Create a new Crowd so you can add agents
  124901. * @param maxAgents the maximum agent count in the crowd
  124902. * @param maxAgentRadius the maximum radius an agent can have
  124903. * @param scene to attach the crowd to
  124904. * @returns the crowd you can add agents to
  124905. */
  124906. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124907. /**
  124908. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124909. * The queries will try to find a solution within those bounds
  124910. * default is (1,1,1)
  124911. * @param extent x,y,z value that define the extent around the queries point of reference
  124912. */
  124913. setDefaultQueryExtent(extent: Vector3): void;
  124914. /**
  124915. * Get the Bounding box extent specified by setDefaultQueryExtent
  124916. * @returns the box extent values
  124917. */
  124918. getDefaultQueryExtent(): Vector3;
  124919. /**
  124920. * Release all resources
  124921. */
  124922. dispose(): void;
  124923. }
  124924. /**
  124925. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124926. */
  124927. export interface ICrowd {
  124928. /**
  124929. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124930. * You can attach anything to that node. The node position is updated in the scene update tick.
  124931. * @param pos world position that will be constrained by the navigation mesh
  124932. * @param parameters agent parameters
  124933. * @param transform hooked to the agent that will be update by the scene
  124934. * @returns agent index
  124935. */
  124936. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124937. /**
  124938. * Returns the agent position in world space
  124939. * @param index agent index returned by addAgent
  124940. * @returns world space position
  124941. */
  124942. getAgentPosition(index: number): Vector3;
  124943. /**
  124944. * Gets the agent velocity in world space
  124945. * @param index agent index returned by addAgent
  124946. * @returns world space velocity
  124947. */
  124948. getAgentVelocity(index: number): Vector3;
  124949. /**
  124950. * remove a particular agent previously created
  124951. * @param index agent index returned by addAgent
  124952. */
  124953. removeAgent(index: number): void;
  124954. /**
  124955. * get the list of all agents attached to this crowd
  124956. * @returns list of agent indices
  124957. */
  124958. getAgents(): number[];
  124959. /**
  124960. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124961. * @param deltaTime in seconds
  124962. */
  124963. update(deltaTime: number): void;
  124964. /**
  124965. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124966. * @param index agent index returned by addAgent
  124967. * @param destination targeted world position
  124968. */
  124969. agentGoto(index: number, destination: Vector3): void;
  124970. /**
  124971. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124972. * The queries will try to find a solution within those bounds
  124973. * default is (1,1,1)
  124974. * @param extent x,y,z value that define the extent around the queries point of reference
  124975. */
  124976. setDefaultQueryExtent(extent: Vector3): void;
  124977. /**
  124978. * Get the Bounding box extent specified by setDefaultQueryExtent
  124979. * @returns the box extent values
  124980. */
  124981. getDefaultQueryExtent(): Vector3;
  124982. /**
  124983. * Release all resources
  124984. */
  124985. dispose(): void;
  124986. }
  124987. /**
  124988. * Configures an agent
  124989. */
  124990. export interface IAgentParameters {
  124991. /**
  124992. * Agent radius. [Limit: >= 0]
  124993. */
  124994. radius: number;
  124995. /**
  124996. * Agent height. [Limit: > 0]
  124997. */
  124998. height: number;
  124999. /**
  125000. * Maximum allowed acceleration. [Limit: >= 0]
  125001. */
  125002. maxAcceleration: number;
  125003. /**
  125004. * Maximum allowed speed. [Limit: >= 0]
  125005. */
  125006. maxSpeed: number;
  125007. /**
  125008. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  125009. */
  125010. collisionQueryRange: number;
  125011. /**
  125012. * The path visibility optimization range. [Limit: > 0]
  125013. */
  125014. pathOptimizationRange: number;
  125015. /**
  125016. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  125017. */
  125018. separationWeight: number;
  125019. }
  125020. /**
  125021. * Configures the navigation mesh creation
  125022. */
  125023. export interface INavMeshParameters {
  125024. /**
  125025. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  125026. */
  125027. cs: number;
  125028. /**
  125029. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  125030. */
  125031. ch: number;
  125032. /**
  125033. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  125034. */
  125035. walkableSlopeAngle: number;
  125036. /**
  125037. * Minimum floor to 'ceiling' height that will still allow the floor area to
  125038. * be considered walkable. [Limit: >= 3] [Units: vx]
  125039. */
  125040. walkableHeight: number;
  125041. /**
  125042. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  125043. */
  125044. walkableClimb: number;
  125045. /**
  125046. * The distance to erode/shrink the walkable area of the heightfield away from
  125047. * obstructions. [Limit: >=0] [Units: vx]
  125048. */
  125049. walkableRadius: number;
  125050. /**
  125051. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  125052. */
  125053. maxEdgeLen: number;
  125054. /**
  125055. * The maximum distance a simplfied contour's border edges should deviate
  125056. * the original raw contour. [Limit: >=0] [Units: vx]
  125057. */
  125058. maxSimplificationError: number;
  125059. /**
  125060. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  125061. */
  125062. minRegionArea: number;
  125063. /**
  125064. * Any regions with a span count smaller than this value will, if possible,
  125065. * be merged with larger regions. [Limit: >=0] [Units: vx]
  125066. */
  125067. mergeRegionArea: number;
  125068. /**
  125069. * The maximum number of vertices allowed for polygons generated during the
  125070. * contour to polygon conversion process. [Limit: >= 3]
  125071. */
  125072. maxVertsPerPoly: number;
  125073. /**
  125074. * Sets the sampling distance to use when generating the detail mesh.
  125075. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  125076. */
  125077. detailSampleDist: number;
  125078. /**
  125079. * The maximum distance the detail mesh surface should deviate from heightfield
  125080. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  125081. */
  125082. detailSampleMaxError: number;
  125083. }
  125084. }
  125085. declare module BABYLON {
  125086. /**
  125087. * RecastJS navigation plugin
  125088. */
  125089. export class RecastJSPlugin implements INavigationEnginePlugin {
  125090. /**
  125091. * Reference to the Recast library
  125092. */
  125093. bjsRECAST: any;
  125094. /**
  125095. * plugin name
  125096. */
  125097. name: string;
  125098. /**
  125099. * the first navmesh created. We might extend this to support multiple navmeshes
  125100. */
  125101. navMesh: any;
  125102. /**
  125103. * Initializes the recastJS plugin
  125104. * @param recastInjection can be used to inject your own recast reference
  125105. */
  125106. constructor(recastInjection?: any);
  125107. /**
  125108. * Creates a navigation mesh
  125109. * @param meshes array of all the geometry used to compute the navigatio mesh
  125110. * @param parameters bunch of parameters used to filter geometry
  125111. */
  125112. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125113. /**
  125114. * Create a navigation mesh debug mesh
  125115. * @param scene is where the mesh will be added
  125116. * @returns debug display mesh
  125117. */
  125118. createDebugNavMesh(scene: Scene): Mesh;
  125119. /**
  125120. * Get a navigation mesh constrained position, closest to the parameter position
  125121. * @param position world position
  125122. * @returns the closest point to position constrained by the navigation mesh
  125123. */
  125124. getClosestPoint(position: Vector3): Vector3;
  125125. /**
  125126. * Get a navigation mesh constrained position, within a particular radius
  125127. * @param position world position
  125128. * @param maxRadius the maximum distance to the constrained world position
  125129. * @returns the closest point to position constrained by the navigation mesh
  125130. */
  125131. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125132. /**
  125133. * Compute the final position from a segment made of destination-position
  125134. * @param position world position
  125135. * @param destination world position
  125136. * @returns the resulting point along the navmesh
  125137. */
  125138. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125139. /**
  125140. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125141. * @param start world position
  125142. * @param end world position
  125143. * @returns array containing world position composing the path
  125144. */
  125145. computePath(start: Vector3, end: Vector3): Vector3[];
  125146. /**
  125147. * Create a new Crowd so you can add agents
  125148. * @param maxAgents the maximum agent count in the crowd
  125149. * @param maxAgentRadius the maximum radius an agent can have
  125150. * @param scene to attach the crowd to
  125151. * @returns the crowd you can add agents to
  125152. */
  125153. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  125154. /**
  125155. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125156. * The queries will try to find a solution within those bounds
  125157. * default is (1,1,1)
  125158. * @param extent x,y,z value that define the extent around the queries point of reference
  125159. */
  125160. setDefaultQueryExtent(extent: Vector3): void;
  125161. /**
  125162. * Get the Bounding box extent specified by setDefaultQueryExtent
  125163. * @returns the box extent values
  125164. */
  125165. getDefaultQueryExtent(): Vector3;
  125166. /**
  125167. * Disposes
  125168. */
  125169. dispose(): void;
  125170. /**
  125171. * If this plugin is supported
  125172. * @returns true if plugin is supported
  125173. */
  125174. isSupported(): boolean;
  125175. }
  125176. /**
  125177. * Recast detour crowd implementation
  125178. */
  125179. export class RecastJSCrowd implements ICrowd {
  125180. /**
  125181. * Recast/detour plugin
  125182. */
  125183. bjsRECASTPlugin: RecastJSPlugin;
  125184. /**
  125185. * Link to the detour crowd
  125186. */
  125187. recastCrowd: any;
  125188. /**
  125189. * One transform per agent
  125190. */
  125191. transforms: TransformNode[];
  125192. /**
  125193. * All agents created
  125194. */
  125195. agents: number[];
  125196. /**
  125197. * Link to the scene is kept to unregister the crowd from the scene
  125198. */
  125199. private _scene;
  125200. /**
  125201. * Observer for crowd updates
  125202. */
  125203. private _onBeforeAnimationsObserver;
  125204. /**
  125205. * Constructor
  125206. * @param plugin recastJS plugin
  125207. * @param maxAgents the maximum agent count in the crowd
  125208. * @param maxAgentRadius the maximum radius an agent can have
  125209. * @param scene to attach the crowd to
  125210. * @returns the crowd you can add agents to
  125211. */
  125212. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  125213. /**
  125214. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  125215. * You can attach anything to that node. The node position is updated in the scene update tick.
  125216. * @param pos world position that will be constrained by the navigation mesh
  125217. * @param parameters agent parameters
  125218. * @param transform hooked to the agent that will be update by the scene
  125219. * @returns agent index
  125220. */
  125221. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  125222. /**
  125223. * Returns the agent position in world space
  125224. * @param index agent index returned by addAgent
  125225. * @returns world space position
  125226. */
  125227. getAgentPosition(index: number): Vector3;
  125228. /**
  125229. * Returns the agent velocity in world space
  125230. * @param index agent index returned by addAgent
  125231. * @returns world space velocity
  125232. */
  125233. getAgentVelocity(index: number): Vector3;
  125234. /**
  125235. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125236. * @param index agent index returned by addAgent
  125237. * @param destination targeted world position
  125238. */
  125239. agentGoto(index: number, destination: Vector3): void;
  125240. /**
  125241. * remove a particular agent previously created
  125242. * @param index agent index returned by addAgent
  125243. */
  125244. removeAgent(index: number): void;
  125245. /**
  125246. * get the list of all agents attached to this crowd
  125247. * @returns list of agent indices
  125248. */
  125249. getAgents(): number[];
  125250. /**
  125251. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125252. * @param deltaTime in seconds
  125253. */
  125254. update(deltaTime: number): void;
  125255. /**
  125256. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125257. * The queries will try to find a solution within those bounds
  125258. * default is (1,1,1)
  125259. * @param extent x,y,z value that define the extent around the queries point of reference
  125260. */
  125261. setDefaultQueryExtent(extent: Vector3): void;
  125262. /**
  125263. * Get the Bounding box extent specified by setDefaultQueryExtent
  125264. * @returns the box extent values
  125265. */
  125266. getDefaultQueryExtent(): Vector3;
  125267. /**
  125268. * Release all resources
  125269. */
  125270. dispose(): void;
  125271. }
  125272. }
  125273. declare module BABYLON {
  125274. /**
  125275. * Class used to enable access to IndexedDB
  125276. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  125277. */
  125278. export class Database implements IOfflineProvider {
  125279. private _callbackManifestChecked;
  125280. private _currentSceneUrl;
  125281. private _db;
  125282. private _enableSceneOffline;
  125283. private _enableTexturesOffline;
  125284. private _manifestVersionFound;
  125285. private _mustUpdateRessources;
  125286. private _hasReachedQuota;
  125287. private _isSupported;
  125288. private _idbFactory;
  125289. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  125290. private static IsUASupportingBlobStorage;
  125291. /**
  125292. * Gets a boolean indicating if Database storate is enabled (off by default)
  125293. */
  125294. static IDBStorageEnabled: boolean;
  125295. /**
  125296. * Gets a boolean indicating if scene must be saved in the database
  125297. */
  125298. readonly enableSceneOffline: boolean;
  125299. /**
  125300. * Gets a boolean indicating if textures must be saved in the database
  125301. */
  125302. readonly enableTexturesOffline: boolean;
  125303. /**
  125304. * Creates a new Database
  125305. * @param urlToScene defines the url to load the scene
  125306. * @param callbackManifestChecked defines the callback to use when manifest is checked
  125307. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  125308. */
  125309. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  125310. private static _ParseURL;
  125311. private static _ReturnFullUrlLocation;
  125312. private _checkManifestFile;
  125313. /**
  125314. * Open the database and make it available
  125315. * @param successCallback defines the callback to call on success
  125316. * @param errorCallback defines the callback to call on error
  125317. */
  125318. open(successCallback: () => void, errorCallback: () => void): void;
  125319. /**
  125320. * Loads an image from the database
  125321. * @param url defines the url to load from
  125322. * @param image defines the target DOM image
  125323. */
  125324. loadImage(url: string, image: HTMLImageElement): void;
  125325. private _loadImageFromDBAsync;
  125326. private _saveImageIntoDBAsync;
  125327. private _checkVersionFromDB;
  125328. private _loadVersionFromDBAsync;
  125329. private _saveVersionIntoDBAsync;
  125330. /**
  125331. * Loads a file from database
  125332. * @param url defines the URL to load from
  125333. * @param sceneLoaded defines a callback to call on success
  125334. * @param progressCallBack defines a callback to call when progress changed
  125335. * @param errorCallback defines a callback to call on error
  125336. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  125337. */
  125338. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  125339. private _loadFileAsync;
  125340. private _saveFileAsync;
  125341. /**
  125342. * Validates if xhr data is correct
  125343. * @param xhr defines the request to validate
  125344. * @param dataType defines the expected data type
  125345. * @returns true if data is correct
  125346. */
  125347. private static _ValidateXHRData;
  125348. }
  125349. }
  125350. declare module BABYLON {
  125351. /** @hidden */
  125352. export var gpuUpdateParticlesPixelShader: {
  125353. name: string;
  125354. shader: string;
  125355. };
  125356. }
  125357. declare module BABYLON {
  125358. /** @hidden */
  125359. export var gpuUpdateParticlesVertexShader: {
  125360. name: string;
  125361. shader: string;
  125362. };
  125363. }
  125364. declare module BABYLON {
  125365. /** @hidden */
  125366. export var clipPlaneFragmentDeclaration2: {
  125367. name: string;
  125368. shader: string;
  125369. };
  125370. }
  125371. declare module BABYLON {
  125372. /** @hidden */
  125373. export var gpuRenderParticlesPixelShader: {
  125374. name: string;
  125375. shader: string;
  125376. };
  125377. }
  125378. declare module BABYLON {
  125379. /** @hidden */
  125380. export var clipPlaneVertexDeclaration2: {
  125381. name: string;
  125382. shader: string;
  125383. };
  125384. }
  125385. declare module BABYLON {
  125386. /** @hidden */
  125387. export var gpuRenderParticlesVertexShader: {
  125388. name: string;
  125389. shader: string;
  125390. };
  125391. }
  125392. declare module BABYLON {
  125393. /**
  125394. * This represents a GPU particle system in Babylon
  125395. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  125396. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  125397. */
  125398. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  125399. /**
  125400. * The layer mask we are rendering the particles through.
  125401. */
  125402. layerMask: number;
  125403. private _capacity;
  125404. private _activeCount;
  125405. private _currentActiveCount;
  125406. private _accumulatedCount;
  125407. private _renderEffect;
  125408. private _updateEffect;
  125409. private _buffer0;
  125410. private _buffer1;
  125411. private _spriteBuffer;
  125412. private _updateVAO;
  125413. private _renderVAO;
  125414. private _targetIndex;
  125415. private _sourceBuffer;
  125416. private _targetBuffer;
  125417. private _engine;
  125418. private _currentRenderId;
  125419. private _started;
  125420. private _stopped;
  125421. private _timeDelta;
  125422. private _randomTexture;
  125423. private _randomTexture2;
  125424. private _attributesStrideSize;
  125425. private _updateEffectOptions;
  125426. private _randomTextureSize;
  125427. private _actualFrame;
  125428. private readonly _rawTextureWidth;
  125429. /**
  125430. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  125431. */
  125432. static readonly IsSupported: boolean;
  125433. /**
  125434. * An event triggered when the system is disposed.
  125435. */
  125436. onDisposeObservable: Observable<GPUParticleSystem>;
  125437. /**
  125438. * Gets the maximum number of particles active at the same time.
  125439. * @returns The max number of active particles.
  125440. */
  125441. getCapacity(): number;
  125442. /**
  125443. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  125444. * to override the particles.
  125445. */
  125446. forceDepthWrite: boolean;
  125447. /**
  125448. * Gets or set the number of active particles
  125449. */
  125450. activeParticleCount: number;
  125451. private _preWarmDone;
  125452. /**
  125453. * Is this system ready to be used/rendered
  125454. * @return true if the system is ready
  125455. */
  125456. isReady(): boolean;
  125457. /**
  125458. * Gets if the system has been started. (Note: this will still be true after stop is called)
  125459. * @returns True if it has been started, otherwise false.
  125460. */
  125461. isStarted(): boolean;
  125462. /**
  125463. * Starts the particle system and begins to emit
  125464. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  125465. */
  125466. start(delay?: number): void;
  125467. /**
  125468. * Stops the particle system.
  125469. */
  125470. stop(): void;
  125471. /**
  125472. * Remove all active particles
  125473. */
  125474. reset(): void;
  125475. /**
  125476. * Returns the string "GPUParticleSystem"
  125477. * @returns a string containing the class name
  125478. */
  125479. getClassName(): string;
  125480. private _colorGradientsTexture;
  125481. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  125482. /**
  125483. * Adds a new color gradient
  125484. * @param gradient defines the gradient to use (between 0 and 1)
  125485. * @param color1 defines the color to affect to the specified gradient
  125486. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  125487. * @returns the current particle system
  125488. */
  125489. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  125490. /**
  125491. * Remove a specific color gradient
  125492. * @param gradient defines the gradient to remove
  125493. * @returns the current particle system
  125494. */
  125495. removeColorGradient(gradient: number): GPUParticleSystem;
  125496. private _angularSpeedGradientsTexture;
  125497. private _sizeGradientsTexture;
  125498. private _velocityGradientsTexture;
  125499. private _limitVelocityGradientsTexture;
  125500. private _dragGradientsTexture;
  125501. private _addFactorGradient;
  125502. /**
  125503. * Adds a new size gradient
  125504. * @param gradient defines the gradient to use (between 0 and 1)
  125505. * @param factor defines the size factor to affect to the specified gradient
  125506. * @returns the current particle system
  125507. */
  125508. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  125509. /**
  125510. * Remove a specific size gradient
  125511. * @param gradient defines the gradient to remove
  125512. * @returns the current particle system
  125513. */
  125514. removeSizeGradient(gradient: number): GPUParticleSystem;
  125515. /**
  125516. * Adds a new angular speed gradient
  125517. * @param gradient defines the gradient to use (between 0 and 1)
  125518. * @param factor defines the angular speed to affect to the specified gradient
  125519. * @returns the current particle system
  125520. */
  125521. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  125522. /**
  125523. * Remove a specific angular speed gradient
  125524. * @param gradient defines the gradient to remove
  125525. * @returns the current particle system
  125526. */
  125527. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  125528. /**
  125529. * Adds a new velocity gradient
  125530. * @param gradient defines the gradient to use (between 0 and 1)
  125531. * @param factor defines the velocity to affect to the specified gradient
  125532. * @returns the current particle system
  125533. */
  125534. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125535. /**
  125536. * Remove a specific velocity gradient
  125537. * @param gradient defines the gradient to remove
  125538. * @returns the current particle system
  125539. */
  125540. removeVelocityGradient(gradient: number): GPUParticleSystem;
  125541. /**
  125542. * Adds a new limit velocity gradient
  125543. * @param gradient defines the gradient to use (between 0 and 1)
  125544. * @param factor defines the limit velocity value to affect to the specified gradient
  125545. * @returns the current particle system
  125546. */
  125547. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125548. /**
  125549. * Remove a specific limit velocity gradient
  125550. * @param gradient defines the gradient to remove
  125551. * @returns the current particle system
  125552. */
  125553. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  125554. /**
  125555. * Adds a new drag gradient
  125556. * @param gradient defines the gradient to use (between 0 and 1)
  125557. * @param factor defines the drag value to affect to the specified gradient
  125558. * @returns the current particle system
  125559. */
  125560. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  125561. /**
  125562. * Remove a specific drag gradient
  125563. * @param gradient defines the gradient to remove
  125564. * @returns the current particle system
  125565. */
  125566. removeDragGradient(gradient: number): GPUParticleSystem;
  125567. /**
  125568. * Not supported by GPUParticleSystem
  125569. * @param gradient defines the gradient to use (between 0 and 1)
  125570. * @param factor defines the emit rate value to affect to the specified gradient
  125571. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125572. * @returns the current particle system
  125573. */
  125574. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125575. /**
  125576. * Not supported by GPUParticleSystem
  125577. * @param gradient defines the gradient to remove
  125578. * @returns the current particle system
  125579. */
  125580. removeEmitRateGradient(gradient: number): IParticleSystem;
  125581. /**
  125582. * Not supported by GPUParticleSystem
  125583. * @param gradient defines the gradient to use (between 0 and 1)
  125584. * @param factor defines the start size value to affect to the specified gradient
  125585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125586. * @returns the current particle system
  125587. */
  125588. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125589. /**
  125590. * Not supported by GPUParticleSystem
  125591. * @param gradient defines the gradient to remove
  125592. * @returns the current particle system
  125593. */
  125594. removeStartSizeGradient(gradient: number): IParticleSystem;
  125595. /**
  125596. * Not supported by GPUParticleSystem
  125597. * @param gradient defines the gradient to use (between 0 and 1)
  125598. * @param min defines the color remap minimal range
  125599. * @param max defines the color remap maximal range
  125600. * @returns the current particle system
  125601. */
  125602. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125603. /**
  125604. * Not supported by GPUParticleSystem
  125605. * @param gradient defines the gradient to remove
  125606. * @returns the current particle system
  125607. */
  125608. removeColorRemapGradient(): IParticleSystem;
  125609. /**
  125610. * Not supported by GPUParticleSystem
  125611. * @param gradient defines the gradient to use (between 0 and 1)
  125612. * @param min defines the alpha remap minimal range
  125613. * @param max defines the alpha remap maximal range
  125614. * @returns the current particle system
  125615. */
  125616. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125617. /**
  125618. * Not supported by GPUParticleSystem
  125619. * @param gradient defines the gradient to remove
  125620. * @returns the current particle system
  125621. */
  125622. removeAlphaRemapGradient(): IParticleSystem;
  125623. /**
  125624. * Not supported by GPUParticleSystem
  125625. * @param gradient defines the gradient to use (between 0 and 1)
  125626. * @param color defines the color to affect to the specified gradient
  125627. * @returns the current particle system
  125628. */
  125629. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  125630. /**
  125631. * Not supported by GPUParticleSystem
  125632. * @param gradient defines the gradient to remove
  125633. * @returns the current particle system
  125634. */
  125635. removeRampGradient(): IParticleSystem;
  125636. /**
  125637. * Not supported by GPUParticleSystem
  125638. * @returns the list of ramp gradients
  125639. */
  125640. getRampGradients(): Nullable<Array<Color3Gradient>>;
  125641. /**
  125642. * Not supported by GPUParticleSystem
  125643. * Gets or sets a boolean indicating that ramp gradients must be used
  125644. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  125645. */
  125646. useRampGradients: boolean;
  125647. /**
  125648. * Not supported by GPUParticleSystem
  125649. * @param gradient defines the gradient to use (between 0 and 1)
  125650. * @param factor defines the life time factor to affect to the specified gradient
  125651. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125652. * @returns the current particle system
  125653. */
  125654. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125655. /**
  125656. * Not supported by GPUParticleSystem
  125657. * @param gradient defines the gradient to remove
  125658. * @returns the current particle system
  125659. */
  125660. removeLifeTimeGradient(gradient: number): IParticleSystem;
  125661. /**
  125662. * Instantiates a GPU particle system.
  125663. * 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.
  125664. * @param name The name of the particle system
  125665. * @param options The options used to create the system
  125666. * @param scene The scene the particle system belongs to
  125667. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  125668. */
  125669. constructor(name: string, options: Partial<{
  125670. capacity: number;
  125671. randomTextureSize: number;
  125672. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  125673. protected _reset(): void;
  125674. private _createUpdateVAO;
  125675. private _createRenderVAO;
  125676. private _initialize;
  125677. /** @hidden */
  125678. _recreateUpdateEffect(): void;
  125679. /** @hidden */
  125680. _recreateRenderEffect(): void;
  125681. /**
  125682. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  125683. * @param preWarm defines if we are in the pre-warmimg phase
  125684. */
  125685. animate(preWarm?: boolean): void;
  125686. private _createFactorGradientTexture;
  125687. private _createSizeGradientTexture;
  125688. private _createAngularSpeedGradientTexture;
  125689. private _createVelocityGradientTexture;
  125690. private _createLimitVelocityGradientTexture;
  125691. private _createDragGradientTexture;
  125692. private _createColorGradientTexture;
  125693. /**
  125694. * Renders the particle system in its current state
  125695. * @param preWarm defines if the system should only update the particles but not render them
  125696. * @returns the current number of particles
  125697. */
  125698. render(preWarm?: boolean): number;
  125699. /**
  125700. * Rebuilds the particle system
  125701. */
  125702. rebuild(): void;
  125703. private _releaseBuffers;
  125704. private _releaseVAOs;
  125705. /**
  125706. * Disposes the particle system and free the associated resources
  125707. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  125708. */
  125709. dispose(disposeTexture?: boolean): void;
  125710. /**
  125711. * Clones the particle system.
  125712. * @param name The name of the cloned object
  125713. * @param newEmitter The new emitter to use
  125714. * @returns the cloned particle system
  125715. */
  125716. clone(name: string, newEmitter: any): GPUParticleSystem;
  125717. /**
  125718. * Serializes the particle system to a JSON object.
  125719. * @returns the JSON object
  125720. */
  125721. serialize(): any;
  125722. /**
  125723. * Parses a JSON object to create a GPU particle system.
  125724. * @param parsedParticleSystem The JSON object to parse
  125725. * @param scene The scene to create the particle system in
  125726. * @param rootUrl The root url to use to load external dependencies like texture
  125727. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  125728. * @returns the parsed GPU particle system
  125729. */
  125730. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  125731. }
  125732. }
  125733. declare module BABYLON {
  125734. /**
  125735. * Represents a set of particle systems working together to create a specific effect
  125736. */
  125737. export class ParticleSystemSet implements IDisposable {
  125738. /**
  125739. * Gets or sets base Assets URL
  125740. */
  125741. static BaseAssetsUrl: string;
  125742. private _emitterCreationOptions;
  125743. private _emitterNode;
  125744. /**
  125745. * Gets the particle system list
  125746. */
  125747. systems: IParticleSystem[];
  125748. /**
  125749. * Gets the emitter node used with this set
  125750. */
  125751. readonly emitterNode: Nullable<TransformNode>;
  125752. /**
  125753. * Creates a new emitter mesh as a sphere
  125754. * @param options defines the options used to create the sphere
  125755. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  125756. * @param scene defines the hosting scene
  125757. */
  125758. setEmitterAsSphere(options: {
  125759. diameter: number;
  125760. segments: number;
  125761. color: Color3;
  125762. }, renderingGroupId: number, scene: Scene): void;
  125763. /**
  125764. * Starts all particle systems of the set
  125765. * @param emitter defines an optional mesh to use as emitter for the particle systems
  125766. */
  125767. start(emitter?: AbstractMesh): void;
  125768. /**
  125769. * Release all associated resources
  125770. */
  125771. dispose(): void;
  125772. /**
  125773. * Serialize the set into a JSON compatible object
  125774. * @returns a JSON compatible representation of the set
  125775. */
  125776. serialize(): any;
  125777. /**
  125778. * Parse a new ParticleSystemSet from a serialized source
  125779. * @param data defines a JSON compatible representation of the set
  125780. * @param scene defines the hosting scene
  125781. * @param gpu defines if we want GPU particles or CPU particles
  125782. * @returns a new ParticleSystemSet
  125783. */
  125784. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125785. }
  125786. }
  125787. declare module BABYLON {
  125788. /**
  125789. * This class is made for on one-liner static method to help creating particle system set.
  125790. */
  125791. export class ParticleHelper {
  125792. /**
  125793. * Gets or sets base Assets URL
  125794. */
  125795. static BaseAssetsUrl: string;
  125796. /**
  125797. * Create a default particle system that you can tweak
  125798. * @param emitter defines the emitter to use
  125799. * @param capacity defines the system capacity (default is 500 particles)
  125800. * @param scene defines the hosting scene
  125801. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125802. * @returns the new Particle system
  125803. */
  125804. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125805. /**
  125806. * This is the main static method (one-liner) of this helper to create different particle systems
  125807. * @param type This string represents the type to the particle system to create
  125808. * @param scene The scene where the particle system should live
  125809. * @param gpu If the system will use gpu
  125810. * @returns the ParticleSystemSet created
  125811. */
  125812. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125813. /**
  125814. * Static function used to export a particle system to a ParticleSystemSet variable.
  125815. * Please note that the emitter shape is not exported
  125816. * @param systems defines the particle systems to export
  125817. * @returns the created particle system set
  125818. */
  125819. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125820. }
  125821. }
  125822. declare module BABYLON {
  125823. interface Engine {
  125824. /**
  125825. * Create an effect to use with particle systems.
  125826. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125827. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125828. * @param uniformsNames defines a list of attribute names
  125829. * @param samplers defines an array of string used to represent textures
  125830. * @param defines defines the string containing the defines to use to compile the shaders
  125831. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125832. * @param onCompiled defines a function to call when the effect creation is successful
  125833. * @param onError defines a function to call when the effect creation has failed
  125834. * @returns the new Effect
  125835. */
  125836. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125837. }
  125838. interface Mesh {
  125839. /**
  125840. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125841. * @returns an array of IParticleSystem
  125842. */
  125843. getEmittedParticleSystems(): IParticleSystem[];
  125844. /**
  125845. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125846. * @returns an array of IParticleSystem
  125847. */
  125848. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125849. }
  125850. /**
  125851. * @hidden
  125852. */
  125853. export var _IDoNeedToBeInTheBuild: number;
  125854. }
  125855. declare module BABYLON {
  125856. /** Defines the 4 color options */
  125857. export enum PointColor {
  125858. /** color value */
  125859. Color = 2,
  125860. /** uv value */
  125861. UV = 1,
  125862. /** random value */
  125863. Random = 0,
  125864. /** stated value */
  125865. Stated = 3
  125866. }
  125867. /**
  125868. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  125869. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  125870. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  125871. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  125872. *
  125873. * Full documentation here : TO BE ENTERED
  125874. */
  125875. export class PointsCloudSystem implements IDisposable {
  125876. /**
  125877. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  125878. * Example : var p = SPS.particles[i];
  125879. */
  125880. particles: CloudPoint[];
  125881. /**
  125882. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  125883. */
  125884. nbParticles: number;
  125885. /**
  125886. * This a counter for your own usage. It's not set by any SPS functions.
  125887. */
  125888. counter: number;
  125889. /**
  125890. * The PCS name. This name is also given to the underlying mesh.
  125891. */
  125892. name: string;
  125893. /**
  125894. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  125895. */
  125896. mesh: Mesh;
  125897. /**
  125898. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  125899. * Please read :
  125900. */
  125901. vars: any;
  125902. /**
  125903. * @hidden
  125904. */
  125905. _size: number;
  125906. private _scene;
  125907. private _promises;
  125908. private _positions;
  125909. private _indices;
  125910. private _normals;
  125911. private _colors;
  125912. private _uvs;
  125913. private _indices32;
  125914. private _positions32;
  125915. private _colors32;
  125916. private _uvs32;
  125917. private _updatable;
  125918. private _isVisibilityBoxLocked;
  125919. private _alwaysVisible;
  125920. private _groups;
  125921. private _groupCounter;
  125922. private _computeParticleColor;
  125923. private _computeParticleTexture;
  125924. private _computeParticleRotation;
  125925. private _computeBoundingBox;
  125926. private _isReady;
  125927. /**
  125928. * Creates a PCS (Points Cloud System) object
  125929. * @param name (String) is the PCS name, this will be the underlying mesh name
  125930. * @param pointSize (number) is the size for each point
  125931. * @param scene (Scene) is the scene in which the PCS is added
  125932. * @param options defines the options of the PCS e.g.
  125933. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  125934. */
  125935. constructor(name: string, pointSize: number, scene: Scene, options?: {
  125936. updatable?: boolean;
  125937. });
  125938. /**
  125939. * Builds the PCS underlying mesh. Returns a standard Mesh.
  125940. * If no points were added to the PCS, the returned mesh is just a single point.
  125941. * @returns a promise for the created mesh
  125942. */
  125943. buildMeshAsync(): Promise<Mesh>;
  125944. /**
  125945. * @hidden
  125946. */
  125947. private _buildMesh;
  125948. private _addParticle;
  125949. private _randomUnitVector;
  125950. private _getColorIndicesForCoord;
  125951. private _setPointsColorOrUV;
  125952. private _colorFromTexture;
  125953. private _calculateDensity;
  125954. /**
  125955. * Adds points to the PCS in random positions within a unit sphere
  125956. * @param nb (positive integer) the number of particles to be created from this model
  125957. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  125958. * @returns the number of groups in the system
  125959. */
  125960. addPoints(nb: number, pointFunction?: any): number;
  125961. /**
  125962. * Adds points to the PCS from the surface of the model shape
  125963. * @param mesh is any Mesh object that will be used as a surface model for the points
  125964. * @param nb (positive integer) the number of particles to be created from this model
  125965. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  125966. * @param color (color3) to be used when colorWith is stated
  125967. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  125968. * @returns the number of groups in the system
  125969. */
  125970. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  125971. /**
  125972. * Adds points to the PCS inside the model shape
  125973. * @param mesh is any Mesh object that will be used as a surface model for the points
  125974. * @param nb (positive integer) the number of particles to be created from this model
  125975. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  125976. * @param color (color4) to be used when colorWith is stated
  125977. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  125978. * @returns the number of groups in the system
  125979. */
  125980. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  125981. /**
  125982. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  125983. * This method calls `updateParticle()` for each particle of the SPS.
  125984. * For an animated SPS, it is usually called within the render loop.
  125985. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  125986. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  125987. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  125988. * @returns the PCS.
  125989. */
  125990. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  125991. /**
  125992. * Disposes the PCS.
  125993. */
  125994. dispose(): void;
  125995. /**
  125996. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  125997. * doc :
  125998. * @returns the PCS.
  125999. */
  126000. refreshVisibleSize(): PointsCloudSystem;
  126001. /**
  126002. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  126003. * @param size the size (float) of the visibility box
  126004. * note : this doesn't lock the PCS mesh bounding box.
  126005. * doc :
  126006. */
  126007. setVisibilityBox(size: number): void;
  126008. /**
  126009. * Gets whether the PCS is always visible or not
  126010. * doc :
  126011. */
  126012. /**
  126013. * Sets the PCS as always visible or not
  126014. * doc :
  126015. */
  126016. isAlwaysVisible: boolean;
  126017. /**
  126018. * Tells to `setParticles()` to compute the particle rotations or not
  126019. * Default value : false. The PCS is faster when it's set to false
  126020. * Note : particle rotations are only applied to parent particles
  126021. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  126022. */
  126023. computeParticleRotation: boolean;
  126024. /**
  126025. * Tells to `setParticles()` to compute the particle colors or not.
  126026. * Default value : true. The PCS is faster when it's set to false.
  126027. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126028. */
  126029. /**
  126030. * Gets if `setParticles()` computes the particle colors or not.
  126031. * Default value : false. The PCS is faster when it's set to false.
  126032. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126033. */
  126034. computeParticleColor: boolean;
  126035. /**
  126036. * Gets if `setParticles()` computes the particle textures or not.
  126037. * Default value : false. The PCS is faster when it's set to false.
  126038. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  126039. */
  126040. computeParticleTexture: boolean;
  126041. /**
  126042. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  126043. */
  126044. /**
  126045. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  126046. */
  126047. computeBoundingBox: boolean;
  126048. /**
  126049. * This function does nothing. It may be overwritten to set all the particle first values.
  126050. * The PCS doesn't call this function, you may have to call it by your own.
  126051. * doc :
  126052. */
  126053. initParticles(): void;
  126054. /**
  126055. * This function does nothing. It may be overwritten to recycle a particle
  126056. * The PCS doesn't call this function, you can to call it
  126057. * doc :
  126058. * @param particle The particle to recycle
  126059. * @returns the recycled particle
  126060. */
  126061. recycleParticle(particle: CloudPoint): CloudPoint;
  126062. /**
  126063. * Updates a particle : this function should be overwritten by the user.
  126064. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  126065. * doc :
  126066. * @example : just set a particle position or velocity and recycle conditions
  126067. * @param particle The particle to update
  126068. * @returns the updated particle
  126069. */
  126070. updateParticle(particle: CloudPoint): CloudPoint;
  126071. /**
  126072. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  126073. * This does nothing and may be overwritten by the user.
  126074. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126075. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126076. * @param update the boolean update value actually passed to setParticles()
  126077. */
  126078. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126079. /**
  126080. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  126081. * This will be passed three parameters.
  126082. * This does nothing and may be overwritten by the user.
  126083. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126084. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126085. * @param update the boolean update value actually passed to setParticles()
  126086. */
  126087. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126088. }
  126089. }
  126090. declare module BABYLON {
  126091. /**
  126092. * Represents one particle of a points cloud system.
  126093. */
  126094. export class CloudPoint {
  126095. /**
  126096. * particle global index
  126097. */
  126098. idx: number;
  126099. /**
  126100. * The color of the particle
  126101. */
  126102. color: Nullable<Color4>;
  126103. /**
  126104. * The world space position of the particle.
  126105. */
  126106. position: Vector3;
  126107. /**
  126108. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  126109. */
  126110. rotation: Vector3;
  126111. /**
  126112. * The world space rotation quaternion of the particle.
  126113. */
  126114. rotationQuaternion: Nullable<Quaternion>;
  126115. /**
  126116. * The uv of the particle.
  126117. */
  126118. uv: Nullable<Vector2>;
  126119. /**
  126120. * The current speed of the particle.
  126121. */
  126122. velocity: Vector3;
  126123. /**
  126124. * The pivot point in the particle local space.
  126125. */
  126126. pivot: Vector3;
  126127. /**
  126128. * Must the particle be translated from its pivot point in its local space ?
  126129. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  126130. * Default : false
  126131. */
  126132. translateFromPivot: boolean;
  126133. /**
  126134. * Index of this particle in the global "positions" array (Internal use)
  126135. * @hidden
  126136. */
  126137. _pos: number;
  126138. /**
  126139. * @hidden Index of this particle in the global "indices" array (Internal use)
  126140. */
  126141. _ind: number;
  126142. /**
  126143. * Group this particle belongs to
  126144. */
  126145. _group: PointsGroup;
  126146. /**
  126147. * Group id of this particle
  126148. */
  126149. groupId: number;
  126150. /**
  126151. * Index of the particle in its group id (Internal use)
  126152. */
  126153. idxInGroup: number;
  126154. /**
  126155. * @hidden Particle BoundingInfo object (Internal use)
  126156. */
  126157. _boundingInfo: BoundingInfo;
  126158. /**
  126159. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  126160. */
  126161. _pcs: PointsCloudSystem;
  126162. /**
  126163. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  126164. */
  126165. _stillInvisible: boolean;
  126166. /**
  126167. * @hidden Last computed particle rotation matrix
  126168. */
  126169. _rotationMatrix: number[];
  126170. /**
  126171. * Parent particle Id, if any.
  126172. * Default null.
  126173. */
  126174. parentId: Nullable<number>;
  126175. /**
  126176. * @hidden Internal global position in the PCS.
  126177. */
  126178. _globalPosition: Vector3;
  126179. /**
  126180. * Creates a Point Cloud object.
  126181. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  126182. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  126183. * @param group (PointsGroup) is the group the particle belongs to
  126184. * @param groupId (integer) is the group identifier in the PCS.
  126185. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  126186. * @param pcs defines the PCS it is associated to
  126187. */
  126188. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  126189. /**
  126190. * get point size
  126191. */
  126192. /**
  126193. * Set point size
  126194. */
  126195. size: Vector3;
  126196. /**
  126197. * Legacy support, changed quaternion to rotationQuaternion
  126198. */
  126199. /**
  126200. * Legacy support, changed quaternion to rotationQuaternion
  126201. */
  126202. quaternion: Nullable<Quaternion>;
  126203. /**
  126204. * Returns a boolean. True if the particle intersects a mesh, else false
  126205. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  126206. * @param target is the object (point or mesh) what the intersection is computed against
  126207. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  126208. * @returns true if it intersects
  126209. */
  126210. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  126211. /**
  126212. * get the rotation matrix of the particle
  126213. * @hidden
  126214. */
  126215. getRotationMatrix(m: Matrix): void;
  126216. }
  126217. /**
  126218. * Represents a group of points in a points cloud system
  126219. * * PCS internal tool, don't use it manually.
  126220. */
  126221. export class PointsGroup {
  126222. /**
  126223. * The group id
  126224. * @hidden
  126225. */
  126226. groupID: number;
  126227. /**
  126228. * image data for group (internal use)
  126229. * @hidden
  126230. */
  126231. _groupImageData: Nullable<ArrayBufferView>;
  126232. /**
  126233. * Image Width (internal use)
  126234. * @hidden
  126235. */
  126236. _groupImgWidth: number;
  126237. /**
  126238. * Image Height (internal use)
  126239. * @hidden
  126240. */
  126241. _groupImgHeight: number;
  126242. /**
  126243. * Custom position function (internal use)
  126244. * @hidden
  126245. */
  126246. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  126247. /**
  126248. * density per facet for surface points
  126249. * @hidden
  126250. */
  126251. _groupDensity: number[];
  126252. /**
  126253. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  126254. * PCS internal tool, don't use it manually.
  126255. * @hidden
  126256. */
  126257. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  126258. }
  126259. }
  126260. declare module BABYLON {
  126261. interface Scene {
  126262. /** @hidden (Backing field) */
  126263. _physicsEngine: Nullable<IPhysicsEngine>;
  126264. /**
  126265. * Gets the current physics engine
  126266. * @returns a IPhysicsEngine or null if none attached
  126267. */
  126268. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  126269. /**
  126270. * Enables physics to the current scene
  126271. * @param gravity defines the scene's gravity for the physics engine
  126272. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  126273. * @return a boolean indicating if the physics engine was initialized
  126274. */
  126275. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  126276. /**
  126277. * Disables and disposes the physics engine associated with the scene
  126278. */
  126279. disablePhysicsEngine(): void;
  126280. /**
  126281. * Gets a boolean indicating if there is an active physics engine
  126282. * @returns a boolean indicating if there is an active physics engine
  126283. */
  126284. isPhysicsEnabled(): boolean;
  126285. /**
  126286. * Deletes a physics compound impostor
  126287. * @param compound defines the compound to delete
  126288. */
  126289. deleteCompoundImpostor(compound: any): void;
  126290. /**
  126291. * An event triggered when physic simulation is about to be run
  126292. */
  126293. onBeforePhysicsObservable: Observable<Scene>;
  126294. /**
  126295. * An event triggered when physic simulation has been done
  126296. */
  126297. onAfterPhysicsObservable: Observable<Scene>;
  126298. }
  126299. interface AbstractMesh {
  126300. /** @hidden */
  126301. _physicsImpostor: Nullable<PhysicsImpostor>;
  126302. /**
  126303. * Gets or sets impostor used for physic simulation
  126304. * @see http://doc.babylonjs.com/features/physics_engine
  126305. */
  126306. physicsImpostor: Nullable<PhysicsImpostor>;
  126307. /**
  126308. * Gets the current physics impostor
  126309. * @see http://doc.babylonjs.com/features/physics_engine
  126310. * @returns a physics impostor or null
  126311. */
  126312. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  126313. /** Apply a physic impulse to the mesh
  126314. * @param force defines the force to apply
  126315. * @param contactPoint defines where to apply the force
  126316. * @returns the current mesh
  126317. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  126318. */
  126319. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  126320. /**
  126321. * Creates a physic joint between two meshes
  126322. * @param otherMesh defines the other mesh to use
  126323. * @param pivot1 defines the pivot to use on this mesh
  126324. * @param pivot2 defines the pivot to use on the other mesh
  126325. * @param options defines additional options (can be plugin dependent)
  126326. * @returns the current mesh
  126327. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  126328. */
  126329. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  126330. /** @hidden */
  126331. _disposePhysicsObserver: Nullable<Observer<Node>>;
  126332. }
  126333. /**
  126334. * Defines the physics engine scene component responsible to manage a physics engine
  126335. */
  126336. export class PhysicsEngineSceneComponent implements ISceneComponent {
  126337. /**
  126338. * The component name helpful to identify the component in the list of scene components.
  126339. */
  126340. readonly name: string;
  126341. /**
  126342. * The scene the component belongs to.
  126343. */
  126344. scene: Scene;
  126345. /**
  126346. * Creates a new instance of the component for the given scene
  126347. * @param scene Defines the scene to register the component in
  126348. */
  126349. constructor(scene: Scene);
  126350. /**
  126351. * Registers the component in a given scene
  126352. */
  126353. register(): void;
  126354. /**
  126355. * Rebuilds the elements related to this component in case of
  126356. * context lost for instance.
  126357. */
  126358. rebuild(): void;
  126359. /**
  126360. * Disposes the component and the associated ressources
  126361. */
  126362. dispose(): void;
  126363. }
  126364. }
  126365. declare module BABYLON {
  126366. /**
  126367. * A helper for physics simulations
  126368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126369. */
  126370. export class PhysicsHelper {
  126371. private _scene;
  126372. private _physicsEngine;
  126373. /**
  126374. * Initializes the Physics helper
  126375. * @param scene Babylon.js scene
  126376. */
  126377. constructor(scene: Scene);
  126378. /**
  126379. * Applies a radial explosion impulse
  126380. * @param origin the origin of the explosion
  126381. * @param radiusOrEventOptions the radius or the options of radial explosion
  126382. * @param strength the explosion strength
  126383. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126384. * @returns A physics radial explosion event, or null
  126385. */
  126386. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126387. /**
  126388. * Applies a radial explosion force
  126389. * @param origin the origin of the explosion
  126390. * @param radiusOrEventOptions the radius or the options of radial explosion
  126391. * @param strength the explosion strength
  126392. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126393. * @returns A physics radial explosion event, or null
  126394. */
  126395. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126396. /**
  126397. * Creates a gravitational field
  126398. * @param origin the origin of the explosion
  126399. * @param radiusOrEventOptions the radius or the options of radial explosion
  126400. * @param strength the explosion strength
  126401. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126402. * @returns A physics gravitational field event, or null
  126403. */
  126404. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  126405. /**
  126406. * Creates a physics updraft event
  126407. * @param origin the origin of the updraft
  126408. * @param radiusOrEventOptions the radius or the options of the updraft
  126409. * @param strength the strength of the updraft
  126410. * @param height the height of the updraft
  126411. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  126412. * @returns A physics updraft event, or null
  126413. */
  126414. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  126415. /**
  126416. * Creates a physics vortex event
  126417. * @param origin the of the vortex
  126418. * @param radiusOrEventOptions the radius or the options of the vortex
  126419. * @param strength the strength of the vortex
  126420. * @param height the height of the vortex
  126421. * @returns a Physics vortex event, or null
  126422. * A physics vortex event or null
  126423. */
  126424. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  126425. }
  126426. /**
  126427. * Represents a physics radial explosion event
  126428. */
  126429. class PhysicsRadialExplosionEvent {
  126430. private _scene;
  126431. private _options;
  126432. private _sphere;
  126433. private _dataFetched;
  126434. /**
  126435. * Initializes a radial explosioin event
  126436. * @param _scene BabylonJS scene
  126437. * @param _options The options for the vortex event
  126438. */
  126439. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  126440. /**
  126441. * Returns the data related to the radial explosion event (sphere).
  126442. * @returns The radial explosion event data
  126443. */
  126444. getData(): PhysicsRadialExplosionEventData;
  126445. /**
  126446. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  126447. * @param impostor A physics imposter
  126448. * @param origin the origin of the explosion
  126449. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  126450. */
  126451. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  126452. /**
  126453. * Triggers affecterd impostors callbacks
  126454. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  126455. */
  126456. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  126457. /**
  126458. * Disposes the sphere.
  126459. * @param force Specifies if the sphere should be disposed by force
  126460. */
  126461. dispose(force?: boolean): void;
  126462. /*** Helpers ***/
  126463. private _prepareSphere;
  126464. private _intersectsWithSphere;
  126465. }
  126466. /**
  126467. * Represents a gravitational field event
  126468. */
  126469. class PhysicsGravitationalFieldEvent {
  126470. private _physicsHelper;
  126471. private _scene;
  126472. private _origin;
  126473. private _options;
  126474. private _tickCallback;
  126475. private _sphere;
  126476. private _dataFetched;
  126477. /**
  126478. * Initializes the physics gravitational field event
  126479. * @param _physicsHelper A physics helper
  126480. * @param _scene BabylonJS scene
  126481. * @param _origin The origin position of the gravitational field event
  126482. * @param _options The options for the vortex event
  126483. */
  126484. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  126485. /**
  126486. * Returns the data related to the gravitational field event (sphere).
  126487. * @returns A gravitational field event
  126488. */
  126489. getData(): PhysicsGravitationalFieldEventData;
  126490. /**
  126491. * Enables the gravitational field.
  126492. */
  126493. enable(): void;
  126494. /**
  126495. * Disables the gravitational field.
  126496. */
  126497. disable(): void;
  126498. /**
  126499. * Disposes the sphere.
  126500. * @param force The force to dispose from the gravitational field event
  126501. */
  126502. dispose(force?: boolean): void;
  126503. private _tick;
  126504. }
  126505. /**
  126506. * Represents a physics updraft event
  126507. */
  126508. class PhysicsUpdraftEvent {
  126509. private _scene;
  126510. private _origin;
  126511. private _options;
  126512. private _physicsEngine;
  126513. private _originTop;
  126514. private _originDirection;
  126515. private _tickCallback;
  126516. private _cylinder;
  126517. private _cylinderPosition;
  126518. private _dataFetched;
  126519. /**
  126520. * Initializes the physics updraft event
  126521. * @param _scene BabylonJS scene
  126522. * @param _origin The origin position of the updraft
  126523. * @param _options The options for the updraft event
  126524. */
  126525. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  126526. /**
  126527. * Returns the data related to the updraft event (cylinder).
  126528. * @returns A physics updraft event
  126529. */
  126530. getData(): PhysicsUpdraftEventData;
  126531. /**
  126532. * Enables the updraft.
  126533. */
  126534. enable(): void;
  126535. /**
  126536. * Disables the updraft.
  126537. */
  126538. disable(): void;
  126539. /**
  126540. * Disposes the cylinder.
  126541. * @param force Specifies if the updraft should be disposed by force
  126542. */
  126543. dispose(force?: boolean): void;
  126544. private getImpostorHitData;
  126545. private _tick;
  126546. /*** Helpers ***/
  126547. private _prepareCylinder;
  126548. private _intersectsWithCylinder;
  126549. }
  126550. /**
  126551. * Represents a physics vortex event
  126552. */
  126553. class PhysicsVortexEvent {
  126554. private _scene;
  126555. private _origin;
  126556. private _options;
  126557. private _physicsEngine;
  126558. private _originTop;
  126559. private _tickCallback;
  126560. private _cylinder;
  126561. private _cylinderPosition;
  126562. private _dataFetched;
  126563. /**
  126564. * Initializes the physics vortex event
  126565. * @param _scene The BabylonJS scene
  126566. * @param _origin The origin position of the vortex
  126567. * @param _options The options for the vortex event
  126568. */
  126569. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  126570. /**
  126571. * Returns the data related to the vortex event (cylinder).
  126572. * @returns The physics vortex event data
  126573. */
  126574. getData(): PhysicsVortexEventData;
  126575. /**
  126576. * Enables the vortex.
  126577. */
  126578. enable(): void;
  126579. /**
  126580. * Disables the cortex.
  126581. */
  126582. disable(): void;
  126583. /**
  126584. * Disposes the sphere.
  126585. * @param force
  126586. */
  126587. dispose(force?: boolean): void;
  126588. private getImpostorHitData;
  126589. private _tick;
  126590. /*** Helpers ***/
  126591. private _prepareCylinder;
  126592. private _intersectsWithCylinder;
  126593. }
  126594. /**
  126595. * Options fot the radial explosion event
  126596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126597. */
  126598. export class PhysicsRadialExplosionEventOptions {
  126599. /**
  126600. * The radius of the sphere for the radial explosion.
  126601. */
  126602. radius: number;
  126603. /**
  126604. * The strenth of the explosion.
  126605. */
  126606. strength: number;
  126607. /**
  126608. * The strenght of the force in correspondence to the distance of the affected object
  126609. */
  126610. falloff: PhysicsRadialImpulseFalloff;
  126611. /**
  126612. * Sphere options for the radial explosion.
  126613. */
  126614. sphere: {
  126615. segments: number;
  126616. diameter: number;
  126617. };
  126618. /**
  126619. * Sphere options for the radial explosion.
  126620. */
  126621. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  126622. }
  126623. /**
  126624. * Options fot the updraft event
  126625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126626. */
  126627. export class PhysicsUpdraftEventOptions {
  126628. /**
  126629. * The radius of the cylinder for the vortex
  126630. */
  126631. radius: number;
  126632. /**
  126633. * The strenth of the updraft.
  126634. */
  126635. strength: number;
  126636. /**
  126637. * The height of the cylinder for the updraft.
  126638. */
  126639. height: number;
  126640. /**
  126641. * The mode for the the updraft.
  126642. */
  126643. updraftMode: PhysicsUpdraftMode;
  126644. }
  126645. /**
  126646. * Options fot the vortex event
  126647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126648. */
  126649. export class PhysicsVortexEventOptions {
  126650. /**
  126651. * The radius of the cylinder for the vortex
  126652. */
  126653. radius: number;
  126654. /**
  126655. * The strenth of the vortex.
  126656. */
  126657. strength: number;
  126658. /**
  126659. * The height of the cylinder for the vortex.
  126660. */
  126661. height: number;
  126662. /**
  126663. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  126664. */
  126665. centripetalForceThreshold: number;
  126666. /**
  126667. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  126668. */
  126669. centripetalForceMultiplier: number;
  126670. /**
  126671. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  126672. */
  126673. centrifugalForceMultiplier: number;
  126674. /**
  126675. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  126676. */
  126677. updraftForceMultiplier: number;
  126678. }
  126679. /**
  126680. * The strenght of the force in correspondence to the distance of the affected object
  126681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126682. */
  126683. export enum PhysicsRadialImpulseFalloff {
  126684. /** Defines that impulse is constant in strength across it's whole radius */
  126685. Constant = 0,
  126686. /** Defines that impulse gets weaker if it's further from the origin */
  126687. Linear = 1
  126688. }
  126689. /**
  126690. * The strength of the force in correspondence to the distance of the affected object
  126691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126692. */
  126693. export enum PhysicsUpdraftMode {
  126694. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  126695. Center = 0,
  126696. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  126697. Perpendicular = 1
  126698. }
  126699. /**
  126700. * Interface for a physics hit data
  126701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126702. */
  126703. export interface PhysicsHitData {
  126704. /**
  126705. * The force applied at the contact point
  126706. */
  126707. force: Vector3;
  126708. /**
  126709. * The contact point
  126710. */
  126711. contactPoint: Vector3;
  126712. /**
  126713. * The distance from the origin to the contact point
  126714. */
  126715. distanceFromOrigin: number;
  126716. }
  126717. /**
  126718. * Interface for radial explosion event data
  126719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126720. */
  126721. export interface PhysicsRadialExplosionEventData {
  126722. /**
  126723. * A sphere used for the radial explosion event
  126724. */
  126725. sphere: Mesh;
  126726. }
  126727. /**
  126728. * Interface for gravitational field event data
  126729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126730. */
  126731. export interface PhysicsGravitationalFieldEventData {
  126732. /**
  126733. * A sphere mesh used for the gravitational field event
  126734. */
  126735. sphere: Mesh;
  126736. }
  126737. /**
  126738. * Interface for updraft event data
  126739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126740. */
  126741. export interface PhysicsUpdraftEventData {
  126742. /**
  126743. * A cylinder used for the updraft event
  126744. */
  126745. cylinder: Mesh;
  126746. }
  126747. /**
  126748. * Interface for vortex event data
  126749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126750. */
  126751. export interface PhysicsVortexEventData {
  126752. /**
  126753. * A cylinder used for the vortex event
  126754. */
  126755. cylinder: Mesh;
  126756. }
  126757. /**
  126758. * Interface for an affected physics impostor
  126759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126760. */
  126761. export interface PhysicsAffectedImpostorWithData {
  126762. /**
  126763. * The impostor affected by the effect
  126764. */
  126765. impostor: PhysicsImpostor;
  126766. /**
  126767. * The data about the hit/horce from the explosion
  126768. */
  126769. hitData: PhysicsHitData;
  126770. }
  126771. }
  126772. declare module BABYLON {
  126773. /** @hidden */
  126774. export var blackAndWhitePixelShader: {
  126775. name: string;
  126776. shader: string;
  126777. };
  126778. }
  126779. declare module BABYLON {
  126780. /**
  126781. * Post process used to render in black and white
  126782. */
  126783. export class BlackAndWhitePostProcess extends PostProcess {
  126784. /**
  126785. * Linear about to convert he result to black and white (default: 1)
  126786. */
  126787. degree: number;
  126788. /**
  126789. * Creates a black and white post process
  126790. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  126791. * @param name The name of the effect.
  126792. * @param options The required width/height ratio to downsize to before computing the render pass.
  126793. * @param camera The camera to apply the render pass to.
  126794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126795. * @param engine The engine which the post process will be applied. (default: current engine)
  126796. * @param reusable If the post process can be reused on the same frame. (default: false)
  126797. */
  126798. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126799. }
  126800. }
  126801. declare module BABYLON {
  126802. /**
  126803. * This represents a set of one or more post processes in Babylon.
  126804. * A post process can be used to apply a shader to a texture after it is rendered.
  126805. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126806. */
  126807. export class PostProcessRenderEffect {
  126808. private _postProcesses;
  126809. private _getPostProcesses;
  126810. private _singleInstance;
  126811. private _cameras;
  126812. private _indicesForCamera;
  126813. /**
  126814. * Name of the effect
  126815. * @hidden
  126816. */
  126817. _name: string;
  126818. /**
  126819. * Instantiates a post process render effect.
  126820. * A post process can be used to apply a shader to a texture after it is rendered.
  126821. * @param engine The engine the effect is tied to
  126822. * @param name The name of the effect
  126823. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  126824. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  126825. */
  126826. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  126827. /**
  126828. * Checks if all the post processes in the effect are supported.
  126829. */
  126830. readonly isSupported: boolean;
  126831. /**
  126832. * Updates the current state of the effect
  126833. * @hidden
  126834. */
  126835. _update(): void;
  126836. /**
  126837. * Attaches the effect on cameras
  126838. * @param cameras The camera to attach to.
  126839. * @hidden
  126840. */
  126841. _attachCameras(cameras: Camera): void;
  126842. /**
  126843. * Attaches the effect on cameras
  126844. * @param cameras The camera to attach to.
  126845. * @hidden
  126846. */
  126847. _attachCameras(cameras: Camera[]): void;
  126848. /**
  126849. * Detaches the effect on cameras
  126850. * @param cameras The camera to detatch from.
  126851. * @hidden
  126852. */
  126853. _detachCameras(cameras: Camera): void;
  126854. /**
  126855. * Detatches the effect on cameras
  126856. * @param cameras The camera to detatch from.
  126857. * @hidden
  126858. */
  126859. _detachCameras(cameras: Camera[]): void;
  126860. /**
  126861. * Enables the effect on given cameras
  126862. * @param cameras The camera to enable.
  126863. * @hidden
  126864. */
  126865. _enable(cameras: Camera): void;
  126866. /**
  126867. * Enables the effect on given cameras
  126868. * @param cameras The camera to enable.
  126869. * @hidden
  126870. */
  126871. _enable(cameras: Nullable<Camera[]>): void;
  126872. /**
  126873. * Disables the effect on the given cameras
  126874. * @param cameras The camera to disable.
  126875. * @hidden
  126876. */
  126877. _disable(cameras: Camera): void;
  126878. /**
  126879. * Disables the effect on the given cameras
  126880. * @param cameras The camera to disable.
  126881. * @hidden
  126882. */
  126883. _disable(cameras: Nullable<Camera[]>): void;
  126884. /**
  126885. * Gets a list of the post processes contained in the effect.
  126886. * @param camera The camera to get the post processes on.
  126887. * @returns The list of the post processes in the effect.
  126888. */
  126889. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  126890. }
  126891. }
  126892. declare module BABYLON {
  126893. /** @hidden */
  126894. export var extractHighlightsPixelShader: {
  126895. name: string;
  126896. shader: string;
  126897. };
  126898. }
  126899. declare module BABYLON {
  126900. /**
  126901. * 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.
  126902. */
  126903. export class ExtractHighlightsPostProcess extends PostProcess {
  126904. /**
  126905. * The luminance threshold, pixels below this value will be set to black.
  126906. */
  126907. threshold: number;
  126908. /** @hidden */
  126909. _exposure: number;
  126910. /**
  126911. * Post process which has the input texture to be used when performing highlight extraction
  126912. * @hidden
  126913. */
  126914. _inputPostProcess: Nullable<PostProcess>;
  126915. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126916. }
  126917. }
  126918. declare module BABYLON {
  126919. /** @hidden */
  126920. export var bloomMergePixelShader: {
  126921. name: string;
  126922. shader: string;
  126923. };
  126924. }
  126925. declare module BABYLON {
  126926. /**
  126927. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126928. */
  126929. export class BloomMergePostProcess extends PostProcess {
  126930. /** Weight of the bloom to be added to the original input. */
  126931. weight: number;
  126932. /**
  126933. * Creates a new instance of @see BloomMergePostProcess
  126934. * @param name The name of the effect.
  126935. * @param originalFromInput Post process which's input will be used for the merge.
  126936. * @param blurred Blurred highlights post process which's output will be used.
  126937. * @param weight Weight of the bloom to be added to the original input.
  126938. * @param options The required width/height ratio to downsize to before computing the render pass.
  126939. * @param camera The camera to apply the render pass to.
  126940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126941. * @param engine The engine which the post process will be applied. (default: current engine)
  126942. * @param reusable If the post process can be reused on the same frame. (default: false)
  126943. * @param textureType Type of textures used when performing the post process. (default: 0)
  126944. * @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)
  126945. */
  126946. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  126947. /** Weight of the bloom to be added to the original input. */
  126948. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126949. }
  126950. }
  126951. declare module BABYLON {
  126952. /**
  126953. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  126954. */
  126955. export class BloomEffect extends PostProcessRenderEffect {
  126956. private bloomScale;
  126957. /**
  126958. * @hidden Internal
  126959. */
  126960. _effects: Array<PostProcess>;
  126961. /**
  126962. * @hidden Internal
  126963. */
  126964. _downscale: ExtractHighlightsPostProcess;
  126965. private _blurX;
  126966. private _blurY;
  126967. private _merge;
  126968. /**
  126969. * The luminance threshold to find bright areas of the image to bloom.
  126970. */
  126971. threshold: number;
  126972. /**
  126973. * The strength of the bloom.
  126974. */
  126975. weight: number;
  126976. /**
  126977. * Specifies the size of the bloom blur kernel, relative to the final output size
  126978. */
  126979. kernel: number;
  126980. /**
  126981. * Creates a new instance of @see BloomEffect
  126982. * @param scene The scene the effect belongs to.
  126983. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  126984. * @param bloomKernel The size of the kernel to be used when applying the blur.
  126985. * @param bloomWeight The the strength of bloom.
  126986. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126987. * @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)
  126988. */
  126989. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  126990. /**
  126991. * Disposes each of the internal effects for a given camera.
  126992. * @param camera The camera to dispose the effect on.
  126993. */
  126994. disposeEffects(camera: Camera): void;
  126995. /**
  126996. * @hidden Internal
  126997. */
  126998. _updateEffects(): void;
  126999. /**
  127000. * Internal
  127001. * @returns if all the contained post processes are ready.
  127002. * @hidden
  127003. */
  127004. _isReady(): boolean;
  127005. }
  127006. }
  127007. declare module BABYLON {
  127008. /** @hidden */
  127009. export var chromaticAberrationPixelShader: {
  127010. name: string;
  127011. shader: string;
  127012. };
  127013. }
  127014. declare module BABYLON {
  127015. /**
  127016. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  127017. */
  127018. export class ChromaticAberrationPostProcess extends PostProcess {
  127019. /**
  127020. * The amount of seperation of rgb channels (default: 30)
  127021. */
  127022. aberrationAmount: number;
  127023. /**
  127024. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  127025. */
  127026. radialIntensity: number;
  127027. /**
  127028. * 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))
  127029. */
  127030. direction: Vector2;
  127031. /**
  127032. * 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))
  127033. */
  127034. centerPosition: Vector2;
  127035. /**
  127036. * Creates a new instance ChromaticAberrationPostProcess
  127037. * @param name The name of the effect.
  127038. * @param screenWidth The width of the screen to apply the effect on.
  127039. * @param screenHeight The height of the screen to apply the effect on.
  127040. * @param options The required width/height ratio to downsize to before computing the render pass.
  127041. * @param camera The camera to apply the render pass to.
  127042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127043. * @param engine The engine which the post process will be applied. (default: current engine)
  127044. * @param reusable If the post process can be reused on the same frame. (default: false)
  127045. * @param textureType Type of textures used when performing the post process. (default: 0)
  127046. * @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)
  127047. */
  127048. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127049. }
  127050. }
  127051. declare module BABYLON {
  127052. /** @hidden */
  127053. export var circleOfConfusionPixelShader: {
  127054. name: string;
  127055. shader: string;
  127056. };
  127057. }
  127058. declare module BABYLON {
  127059. /**
  127060. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  127061. */
  127062. export class CircleOfConfusionPostProcess extends PostProcess {
  127063. /**
  127064. * 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.
  127065. */
  127066. lensSize: number;
  127067. /**
  127068. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127069. */
  127070. fStop: number;
  127071. /**
  127072. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127073. */
  127074. focusDistance: number;
  127075. /**
  127076. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  127077. */
  127078. focalLength: number;
  127079. private _depthTexture;
  127080. /**
  127081. * Creates a new instance CircleOfConfusionPostProcess
  127082. * @param name The name of the effect.
  127083. * @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.
  127084. * @param options The required width/height ratio to downsize to before computing the render pass.
  127085. * @param camera The camera to apply the render pass to.
  127086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127087. * @param engine The engine which the post process will be applied. (default: current engine)
  127088. * @param reusable If the post process can be reused on the same frame. (default: false)
  127089. * @param textureType Type of textures used when performing the post process. (default: 0)
  127090. * @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)
  127091. */
  127092. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127093. /**
  127094. * 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.
  127095. */
  127096. depthTexture: RenderTargetTexture;
  127097. }
  127098. }
  127099. declare module BABYLON {
  127100. /** @hidden */
  127101. export var colorCorrectionPixelShader: {
  127102. name: string;
  127103. shader: string;
  127104. };
  127105. }
  127106. declare module BABYLON {
  127107. /**
  127108. *
  127109. * This post-process allows the modification of rendered colors by using
  127110. * a 'look-up table' (LUT). This effect is also called Color Grading.
  127111. *
  127112. * The object needs to be provided an url to a texture containing the color
  127113. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  127114. * Use an image editing software to tweak the LUT to match your needs.
  127115. *
  127116. * For an example of a color LUT, see here:
  127117. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  127118. * For explanations on color grading, see here:
  127119. * @see http://udn.epicgames.com/Three/ColorGrading.html
  127120. *
  127121. */
  127122. export class ColorCorrectionPostProcess extends PostProcess {
  127123. private _colorTableTexture;
  127124. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127125. }
  127126. }
  127127. declare module BABYLON {
  127128. /** @hidden */
  127129. export var convolutionPixelShader: {
  127130. name: string;
  127131. shader: string;
  127132. };
  127133. }
  127134. declare module BABYLON {
  127135. /**
  127136. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  127137. * input texture to perform effects such as edge detection or sharpening
  127138. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127139. */
  127140. export class ConvolutionPostProcess extends PostProcess {
  127141. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127142. kernel: number[];
  127143. /**
  127144. * Creates a new instance ConvolutionPostProcess
  127145. * @param name The name of the effect.
  127146. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  127147. * @param options The required width/height ratio to downsize to before computing the render pass.
  127148. * @param camera The camera to apply the render pass to.
  127149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127150. * @param engine The engine which the post process will be applied. (default: current engine)
  127151. * @param reusable If the post process can be reused on the same frame. (default: false)
  127152. * @param textureType Type of textures used when performing the post process. (default: 0)
  127153. */
  127154. constructor(name: string,
  127155. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127156. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127157. /**
  127158. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127159. */
  127160. static EdgeDetect0Kernel: number[];
  127161. /**
  127162. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127163. */
  127164. static EdgeDetect1Kernel: number[];
  127165. /**
  127166. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127167. */
  127168. static EdgeDetect2Kernel: number[];
  127169. /**
  127170. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127171. */
  127172. static SharpenKernel: number[];
  127173. /**
  127174. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127175. */
  127176. static EmbossKernel: number[];
  127177. /**
  127178. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127179. */
  127180. static GaussianKernel: number[];
  127181. }
  127182. }
  127183. declare module BABYLON {
  127184. /**
  127185. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  127186. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  127187. * based on samples that have a large difference in distance than the center pixel.
  127188. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  127189. */
  127190. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  127191. direction: Vector2;
  127192. /**
  127193. * Creates a new instance CircleOfConfusionPostProcess
  127194. * @param name The name of the effect.
  127195. * @param scene The scene the effect belongs to.
  127196. * @param direction The direction the blur should be applied.
  127197. * @param kernel The size of the kernel used to blur.
  127198. * @param options The required width/height ratio to downsize to before computing the render pass.
  127199. * @param camera The camera to apply the render pass to.
  127200. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  127201. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  127202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127203. * @param engine The engine which the post process will be applied. (default: current engine)
  127204. * @param reusable If the post process can be reused on the same frame. (default: false)
  127205. * @param textureType Type of textures used when performing the post process. (default: 0)
  127206. * @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)
  127207. */
  127208. 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);
  127209. }
  127210. }
  127211. declare module BABYLON {
  127212. /** @hidden */
  127213. export var depthOfFieldMergePixelShader: {
  127214. name: string;
  127215. shader: string;
  127216. };
  127217. }
  127218. declare module BABYLON {
  127219. /**
  127220. * Options to be set when merging outputs from the default pipeline.
  127221. */
  127222. export class DepthOfFieldMergePostProcessOptions {
  127223. /**
  127224. * The original image to merge on top of
  127225. */
  127226. originalFromInput: PostProcess;
  127227. /**
  127228. * Parameters to perform the merge of the depth of field effect
  127229. */
  127230. depthOfField?: {
  127231. circleOfConfusion: PostProcess;
  127232. blurSteps: Array<PostProcess>;
  127233. };
  127234. /**
  127235. * Parameters to perform the merge of bloom effect
  127236. */
  127237. bloom?: {
  127238. blurred: PostProcess;
  127239. weight: number;
  127240. };
  127241. }
  127242. /**
  127243. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  127244. */
  127245. export class DepthOfFieldMergePostProcess extends PostProcess {
  127246. private blurSteps;
  127247. /**
  127248. * Creates a new instance of DepthOfFieldMergePostProcess
  127249. * @param name The name of the effect.
  127250. * @param originalFromInput Post process which's input will be used for the merge.
  127251. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  127252. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  127253. * @param options The required width/height ratio to downsize to before computing the render pass.
  127254. * @param camera The camera to apply the render pass to.
  127255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127256. * @param engine The engine which the post process will be applied. (default: current engine)
  127257. * @param reusable If the post process can be reused on the same frame. (default: false)
  127258. * @param textureType Type of textures used when performing the post process. (default: 0)
  127259. * @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)
  127260. */
  127261. 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);
  127262. /**
  127263. * Updates the effect with the current post process compile time values and recompiles the shader.
  127264. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  127265. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  127266. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  127267. * @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
  127268. * @param onCompiled Called when the shader has been compiled.
  127269. * @param onError Called if there is an error when compiling a shader.
  127270. */
  127271. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  127272. }
  127273. }
  127274. declare module BABYLON {
  127275. /**
  127276. * Specifies the level of max blur that should be applied when using the depth of field effect
  127277. */
  127278. export enum DepthOfFieldEffectBlurLevel {
  127279. /**
  127280. * Subtle blur
  127281. */
  127282. Low = 0,
  127283. /**
  127284. * Medium blur
  127285. */
  127286. Medium = 1,
  127287. /**
  127288. * Large blur
  127289. */
  127290. High = 2
  127291. }
  127292. /**
  127293. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  127294. */
  127295. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  127296. private _circleOfConfusion;
  127297. /**
  127298. * @hidden Internal, blurs from high to low
  127299. */
  127300. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  127301. private _depthOfFieldBlurY;
  127302. private _dofMerge;
  127303. /**
  127304. * @hidden Internal post processes in depth of field effect
  127305. */
  127306. _effects: Array<PostProcess>;
  127307. /**
  127308. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  127309. */
  127310. focalLength: number;
  127311. /**
  127312. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127313. */
  127314. fStop: number;
  127315. /**
  127316. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127317. */
  127318. focusDistance: number;
  127319. /**
  127320. * 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.
  127321. */
  127322. lensSize: number;
  127323. /**
  127324. * Creates a new instance DepthOfFieldEffect
  127325. * @param scene The scene the effect belongs to.
  127326. * @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.
  127327. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127328. * @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)
  127329. */
  127330. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  127331. /**
  127332. * Get the current class name of the current effet
  127333. * @returns "DepthOfFieldEffect"
  127334. */
  127335. getClassName(): string;
  127336. /**
  127337. * 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.
  127338. */
  127339. depthTexture: RenderTargetTexture;
  127340. /**
  127341. * Disposes each of the internal effects for a given camera.
  127342. * @param camera The camera to dispose the effect on.
  127343. */
  127344. disposeEffects(camera: Camera): void;
  127345. /**
  127346. * @hidden Internal
  127347. */
  127348. _updateEffects(): void;
  127349. /**
  127350. * Internal
  127351. * @returns if all the contained post processes are ready.
  127352. * @hidden
  127353. */
  127354. _isReady(): boolean;
  127355. }
  127356. }
  127357. declare module BABYLON {
  127358. /** @hidden */
  127359. export var displayPassPixelShader: {
  127360. name: string;
  127361. shader: string;
  127362. };
  127363. }
  127364. declare module BABYLON {
  127365. /**
  127366. * DisplayPassPostProcess which produces an output the same as it's input
  127367. */
  127368. export class DisplayPassPostProcess extends PostProcess {
  127369. /**
  127370. * Creates the DisplayPassPostProcess
  127371. * @param name The name of the effect.
  127372. * @param options The required width/height ratio to downsize to before computing the render pass.
  127373. * @param camera The camera to apply the render pass to.
  127374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127375. * @param engine The engine which the post process will be applied. (default: current engine)
  127376. * @param reusable If the post process can be reused on the same frame. (default: false)
  127377. */
  127378. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127379. }
  127380. }
  127381. declare module BABYLON {
  127382. /** @hidden */
  127383. export var filterPixelShader: {
  127384. name: string;
  127385. shader: string;
  127386. };
  127387. }
  127388. declare module BABYLON {
  127389. /**
  127390. * Applies a kernel filter to the image
  127391. */
  127392. export class FilterPostProcess extends PostProcess {
  127393. /** The matrix to be applied to the image */
  127394. kernelMatrix: Matrix;
  127395. /**
  127396. *
  127397. * @param name The name of the effect.
  127398. * @param kernelMatrix The matrix to be applied to the image
  127399. * @param options The required width/height ratio to downsize to before computing the render pass.
  127400. * @param camera The camera to apply the render pass to.
  127401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127402. * @param engine The engine which the post process will be applied. (default: current engine)
  127403. * @param reusable If the post process can be reused on the same frame. (default: false)
  127404. */
  127405. constructor(name: string,
  127406. /** The matrix to be applied to the image */
  127407. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127408. }
  127409. }
  127410. declare module BABYLON {
  127411. /** @hidden */
  127412. export var fxaaPixelShader: {
  127413. name: string;
  127414. shader: string;
  127415. };
  127416. }
  127417. declare module BABYLON {
  127418. /** @hidden */
  127419. export var fxaaVertexShader: {
  127420. name: string;
  127421. shader: string;
  127422. };
  127423. }
  127424. declare module BABYLON {
  127425. /**
  127426. * Fxaa post process
  127427. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  127428. */
  127429. export class FxaaPostProcess extends PostProcess {
  127430. /** @hidden */
  127431. texelWidth: number;
  127432. /** @hidden */
  127433. texelHeight: number;
  127434. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127435. private _getDefines;
  127436. }
  127437. }
  127438. declare module BABYLON {
  127439. /** @hidden */
  127440. export var grainPixelShader: {
  127441. name: string;
  127442. shader: string;
  127443. };
  127444. }
  127445. declare module BABYLON {
  127446. /**
  127447. * The GrainPostProcess adds noise to the image at mid luminance levels
  127448. */
  127449. export class GrainPostProcess extends PostProcess {
  127450. /**
  127451. * The intensity of the grain added (default: 30)
  127452. */
  127453. intensity: number;
  127454. /**
  127455. * If the grain should be randomized on every frame
  127456. */
  127457. animated: boolean;
  127458. /**
  127459. * Creates a new instance of @see GrainPostProcess
  127460. * @param name The name of the effect.
  127461. * @param options The required width/height ratio to downsize to before computing the render pass.
  127462. * @param camera The camera to apply the render pass to.
  127463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127464. * @param engine The engine which the post process will be applied. (default: current engine)
  127465. * @param reusable If the post process can be reused on the same frame. (default: false)
  127466. * @param textureType Type of textures used when performing the post process. (default: 0)
  127467. * @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)
  127468. */
  127469. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127470. }
  127471. }
  127472. declare module BABYLON {
  127473. /** @hidden */
  127474. export var highlightsPixelShader: {
  127475. name: string;
  127476. shader: string;
  127477. };
  127478. }
  127479. declare module BABYLON {
  127480. /**
  127481. * Extracts highlights from the image
  127482. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127483. */
  127484. export class HighlightsPostProcess extends PostProcess {
  127485. /**
  127486. * Extracts highlights from the image
  127487. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127488. * @param name The name of the effect.
  127489. * @param options The required width/height ratio to downsize to before computing the render pass.
  127490. * @param camera The camera to apply the render pass to.
  127491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127492. * @param engine The engine which the post process will be applied. (default: current engine)
  127493. * @param reusable If the post process can be reused on the same frame. (default: false)
  127494. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  127495. */
  127496. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127497. }
  127498. }
  127499. declare module BABYLON {
  127500. /** @hidden */
  127501. export var mrtFragmentDeclaration: {
  127502. name: string;
  127503. shader: string;
  127504. };
  127505. }
  127506. declare module BABYLON {
  127507. /** @hidden */
  127508. export var geometryPixelShader: {
  127509. name: string;
  127510. shader: string;
  127511. };
  127512. }
  127513. declare module BABYLON {
  127514. /** @hidden */
  127515. export var geometryVertexShader: {
  127516. name: string;
  127517. shader: string;
  127518. };
  127519. }
  127520. declare module BABYLON {
  127521. /** @hidden */
  127522. interface ISavedTransformationMatrix {
  127523. world: Matrix;
  127524. viewProjection: Matrix;
  127525. }
  127526. /**
  127527. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  127528. */
  127529. export class GeometryBufferRenderer {
  127530. /**
  127531. * Constant used to retrieve the position texture index in the G-Buffer textures array
  127532. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  127533. */
  127534. static readonly POSITION_TEXTURE_TYPE: number;
  127535. /**
  127536. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  127537. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  127538. */
  127539. static readonly VELOCITY_TEXTURE_TYPE: number;
  127540. /**
  127541. * Dictionary used to store the previous transformation matrices of each rendered mesh
  127542. * in order to compute objects velocities when enableVelocity is set to "true"
  127543. * @hidden
  127544. */
  127545. _previousTransformationMatrices: {
  127546. [index: number]: ISavedTransformationMatrix;
  127547. };
  127548. /**
  127549. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  127550. * in order to compute objects velocities when enableVelocity is set to "true"
  127551. * @hidden
  127552. */
  127553. _previousBonesTransformationMatrices: {
  127554. [index: number]: Float32Array;
  127555. };
  127556. /**
  127557. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  127558. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  127559. */
  127560. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  127561. private _scene;
  127562. private _multiRenderTarget;
  127563. private _ratio;
  127564. private _enablePosition;
  127565. private _enableVelocity;
  127566. private _positionIndex;
  127567. private _velocityIndex;
  127568. protected _effect: Effect;
  127569. protected _cachedDefines: string;
  127570. /**
  127571. * Set the render list (meshes to be rendered) used in the G buffer.
  127572. */
  127573. renderList: Mesh[];
  127574. /**
  127575. * Gets wether or not G buffer are supported by the running hardware.
  127576. * This requires draw buffer supports
  127577. */
  127578. readonly isSupported: boolean;
  127579. /**
  127580. * Returns the index of the given texture type in the G-Buffer textures array
  127581. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  127582. * @returns the index of the given texture type in the G-Buffer textures array
  127583. */
  127584. getTextureIndex(textureType: number): number;
  127585. /**
  127586. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  127587. */
  127588. /**
  127589. * Sets whether or not objects positions are enabled for the G buffer.
  127590. */
  127591. enablePosition: boolean;
  127592. /**
  127593. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  127594. */
  127595. /**
  127596. * Sets wether or not objects velocities are enabled for the G buffer.
  127597. */
  127598. enableVelocity: boolean;
  127599. /**
  127600. * Gets the scene associated with the buffer.
  127601. */
  127602. readonly scene: Scene;
  127603. /**
  127604. * Gets the ratio used by the buffer during its creation.
  127605. * How big is the buffer related to the main canvas.
  127606. */
  127607. readonly ratio: number;
  127608. /** @hidden */
  127609. static _SceneComponentInitialization: (scene: Scene) => void;
  127610. /**
  127611. * Creates a new G Buffer for the scene
  127612. * @param scene The scene the buffer belongs to
  127613. * @param ratio How big is the buffer related to the main canvas.
  127614. */
  127615. constructor(scene: Scene, ratio?: number);
  127616. /**
  127617. * Checks wether everything is ready to render a submesh to the G buffer.
  127618. * @param subMesh the submesh to check readiness for
  127619. * @param useInstances is the mesh drawn using instance or not
  127620. * @returns true if ready otherwise false
  127621. */
  127622. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127623. /**
  127624. * Gets the current underlying G Buffer.
  127625. * @returns the buffer
  127626. */
  127627. getGBuffer(): MultiRenderTarget;
  127628. /**
  127629. * Gets the number of samples used to render the buffer (anti aliasing).
  127630. */
  127631. /**
  127632. * Sets the number of samples used to render the buffer (anti aliasing).
  127633. */
  127634. samples: number;
  127635. /**
  127636. * Disposes the renderer and frees up associated resources.
  127637. */
  127638. dispose(): void;
  127639. protected _createRenderTargets(): void;
  127640. private _copyBonesTransformationMatrices;
  127641. }
  127642. }
  127643. declare module BABYLON {
  127644. interface Scene {
  127645. /** @hidden (Backing field) */
  127646. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127647. /**
  127648. * Gets or Sets the current geometry buffer associated to the scene.
  127649. */
  127650. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127651. /**
  127652. * Enables a GeometryBufferRender and associates it with the scene
  127653. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  127654. * @returns the GeometryBufferRenderer
  127655. */
  127656. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  127657. /**
  127658. * Disables the GeometryBufferRender associated with the scene
  127659. */
  127660. disableGeometryBufferRenderer(): void;
  127661. }
  127662. /**
  127663. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  127664. * in several rendering techniques.
  127665. */
  127666. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  127667. /**
  127668. * The component name helpful to identify the component in the list of scene components.
  127669. */
  127670. readonly name: string;
  127671. /**
  127672. * The scene the component belongs to.
  127673. */
  127674. scene: Scene;
  127675. /**
  127676. * Creates a new instance of the component for the given scene
  127677. * @param scene Defines the scene to register the component in
  127678. */
  127679. constructor(scene: Scene);
  127680. /**
  127681. * Registers the component in a given scene
  127682. */
  127683. register(): void;
  127684. /**
  127685. * Rebuilds the elements related to this component in case of
  127686. * context lost for instance.
  127687. */
  127688. rebuild(): void;
  127689. /**
  127690. * Disposes the component and the associated ressources
  127691. */
  127692. dispose(): void;
  127693. private _gatherRenderTargets;
  127694. }
  127695. }
  127696. declare module BABYLON {
  127697. /** @hidden */
  127698. export var motionBlurPixelShader: {
  127699. name: string;
  127700. shader: string;
  127701. };
  127702. }
  127703. declare module BABYLON {
  127704. /**
  127705. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  127706. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  127707. * As an example, all you have to do is to create the post-process:
  127708. * var mb = new BABYLON.MotionBlurPostProcess(
  127709. * 'mb', // The name of the effect.
  127710. * scene, // The scene containing the objects to blur according to their velocity.
  127711. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  127712. * camera // The camera to apply the render pass to.
  127713. * );
  127714. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  127715. */
  127716. export class MotionBlurPostProcess extends PostProcess {
  127717. /**
  127718. * Defines how much the image is blurred by the movement. Default value is equal to 1
  127719. */
  127720. motionStrength: number;
  127721. /**
  127722. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  127723. */
  127724. /**
  127725. * Sets the number of iterations to be used for motion blur quality
  127726. */
  127727. motionBlurSamples: number;
  127728. private _motionBlurSamples;
  127729. private _geometryBufferRenderer;
  127730. /**
  127731. * Creates a new instance MotionBlurPostProcess
  127732. * @param name The name of the effect.
  127733. * @param scene The scene containing the objects to blur according to their velocity.
  127734. * @param options The required width/height ratio to downsize to before computing the render pass.
  127735. * @param camera The camera to apply the render pass to.
  127736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127737. * @param engine The engine which the post process will be applied. (default: current engine)
  127738. * @param reusable If the post process can be reused on the same frame. (default: false)
  127739. * @param textureType Type of textures used when performing the post process. (default: 0)
  127740. * @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)
  127741. */
  127742. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127743. /**
  127744. * Excludes the given skinned mesh from computing bones velocities.
  127745. * 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.
  127746. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  127747. */
  127748. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127749. /**
  127750. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  127751. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  127752. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  127753. */
  127754. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127755. /**
  127756. * Disposes the post process.
  127757. * @param camera The camera to dispose the post process on.
  127758. */
  127759. dispose(camera?: Camera): void;
  127760. }
  127761. }
  127762. declare module BABYLON {
  127763. /** @hidden */
  127764. export var refractionPixelShader: {
  127765. name: string;
  127766. shader: string;
  127767. };
  127768. }
  127769. declare module BABYLON {
  127770. /**
  127771. * Post process which applies a refractin texture
  127772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127773. */
  127774. export class RefractionPostProcess extends PostProcess {
  127775. /** the base color of the refraction (used to taint the rendering) */
  127776. color: Color3;
  127777. /** simulated refraction depth */
  127778. depth: number;
  127779. /** the coefficient of the base color (0 to remove base color tainting) */
  127780. colorLevel: number;
  127781. private _refTexture;
  127782. private _ownRefractionTexture;
  127783. /**
  127784. * Gets or sets the refraction texture
  127785. * Please note that you are responsible for disposing the texture if you set it manually
  127786. */
  127787. refractionTexture: Texture;
  127788. /**
  127789. * Initializes the RefractionPostProcess
  127790. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127791. * @param name The name of the effect.
  127792. * @param refractionTextureUrl Url of the refraction texture to use
  127793. * @param color the base color of the refraction (used to taint the rendering)
  127794. * @param depth simulated refraction depth
  127795. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  127796. * @param camera The camera to apply the render pass to.
  127797. * @param options The required width/height ratio to downsize to before computing the render pass.
  127798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127799. * @param engine The engine which the post process will be applied. (default: current engine)
  127800. * @param reusable If the post process can be reused on the same frame. (default: false)
  127801. */
  127802. constructor(name: string, refractionTextureUrl: string,
  127803. /** the base color of the refraction (used to taint the rendering) */
  127804. color: Color3,
  127805. /** simulated refraction depth */
  127806. depth: number,
  127807. /** the coefficient of the base color (0 to remove base color tainting) */
  127808. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127809. /**
  127810. * Disposes of the post process
  127811. * @param camera Camera to dispose post process on
  127812. */
  127813. dispose(camera: Camera): void;
  127814. }
  127815. }
  127816. declare module BABYLON {
  127817. /** @hidden */
  127818. export var sharpenPixelShader: {
  127819. name: string;
  127820. shader: string;
  127821. };
  127822. }
  127823. declare module BABYLON {
  127824. /**
  127825. * The SharpenPostProcess applies a sharpen kernel to every pixel
  127826. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127827. */
  127828. export class SharpenPostProcess extends PostProcess {
  127829. /**
  127830. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  127831. */
  127832. colorAmount: number;
  127833. /**
  127834. * How much sharpness should be applied (default: 0.3)
  127835. */
  127836. edgeAmount: number;
  127837. /**
  127838. * Creates a new instance ConvolutionPostProcess
  127839. * @param name The name of the effect.
  127840. * @param options The required width/height ratio to downsize to before computing the render pass.
  127841. * @param camera The camera to apply the render pass to.
  127842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127843. * @param engine The engine which the post process will be applied. (default: current engine)
  127844. * @param reusable If the post process can be reused on the same frame. (default: false)
  127845. * @param textureType Type of textures used when performing the post process. (default: 0)
  127846. * @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)
  127847. */
  127848. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127849. }
  127850. }
  127851. declare module BABYLON {
  127852. /**
  127853. * PostProcessRenderPipeline
  127854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127855. */
  127856. export class PostProcessRenderPipeline {
  127857. private engine;
  127858. private _renderEffects;
  127859. private _renderEffectsForIsolatedPass;
  127860. /**
  127861. * List of inspectable custom properties (used by the Inspector)
  127862. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  127863. */
  127864. inspectableCustomProperties: IInspectable[];
  127865. /**
  127866. * @hidden
  127867. */
  127868. protected _cameras: Camera[];
  127869. /** @hidden */
  127870. _name: string;
  127871. /**
  127872. * Gets pipeline name
  127873. */
  127874. readonly name: string;
  127875. /**
  127876. * Initializes a PostProcessRenderPipeline
  127877. * @param engine engine to add the pipeline to
  127878. * @param name name of the pipeline
  127879. */
  127880. constructor(engine: Engine, name: string);
  127881. /**
  127882. * Gets the class name
  127883. * @returns "PostProcessRenderPipeline"
  127884. */
  127885. getClassName(): string;
  127886. /**
  127887. * If all the render effects in the pipeline are supported
  127888. */
  127889. readonly isSupported: boolean;
  127890. /**
  127891. * Adds an effect to the pipeline
  127892. * @param renderEffect the effect to add
  127893. */
  127894. addEffect(renderEffect: PostProcessRenderEffect): void;
  127895. /** @hidden */
  127896. _rebuild(): void;
  127897. /** @hidden */
  127898. _enableEffect(renderEffectName: string, cameras: Camera): void;
  127899. /** @hidden */
  127900. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  127901. /** @hidden */
  127902. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127903. /** @hidden */
  127904. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127905. /** @hidden */
  127906. _attachCameras(cameras: Camera, unique: boolean): void;
  127907. /** @hidden */
  127908. _attachCameras(cameras: Camera[], unique: boolean): void;
  127909. /** @hidden */
  127910. _detachCameras(cameras: Camera): void;
  127911. /** @hidden */
  127912. _detachCameras(cameras: Nullable<Camera[]>): void;
  127913. /** @hidden */
  127914. _update(): void;
  127915. /** @hidden */
  127916. _reset(): void;
  127917. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  127918. /**
  127919. * Disposes of the pipeline
  127920. */
  127921. dispose(): void;
  127922. }
  127923. }
  127924. declare module BABYLON {
  127925. /**
  127926. * PostProcessRenderPipelineManager class
  127927. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127928. */
  127929. export class PostProcessRenderPipelineManager {
  127930. private _renderPipelines;
  127931. /**
  127932. * Initializes a PostProcessRenderPipelineManager
  127933. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127934. */
  127935. constructor();
  127936. /**
  127937. * Gets the list of supported render pipelines
  127938. */
  127939. readonly supportedPipelines: PostProcessRenderPipeline[];
  127940. /**
  127941. * Adds a pipeline to the manager
  127942. * @param renderPipeline The pipeline to add
  127943. */
  127944. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  127945. /**
  127946. * Attaches a camera to the pipeline
  127947. * @param renderPipelineName The name of the pipeline to attach to
  127948. * @param cameras the camera to attach
  127949. * @param unique if the camera can be attached multiple times to the pipeline
  127950. */
  127951. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  127952. /**
  127953. * Detaches a camera from the pipeline
  127954. * @param renderPipelineName The name of the pipeline to detach from
  127955. * @param cameras the camera to detach
  127956. */
  127957. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  127958. /**
  127959. * Enables an effect by name on a pipeline
  127960. * @param renderPipelineName the name of the pipeline to enable the effect in
  127961. * @param renderEffectName the name of the effect to enable
  127962. * @param cameras the cameras that the effect should be enabled on
  127963. */
  127964. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  127965. /**
  127966. * Disables an effect by name on a pipeline
  127967. * @param renderPipelineName the name of the pipeline to disable the effect in
  127968. * @param renderEffectName the name of the effect to disable
  127969. * @param cameras the cameras that the effect should be disabled on
  127970. */
  127971. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  127972. /**
  127973. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  127974. */
  127975. update(): void;
  127976. /** @hidden */
  127977. _rebuild(): void;
  127978. /**
  127979. * Disposes of the manager and pipelines
  127980. */
  127981. dispose(): void;
  127982. }
  127983. }
  127984. declare module BABYLON {
  127985. interface Scene {
  127986. /** @hidden (Backing field) */
  127987. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  127988. /**
  127989. * Gets the postprocess render pipeline manager
  127990. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127991. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  127992. */
  127993. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  127994. }
  127995. /**
  127996. * Defines the Render Pipeline scene component responsible to rendering pipelines
  127997. */
  127998. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  127999. /**
  128000. * The component name helpfull to identify the component in the list of scene components.
  128001. */
  128002. readonly name: string;
  128003. /**
  128004. * The scene the component belongs to.
  128005. */
  128006. scene: Scene;
  128007. /**
  128008. * Creates a new instance of the component for the given scene
  128009. * @param scene Defines the scene to register the component in
  128010. */
  128011. constructor(scene: Scene);
  128012. /**
  128013. * Registers the component in a given scene
  128014. */
  128015. register(): void;
  128016. /**
  128017. * Rebuilds the elements related to this component in case of
  128018. * context lost for instance.
  128019. */
  128020. rebuild(): void;
  128021. /**
  128022. * Disposes the component and the associated ressources
  128023. */
  128024. dispose(): void;
  128025. private _gatherRenderTargets;
  128026. }
  128027. }
  128028. declare module BABYLON {
  128029. /**
  128030. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  128031. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  128032. */
  128033. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128034. private _scene;
  128035. private _camerasToBeAttached;
  128036. /**
  128037. * ID of the sharpen post process,
  128038. */
  128039. private readonly SharpenPostProcessId;
  128040. /**
  128041. * @ignore
  128042. * ID of the image processing post process;
  128043. */
  128044. readonly ImageProcessingPostProcessId: string;
  128045. /**
  128046. * @ignore
  128047. * ID of the Fast Approximate Anti-Aliasing post process;
  128048. */
  128049. readonly FxaaPostProcessId: string;
  128050. /**
  128051. * ID of the chromatic aberration post process,
  128052. */
  128053. private readonly ChromaticAberrationPostProcessId;
  128054. /**
  128055. * ID of the grain post process
  128056. */
  128057. private readonly GrainPostProcessId;
  128058. /**
  128059. * Sharpen post process which will apply a sharpen convolution to enhance edges
  128060. */
  128061. sharpen: SharpenPostProcess;
  128062. private _sharpenEffect;
  128063. private bloom;
  128064. /**
  128065. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  128066. */
  128067. depthOfField: DepthOfFieldEffect;
  128068. /**
  128069. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128070. */
  128071. fxaa: FxaaPostProcess;
  128072. /**
  128073. * Image post processing pass used to perform operations such as tone mapping or color grading.
  128074. */
  128075. imageProcessing: ImageProcessingPostProcess;
  128076. /**
  128077. * Chromatic aberration post process which will shift rgb colors in the image
  128078. */
  128079. chromaticAberration: ChromaticAberrationPostProcess;
  128080. private _chromaticAberrationEffect;
  128081. /**
  128082. * Grain post process which add noise to the image
  128083. */
  128084. grain: GrainPostProcess;
  128085. private _grainEffect;
  128086. /**
  128087. * Glow post process which adds a glow to emissive areas of the image
  128088. */
  128089. private _glowLayer;
  128090. /**
  128091. * Animations which can be used to tweak settings over a period of time
  128092. */
  128093. animations: Animation[];
  128094. private _imageProcessingConfigurationObserver;
  128095. private _sharpenEnabled;
  128096. private _bloomEnabled;
  128097. private _depthOfFieldEnabled;
  128098. private _depthOfFieldBlurLevel;
  128099. private _fxaaEnabled;
  128100. private _imageProcessingEnabled;
  128101. private _defaultPipelineTextureType;
  128102. private _bloomScale;
  128103. private _chromaticAberrationEnabled;
  128104. private _grainEnabled;
  128105. private _buildAllowed;
  128106. /**
  128107. * Gets active scene
  128108. */
  128109. readonly scene: Scene;
  128110. /**
  128111. * Enable or disable the sharpen process from the pipeline
  128112. */
  128113. sharpenEnabled: boolean;
  128114. private _resizeObserver;
  128115. private _hardwareScaleLevel;
  128116. private _bloomKernel;
  128117. /**
  128118. * Specifies the size of the bloom blur kernel, relative to the final output size
  128119. */
  128120. bloomKernel: number;
  128121. /**
  128122. * Specifies the weight of the bloom in the final rendering
  128123. */
  128124. private _bloomWeight;
  128125. /**
  128126. * Specifies the luma threshold for the area that will be blurred by the bloom
  128127. */
  128128. private _bloomThreshold;
  128129. private _hdr;
  128130. /**
  128131. * The strength of the bloom.
  128132. */
  128133. bloomWeight: number;
  128134. /**
  128135. * The strength of the bloom.
  128136. */
  128137. bloomThreshold: number;
  128138. /**
  128139. * The scale of the bloom, lower value will provide better performance.
  128140. */
  128141. bloomScale: number;
  128142. /**
  128143. * Enable or disable the bloom from the pipeline
  128144. */
  128145. bloomEnabled: boolean;
  128146. private _rebuildBloom;
  128147. /**
  128148. * If the depth of field is enabled.
  128149. */
  128150. depthOfFieldEnabled: boolean;
  128151. /**
  128152. * Blur level of the depth of field effect. (Higher blur will effect performance)
  128153. */
  128154. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  128155. /**
  128156. * If the anti aliasing is enabled.
  128157. */
  128158. fxaaEnabled: boolean;
  128159. private _samples;
  128160. /**
  128161. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  128162. */
  128163. samples: number;
  128164. /**
  128165. * If image processing is enabled.
  128166. */
  128167. imageProcessingEnabled: boolean;
  128168. /**
  128169. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  128170. */
  128171. glowLayerEnabled: boolean;
  128172. /**
  128173. * Gets the glow layer (or null if not defined)
  128174. */
  128175. readonly glowLayer: Nullable<GlowLayer>;
  128176. /**
  128177. * Enable or disable the chromaticAberration process from the pipeline
  128178. */
  128179. chromaticAberrationEnabled: boolean;
  128180. /**
  128181. * Enable or disable the grain process from the pipeline
  128182. */
  128183. grainEnabled: boolean;
  128184. /**
  128185. * @constructor
  128186. * @param name - The rendering pipeline name (default: "")
  128187. * @param hdr - If high dynamic range textures should be used (default: true)
  128188. * @param scene - The scene linked to this pipeline (default: the last created scene)
  128189. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  128190. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  128191. */
  128192. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  128193. /**
  128194. * Get the class name
  128195. * @returns "DefaultRenderingPipeline"
  128196. */
  128197. getClassName(): string;
  128198. /**
  128199. * Force the compilation of the entire pipeline.
  128200. */
  128201. prepare(): void;
  128202. private _hasCleared;
  128203. private _prevPostProcess;
  128204. private _prevPrevPostProcess;
  128205. private _setAutoClearAndTextureSharing;
  128206. private _depthOfFieldSceneObserver;
  128207. private _buildPipeline;
  128208. private _disposePostProcesses;
  128209. /**
  128210. * Adds a camera to the pipeline
  128211. * @param camera the camera to be added
  128212. */
  128213. addCamera(camera: Camera): void;
  128214. /**
  128215. * Removes a camera from the pipeline
  128216. * @param camera the camera to remove
  128217. */
  128218. removeCamera(camera: Camera): void;
  128219. /**
  128220. * Dispose of the pipeline and stop all post processes
  128221. */
  128222. dispose(): void;
  128223. /**
  128224. * Serialize the rendering pipeline (Used when exporting)
  128225. * @returns the serialized object
  128226. */
  128227. serialize(): any;
  128228. /**
  128229. * Parse the serialized pipeline
  128230. * @param source Source pipeline.
  128231. * @param scene The scene to load the pipeline to.
  128232. * @param rootUrl The URL of the serialized pipeline.
  128233. * @returns An instantiated pipeline from the serialized object.
  128234. */
  128235. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  128236. }
  128237. }
  128238. declare module BABYLON {
  128239. /** @hidden */
  128240. export var lensHighlightsPixelShader: {
  128241. name: string;
  128242. shader: string;
  128243. };
  128244. }
  128245. declare module BABYLON {
  128246. /** @hidden */
  128247. export var depthOfFieldPixelShader: {
  128248. name: string;
  128249. shader: string;
  128250. };
  128251. }
  128252. declare module BABYLON {
  128253. /**
  128254. * BABYLON.JS Chromatic Aberration GLSL Shader
  128255. * Author: Olivier Guyot
  128256. * Separates very slightly R, G and B colors on the edges of the screen
  128257. * Inspired by Francois Tarlier & Martins Upitis
  128258. */
  128259. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  128260. /**
  128261. * @ignore
  128262. * The chromatic aberration PostProcess id in the pipeline
  128263. */
  128264. LensChromaticAberrationEffect: string;
  128265. /**
  128266. * @ignore
  128267. * The highlights enhancing PostProcess id in the pipeline
  128268. */
  128269. HighlightsEnhancingEffect: string;
  128270. /**
  128271. * @ignore
  128272. * The depth-of-field PostProcess id in the pipeline
  128273. */
  128274. LensDepthOfFieldEffect: string;
  128275. private _scene;
  128276. private _depthTexture;
  128277. private _grainTexture;
  128278. private _chromaticAberrationPostProcess;
  128279. private _highlightsPostProcess;
  128280. private _depthOfFieldPostProcess;
  128281. private _edgeBlur;
  128282. private _grainAmount;
  128283. private _chromaticAberration;
  128284. private _distortion;
  128285. private _highlightsGain;
  128286. private _highlightsThreshold;
  128287. private _dofDistance;
  128288. private _dofAperture;
  128289. private _dofDarken;
  128290. private _dofPentagon;
  128291. private _blurNoise;
  128292. /**
  128293. * @constructor
  128294. *
  128295. * Effect parameters are as follow:
  128296. * {
  128297. * chromatic_aberration: number; // from 0 to x (1 for realism)
  128298. * edge_blur: number; // from 0 to x (1 for realism)
  128299. * distortion: number; // from 0 to x (1 for realism)
  128300. * grain_amount: number; // from 0 to 1
  128301. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  128302. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  128303. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  128304. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  128305. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  128306. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  128307. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  128308. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  128309. * }
  128310. * Note: if an effect parameter is unset, effect is disabled
  128311. *
  128312. * @param name The rendering pipeline name
  128313. * @param parameters - An object containing all parameters (see above)
  128314. * @param scene The scene linked to this pipeline
  128315. * @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)
  128316. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128317. */
  128318. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  128319. /**
  128320. * Get the class name
  128321. * @returns "LensRenderingPipeline"
  128322. */
  128323. getClassName(): string;
  128324. /**
  128325. * Gets associated scene
  128326. */
  128327. readonly scene: Scene;
  128328. /**
  128329. * Gets or sets the edge blur
  128330. */
  128331. edgeBlur: number;
  128332. /**
  128333. * Gets or sets the grain amount
  128334. */
  128335. grainAmount: number;
  128336. /**
  128337. * Gets or sets the chromatic aberration amount
  128338. */
  128339. chromaticAberration: number;
  128340. /**
  128341. * Gets or sets the depth of field aperture
  128342. */
  128343. dofAperture: number;
  128344. /**
  128345. * Gets or sets the edge distortion
  128346. */
  128347. edgeDistortion: number;
  128348. /**
  128349. * Gets or sets the depth of field distortion
  128350. */
  128351. dofDistortion: number;
  128352. /**
  128353. * Gets or sets the darken out of focus amount
  128354. */
  128355. darkenOutOfFocus: number;
  128356. /**
  128357. * Gets or sets a boolean indicating if blur noise is enabled
  128358. */
  128359. blurNoise: boolean;
  128360. /**
  128361. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  128362. */
  128363. pentagonBokeh: boolean;
  128364. /**
  128365. * Gets or sets the highlight grain amount
  128366. */
  128367. highlightsGain: number;
  128368. /**
  128369. * Gets or sets the highlight threshold
  128370. */
  128371. highlightsThreshold: number;
  128372. /**
  128373. * Sets the amount of blur at the edges
  128374. * @param amount blur amount
  128375. */
  128376. setEdgeBlur(amount: number): void;
  128377. /**
  128378. * Sets edge blur to 0
  128379. */
  128380. disableEdgeBlur(): void;
  128381. /**
  128382. * Sets the amout of grain
  128383. * @param amount Amount of grain
  128384. */
  128385. setGrainAmount(amount: number): void;
  128386. /**
  128387. * Set grain amount to 0
  128388. */
  128389. disableGrain(): void;
  128390. /**
  128391. * Sets the chromatic aberration amount
  128392. * @param amount amount of chromatic aberration
  128393. */
  128394. setChromaticAberration(amount: number): void;
  128395. /**
  128396. * Sets chromatic aberration amount to 0
  128397. */
  128398. disableChromaticAberration(): void;
  128399. /**
  128400. * Sets the EdgeDistortion amount
  128401. * @param amount amount of EdgeDistortion
  128402. */
  128403. setEdgeDistortion(amount: number): void;
  128404. /**
  128405. * Sets edge distortion to 0
  128406. */
  128407. disableEdgeDistortion(): void;
  128408. /**
  128409. * Sets the FocusDistance amount
  128410. * @param amount amount of FocusDistance
  128411. */
  128412. setFocusDistance(amount: number): void;
  128413. /**
  128414. * Disables depth of field
  128415. */
  128416. disableDepthOfField(): void;
  128417. /**
  128418. * Sets the Aperture amount
  128419. * @param amount amount of Aperture
  128420. */
  128421. setAperture(amount: number): void;
  128422. /**
  128423. * Sets the DarkenOutOfFocus amount
  128424. * @param amount amount of DarkenOutOfFocus
  128425. */
  128426. setDarkenOutOfFocus(amount: number): void;
  128427. private _pentagonBokehIsEnabled;
  128428. /**
  128429. * Creates a pentagon bokeh effect
  128430. */
  128431. enablePentagonBokeh(): void;
  128432. /**
  128433. * Disables the pentagon bokeh effect
  128434. */
  128435. disablePentagonBokeh(): void;
  128436. /**
  128437. * Enables noise blur
  128438. */
  128439. enableNoiseBlur(): void;
  128440. /**
  128441. * Disables noise blur
  128442. */
  128443. disableNoiseBlur(): void;
  128444. /**
  128445. * Sets the HighlightsGain amount
  128446. * @param amount amount of HighlightsGain
  128447. */
  128448. setHighlightsGain(amount: number): void;
  128449. /**
  128450. * Sets the HighlightsThreshold amount
  128451. * @param amount amount of HighlightsThreshold
  128452. */
  128453. setHighlightsThreshold(amount: number): void;
  128454. /**
  128455. * Disables highlights
  128456. */
  128457. disableHighlights(): void;
  128458. /**
  128459. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  128460. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  128461. */
  128462. dispose(disableDepthRender?: boolean): void;
  128463. private _createChromaticAberrationPostProcess;
  128464. private _createHighlightsPostProcess;
  128465. private _createDepthOfFieldPostProcess;
  128466. private _createGrainTexture;
  128467. }
  128468. }
  128469. declare module BABYLON {
  128470. /** @hidden */
  128471. export var ssao2PixelShader: {
  128472. name: string;
  128473. shader: string;
  128474. };
  128475. }
  128476. declare module BABYLON {
  128477. /** @hidden */
  128478. export var ssaoCombinePixelShader: {
  128479. name: string;
  128480. shader: string;
  128481. };
  128482. }
  128483. declare module BABYLON {
  128484. /**
  128485. * Render pipeline to produce ssao effect
  128486. */
  128487. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  128488. /**
  128489. * @ignore
  128490. * The PassPostProcess id in the pipeline that contains the original scene color
  128491. */
  128492. SSAOOriginalSceneColorEffect: string;
  128493. /**
  128494. * @ignore
  128495. * The SSAO PostProcess id in the pipeline
  128496. */
  128497. SSAORenderEffect: string;
  128498. /**
  128499. * @ignore
  128500. * The horizontal blur PostProcess id in the pipeline
  128501. */
  128502. SSAOBlurHRenderEffect: string;
  128503. /**
  128504. * @ignore
  128505. * The vertical blur PostProcess id in the pipeline
  128506. */
  128507. SSAOBlurVRenderEffect: string;
  128508. /**
  128509. * @ignore
  128510. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128511. */
  128512. SSAOCombineRenderEffect: string;
  128513. /**
  128514. * The output strength of the SSAO post-process. Default value is 1.0.
  128515. */
  128516. totalStrength: number;
  128517. /**
  128518. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  128519. */
  128520. maxZ: number;
  128521. /**
  128522. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  128523. */
  128524. minZAspect: number;
  128525. private _samples;
  128526. /**
  128527. * Number of samples used for the SSAO calculations. Default value is 8
  128528. */
  128529. samples: number;
  128530. private _textureSamples;
  128531. /**
  128532. * Number of samples to use for antialiasing
  128533. */
  128534. textureSamples: number;
  128535. /**
  128536. * Ratio object used for SSAO ratio and blur ratio
  128537. */
  128538. private _ratio;
  128539. /**
  128540. * Dynamically generated sphere sampler.
  128541. */
  128542. private _sampleSphere;
  128543. /**
  128544. * Blur filter offsets
  128545. */
  128546. private _samplerOffsets;
  128547. private _expensiveBlur;
  128548. /**
  128549. * If bilateral blur should be used
  128550. */
  128551. expensiveBlur: boolean;
  128552. /**
  128553. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  128554. */
  128555. radius: number;
  128556. /**
  128557. * The base color of the SSAO post-process
  128558. * The final result is "base + ssao" between [0, 1]
  128559. */
  128560. base: number;
  128561. /**
  128562. * Support test.
  128563. */
  128564. static readonly IsSupported: boolean;
  128565. private _scene;
  128566. private _depthTexture;
  128567. private _normalTexture;
  128568. private _randomTexture;
  128569. private _originalColorPostProcess;
  128570. private _ssaoPostProcess;
  128571. private _blurHPostProcess;
  128572. private _blurVPostProcess;
  128573. private _ssaoCombinePostProcess;
  128574. private _firstUpdate;
  128575. /**
  128576. * Gets active scene
  128577. */
  128578. readonly scene: Scene;
  128579. /**
  128580. * @constructor
  128581. * @param name The rendering pipeline name
  128582. * @param scene The scene linked to this pipeline
  128583. * @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 }
  128584. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128585. */
  128586. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128587. /**
  128588. * Get the class name
  128589. * @returns "SSAO2RenderingPipeline"
  128590. */
  128591. getClassName(): string;
  128592. /**
  128593. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128594. */
  128595. dispose(disableGeometryBufferRenderer?: boolean): void;
  128596. private _createBlurPostProcess;
  128597. /** @hidden */
  128598. _rebuild(): void;
  128599. private _bits;
  128600. private _radicalInverse_VdC;
  128601. private _hammersley;
  128602. private _hemisphereSample_uniform;
  128603. private _generateHemisphere;
  128604. private _createSSAOPostProcess;
  128605. private _createSSAOCombinePostProcess;
  128606. private _createRandomTexture;
  128607. /**
  128608. * Serialize the rendering pipeline (Used when exporting)
  128609. * @returns the serialized object
  128610. */
  128611. serialize(): any;
  128612. /**
  128613. * Parse the serialized pipeline
  128614. * @param source Source pipeline.
  128615. * @param scene The scene to load the pipeline to.
  128616. * @param rootUrl The URL of the serialized pipeline.
  128617. * @returns An instantiated pipeline from the serialized object.
  128618. */
  128619. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  128620. }
  128621. }
  128622. declare module BABYLON {
  128623. /** @hidden */
  128624. export var ssaoPixelShader: {
  128625. name: string;
  128626. shader: string;
  128627. };
  128628. }
  128629. declare module BABYLON {
  128630. /**
  128631. * Render pipeline to produce ssao effect
  128632. */
  128633. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  128634. /**
  128635. * @ignore
  128636. * The PassPostProcess id in the pipeline that contains the original scene color
  128637. */
  128638. SSAOOriginalSceneColorEffect: string;
  128639. /**
  128640. * @ignore
  128641. * The SSAO PostProcess id in the pipeline
  128642. */
  128643. SSAORenderEffect: string;
  128644. /**
  128645. * @ignore
  128646. * The horizontal blur PostProcess id in the pipeline
  128647. */
  128648. SSAOBlurHRenderEffect: string;
  128649. /**
  128650. * @ignore
  128651. * The vertical blur PostProcess id in the pipeline
  128652. */
  128653. SSAOBlurVRenderEffect: string;
  128654. /**
  128655. * @ignore
  128656. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128657. */
  128658. SSAOCombineRenderEffect: string;
  128659. /**
  128660. * The output strength of the SSAO post-process. Default value is 1.0.
  128661. */
  128662. totalStrength: number;
  128663. /**
  128664. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  128665. */
  128666. radius: number;
  128667. /**
  128668. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  128669. * Must not be equal to fallOff and superior to fallOff.
  128670. * Default value is 0.0075
  128671. */
  128672. area: number;
  128673. /**
  128674. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  128675. * Must not be equal to area and inferior to area.
  128676. * Default value is 0.000001
  128677. */
  128678. fallOff: number;
  128679. /**
  128680. * The base color of the SSAO post-process
  128681. * The final result is "base + ssao" between [0, 1]
  128682. */
  128683. base: number;
  128684. private _scene;
  128685. private _depthTexture;
  128686. private _randomTexture;
  128687. private _originalColorPostProcess;
  128688. private _ssaoPostProcess;
  128689. private _blurHPostProcess;
  128690. private _blurVPostProcess;
  128691. private _ssaoCombinePostProcess;
  128692. private _firstUpdate;
  128693. /**
  128694. * Gets active scene
  128695. */
  128696. readonly scene: Scene;
  128697. /**
  128698. * @constructor
  128699. * @param name - The rendering pipeline name
  128700. * @param scene - The scene linked to this pipeline
  128701. * @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 }
  128702. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  128703. */
  128704. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128705. /**
  128706. * Get the class name
  128707. * @returns "SSAORenderingPipeline"
  128708. */
  128709. getClassName(): string;
  128710. /**
  128711. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128712. */
  128713. dispose(disableDepthRender?: boolean): void;
  128714. private _createBlurPostProcess;
  128715. /** @hidden */
  128716. _rebuild(): void;
  128717. private _createSSAOPostProcess;
  128718. private _createSSAOCombinePostProcess;
  128719. private _createRandomTexture;
  128720. }
  128721. }
  128722. declare module BABYLON {
  128723. /** @hidden */
  128724. export var standardPixelShader: {
  128725. name: string;
  128726. shader: string;
  128727. };
  128728. }
  128729. declare module BABYLON {
  128730. /**
  128731. * Standard rendering pipeline
  128732. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  128733. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  128734. */
  128735. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128736. /**
  128737. * Public members
  128738. */
  128739. /**
  128740. * Post-process which contains the original scene color before the pipeline applies all the effects
  128741. */
  128742. originalPostProcess: Nullable<PostProcess>;
  128743. /**
  128744. * Post-process used to down scale an image x4
  128745. */
  128746. downSampleX4PostProcess: Nullable<PostProcess>;
  128747. /**
  128748. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  128749. */
  128750. brightPassPostProcess: Nullable<PostProcess>;
  128751. /**
  128752. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  128753. */
  128754. blurHPostProcesses: PostProcess[];
  128755. /**
  128756. * Post-process array storing all the vertical blur post-processes used by the pipeline
  128757. */
  128758. blurVPostProcesses: PostProcess[];
  128759. /**
  128760. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  128761. */
  128762. textureAdderPostProcess: Nullable<PostProcess>;
  128763. /**
  128764. * Post-process used to create volumetric lighting effect
  128765. */
  128766. volumetricLightPostProcess: Nullable<PostProcess>;
  128767. /**
  128768. * Post-process used to smooth the previous volumetric light post-process on the X axis
  128769. */
  128770. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  128771. /**
  128772. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  128773. */
  128774. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  128775. /**
  128776. * Post-process used to merge the volumetric light effect and the real scene color
  128777. */
  128778. volumetricLightMergePostProces: Nullable<PostProcess>;
  128779. /**
  128780. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  128781. */
  128782. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  128783. /**
  128784. * Base post-process used to calculate the average luminance of the final image for HDR
  128785. */
  128786. luminancePostProcess: Nullable<PostProcess>;
  128787. /**
  128788. * Post-processes used to create down sample post-processes in order to get
  128789. * the average luminance of the final image for HDR
  128790. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  128791. */
  128792. luminanceDownSamplePostProcesses: PostProcess[];
  128793. /**
  128794. * Post-process used to create a HDR effect (light adaptation)
  128795. */
  128796. hdrPostProcess: Nullable<PostProcess>;
  128797. /**
  128798. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  128799. */
  128800. textureAdderFinalPostProcess: Nullable<PostProcess>;
  128801. /**
  128802. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  128803. */
  128804. lensFlareFinalPostProcess: Nullable<PostProcess>;
  128805. /**
  128806. * Post-process used to merge the final HDR post-process and the real scene color
  128807. */
  128808. hdrFinalPostProcess: Nullable<PostProcess>;
  128809. /**
  128810. * Post-process used to create a lens flare effect
  128811. */
  128812. lensFlarePostProcess: Nullable<PostProcess>;
  128813. /**
  128814. * Post-process that merges the result of the lens flare post-process and the real scene color
  128815. */
  128816. lensFlareComposePostProcess: Nullable<PostProcess>;
  128817. /**
  128818. * Post-process used to create a motion blur effect
  128819. */
  128820. motionBlurPostProcess: Nullable<PostProcess>;
  128821. /**
  128822. * Post-process used to create a depth of field effect
  128823. */
  128824. depthOfFieldPostProcess: Nullable<PostProcess>;
  128825. /**
  128826. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128827. */
  128828. fxaaPostProcess: Nullable<FxaaPostProcess>;
  128829. /**
  128830. * Represents the brightness threshold in order to configure the illuminated surfaces
  128831. */
  128832. brightThreshold: number;
  128833. /**
  128834. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  128835. */
  128836. blurWidth: number;
  128837. /**
  128838. * Sets if the blur for highlighted surfaces must be only horizontal
  128839. */
  128840. horizontalBlur: boolean;
  128841. /**
  128842. * Gets the overall exposure used by the pipeline
  128843. */
  128844. /**
  128845. * Sets the overall exposure used by the pipeline
  128846. */
  128847. exposure: number;
  128848. /**
  128849. * Texture used typically to simulate "dirty" on camera lens
  128850. */
  128851. lensTexture: Nullable<Texture>;
  128852. /**
  128853. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  128854. */
  128855. volumetricLightCoefficient: number;
  128856. /**
  128857. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  128858. */
  128859. volumetricLightPower: number;
  128860. /**
  128861. * Used the set the blur intensity to smooth the volumetric lights
  128862. */
  128863. volumetricLightBlurScale: number;
  128864. /**
  128865. * Light (spot or directional) used to generate the volumetric lights rays
  128866. * The source light must have a shadow generate so the pipeline can get its
  128867. * depth map
  128868. */
  128869. sourceLight: Nullable<SpotLight | DirectionalLight>;
  128870. /**
  128871. * For eye adaptation, represents the minimum luminance the eye can see
  128872. */
  128873. hdrMinimumLuminance: number;
  128874. /**
  128875. * For eye adaptation, represents the decrease luminance speed
  128876. */
  128877. hdrDecreaseRate: number;
  128878. /**
  128879. * For eye adaptation, represents the increase luminance speed
  128880. */
  128881. hdrIncreaseRate: number;
  128882. /**
  128883. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128884. */
  128885. /**
  128886. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128887. */
  128888. hdrAutoExposure: boolean;
  128889. /**
  128890. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  128891. */
  128892. lensColorTexture: Nullable<Texture>;
  128893. /**
  128894. * The overall strengh for the lens flare effect
  128895. */
  128896. lensFlareStrength: number;
  128897. /**
  128898. * Dispersion coefficient for lens flare ghosts
  128899. */
  128900. lensFlareGhostDispersal: number;
  128901. /**
  128902. * Main lens flare halo width
  128903. */
  128904. lensFlareHaloWidth: number;
  128905. /**
  128906. * Based on the lens distortion effect, defines how much the lens flare result
  128907. * is distorted
  128908. */
  128909. lensFlareDistortionStrength: number;
  128910. /**
  128911. * Configures the blur intensity used for for lens flare (halo)
  128912. */
  128913. lensFlareBlurWidth: number;
  128914. /**
  128915. * Lens star texture must be used to simulate rays on the flares and is available
  128916. * in the documentation
  128917. */
  128918. lensStarTexture: Nullable<Texture>;
  128919. /**
  128920. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  128921. * flare effect by taking account of the dirt texture
  128922. */
  128923. lensFlareDirtTexture: Nullable<Texture>;
  128924. /**
  128925. * Represents the focal length for the depth of field effect
  128926. */
  128927. depthOfFieldDistance: number;
  128928. /**
  128929. * Represents the blur intensity for the blurred part of the depth of field effect
  128930. */
  128931. depthOfFieldBlurWidth: number;
  128932. /**
  128933. * Gets how much the image is blurred by the movement while using the motion blur post-process
  128934. */
  128935. /**
  128936. * Sets how much the image is blurred by the movement while using the motion blur post-process
  128937. */
  128938. motionStrength: number;
  128939. /**
  128940. * Gets wether or not the motion blur post-process is object based or screen based.
  128941. */
  128942. /**
  128943. * Sets wether or not the motion blur post-process should be object based or screen based
  128944. */
  128945. objectBasedMotionBlur: boolean;
  128946. /**
  128947. * List of animations for the pipeline (IAnimatable implementation)
  128948. */
  128949. animations: Animation[];
  128950. /**
  128951. * Private members
  128952. */
  128953. private _scene;
  128954. private _currentDepthOfFieldSource;
  128955. private _basePostProcess;
  128956. private _fixedExposure;
  128957. private _currentExposure;
  128958. private _hdrAutoExposure;
  128959. private _hdrCurrentLuminance;
  128960. private _motionStrength;
  128961. private _isObjectBasedMotionBlur;
  128962. private _floatTextureType;
  128963. private _camerasToBeAttached;
  128964. private _ratio;
  128965. private _bloomEnabled;
  128966. private _depthOfFieldEnabled;
  128967. private _vlsEnabled;
  128968. private _lensFlareEnabled;
  128969. private _hdrEnabled;
  128970. private _motionBlurEnabled;
  128971. private _fxaaEnabled;
  128972. private _motionBlurSamples;
  128973. private _volumetricLightStepsCount;
  128974. private _samples;
  128975. /**
  128976. * @ignore
  128977. * Specifies if the bloom pipeline is enabled
  128978. */
  128979. BloomEnabled: boolean;
  128980. /**
  128981. * @ignore
  128982. * Specifies if the depth of field pipeline is enabed
  128983. */
  128984. DepthOfFieldEnabled: boolean;
  128985. /**
  128986. * @ignore
  128987. * Specifies if the lens flare pipeline is enabed
  128988. */
  128989. LensFlareEnabled: boolean;
  128990. /**
  128991. * @ignore
  128992. * Specifies if the HDR pipeline is enabled
  128993. */
  128994. HDREnabled: boolean;
  128995. /**
  128996. * @ignore
  128997. * Specifies if the volumetric lights scattering effect is enabled
  128998. */
  128999. VLSEnabled: boolean;
  129000. /**
  129001. * @ignore
  129002. * Specifies if the motion blur effect is enabled
  129003. */
  129004. MotionBlurEnabled: boolean;
  129005. /**
  129006. * Specifies if anti-aliasing is enabled
  129007. */
  129008. fxaaEnabled: boolean;
  129009. /**
  129010. * Specifies the number of steps used to calculate the volumetric lights
  129011. * Typically in interval [50, 200]
  129012. */
  129013. volumetricLightStepsCount: number;
  129014. /**
  129015. * Specifies the number of samples used for the motion blur effect
  129016. * Typically in interval [16, 64]
  129017. */
  129018. motionBlurSamples: number;
  129019. /**
  129020. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129021. */
  129022. samples: number;
  129023. /**
  129024. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129025. * @constructor
  129026. * @param name The rendering pipeline name
  129027. * @param scene The scene linked to this pipeline
  129028. * @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)
  129029. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  129030. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129031. */
  129032. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  129033. private _buildPipeline;
  129034. private _createDownSampleX4PostProcess;
  129035. private _createBrightPassPostProcess;
  129036. private _createBlurPostProcesses;
  129037. private _createTextureAdderPostProcess;
  129038. private _createVolumetricLightPostProcess;
  129039. private _createLuminancePostProcesses;
  129040. private _createHdrPostProcess;
  129041. private _createLensFlarePostProcess;
  129042. private _createDepthOfFieldPostProcess;
  129043. private _createMotionBlurPostProcess;
  129044. private _getDepthTexture;
  129045. private _disposePostProcesses;
  129046. /**
  129047. * Dispose of the pipeline and stop all post processes
  129048. */
  129049. dispose(): void;
  129050. /**
  129051. * Serialize the rendering pipeline (Used when exporting)
  129052. * @returns the serialized object
  129053. */
  129054. serialize(): any;
  129055. /**
  129056. * Parse the serialized pipeline
  129057. * @param source Source pipeline.
  129058. * @param scene The scene to load the pipeline to.
  129059. * @param rootUrl The URL of the serialized pipeline.
  129060. * @returns An instantiated pipeline from the serialized object.
  129061. */
  129062. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  129063. /**
  129064. * Luminance steps
  129065. */
  129066. static LuminanceSteps: number;
  129067. }
  129068. }
  129069. declare module BABYLON {
  129070. /** @hidden */
  129071. export var tonemapPixelShader: {
  129072. name: string;
  129073. shader: string;
  129074. };
  129075. }
  129076. declare module BABYLON {
  129077. /** Defines operator used for tonemapping */
  129078. export enum TonemappingOperator {
  129079. /** Hable */
  129080. Hable = 0,
  129081. /** Reinhard */
  129082. Reinhard = 1,
  129083. /** HejiDawson */
  129084. HejiDawson = 2,
  129085. /** Photographic */
  129086. Photographic = 3
  129087. }
  129088. /**
  129089. * Defines a post process to apply tone mapping
  129090. */
  129091. export class TonemapPostProcess extends PostProcess {
  129092. private _operator;
  129093. /** Defines the required exposure adjustement */
  129094. exposureAdjustment: number;
  129095. /**
  129096. * Creates a new TonemapPostProcess
  129097. * @param name defines the name of the postprocess
  129098. * @param _operator defines the operator to use
  129099. * @param exposureAdjustment defines the required exposure adjustement
  129100. * @param camera defines the camera to use (can be null)
  129101. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  129102. * @param engine defines the hosting engine (can be ignore if camera is set)
  129103. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129104. */
  129105. constructor(name: string, _operator: TonemappingOperator,
  129106. /** Defines the required exposure adjustement */
  129107. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  129108. }
  129109. }
  129110. declare module BABYLON {
  129111. /** @hidden */
  129112. export var depthVertexShader: {
  129113. name: string;
  129114. shader: string;
  129115. };
  129116. }
  129117. declare module BABYLON {
  129118. /** @hidden */
  129119. export var volumetricLightScatteringPixelShader: {
  129120. name: string;
  129121. shader: string;
  129122. };
  129123. }
  129124. declare module BABYLON {
  129125. /** @hidden */
  129126. export var volumetricLightScatteringPassVertexShader: {
  129127. name: string;
  129128. shader: string;
  129129. };
  129130. }
  129131. declare module BABYLON {
  129132. /** @hidden */
  129133. export var volumetricLightScatteringPassPixelShader: {
  129134. name: string;
  129135. shader: string;
  129136. };
  129137. }
  129138. declare module BABYLON {
  129139. /**
  129140. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  129141. */
  129142. export class VolumetricLightScatteringPostProcess extends PostProcess {
  129143. private _volumetricLightScatteringPass;
  129144. private _volumetricLightScatteringRTT;
  129145. private _viewPort;
  129146. private _screenCoordinates;
  129147. private _cachedDefines;
  129148. /**
  129149. * If not undefined, the mesh position is computed from the attached node position
  129150. */
  129151. attachedNode: {
  129152. position: Vector3;
  129153. };
  129154. /**
  129155. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  129156. */
  129157. customMeshPosition: Vector3;
  129158. /**
  129159. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  129160. */
  129161. useCustomMeshPosition: boolean;
  129162. /**
  129163. * If the post-process should inverse the light scattering direction
  129164. */
  129165. invert: boolean;
  129166. /**
  129167. * The internal mesh used by the post-process
  129168. */
  129169. mesh: Mesh;
  129170. /**
  129171. * @hidden
  129172. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  129173. */
  129174. useDiffuseColor: boolean;
  129175. /**
  129176. * Array containing the excluded meshes not rendered in the internal pass
  129177. */
  129178. excludedMeshes: AbstractMesh[];
  129179. /**
  129180. * Controls the overall intensity of the post-process
  129181. */
  129182. exposure: number;
  129183. /**
  129184. * Dissipates each sample's contribution in range [0, 1]
  129185. */
  129186. decay: number;
  129187. /**
  129188. * Controls the overall intensity of each sample
  129189. */
  129190. weight: number;
  129191. /**
  129192. * Controls the density of each sample
  129193. */
  129194. density: number;
  129195. /**
  129196. * @constructor
  129197. * @param name The post-process name
  129198. * @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)
  129199. * @param camera The camera that the post-process will be attached to
  129200. * @param mesh The mesh used to create the light scattering
  129201. * @param samples The post-process quality, default 100
  129202. * @param samplingModeThe post-process filtering mode
  129203. * @param engine The babylon engine
  129204. * @param reusable If the post-process is reusable
  129205. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  129206. */
  129207. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  129208. /**
  129209. * Returns the string "VolumetricLightScatteringPostProcess"
  129210. * @returns "VolumetricLightScatteringPostProcess"
  129211. */
  129212. getClassName(): string;
  129213. private _isReady;
  129214. /**
  129215. * Sets the new light position for light scattering effect
  129216. * @param position The new custom light position
  129217. */
  129218. setCustomMeshPosition(position: Vector3): void;
  129219. /**
  129220. * Returns the light position for light scattering effect
  129221. * @return Vector3 The custom light position
  129222. */
  129223. getCustomMeshPosition(): Vector3;
  129224. /**
  129225. * Disposes the internal assets and detaches the post-process from the camera
  129226. */
  129227. dispose(camera: Camera): void;
  129228. /**
  129229. * Returns the render target texture used by the post-process
  129230. * @return the render target texture used by the post-process
  129231. */
  129232. getPass(): RenderTargetTexture;
  129233. private _meshExcluded;
  129234. private _createPass;
  129235. private _updateMeshScreenCoordinates;
  129236. /**
  129237. * Creates a default mesh for the Volumeric Light Scattering post-process
  129238. * @param name The mesh name
  129239. * @param scene The scene where to create the mesh
  129240. * @return the default mesh
  129241. */
  129242. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  129243. }
  129244. }
  129245. declare module BABYLON {
  129246. interface Scene {
  129247. /** @hidden (Backing field) */
  129248. _boundingBoxRenderer: BoundingBoxRenderer;
  129249. /** @hidden (Backing field) */
  129250. _forceShowBoundingBoxes: boolean;
  129251. /**
  129252. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  129253. */
  129254. forceShowBoundingBoxes: boolean;
  129255. /**
  129256. * Gets the bounding box renderer associated with the scene
  129257. * @returns a BoundingBoxRenderer
  129258. */
  129259. getBoundingBoxRenderer(): BoundingBoxRenderer;
  129260. }
  129261. interface AbstractMesh {
  129262. /** @hidden (Backing field) */
  129263. _showBoundingBox: boolean;
  129264. /**
  129265. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  129266. */
  129267. showBoundingBox: boolean;
  129268. }
  129269. /**
  129270. * Component responsible of rendering the bounding box of the meshes in a scene.
  129271. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  129272. */
  129273. export class BoundingBoxRenderer implements ISceneComponent {
  129274. /**
  129275. * The component name helpfull to identify the component in the list of scene components.
  129276. */
  129277. readonly name: string;
  129278. /**
  129279. * The scene the component belongs to.
  129280. */
  129281. scene: Scene;
  129282. /**
  129283. * Color of the bounding box lines placed in front of an object
  129284. */
  129285. frontColor: Color3;
  129286. /**
  129287. * Color of the bounding box lines placed behind an object
  129288. */
  129289. backColor: Color3;
  129290. /**
  129291. * Defines if the renderer should show the back lines or not
  129292. */
  129293. showBackLines: boolean;
  129294. /**
  129295. * @hidden
  129296. */
  129297. renderList: SmartArray<BoundingBox>;
  129298. private _colorShader;
  129299. private _vertexBuffers;
  129300. private _indexBuffer;
  129301. private _fillIndexBuffer;
  129302. private _fillIndexData;
  129303. /**
  129304. * Instantiates a new bounding box renderer in a scene.
  129305. * @param scene the scene the renderer renders in
  129306. */
  129307. constructor(scene: Scene);
  129308. /**
  129309. * Registers the component in a given scene
  129310. */
  129311. register(): void;
  129312. private _evaluateSubMesh;
  129313. private _activeMesh;
  129314. private _prepareRessources;
  129315. private _createIndexBuffer;
  129316. /**
  129317. * Rebuilds the elements related to this component in case of
  129318. * context lost for instance.
  129319. */
  129320. rebuild(): void;
  129321. /**
  129322. * @hidden
  129323. */
  129324. reset(): void;
  129325. /**
  129326. * Render the bounding boxes of a specific rendering group
  129327. * @param renderingGroupId defines the rendering group to render
  129328. */
  129329. render(renderingGroupId: number): void;
  129330. /**
  129331. * In case of occlusion queries, we can render the occlusion bounding box through this method
  129332. * @param mesh Define the mesh to render the occlusion bounding box for
  129333. */
  129334. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  129335. /**
  129336. * Dispose and release the resources attached to this renderer.
  129337. */
  129338. dispose(): void;
  129339. }
  129340. }
  129341. declare module BABYLON {
  129342. /** @hidden */
  129343. export var depthPixelShader: {
  129344. name: string;
  129345. shader: string;
  129346. };
  129347. }
  129348. declare module BABYLON {
  129349. /**
  129350. * This represents a depth renderer in Babylon.
  129351. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  129352. */
  129353. export class DepthRenderer {
  129354. private _scene;
  129355. private _depthMap;
  129356. private _effect;
  129357. private readonly _storeNonLinearDepth;
  129358. private readonly _clearColor;
  129359. /** Get if the depth renderer is using packed depth or not */
  129360. readonly isPacked: boolean;
  129361. private _cachedDefines;
  129362. private _camera;
  129363. /**
  129364. * Specifiess that the depth renderer will only be used within
  129365. * the camera it is created for.
  129366. * This can help forcing its rendering during the camera processing.
  129367. */
  129368. useOnlyInActiveCamera: boolean;
  129369. /** @hidden */
  129370. static _SceneComponentInitialization: (scene: Scene) => void;
  129371. /**
  129372. * Instantiates a depth renderer
  129373. * @param scene The scene the renderer belongs to
  129374. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  129375. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  129376. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129377. */
  129378. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  129379. /**
  129380. * Creates the depth rendering effect and checks if the effect is ready.
  129381. * @param subMesh The submesh to be used to render the depth map of
  129382. * @param useInstances If multiple world instances should be used
  129383. * @returns if the depth renderer is ready to render the depth map
  129384. */
  129385. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129386. /**
  129387. * Gets the texture which the depth map will be written to.
  129388. * @returns The depth map texture
  129389. */
  129390. getDepthMap(): RenderTargetTexture;
  129391. /**
  129392. * Disposes of the depth renderer.
  129393. */
  129394. dispose(): void;
  129395. }
  129396. }
  129397. declare module BABYLON {
  129398. interface Scene {
  129399. /** @hidden (Backing field) */
  129400. _depthRenderer: {
  129401. [id: string]: DepthRenderer;
  129402. };
  129403. /**
  129404. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  129405. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  129406. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129407. * @returns the created depth renderer
  129408. */
  129409. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  129410. /**
  129411. * Disables a depth renderer for a given camera
  129412. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  129413. */
  129414. disableDepthRenderer(camera?: Nullable<Camera>): void;
  129415. }
  129416. /**
  129417. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  129418. * in several rendering techniques.
  129419. */
  129420. export class DepthRendererSceneComponent implements ISceneComponent {
  129421. /**
  129422. * The component name helpfull to identify the component in the list of scene components.
  129423. */
  129424. readonly name: string;
  129425. /**
  129426. * The scene the component belongs to.
  129427. */
  129428. scene: Scene;
  129429. /**
  129430. * Creates a new instance of the component for the given scene
  129431. * @param scene Defines the scene to register the component in
  129432. */
  129433. constructor(scene: Scene);
  129434. /**
  129435. * Registers the component in a given scene
  129436. */
  129437. register(): void;
  129438. /**
  129439. * Rebuilds the elements related to this component in case of
  129440. * context lost for instance.
  129441. */
  129442. rebuild(): void;
  129443. /**
  129444. * Disposes the component and the associated ressources
  129445. */
  129446. dispose(): void;
  129447. private _gatherRenderTargets;
  129448. private _gatherActiveCameraRenderTargets;
  129449. }
  129450. }
  129451. declare module BABYLON {
  129452. /** @hidden */
  129453. export var outlinePixelShader: {
  129454. name: string;
  129455. shader: string;
  129456. };
  129457. }
  129458. declare module BABYLON {
  129459. /** @hidden */
  129460. export var outlineVertexShader: {
  129461. name: string;
  129462. shader: string;
  129463. };
  129464. }
  129465. declare module BABYLON {
  129466. interface Scene {
  129467. /** @hidden */
  129468. _outlineRenderer: OutlineRenderer;
  129469. /**
  129470. * Gets the outline renderer associated with the scene
  129471. * @returns a OutlineRenderer
  129472. */
  129473. getOutlineRenderer(): OutlineRenderer;
  129474. }
  129475. interface AbstractMesh {
  129476. /** @hidden (Backing field) */
  129477. _renderOutline: boolean;
  129478. /**
  129479. * Gets or sets a boolean indicating if the outline must be rendered as well
  129480. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  129481. */
  129482. renderOutline: boolean;
  129483. /** @hidden (Backing field) */
  129484. _renderOverlay: boolean;
  129485. /**
  129486. * Gets or sets a boolean indicating if the overlay must be rendered as well
  129487. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  129488. */
  129489. renderOverlay: boolean;
  129490. }
  129491. /**
  129492. * This class is responsible to draw bothe outline/overlay of meshes.
  129493. * It should not be used directly but through the available method on mesh.
  129494. */
  129495. export class OutlineRenderer implements ISceneComponent {
  129496. /**
  129497. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  129498. */
  129499. private static _StencilReference;
  129500. /**
  129501. * The name of the component. Each component must have a unique name.
  129502. */
  129503. name: string;
  129504. /**
  129505. * The scene the component belongs to.
  129506. */
  129507. scene: Scene;
  129508. /**
  129509. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  129510. */
  129511. zOffset: number;
  129512. private _engine;
  129513. private _effect;
  129514. private _cachedDefines;
  129515. private _savedDepthWrite;
  129516. /**
  129517. * Instantiates a new outline renderer. (There could be only one per scene).
  129518. * @param scene Defines the scene it belongs to
  129519. */
  129520. constructor(scene: Scene);
  129521. /**
  129522. * Register the component to one instance of a scene.
  129523. */
  129524. register(): void;
  129525. /**
  129526. * Rebuilds the elements related to this component in case of
  129527. * context lost for instance.
  129528. */
  129529. rebuild(): void;
  129530. /**
  129531. * Disposes the component and the associated ressources.
  129532. */
  129533. dispose(): void;
  129534. /**
  129535. * Renders the outline in the canvas.
  129536. * @param subMesh Defines the sumesh to render
  129537. * @param batch Defines the batch of meshes in case of instances
  129538. * @param useOverlay Defines if the rendering is for the overlay or the outline
  129539. */
  129540. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  129541. /**
  129542. * Returns whether or not the outline renderer is ready for a given submesh.
  129543. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  129544. * @param subMesh Defines the submesh to check readyness for
  129545. * @param useInstances Defines wheter wee are trying to render instances or not
  129546. * @returns true if ready otherwise false
  129547. */
  129548. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129549. private _beforeRenderingMesh;
  129550. private _afterRenderingMesh;
  129551. }
  129552. }
  129553. declare module BABYLON {
  129554. /**
  129555. * Class used to manage multiple sprites of different sizes on the same spritesheet
  129556. * @see http://doc.babylonjs.com/babylon101/sprites
  129557. */
  129558. export class SpritePackedManager extends SpriteManager {
  129559. /** defines the packed manager's name */
  129560. name: string;
  129561. /**
  129562. * Creates a new sprite manager from a packed sprite sheet
  129563. * @param name defines the manager's name
  129564. * @param imgUrl defines the sprite sheet url
  129565. * @param capacity defines the maximum allowed number of sprites
  129566. * @param scene defines the hosting scene
  129567. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  129568. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  129569. * @param samplingMode defines the smapling mode to use with spritesheet
  129570. * @param fromPacked set to true; do not alter
  129571. */
  129572. constructor(
  129573. /** defines the packed manager's name */
  129574. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  129575. }
  129576. }
  129577. declare module BABYLON {
  129578. /**
  129579. * Defines the list of states available for a task inside a AssetsManager
  129580. */
  129581. export enum AssetTaskState {
  129582. /**
  129583. * Initialization
  129584. */
  129585. INIT = 0,
  129586. /**
  129587. * Running
  129588. */
  129589. RUNNING = 1,
  129590. /**
  129591. * Done
  129592. */
  129593. DONE = 2,
  129594. /**
  129595. * Error
  129596. */
  129597. ERROR = 3
  129598. }
  129599. /**
  129600. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  129601. */
  129602. export abstract class AbstractAssetTask {
  129603. /**
  129604. * Task name
  129605. */ name: string;
  129606. /**
  129607. * Callback called when the task is successful
  129608. */
  129609. onSuccess: (task: any) => void;
  129610. /**
  129611. * Callback called when the task is not successful
  129612. */
  129613. onError: (task: any, message?: string, exception?: any) => void;
  129614. /**
  129615. * Creates a new AssetsManager
  129616. * @param name defines the name of the task
  129617. */
  129618. constructor(
  129619. /**
  129620. * Task name
  129621. */ name: string);
  129622. private _isCompleted;
  129623. private _taskState;
  129624. private _errorObject;
  129625. /**
  129626. * Get if the task is completed
  129627. */
  129628. readonly isCompleted: boolean;
  129629. /**
  129630. * Gets the current state of the task
  129631. */
  129632. readonly taskState: AssetTaskState;
  129633. /**
  129634. * Gets the current error object (if task is in error)
  129635. */
  129636. readonly errorObject: {
  129637. message?: string;
  129638. exception?: any;
  129639. };
  129640. /**
  129641. * Internal only
  129642. * @hidden
  129643. */
  129644. _setErrorObject(message?: string, exception?: any): void;
  129645. /**
  129646. * Execute the current task
  129647. * @param scene defines the scene where you want your assets to be loaded
  129648. * @param onSuccess is a callback called when the task is successfully executed
  129649. * @param onError is a callback called if an error occurs
  129650. */
  129651. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129652. /**
  129653. * Execute the current task
  129654. * @param scene defines the scene where you want your assets to be loaded
  129655. * @param onSuccess is a callback called when the task is successfully executed
  129656. * @param onError is a callback called if an error occurs
  129657. */
  129658. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129659. /**
  129660. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  129661. * This can be used with failed tasks that have the reason for failure fixed.
  129662. */
  129663. reset(): void;
  129664. private onErrorCallback;
  129665. private onDoneCallback;
  129666. }
  129667. /**
  129668. * Define the interface used by progress events raised during assets loading
  129669. */
  129670. export interface IAssetsProgressEvent {
  129671. /**
  129672. * Defines the number of remaining tasks to process
  129673. */
  129674. remainingCount: number;
  129675. /**
  129676. * Defines the total number of tasks
  129677. */
  129678. totalCount: number;
  129679. /**
  129680. * Defines the task that was just processed
  129681. */
  129682. task: AbstractAssetTask;
  129683. }
  129684. /**
  129685. * Class used to share progress information about assets loading
  129686. */
  129687. export class AssetsProgressEvent implements IAssetsProgressEvent {
  129688. /**
  129689. * Defines the number of remaining tasks to process
  129690. */
  129691. remainingCount: number;
  129692. /**
  129693. * Defines the total number of tasks
  129694. */
  129695. totalCount: number;
  129696. /**
  129697. * Defines the task that was just processed
  129698. */
  129699. task: AbstractAssetTask;
  129700. /**
  129701. * Creates a AssetsProgressEvent
  129702. * @param remainingCount defines the number of remaining tasks to process
  129703. * @param totalCount defines the total number of tasks
  129704. * @param task defines the task that was just processed
  129705. */
  129706. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  129707. }
  129708. /**
  129709. * Define a task used by AssetsManager to load meshes
  129710. */
  129711. export class MeshAssetTask extends AbstractAssetTask {
  129712. /**
  129713. * Defines the name of the task
  129714. */
  129715. name: string;
  129716. /**
  129717. * Defines the list of mesh's names you want to load
  129718. */
  129719. meshesNames: any;
  129720. /**
  129721. * Defines the root url to use as a base to load your meshes and associated resources
  129722. */
  129723. rootUrl: string;
  129724. /**
  129725. * Defines the filename of the scene to load from
  129726. */
  129727. sceneFilename: string;
  129728. /**
  129729. * Gets the list of loaded meshes
  129730. */
  129731. loadedMeshes: Array<AbstractMesh>;
  129732. /**
  129733. * Gets the list of loaded particle systems
  129734. */
  129735. loadedParticleSystems: Array<IParticleSystem>;
  129736. /**
  129737. * Gets the list of loaded skeletons
  129738. */
  129739. loadedSkeletons: Array<Skeleton>;
  129740. /**
  129741. * Gets the list of loaded animation groups
  129742. */
  129743. loadedAnimationGroups: Array<AnimationGroup>;
  129744. /**
  129745. * Callback called when the task is successful
  129746. */
  129747. onSuccess: (task: MeshAssetTask) => void;
  129748. /**
  129749. * Callback called when the task is successful
  129750. */
  129751. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  129752. /**
  129753. * Creates a new MeshAssetTask
  129754. * @param name defines the name of the task
  129755. * @param meshesNames defines the list of mesh's names you want to load
  129756. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  129757. * @param sceneFilename defines the filename of the scene to load from
  129758. */
  129759. constructor(
  129760. /**
  129761. * Defines the name of the task
  129762. */
  129763. name: string,
  129764. /**
  129765. * Defines the list of mesh's names you want to load
  129766. */
  129767. meshesNames: any,
  129768. /**
  129769. * Defines the root url to use as a base to load your meshes and associated resources
  129770. */
  129771. rootUrl: string,
  129772. /**
  129773. * Defines the filename of the scene to load from
  129774. */
  129775. sceneFilename: string);
  129776. /**
  129777. * Execute the current task
  129778. * @param scene defines the scene where you want your assets to be loaded
  129779. * @param onSuccess is a callback called when the task is successfully executed
  129780. * @param onError is a callback called if an error occurs
  129781. */
  129782. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129783. }
  129784. /**
  129785. * Define a task used by AssetsManager to load text content
  129786. */
  129787. export class TextFileAssetTask extends AbstractAssetTask {
  129788. /**
  129789. * Defines the name of the task
  129790. */
  129791. name: string;
  129792. /**
  129793. * Defines the location of the file to load
  129794. */
  129795. url: string;
  129796. /**
  129797. * Gets the loaded text string
  129798. */
  129799. text: string;
  129800. /**
  129801. * Callback called when the task is successful
  129802. */
  129803. onSuccess: (task: TextFileAssetTask) => void;
  129804. /**
  129805. * Callback called when the task is successful
  129806. */
  129807. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  129808. /**
  129809. * Creates a new TextFileAssetTask object
  129810. * @param name defines the name of the task
  129811. * @param url defines the location of the file to load
  129812. */
  129813. constructor(
  129814. /**
  129815. * Defines the name of the task
  129816. */
  129817. name: string,
  129818. /**
  129819. * Defines the location of the file to load
  129820. */
  129821. url: string);
  129822. /**
  129823. * Execute the current task
  129824. * @param scene defines the scene where you want your assets to be loaded
  129825. * @param onSuccess is a callback called when the task is successfully executed
  129826. * @param onError is a callback called if an error occurs
  129827. */
  129828. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129829. }
  129830. /**
  129831. * Define a task used by AssetsManager to load binary data
  129832. */
  129833. export class BinaryFileAssetTask extends AbstractAssetTask {
  129834. /**
  129835. * Defines the name of the task
  129836. */
  129837. name: string;
  129838. /**
  129839. * Defines the location of the file to load
  129840. */
  129841. url: string;
  129842. /**
  129843. * Gets the lodaded data (as an array buffer)
  129844. */
  129845. data: ArrayBuffer;
  129846. /**
  129847. * Callback called when the task is successful
  129848. */
  129849. onSuccess: (task: BinaryFileAssetTask) => void;
  129850. /**
  129851. * Callback called when the task is successful
  129852. */
  129853. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  129854. /**
  129855. * Creates a new BinaryFileAssetTask object
  129856. * @param name defines the name of the new task
  129857. * @param url defines the location of the file to load
  129858. */
  129859. constructor(
  129860. /**
  129861. * Defines the name of the task
  129862. */
  129863. name: string,
  129864. /**
  129865. * Defines the location of the file to load
  129866. */
  129867. url: string);
  129868. /**
  129869. * Execute the current task
  129870. * @param scene defines the scene where you want your assets to be loaded
  129871. * @param onSuccess is a callback called when the task is successfully executed
  129872. * @param onError is a callback called if an error occurs
  129873. */
  129874. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129875. }
  129876. /**
  129877. * Define a task used by AssetsManager to load images
  129878. */
  129879. export class ImageAssetTask extends AbstractAssetTask {
  129880. /**
  129881. * Defines the name of the task
  129882. */
  129883. name: string;
  129884. /**
  129885. * Defines the location of the image to load
  129886. */
  129887. url: string;
  129888. /**
  129889. * Gets the loaded images
  129890. */
  129891. image: HTMLImageElement;
  129892. /**
  129893. * Callback called when the task is successful
  129894. */
  129895. onSuccess: (task: ImageAssetTask) => void;
  129896. /**
  129897. * Callback called when the task is successful
  129898. */
  129899. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  129900. /**
  129901. * Creates a new ImageAssetTask
  129902. * @param name defines the name of the task
  129903. * @param url defines the location of the image to load
  129904. */
  129905. constructor(
  129906. /**
  129907. * Defines the name of the task
  129908. */
  129909. name: string,
  129910. /**
  129911. * Defines the location of the image to load
  129912. */
  129913. url: string);
  129914. /**
  129915. * Execute the current task
  129916. * @param scene defines the scene where you want your assets to be loaded
  129917. * @param onSuccess is a callback called when the task is successfully executed
  129918. * @param onError is a callback called if an error occurs
  129919. */
  129920. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129921. }
  129922. /**
  129923. * Defines the interface used by texture loading tasks
  129924. */
  129925. export interface ITextureAssetTask<TEX extends BaseTexture> {
  129926. /**
  129927. * Gets the loaded texture
  129928. */
  129929. texture: TEX;
  129930. }
  129931. /**
  129932. * Define a task used by AssetsManager to load 2D textures
  129933. */
  129934. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  129935. /**
  129936. * Defines the name of the task
  129937. */
  129938. name: string;
  129939. /**
  129940. * Defines the location of the file to load
  129941. */
  129942. url: string;
  129943. /**
  129944. * Defines if mipmap should not be generated (default is false)
  129945. */
  129946. noMipmap?: boolean | undefined;
  129947. /**
  129948. * Defines if texture must be inverted on Y axis (default is false)
  129949. */
  129950. invertY?: boolean | undefined;
  129951. /**
  129952. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129953. */
  129954. samplingMode: number;
  129955. /**
  129956. * Gets the loaded texture
  129957. */
  129958. texture: Texture;
  129959. /**
  129960. * Callback called when the task is successful
  129961. */
  129962. onSuccess: (task: TextureAssetTask) => void;
  129963. /**
  129964. * Callback called when the task is successful
  129965. */
  129966. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  129967. /**
  129968. * Creates a new TextureAssetTask object
  129969. * @param name defines the name of the task
  129970. * @param url defines the location of the file to load
  129971. * @param noMipmap defines if mipmap should not be generated (default is false)
  129972. * @param invertY defines if texture must be inverted on Y axis (default is false)
  129973. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129974. */
  129975. constructor(
  129976. /**
  129977. * Defines the name of the task
  129978. */
  129979. name: string,
  129980. /**
  129981. * Defines the location of the file to load
  129982. */
  129983. url: string,
  129984. /**
  129985. * Defines if mipmap should not be generated (default is false)
  129986. */
  129987. noMipmap?: boolean | undefined,
  129988. /**
  129989. * Defines if texture must be inverted on Y axis (default is false)
  129990. */
  129991. invertY?: boolean | undefined,
  129992. /**
  129993. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129994. */
  129995. samplingMode?: number);
  129996. /**
  129997. * Execute the current task
  129998. * @param scene defines the scene where you want your assets to be loaded
  129999. * @param onSuccess is a callback called when the task is successfully executed
  130000. * @param onError is a callback called if an error occurs
  130001. */
  130002. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130003. }
  130004. /**
  130005. * Define a task used by AssetsManager to load cube textures
  130006. */
  130007. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  130008. /**
  130009. * Defines the name of the task
  130010. */
  130011. name: string;
  130012. /**
  130013. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130014. */
  130015. url: string;
  130016. /**
  130017. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130018. */
  130019. extensions?: string[] | undefined;
  130020. /**
  130021. * Defines if mipmaps should not be generated (default is false)
  130022. */
  130023. noMipmap?: boolean | undefined;
  130024. /**
  130025. * Defines the explicit list of files (undefined by default)
  130026. */
  130027. files?: string[] | undefined;
  130028. /**
  130029. * Gets the loaded texture
  130030. */
  130031. texture: CubeTexture;
  130032. /**
  130033. * Callback called when the task is successful
  130034. */
  130035. onSuccess: (task: CubeTextureAssetTask) => void;
  130036. /**
  130037. * Callback called when the task is successful
  130038. */
  130039. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  130040. /**
  130041. * Creates a new CubeTextureAssetTask
  130042. * @param name defines the name of the task
  130043. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130044. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130045. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130046. * @param files defines the explicit list of files (undefined by default)
  130047. */
  130048. constructor(
  130049. /**
  130050. * Defines the name of the task
  130051. */
  130052. name: string,
  130053. /**
  130054. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130055. */
  130056. url: string,
  130057. /**
  130058. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130059. */
  130060. extensions?: string[] | undefined,
  130061. /**
  130062. * Defines if mipmaps should not be generated (default is false)
  130063. */
  130064. noMipmap?: boolean | undefined,
  130065. /**
  130066. * Defines the explicit list of files (undefined by default)
  130067. */
  130068. files?: string[] | undefined);
  130069. /**
  130070. * Execute the current task
  130071. * @param scene defines the scene where you want your assets to be loaded
  130072. * @param onSuccess is a callback called when the task is successfully executed
  130073. * @param onError is a callback called if an error occurs
  130074. */
  130075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130076. }
  130077. /**
  130078. * Define a task used by AssetsManager to load HDR cube textures
  130079. */
  130080. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  130081. /**
  130082. * Defines the name of the task
  130083. */
  130084. name: string;
  130085. /**
  130086. * Defines the location of the file to load
  130087. */
  130088. url: string;
  130089. /**
  130090. * Defines the desired size (the more it increases the longer the generation will be)
  130091. */
  130092. size: number;
  130093. /**
  130094. * Defines if mipmaps should not be generated (default is false)
  130095. */
  130096. noMipmap: boolean;
  130097. /**
  130098. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130099. */
  130100. generateHarmonics: boolean;
  130101. /**
  130102. * 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)
  130103. */
  130104. gammaSpace: boolean;
  130105. /**
  130106. * Internal Use Only
  130107. */
  130108. reserved: boolean;
  130109. /**
  130110. * Gets the loaded texture
  130111. */
  130112. texture: HDRCubeTexture;
  130113. /**
  130114. * Callback called when the task is successful
  130115. */
  130116. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  130117. /**
  130118. * Callback called when the task is successful
  130119. */
  130120. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  130121. /**
  130122. * Creates a new HDRCubeTextureAssetTask object
  130123. * @param name defines the name of the task
  130124. * @param url defines the location of the file to load
  130125. * @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.
  130126. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130127. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130128. * @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)
  130129. * @param reserved Internal use only
  130130. */
  130131. constructor(
  130132. /**
  130133. * Defines the name of the task
  130134. */
  130135. name: string,
  130136. /**
  130137. * Defines the location of the file to load
  130138. */
  130139. url: string,
  130140. /**
  130141. * Defines the desired size (the more it increases the longer the generation will be)
  130142. */
  130143. size: number,
  130144. /**
  130145. * Defines if mipmaps should not be generated (default is false)
  130146. */
  130147. noMipmap?: boolean,
  130148. /**
  130149. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130150. */
  130151. generateHarmonics?: boolean,
  130152. /**
  130153. * 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)
  130154. */
  130155. gammaSpace?: boolean,
  130156. /**
  130157. * Internal Use Only
  130158. */
  130159. reserved?: boolean);
  130160. /**
  130161. * Execute the current task
  130162. * @param scene defines the scene where you want your assets to be loaded
  130163. * @param onSuccess is a callback called when the task is successfully executed
  130164. * @param onError is a callback called if an error occurs
  130165. */
  130166. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130167. }
  130168. /**
  130169. * Define a task used by AssetsManager to load Equirectangular cube textures
  130170. */
  130171. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  130172. /**
  130173. * Defines the name of the task
  130174. */
  130175. name: string;
  130176. /**
  130177. * Defines the location of the file to load
  130178. */
  130179. url: string;
  130180. /**
  130181. * Defines the desired size (the more it increases the longer the generation will be)
  130182. */
  130183. size: number;
  130184. /**
  130185. * Defines if mipmaps should not be generated (default is false)
  130186. */
  130187. noMipmap: boolean;
  130188. /**
  130189. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130190. * but the standard material would require them in Gamma space) (default is true)
  130191. */
  130192. gammaSpace: boolean;
  130193. /**
  130194. * Gets the loaded texture
  130195. */
  130196. texture: EquiRectangularCubeTexture;
  130197. /**
  130198. * Callback called when the task is successful
  130199. */
  130200. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  130201. /**
  130202. * Callback called when the task is successful
  130203. */
  130204. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  130205. /**
  130206. * Creates a new EquiRectangularCubeTextureAssetTask object
  130207. * @param name defines the name of the task
  130208. * @param url defines the location of the file to load
  130209. * @param size defines the desired size (the more it increases the longer the generation will be)
  130210. * If the size is omitted this implies you are using a preprocessed cubemap.
  130211. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130212. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  130213. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  130214. * (default is true)
  130215. */
  130216. constructor(
  130217. /**
  130218. * Defines the name of the task
  130219. */
  130220. name: string,
  130221. /**
  130222. * Defines the location of the file to load
  130223. */
  130224. url: string,
  130225. /**
  130226. * Defines the desired size (the more it increases the longer the generation will be)
  130227. */
  130228. size: number,
  130229. /**
  130230. * Defines if mipmaps should not be generated (default is false)
  130231. */
  130232. noMipmap?: boolean,
  130233. /**
  130234. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130235. * but the standard material would require them in Gamma space) (default is true)
  130236. */
  130237. gammaSpace?: boolean);
  130238. /**
  130239. * Execute the current task
  130240. * @param scene defines the scene where you want your assets to be loaded
  130241. * @param onSuccess is a callback called when the task is successfully executed
  130242. * @param onError is a callback called if an error occurs
  130243. */
  130244. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130245. }
  130246. /**
  130247. * This class can be used to easily import assets into a scene
  130248. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  130249. */
  130250. export class AssetsManager {
  130251. private _scene;
  130252. private _isLoading;
  130253. protected _tasks: AbstractAssetTask[];
  130254. protected _waitingTasksCount: number;
  130255. protected _totalTasksCount: number;
  130256. /**
  130257. * Callback called when all tasks are processed
  130258. */
  130259. onFinish: (tasks: AbstractAssetTask[]) => void;
  130260. /**
  130261. * Callback called when a task is successful
  130262. */
  130263. onTaskSuccess: (task: AbstractAssetTask) => void;
  130264. /**
  130265. * Callback called when a task had an error
  130266. */
  130267. onTaskError: (task: AbstractAssetTask) => void;
  130268. /**
  130269. * Callback called when a task is done (whatever the result is)
  130270. */
  130271. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  130272. /**
  130273. * Observable called when all tasks are processed
  130274. */
  130275. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  130276. /**
  130277. * Observable called when a task had an error
  130278. */
  130279. onTaskErrorObservable: Observable<AbstractAssetTask>;
  130280. /**
  130281. * Observable called when all tasks were executed
  130282. */
  130283. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  130284. /**
  130285. * Observable called when a task is done (whatever the result is)
  130286. */
  130287. onProgressObservable: Observable<IAssetsProgressEvent>;
  130288. /**
  130289. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  130290. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  130291. */
  130292. useDefaultLoadingScreen: boolean;
  130293. /**
  130294. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  130295. * when all assets have been downloaded.
  130296. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  130297. */
  130298. autoHideLoadingUI: boolean;
  130299. /**
  130300. * Creates a new AssetsManager
  130301. * @param scene defines the scene to work on
  130302. */
  130303. constructor(scene: Scene);
  130304. /**
  130305. * Add a MeshAssetTask to the list of active tasks
  130306. * @param taskName defines the name of the new task
  130307. * @param meshesNames defines the name of meshes to load
  130308. * @param rootUrl defines the root url to use to locate files
  130309. * @param sceneFilename defines the filename of the scene file
  130310. * @returns a new MeshAssetTask object
  130311. */
  130312. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  130313. /**
  130314. * Add a TextFileAssetTask to the list of active tasks
  130315. * @param taskName defines the name of the new task
  130316. * @param url defines the url of the file to load
  130317. * @returns a new TextFileAssetTask object
  130318. */
  130319. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  130320. /**
  130321. * Add a BinaryFileAssetTask to the list of active tasks
  130322. * @param taskName defines the name of the new task
  130323. * @param url defines the url of the file to load
  130324. * @returns a new BinaryFileAssetTask object
  130325. */
  130326. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  130327. /**
  130328. * Add a ImageAssetTask to the list of active tasks
  130329. * @param taskName defines the name of the new task
  130330. * @param url defines the url of the file to load
  130331. * @returns a new ImageAssetTask object
  130332. */
  130333. addImageTask(taskName: string, url: string): ImageAssetTask;
  130334. /**
  130335. * Add a TextureAssetTask to the list of active tasks
  130336. * @param taskName defines the name of the new task
  130337. * @param url defines the url of the file to load
  130338. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130339. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  130340. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130341. * @returns a new TextureAssetTask object
  130342. */
  130343. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  130344. /**
  130345. * Add a CubeTextureAssetTask to the list of active tasks
  130346. * @param taskName defines the name of the new task
  130347. * @param url defines the url of the file to load
  130348. * @param extensions defines the extension to use to load the cube map (can be null)
  130349. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130350. * @param files defines the list of files to load (can be null)
  130351. * @returns a new CubeTextureAssetTask object
  130352. */
  130353. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  130354. /**
  130355. *
  130356. * Add a HDRCubeTextureAssetTask to the list of active tasks
  130357. * @param taskName defines the name of the new task
  130358. * @param url defines the url of the file to load
  130359. * @param size defines the size you want for the cubemap (can be null)
  130360. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130361. * @param generateHarmonics defines if you want to automatically generate (true by default)
  130362. * @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)
  130363. * @param reserved Internal use only
  130364. * @returns a new HDRCubeTextureAssetTask object
  130365. */
  130366. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  130367. /**
  130368. *
  130369. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  130370. * @param taskName defines the name of the new task
  130371. * @param url defines the url of the file to load
  130372. * @param size defines the size you want for the cubemap (can be null)
  130373. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130374. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130375. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130376. * @returns a new EquiRectangularCubeTextureAssetTask object
  130377. */
  130378. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  130379. /**
  130380. * Remove a task from the assets manager.
  130381. * @param task the task to remove
  130382. */
  130383. removeTask(task: AbstractAssetTask): void;
  130384. private _decreaseWaitingTasksCount;
  130385. private _runTask;
  130386. /**
  130387. * Reset the AssetsManager and remove all tasks
  130388. * @return the current instance of the AssetsManager
  130389. */
  130390. reset(): AssetsManager;
  130391. /**
  130392. * Start the loading process
  130393. * @return the current instance of the AssetsManager
  130394. */
  130395. load(): AssetsManager;
  130396. /**
  130397. * Start the loading process as an async operation
  130398. * @return a promise returning the list of failed tasks
  130399. */
  130400. loadAsync(): Promise<void>;
  130401. }
  130402. }
  130403. declare module BABYLON {
  130404. /**
  130405. * Wrapper class for promise with external resolve and reject.
  130406. */
  130407. export class Deferred<T> {
  130408. /**
  130409. * The promise associated with this deferred object.
  130410. */
  130411. readonly promise: Promise<T>;
  130412. private _resolve;
  130413. private _reject;
  130414. /**
  130415. * The resolve method of the promise associated with this deferred object.
  130416. */
  130417. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  130418. /**
  130419. * The reject method of the promise associated with this deferred object.
  130420. */
  130421. readonly reject: (reason?: any) => void;
  130422. /**
  130423. * Constructor for this deferred object.
  130424. */
  130425. constructor();
  130426. }
  130427. }
  130428. declare module BABYLON {
  130429. /**
  130430. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  130431. */
  130432. export class MeshExploder {
  130433. private _centerMesh;
  130434. private _meshes;
  130435. private _meshesOrigins;
  130436. private _toCenterVectors;
  130437. private _scaledDirection;
  130438. private _newPosition;
  130439. private _centerPosition;
  130440. /**
  130441. * Explodes meshes from a center mesh.
  130442. * @param meshes The meshes to explode.
  130443. * @param centerMesh The mesh to be center of explosion.
  130444. */
  130445. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  130446. private _setCenterMesh;
  130447. /**
  130448. * Get class name
  130449. * @returns "MeshExploder"
  130450. */
  130451. getClassName(): string;
  130452. /**
  130453. * "Exploded meshes"
  130454. * @returns Array of meshes with the centerMesh at index 0.
  130455. */
  130456. getMeshes(): Array<Mesh>;
  130457. /**
  130458. * Explodes meshes giving a specific direction
  130459. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  130460. */
  130461. explode(direction?: number): void;
  130462. }
  130463. }
  130464. declare module BABYLON {
  130465. /**
  130466. * Class used to help managing file picking and drag'n'drop
  130467. */
  130468. export class FilesInput {
  130469. /**
  130470. * List of files ready to be loaded
  130471. */
  130472. static readonly FilesToLoad: {
  130473. [key: string]: File;
  130474. };
  130475. /**
  130476. * Callback called when a file is processed
  130477. */
  130478. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  130479. private _engine;
  130480. private _currentScene;
  130481. private _sceneLoadedCallback;
  130482. private _progressCallback;
  130483. private _additionalRenderLoopLogicCallback;
  130484. private _textureLoadingCallback;
  130485. private _startingProcessingFilesCallback;
  130486. private _onReloadCallback;
  130487. private _errorCallback;
  130488. private _elementToMonitor;
  130489. private _sceneFileToLoad;
  130490. private _filesToLoad;
  130491. /**
  130492. * Creates a new FilesInput
  130493. * @param engine defines the rendering engine
  130494. * @param scene defines the hosting scene
  130495. * @param sceneLoadedCallback callback called when scene is loaded
  130496. * @param progressCallback callback called to track progress
  130497. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  130498. * @param textureLoadingCallback callback called when a texture is loading
  130499. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  130500. * @param onReloadCallback callback called when a reload is requested
  130501. * @param errorCallback callback call if an error occurs
  130502. */
  130503. 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);
  130504. private _dragEnterHandler;
  130505. private _dragOverHandler;
  130506. private _dropHandler;
  130507. /**
  130508. * Calls this function to listen to drag'n'drop events on a specific DOM element
  130509. * @param elementToMonitor defines the DOM element to track
  130510. */
  130511. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  130512. /**
  130513. * Release all associated resources
  130514. */
  130515. dispose(): void;
  130516. private renderFunction;
  130517. private drag;
  130518. private drop;
  130519. private _traverseFolder;
  130520. private _processFiles;
  130521. /**
  130522. * Load files from a drop event
  130523. * @param event defines the drop event to use as source
  130524. */
  130525. loadFiles(event: any): void;
  130526. private _processReload;
  130527. /**
  130528. * Reload the current scene from the loaded files
  130529. */
  130530. reload(): void;
  130531. }
  130532. }
  130533. declare module BABYLON {
  130534. /**
  130535. * Defines the root class used to create scene optimization to use with SceneOptimizer
  130536. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130537. */
  130538. export class SceneOptimization {
  130539. /**
  130540. * Defines the priority of this optimization (0 by default which means first in the list)
  130541. */
  130542. priority: number;
  130543. /**
  130544. * Gets a string describing the action executed by the current optimization
  130545. * @returns description string
  130546. */
  130547. getDescription(): string;
  130548. /**
  130549. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130550. * @param scene defines the current scene where to apply this optimization
  130551. * @param optimizer defines the current optimizer
  130552. * @returns true if everything that can be done was applied
  130553. */
  130554. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130555. /**
  130556. * Creates the SceneOptimization object
  130557. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130558. * @param desc defines the description associated with the optimization
  130559. */
  130560. constructor(
  130561. /**
  130562. * Defines the priority of this optimization (0 by default which means first in the list)
  130563. */
  130564. priority?: number);
  130565. }
  130566. /**
  130567. * Defines an optimization used to reduce the size of render target textures
  130568. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130569. */
  130570. export class TextureOptimization extends SceneOptimization {
  130571. /**
  130572. * Defines the priority of this optimization (0 by default which means first in the list)
  130573. */
  130574. priority: number;
  130575. /**
  130576. * 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
  130577. */
  130578. maximumSize: number;
  130579. /**
  130580. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130581. */
  130582. step: number;
  130583. /**
  130584. * Gets a string describing the action executed by the current optimization
  130585. * @returns description string
  130586. */
  130587. getDescription(): string;
  130588. /**
  130589. * Creates the TextureOptimization object
  130590. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130591. * @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
  130592. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130593. */
  130594. constructor(
  130595. /**
  130596. * Defines the priority of this optimization (0 by default which means first in the list)
  130597. */
  130598. priority?: number,
  130599. /**
  130600. * 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
  130601. */
  130602. maximumSize?: number,
  130603. /**
  130604. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130605. */
  130606. step?: number);
  130607. /**
  130608. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130609. * @param scene defines the current scene where to apply this optimization
  130610. * @param optimizer defines the current optimizer
  130611. * @returns true if everything that can be done was applied
  130612. */
  130613. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130614. }
  130615. /**
  130616. * Defines an optimization used to increase or decrease the rendering resolution
  130617. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130618. */
  130619. export class HardwareScalingOptimization extends SceneOptimization {
  130620. /**
  130621. * Defines the priority of this optimization (0 by default which means first in the list)
  130622. */
  130623. priority: number;
  130624. /**
  130625. * Defines the maximum scale to use (2 by default)
  130626. */
  130627. maximumScale: number;
  130628. /**
  130629. * Defines the step to use between two passes (0.5 by default)
  130630. */
  130631. step: number;
  130632. private _currentScale;
  130633. private _directionOffset;
  130634. /**
  130635. * Gets a string describing the action executed by the current optimization
  130636. * @return description string
  130637. */
  130638. getDescription(): string;
  130639. /**
  130640. * Creates the HardwareScalingOptimization object
  130641. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130642. * @param maximumScale defines the maximum scale to use (2 by default)
  130643. * @param step defines the step to use between two passes (0.5 by default)
  130644. */
  130645. constructor(
  130646. /**
  130647. * Defines the priority of this optimization (0 by default which means first in the list)
  130648. */
  130649. priority?: number,
  130650. /**
  130651. * Defines the maximum scale to use (2 by default)
  130652. */
  130653. maximumScale?: number,
  130654. /**
  130655. * Defines the step to use between two passes (0.5 by default)
  130656. */
  130657. step?: number);
  130658. /**
  130659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130660. * @param scene defines the current scene where to apply this optimization
  130661. * @param optimizer defines the current optimizer
  130662. * @returns true if everything that can be done was applied
  130663. */
  130664. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130665. }
  130666. /**
  130667. * Defines an optimization used to remove shadows
  130668. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130669. */
  130670. export class ShadowsOptimization extends SceneOptimization {
  130671. /**
  130672. * Gets a string describing the action executed by the current optimization
  130673. * @return description string
  130674. */
  130675. getDescription(): string;
  130676. /**
  130677. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130678. * @param scene defines the current scene where to apply this optimization
  130679. * @param optimizer defines the current optimizer
  130680. * @returns true if everything that can be done was applied
  130681. */
  130682. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130683. }
  130684. /**
  130685. * Defines an optimization used to turn post-processes off
  130686. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130687. */
  130688. export class PostProcessesOptimization extends SceneOptimization {
  130689. /**
  130690. * Gets a string describing the action executed by the current optimization
  130691. * @return description string
  130692. */
  130693. getDescription(): string;
  130694. /**
  130695. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130696. * @param scene defines the current scene where to apply this optimization
  130697. * @param optimizer defines the current optimizer
  130698. * @returns true if everything that can be done was applied
  130699. */
  130700. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130701. }
  130702. /**
  130703. * Defines an optimization used to turn lens flares off
  130704. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130705. */
  130706. export class LensFlaresOptimization extends SceneOptimization {
  130707. /**
  130708. * Gets a string describing the action executed by the current optimization
  130709. * @return description string
  130710. */
  130711. getDescription(): string;
  130712. /**
  130713. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130714. * @param scene defines the current scene where to apply this optimization
  130715. * @param optimizer defines the current optimizer
  130716. * @returns true if everything that can be done was applied
  130717. */
  130718. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130719. }
  130720. /**
  130721. * Defines an optimization based on user defined callback.
  130722. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130723. */
  130724. export class CustomOptimization extends SceneOptimization {
  130725. /**
  130726. * Callback called to apply the custom optimization.
  130727. */
  130728. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  130729. /**
  130730. * Callback called to get custom description
  130731. */
  130732. onGetDescription: () => string;
  130733. /**
  130734. * Gets a string describing the action executed by the current optimization
  130735. * @returns description string
  130736. */
  130737. getDescription(): string;
  130738. /**
  130739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130740. * @param scene defines the current scene where to apply this optimization
  130741. * @param optimizer defines the current optimizer
  130742. * @returns true if everything that can be done was applied
  130743. */
  130744. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130745. }
  130746. /**
  130747. * Defines an optimization used to turn particles off
  130748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130749. */
  130750. export class ParticlesOptimization extends SceneOptimization {
  130751. /**
  130752. * Gets a string describing the action executed by the current optimization
  130753. * @return description string
  130754. */
  130755. getDescription(): string;
  130756. /**
  130757. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130758. * @param scene defines the current scene where to apply this optimization
  130759. * @param optimizer defines the current optimizer
  130760. * @returns true if everything that can be done was applied
  130761. */
  130762. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130763. }
  130764. /**
  130765. * Defines an optimization used to turn render targets off
  130766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130767. */
  130768. export class RenderTargetsOptimization extends SceneOptimization {
  130769. /**
  130770. * Gets a string describing the action executed by the current optimization
  130771. * @return description string
  130772. */
  130773. getDescription(): string;
  130774. /**
  130775. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130776. * @param scene defines the current scene where to apply this optimization
  130777. * @param optimizer defines the current optimizer
  130778. * @returns true if everything that can be done was applied
  130779. */
  130780. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130781. }
  130782. /**
  130783. * Defines an optimization used to merge meshes with compatible materials
  130784. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130785. */
  130786. export class MergeMeshesOptimization extends SceneOptimization {
  130787. private static _UpdateSelectionTree;
  130788. /**
  130789. * Gets or sets a boolean which defines if optimization octree has to be updated
  130790. */
  130791. /**
  130792. * Gets or sets a boolean which defines if optimization octree has to be updated
  130793. */
  130794. static UpdateSelectionTree: boolean;
  130795. /**
  130796. * Gets a string describing the action executed by the current optimization
  130797. * @return description string
  130798. */
  130799. getDescription(): string;
  130800. private _canBeMerged;
  130801. /**
  130802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130803. * @param scene defines the current scene where to apply this optimization
  130804. * @param optimizer defines the current optimizer
  130805. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  130806. * @returns true if everything that can be done was applied
  130807. */
  130808. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  130809. }
  130810. /**
  130811. * Defines a list of options used by SceneOptimizer
  130812. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130813. */
  130814. export class SceneOptimizerOptions {
  130815. /**
  130816. * Defines the target frame rate to reach (60 by default)
  130817. */
  130818. targetFrameRate: number;
  130819. /**
  130820. * Defines the interval between two checkes (2000ms by default)
  130821. */
  130822. trackerDuration: number;
  130823. /**
  130824. * Gets the list of optimizations to apply
  130825. */
  130826. optimizations: SceneOptimization[];
  130827. /**
  130828. * Creates a new list of options used by SceneOptimizer
  130829. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  130830. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  130831. */
  130832. constructor(
  130833. /**
  130834. * Defines the target frame rate to reach (60 by default)
  130835. */
  130836. targetFrameRate?: number,
  130837. /**
  130838. * Defines the interval between two checkes (2000ms by default)
  130839. */
  130840. trackerDuration?: number);
  130841. /**
  130842. * Add a new optimization
  130843. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  130844. * @returns the current SceneOptimizerOptions
  130845. */
  130846. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  130847. /**
  130848. * Add a new custom optimization
  130849. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  130850. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  130851. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130852. * @returns the current SceneOptimizerOptions
  130853. */
  130854. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  130855. /**
  130856. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  130857. * @param targetFrameRate defines the target frame rate (60 by default)
  130858. * @returns a SceneOptimizerOptions object
  130859. */
  130860. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130861. /**
  130862. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  130863. * @param targetFrameRate defines the target frame rate (60 by default)
  130864. * @returns a SceneOptimizerOptions object
  130865. */
  130866. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130867. /**
  130868. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  130869. * @param targetFrameRate defines the target frame rate (60 by default)
  130870. * @returns a SceneOptimizerOptions object
  130871. */
  130872. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130873. }
  130874. /**
  130875. * Class used to run optimizations in order to reach a target frame rate
  130876. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130877. */
  130878. export class SceneOptimizer implements IDisposable {
  130879. private _isRunning;
  130880. private _options;
  130881. private _scene;
  130882. private _currentPriorityLevel;
  130883. private _targetFrameRate;
  130884. private _trackerDuration;
  130885. private _currentFrameRate;
  130886. private _sceneDisposeObserver;
  130887. private _improvementMode;
  130888. /**
  130889. * Defines an observable called when the optimizer reaches the target frame rate
  130890. */
  130891. onSuccessObservable: Observable<SceneOptimizer>;
  130892. /**
  130893. * Defines an observable called when the optimizer enables an optimization
  130894. */
  130895. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  130896. /**
  130897. * Defines an observable called when the optimizer is not able to reach the target frame rate
  130898. */
  130899. onFailureObservable: Observable<SceneOptimizer>;
  130900. /**
  130901. * Gets a boolean indicating if the optimizer is in improvement mode
  130902. */
  130903. readonly isInImprovementMode: boolean;
  130904. /**
  130905. * Gets the current priority level (0 at start)
  130906. */
  130907. readonly currentPriorityLevel: number;
  130908. /**
  130909. * Gets the current frame rate checked by the SceneOptimizer
  130910. */
  130911. readonly currentFrameRate: number;
  130912. /**
  130913. * Gets or sets the current target frame rate (60 by default)
  130914. */
  130915. /**
  130916. * Gets or sets the current target frame rate (60 by default)
  130917. */
  130918. targetFrameRate: number;
  130919. /**
  130920. * Gets or sets the current interval between two checks (every 2000ms by default)
  130921. */
  130922. /**
  130923. * Gets or sets the current interval between two checks (every 2000ms by default)
  130924. */
  130925. trackerDuration: number;
  130926. /**
  130927. * Gets the list of active optimizations
  130928. */
  130929. readonly optimizations: SceneOptimization[];
  130930. /**
  130931. * Creates a new SceneOptimizer
  130932. * @param scene defines the scene to work on
  130933. * @param options defines the options to use with the SceneOptimizer
  130934. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  130935. * @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)
  130936. */
  130937. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  130938. /**
  130939. * Stops the current optimizer
  130940. */
  130941. stop(): void;
  130942. /**
  130943. * Reset the optimizer to initial step (current priority level = 0)
  130944. */
  130945. reset(): void;
  130946. /**
  130947. * Start the optimizer. By default it will try to reach a specific framerate
  130948. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  130949. */
  130950. start(): void;
  130951. private _checkCurrentState;
  130952. /**
  130953. * Release all resources
  130954. */
  130955. dispose(): void;
  130956. /**
  130957. * Helper function to create a SceneOptimizer with one single line of code
  130958. * @param scene defines the scene to work on
  130959. * @param options defines the options to use with the SceneOptimizer
  130960. * @param onSuccess defines a callback to call on success
  130961. * @param onFailure defines a callback to call on failure
  130962. * @returns the new SceneOptimizer object
  130963. */
  130964. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  130965. }
  130966. }
  130967. declare module BABYLON {
  130968. /**
  130969. * Class used to serialize a scene into a string
  130970. */
  130971. export class SceneSerializer {
  130972. /**
  130973. * Clear cache used by a previous serialization
  130974. */
  130975. static ClearCache(): void;
  130976. /**
  130977. * Serialize a scene into a JSON compatible object
  130978. * @param scene defines the scene to serialize
  130979. * @returns a JSON compatible object
  130980. */
  130981. static Serialize(scene: Scene): any;
  130982. /**
  130983. * Serialize a mesh into a JSON compatible object
  130984. * @param toSerialize defines the mesh to serialize
  130985. * @param withParents defines if parents must be serialized as well
  130986. * @param withChildren defines if children must be serialized as well
  130987. * @returns a JSON compatible object
  130988. */
  130989. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  130990. }
  130991. }
  130992. declare module BABYLON {
  130993. /**
  130994. * Class used to host texture specific utilities
  130995. */
  130996. export class TextureTools {
  130997. /**
  130998. * Uses the GPU to create a copy texture rescaled at a given size
  130999. * @param texture Texture to copy from
  131000. * @param width defines the desired width
  131001. * @param height defines the desired height
  131002. * @param useBilinearMode defines if bilinear mode has to be used
  131003. * @return the generated texture
  131004. */
  131005. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  131006. }
  131007. }
  131008. declare module BABYLON {
  131009. /**
  131010. * This represents the different options available for the video capture.
  131011. */
  131012. export interface VideoRecorderOptions {
  131013. /** Defines the mime type of the video. */
  131014. mimeType: string;
  131015. /** Defines the FPS the video should be recorded at. */
  131016. fps: number;
  131017. /** Defines the chunk size for the recording data. */
  131018. recordChunckSize: number;
  131019. /** The audio tracks to attach to the recording. */
  131020. audioTracks?: MediaStreamTrack[];
  131021. }
  131022. /**
  131023. * This can help with recording videos from BabylonJS.
  131024. * This is based on the available WebRTC functionalities of the browser.
  131025. *
  131026. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  131027. */
  131028. export class VideoRecorder {
  131029. private static readonly _defaultOptions;
  131030. /**
  131031. * Returns whether or not the VideoRecorder is available in your browser.
  131032. * @param engine Defines the Babylon Engine.
  131033. * @returns true if supported otherwise false.
  131034. */
  131035. static IsSupported(engine: Engine): boolean;
  131036. private readonly _options;
  131037. private _canvas;
  131038. private _mediaRecorder;
  131039. private _recordedChunks;
  131040. private _fileName;
  131041. private _resolve;
  131042. private _reject;
  131043. /**
  131044. * True when a recording is already in progress.
  131045. */
  131046. readonly isRecording: boolean;
  131047. /**
  131048. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  131049. * @param engine Defines the BabylonJS Engine you wish to record.
  131050. * @param options Defines options that can be used to customize the capture.
  131051. */
  131052. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  131053. /**
  131054. * Stops the current recording before the default capture timeout passed in the startRecording function.
  131055. */
  131056. stopRecording(): void;
  131057. /**
  131058. * Starts recording the canvas for a max duration specified in parameters.
  131059. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  131060. * If null no automatic download will start and you can rely on the promise to get the data back.
  131061. * @param maxDuration Defines the maximum recording time in seconds.
  131062. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  131063. * @return A promise callback at the end of the recording with the video data in Blob.
  131064. */
  131065. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  131066. /**
  131067. * Releases internal resources used during the recording.
  131068. */
  131069. dispose(): void;
  131070. private _handleDataAvailable;
  131071. private _handleError;
  131072. private _handleStop;
  131073. }
  131074. }
  131075. declare module BABYLON {
  131076. /**
  131077. * Class containing a set of static utilities functions for screenshots
  131078. */
  131079. export class ScreenshotTools {
  131080. /**
  131081. * Captures a screenshot of the current rendering
  131082. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131083. * @param engine defines the rendering engine
  131084. * @param camera defines the source camera
  131085. * @param size This parameter can be set to a single number or to an object with the
  131086. * following (optional) properties: precision, width, height. If a single number is passed,
  131087. * it will be used for both width and height. If an object is passed, the screenshot size
  131088. * will be derived from the parameters. The precision property is a multiplier allowing
  131089. * rendering at a higher or lower resolution
  131090. * @param successCallback defines the callback receives a single parameter which contains the
  131091. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131092. * src parameter of an <img> to display it
  131093. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131094. * Check your browser for supported MIME types
  131095. */
  131096. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  131097. /**
  131098. * Captures a screenshot of the current rendering
  131099. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131100. * @param engine defines the rendering engine
  131101. * @param camera defines the source camera
  131102. * @param size This parameter can be set to a single number or to an object with the
  131103. * following (optional) properties: precision, width, height. If a single number is passed,
  131104. * it will be used for both width and height. If an object is passed, the screenshot size
  131105. * will be derived from the parameters. The precision property is a multiplier allowing
  131106. * rendering at a higher or lower resolution
  131107. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131108. * Check your browser for supported MIME types
  131109. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131110. * to the src parameter of an <img> to display it
  131111. */
  131112. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  131113. /**
  131114. * Generates an image screenshot from the specified camera.
  131115. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131116. * @param engine The engine to use for rendering
  131117. * @param camera The camera to use for rendering
  131118. * @param size This parameter can be set to a single number or to an object with the
  131119. * following (optional) properties: precision, width, height. If a single number is passed,
  131120. * it will be used for both width and height. If an object is passed, the screenshot size
  131121. * will be derived from the parameters. The precision property is a multiplier allowing
  131122. * rendering at a higher or lower resolution
  131123. * @param successCallback The callback receives a single parameter which contains the
  131124. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131125. * src parameter of an <img> to display it
  131126. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131127. * Check your browser for supported MIME types
  131128. * @param samples Texture samples (default: 1)
  131129. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131130. * @param fileName A name for for the downloaded file.
  131131. */
  131132. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  131133. /**
  131134. * Generates an image screenshot from the specified camera.
  131135. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131136. * @param engine The engine to use for rendering
  131137. * @param camera The camera to use for rendering
  131138. * @param size This parameter can be set to a single number or to an object with the
  131139. * following (optional) properties: precision, width, height. If a single number is passed,
  131140. * it will be used for both width and height. If an object is passed, the screenshot size
  131141. * will be derived from the parameters. The precision property is a multiplier allowing
  131142. * rendering at a higher or lower resolution
  131143. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131144. * Check your browser for supported MIME types
  131145. * @param samples Texture samples (default: 1)
  131146. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131147. * @param fileName A name for for the downloaded file.
  131148. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131149. * to the src parameter of an <img> to display it
  131150. */
  131151. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  131152. /**
  131153. * Gets height and width for screenshot size
  131154. * @private
  131155. */
  131156. private static _getScreenshotSize;
  131157. }
  131158. }
  131159. declare module BABYLON {
  131160. /**
  131161. * A cursor which tracks a point on a path
  131162. */
  131163. export class PathCursor {
  131164. private path;
  131165. /**
  131166. * Stores path cursor callbacks for when an onchange event is triggered
  131167. */
  131168. private _onchange;
  131169. /**
  131170. * The value of the path cursor
  131171. */
  131172. value: number;
  131173. /**
  131174. * The animation array of the path cursor
  131175. */
  131176. animations: Animation[];
  131177. /**
  131178. * Initializes the path cursor
  131179. * @param path The path to track
  131180. */
  131181. constructor(path: Path2);
  131182. /**
  131183. * Gets the cursor point on the path
  131184. * @returns A point on the path cursor at the cursor location
  131185. */
  131186. getPoint(): Vector3;
  131187. /**
  131188. * Moves the cursor ahead by the step amount
  131189. * @param step The amount to move the cursor forward
  131190. * @returns This path cursor
  131191. */
  131192. moveAhead(step?: number): PathCursor;
  131193. /**
  131194. * Moves the cursor behind by the step amount
  131195. * @param step The amount to move the cursor back
  131196. * @returns This path cursor
  131197. */
  131198. moveBack(step?: number): PathCursor;
  131199. /**
  131200. * Moves the cursor by the step amount
  131201. * If the step amount is greater than one, an exception is thrown
  131202. * @param step The amount to move the cursor
  131203. * @returns This path cursor
  131204. */
  131205. move(step: number): PathCursor;
  131206. /**
  131207. * Ensures that the value is limited between zero and one
  131208. * @returns This path cursor
  131209. */
  131210. private ensureLimits;
  131211. /**
  131212. * Runs onchange callbacks on change (used by the animation engine)
  131213. * @returns This path cursor
  131214. */
  131215. private raiseOnChange;
  131216. /**
  131217. * Executes a function on change
  131218. * @param f A path cursor onchange callback
  131219. * @returns This path cursor
  131220. */
  131221. onchange(f: (cursor: PathCursor) => void): PathCursor;
  131222. }
  131223. }
  131224. declare module BABYLON {
  131225. /** @hidden */
  131226. export var blurPixelShader: {
  131227. name: string;
  131228. shader: string;
  131229. };
  131230. }
  131231. declare module BABYLON {
  131232. /** @hidden */
  131233. export var pointCloudVertexDeclaration: {
  131234. name: string;
  131235. shader: string;
  131236. };
  131237. }
  131238. // Mixins
  131239. interface Window {
  131240. mozIndexedDB: IDBFactory;
  131241. webkitIndexedDB: IDBFactory;
  131242. msIndexedDB: IDBFactory;
  131243. webkitURL: typeof URL;
  131244. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  131245. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  131246. WebGLRenderingContext: WebGLRenderingContext;
  131247. MSGesture: MSGesture;
  131248. CANNON: any;
  131249. AudioContext: AudioContext;
  131250. webkitAudioContext: AudioContext;
  131251. PointerEvent: any;
  131252. Math: Math;
  131253. Uint8Array: Uint8ArrayConstructor;
  131254. Float32Array: Float32ArrayConstructor;
  131255. mozURL: typeof URL;
  131256. msURL: typeof URL;
  131257. VRFrameData: any; // WebVR, from specs 1.1
  131258. DracoDecoderModule: any;
  131259. setImmediate(handler: (...args: any[]) => void): number;
  131260. }
  131261. interface HTMLCanvasElement {
  131262. requestPointerLock(): void;
  131263. msRequestPointerLock?(): void;
  131264. mozRequestPointerLock?(): void;
  131265. webkitRequestPointerLock?(): void;
  131266. /** Track wether a record is in progress */
  131267. isRecording: boolean;
  131268. /** Capture Stream method defined by some browsers */
  131269. captureStream(fps?: number): MediaStream;
  131270. }
  131271. interface CanvasRenderingContext2D {
  131272. msImageSmoothingEnabled: boolean;
  131273. }
  131274. interface MouseEvent {
  131275. mozMovementX: number;
  131276. mozMovementY: number;
  131277. webkitMovementX: number;
  131278. webkitMovementY: number;
  131279. msMovementX: number;
  131280. msMovementY: number;
  131281. }
  131282. interface Navigator {
  131283. mozGetVRDevices: (any: any) => any;
  131284. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131285. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131286. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131287. webkitGetGamepads(): Gamepad[];
  131288. msGetGamepads(): Gamepad[];
  131289. webkitGamepads(): Gamepad[];
  131290. }
  131291. interface HTMLVideoElement {
  131292. mozSrcObject: any;
  131293. }
  131294. interface Math {
  131295. fround(x: number): number;
  131296. imul(a: number, b: number): number;
  131297. }
  131298. interface WebGLRenderingContext {
  131299. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  131300. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  131301. vertexAttribDivisor(index: number, divisor: number): void;
  131302. createVertexArray(): any;
  131303. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  131304. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  131305. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  131306. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  131307. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  131308. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  131309. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  131310. // Queries
  131311. createQuery(): WebGLQuery;
  131312. deleteQuery(query: WebGLQuery): void;
  131313. beginQuery(target: number, query: WebGLQuery): void;
  131314. endQuery(target: number): void;
  131315. getQueryParameter(query: WebGLQuery, pname: number): any;
  131316. getQuery(target: number, pname: number): any;
  131317. MAX_SAMPLES: number;
  131318. RGBA8: number;
  131319. READ_FRAMEBUFFER: number;
  131320. DRAW_FRAMEBUFFER: number;
  131321. UNIFORM_BUFFER: number;
  131322. HALF_FLOAT_OES: number;
  131323. RGBA16F: number;
  131324. RGBA32F: number;
  131325. R32F: number;
  131326. RG32F: number;
  131327. RGB32F: number;
  131328. R16F: number;
  131329. RG16F: number;
  131330. RGB16F: number;
  131331. RED: number;
  131332. RG: number;
  131333. R8: number;
  131334. RG8: number;
  131335. UNSIGNED_INT_24_8: number;
  131336. DEPTH24_STENCIL8: number;
  131337. MIN: number;
  131338. MAX: number;
  131339. /* Multiple Render Targets */
  131340. drawBuffers(buffers: number[]): void;
  131341. readBuffer(src: number): void;
  131342. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  131343. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  131344. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  131345. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  131346. // Occlusion Query
  131347. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  131348. ANY_SAMPLES_PASSED: number;
  131349. QUERY_RESULT_AVAILABLE: number;
  131350. QUERY_RESULT: number;
  131351. }
  131352. interface WebGLProgram {
  131353. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  131354. }
  131355. interface EXT_disjoint_timer_query {
  131356. QUERY_COUNTER_BITS_EXT: number;
  131357. TIME_ELAPSED_EXT: number;
  131358. TIMESTAMP_EXT: number;
  131359. GPU_DISJOINT_EXT: number;
  131360. QUERY_RESULT_EXT: number;
  131361. QUERY_RESULT_AVAILABLE_EXT: number;
  131362. queryCounterEXT(query: WebGLQuery, target: number): void;
  131363. createQueryEXT(): WebGLQuery;
  131364. beginQueryEXT(target: number, query: WebGLQuery): void;
  131365. endQueryEXT(target: number): void;
  131366. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  131367. deleteQueryEXT(query: WebGLQuery): void;
  131368. }
  131369. interface WebGLUniformLocation {
  131370. _currentState: any;
  131371. }
  131372. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  131373. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  131374. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  131375. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131376. interface WebGLRenderingContext {
  131377. readonly RASTERIZER_DISCARD: number;
  131378. readonly DEPTH_COMPONENT24: number;
  131379. readonly TEXTURE_3D: number;
  131380. readonly TEXTURE_2D_ARRAY: number;
  131381. readonly TEXTURE_COMPARE_FUNC: number;
  131382. readonly TEXTURE_COMPARE_MODE: number;
  131383. readonly COMPARE_REF_TO_TEXTURE: number;
  131384. readonly TEXTURE_WRAP_R: number;
  131385. readonly HALF_FLOAT: number;
  131386. readonly RGB8: number;
  131387. readonly RED_INTEGER: number;
  131388. readonly RG_INTEGER: number;
  131389. readonly RGB_INTEGER: number;
  131390. readonly RGBA_INTEGER: number;
  131391. readonly R8_SNORM: number;
  131392. readonly RG8_SNORM: number;
  131393. readonly RGB8_SNORM: number;
  131394. readonly RGBA8_SNORM: number;
  131395. readonly R8I: number;
  131396. readonly RG8I: number;
  131397. readonly RGB8I: number;
  131398. readonly RGBA8I: number;
  131399. readonly R8UI: number;
  131400. readonly RG8UI: number;
  131401. readonly RGB8UI: number;
  131402. readonly RGBA8UI: number;
  131403. readonly R16I: number;
  131404. readonly RG16I: number;
  131405. readonly RGB16I: number;
  131406. readonly RGBA16I: number;
  131407. readonly R16UI: number;
  131408. readonly RG16UI: number;
  131409. readonly RGB16UI: number;
  131410. readonly RGBA16UI: number;
  131411. readonly R32I: number;
  131412. readonly RG32I: number;
  131413. readonly RGB32I: number;
  131414. readonly RGBA32I: number;
  131415. readonly R32UI: number;
  131416. readonly RG32UI: number;
  131417. readonly RGB32UI: number;
  131418. readonly RGBA32UI: number;
  131419. readonly RGB10_A2UI: number;
  131420. readonly R11F_G11F_B10F: number;
  131421. readonly RGB9_E5: number;
  131422. readonly RGB10_A2: number;
  131423. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  131424. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  131425. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  131426. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  131427. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  131428. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  131429. 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;
  131430. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  131431. readonly TRANSFORM_FEEDBACK: number;
  131432. readonly INTERLEAVED_ATTRIBS: number;
  131433. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  131434. createTransformFeedback(): WebGLTransformFeedback;
  131435. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  131436. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  131437. beginTransformFeedback(primitiveMode: number): void;
  131438. endTransformFeedback(): void;
  131439. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  131440. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131441. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131442. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131443. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  131444. }
  131445. interface ImageBitmap {
  131446. readonly width: number;
  131447. readonly height: number;
  131448. close(): void;
  131449. }
  131450. interface WebGLQuery extends WebGLObject {
  131451. }
  131452. declare var WebGLQuery: {
  131453. prototype: WebGLQuery;
  131454. new(): WebGLQuery;
  131455. };
  131456. interface WebGLSampler extends WebGLObject {
  131457. }
  131458. declare var WebGLSampler: {
  131459. prototype: WebGLSampler;
  131460. new(): WebGLSampler;
  131461. };
  131462. interface WebGLSync extends WebGLObject {
  131463. }
  131464. declare var WebGLSync: {
  131465. prototype: WebGLSync;
  131466. new(): WebGLSync;
  131467. };
  131468. interface WebGLTransformFeedback extends WebGLObject {
  131469. }
  131470. declare var WebGLTransformFeedback: {
  131471. prototype: WebGLTransformFeedback;
  131472. new(): WebGLTransformFeedback;
  131473. };
  131474. interface WebGLVertexArrayObject extends WebGLObject {
  131475. }
  131476. declare var WebGLVertexArrayObject: {
  131477. prototype: WebGLVertexArrayObject;
  131478. new(): WebGLVertexArrayObject;
  131479. };
  131480. // Type definitions for WebVR API
  131481. // Project: https://w3c.github.io/webvr/
  131482. // Definitions by: six a <https://github.com/lostfictions>
  131483. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131484. interface VRDisplay extends EventTarget {
  131485. /**
  131486. * Dictionary of capabilities describing the VRDisplay.
  131487. */
  131488. readonly capabilities: VRDisplayCapabilities;
  131489. /**
  131490. * z-depth defining the far plane of the eye view frustum
  131491. * enables mapping of values in the render target depth
  131492. * attachment to scene coordinates. Initially set to 10000.0.
  131493. */
  131494. depthFar: number;
  131495. /**
  131496. * z-depth defining the near plane of the eye view frustum
  131497. * enables mapping of values in the render target depth
  131498. * attachment to scene coordinates. Initially set to 0.01.
  131499. */
  131500. depthNear: number;
  131501. /**
  131502. * An identifier for this distinct VRDisplay. Used as an
  131503. * association point in the Gamepad API.
  131504. */
  131505. readonly displayId: number;
  131506. /**
  131507. * A display name, a user-readable name identifying it.
  131508. */
  131509. readonly displayName: string;
  131510. readonly isConnected: boolean;
  131511. readonly isPresenting: boolean;
  131512. /**
  131513. * If this VRDisplay supports room-scale experiences, the optional
  131514. * stage attribute contains details on the room-scale parameters.
  131515. */
  131516. readonly stageParameters: VRStageParameters | null;
  131517. /**
  131518. * Passing the value returned by `requestAnimationFrame` to
  131519. * `cancelAnimationFrame` will unregister the callback.
  131520. * @param handle Define the hanle of the request to cancel
  131521. */
  131522. cancelAnimationFrame(handle: number): void;
  131523. /**
  131524. * Stops presenting to the VRDisplay.
  131525. * @returns a promise to know when it stopped
  131526. */
  131527. exitPresent(): Promise<void>;
  131528. /**
  131529. * Return the current VREyeParameters for the given eye.
  131530. * @param whichEye Define the eye we want the parameter for
  131531. * @returns the eye parameters
  131532. */
  131533. getEyeParameters(whichEye: string): VREyeParameters;
  131534. /**
  131535. * Populates the passed VRFrameData with the information required to render
  131536. * the current frame.
  131537. * @param frameData Define the data structure to populate
  131538. * @returns true if ok otherwise false
  131539. */
  131540. getFrameData(frameData: VRFrameData): boolean;
  131541. /**
  131542. * Get the layers currently being presented.
  131543. * @returns the list of VR layers
  131544. */
  131545. getLayers(): VRLayer[];
  131546. /**
  131547. * Return a VRPose containing the future predicted pose of the VRDisplay
  131548. * when the current frame will be presented. The value returned will not
  131549. * change until JavaScript has returned control to the browser.
  131550. *
  131551. * The VRPose will contain the position, orientation, velocity,
  131552. * and acceleration of each of these properties.
  131553. * @returns the pose object
  131554. */
  131555. getPose(): VRPose;
  131556. /**
  131557. * Return the current instantaneous pose of the VRDisplay, with no
  131558. * prediction applied.
  131559. * @returns the current instantaneous pose
  131560. */
  131561. getImmediatePose(): VRPose;
  131562. /**
  131563. * The callback passed to `requestAnimationFrame` will be called
  131564. * any time a new frame should be rendered. When the VRDisplay is
  131565. * presenting the callback will be called at the native refresh
  131566. * rate of the HMD. When not presenting this function acts
  131567. * identically to how window.requestAnimationFrame acts. Content should
  131568. * make no assumptions of frame rate or vsync behavior as the HMD runs
  131569. * asynchronously from other displays and at differing refresh rates.
  131570. * @param callback Define the eaction to run next frame
  131571. * @returns the request handle it
  131572. */
  131573. requestAnimationFrame(callback: FrameRequestCallback): number;
  131574. /**
  131575. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  131576. * Repeat calls while already presenting will update the VRLayers being displayed.
  131577. * @param layers Define the list of layer to present
  131578. * @returns a promise to know when the request has been fulfilled
  131579. */
  131580. requestPresent(layers: VRLayer[]): Promise<void>;
  131581. /**
  131582. * Reset the pose for this display, treating its current position and
  131583. * orientation as the "origin/zero" values. VRPose.position,
  131584. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  131585. * updated when calling resetPose(). This should be called in only
  131586. * sitting-space experiences.
  131587. */
  131588. resetPose(): void;
  131589. /**
  131590. * The VRLayer provided to the VRDisplay will be captured and presented
  131591. * in the HMD. Calling this function has the same effect on the source
  131592. * canvas as any other operation that uses its source image, and canvases
  131593. * created without preserveDrawingBuffer set to true will be cleared.
  131594. * @param pose Define the pose to submit
  131595. */
  131596. submitFrame(pose?: VRPose): void;
  131597. }
  131598. declare var VRDisplay: {
  131599. prototype: VRDisplay;
  131600. new(): VRDisplay;
  131601. };
  131602. interface VRLayer {
  131603. leftBounds?: number[] | Float32Array | null;
  131604. rightBounds?: number[] | Float32Array | null;
  131605. source?: HTMLCanvasElement | null;
  131606. }
  131607. interface VRDisplayCapabilities {
  131608. readonly canPresent: boolean;
  131609. readonly hasExternalDisplay: boolean;
  131610. readonly hasOrientation: boolean;
  131611. readonly hasPosition: boolean;
  131612. readonly maxLayers: number;
  131613. }
  131614. interface VREyeParameters {
  131615. /** @deprecated */
  131616. readonly fieldOfView: VRFieldOfView;
  131617. readonly offset: Float32Array;
  131618. readonly renderHeight: number;
  131619. readonly renderWidth: number;
  131620. }
  131621. interface VRFieldOfView {
  131622. readonly downDegrees: number;
  131623. readonly leftDegrees: number;
  131624. readonly rightDegrees: number;
  131625. readonly upDegrees: number;
  131626. }
  131627. interface VRFrameData {
  131628. readonly leftProjectionMatrix: Float32Array;
  131629. readonly leftViewMatrix: Float32Array;
  131630. readonly pose: VRPose;
  131631. readonly rightProjectionMatrix: Float32Array;
  131632. readonly rightViewMatrix: Float32Array;
  131633. readonly timestamp: number;
  131634. }
  131635. interface VRPose {
  131636. readonly angularAcceleration: Float32Array | null;
  131637. readonly angularVelocity: Float32Array | null;
  131638. readonly linearAcceleration: Float32Array | null;
  131639. readonly linearVelocity: Float32Array | null;
  131640. readonly orientation: Float32Array | null;
  131641. readonly position: Float32Array | null;
  131642. readonly timestamp: number;
  131643. }
  131644. interface VRStageParameters {
  131645. sittingToStandingTransform?: Float32Array;
  131646. sizeX?: number;
  131647. sizeY?: number;
  131648. }
  131649. interface Navigator {
  131650. getVRDisplays(): Promise<VRDisplay[]>;
  131651. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  131652. }
  131653. interface Window {
  131654. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  131655. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  131656. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  131657. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131658. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131659. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  131660. }
  131661. interface Gamepad {
  131662. readonly displayId: number;
  131663. }
  131664. type XRSessionMode =
  131665. | "inline"
  131666. | "immersive-vr"
  131667. | "immersive-ar";
  131668. type XRReferenceSpaceType =
  131669. | "viewer"
  131670. | "local"
  131671. | "local-floor"
  131672. | "bounded-floor"
  131673. | "unbounded";
  131674. type XREnvironmentBlendMode =
  131675. | "opaque"
  131676. | "additive"
  131677. | "alpha-blend";
  131678. type XRVisibilityState =
  131679. | "visible"
  131680. | "visible-blurred"
  131681. | "hidden";
  131682. type XRHandedness =
  131683. | "none"
  131684. | "left"
  131685. | "right";
  131686. type XRTargetRayMode =
  131687. | "gaze"
  131688. | "tracked-pointer"
  131689. | "screen";
  131690. type XREye =
  131691. | "none"
  131692. | "left"
  131693. | "right";
  131694. interface XRSpace extends EventTarget {
  131695. }
  131696. interface XRRenderState {
  131697. depthNear?: number;
  131698. depthFar?: number;
  131699. inlineVerticalFieldOfView?: number;
  131700. baseLayer?: XRWebGLLayer;
  131701. }
  131702. interface XRInputSource {
  131703. handedness: XRHandedness;
  131704. targetRayMode: XRTargetRayMode;
  131705. targetRaySpace: XRSpace;
  131706. gripSpace: XRSpace | undefined;
  131707. gamepad: Gamepad | undefined;
  131708. profiles: Array<string>;
  131709. }
  131710. interface XRSession {
  131711. addEventListener: Function;
  131712. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  131713. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  131714. requestAnimationFrame: Function;
  131715. end(): Promise<void>;
  131716. renderState: XRRenderState;
  131717. inputSources: Array<XRInputSource>;
  131718. }
  131719. interface XRReferenceSpace extends XRSpace {
  131720. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  131721. onreset: any;
  131722. }
  131723. interface XRFrame {
  131724. session: XRSession;
  131725. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  131726. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  131727. }
  131728. interface XRViewerPose extends XRPose {
  131729. views: Array<XRView>;
  131730. }
  131731. interface XRPose {
  131732. transform: XRRigidTransform;
  131733. emulatedPosition: boolean;
  131734. }
  131735. declare var XRWebGLLayer: {
  131736. prototype: XRWebGLLayer;
  131737. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  131738. };
  131739. interface XRWebGLLayer {
  131740. framebuffer: WebGLFramebuffer;
  131741. framebufferWidth: number;
  131742. framebufferHeight: number;
  131743. getViewport: Function;
  131744. }
  131745. interface XRRigidTransform {
  131746. position: DOMPointReadOnly;
  131747. orientation: DOMPointReadOnly;
  131748. matrix: Float32Array;
  131749. inverse: XRRigidTransform;
  131750. }
  131751. interface XRView {
  131752. eye: XREye;
  131753. projectionMatrix: Float32Array;
  131754. transform: XRRigidTransform;
  131755. }
  131756. interface XRInputSourceChangeEvent {
  131757. session: XRSession;
  131758. removed: Array<XRInputSource>;
  131759. added: Array<XRInputSource>;
  131760. }